Repository navigation
Commit aa57c76
feat(spec): add next_month, next_quarter and next_30_days date-range presets (#30133)
domain:spec#3 · os-support-ai · session_01WGufzfgvGexKn9vLHsy89K
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBNZcb3qbDCs7tSZcvMtReq8)_
Fixes #30076
Ruling-ref: 6631151570
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none — `git grep -n "last_90_days\|last_30_days" -- skills
.claude/skills` has 0 hits, and no `skills/**` line lists the preset
vocabulary (the dashboards rule only uses `this_quarter` / `this_year`
as examples). Nothing is owed to the paused skills lane.
Prior rulings read: date-range-presets,date_range_presets,next_month → 0
hits; none; thread: none; repo: objectstack-ai/objectstack (the card's
own ruling 6631151570 is the scope; the tool reads rulings by first-line
shape and did not classify it)
ADR-0087: not needed. Nothing is removed or narrowed; the 13 existing
windows are byte-identical.
## 维护者速读
- 改了什么:spec
的日期预设表新增三个往后看的预设:`next_month`(下月)、`next_quarter`(下季度)、`next_30_days`(未来
30 天),服务端 `analytics-date-range` 能解析它们,控制台 10 种语言都有标签。
- 为什么改:卡片 #30076 的裁决 A(「其他全部同意」)。销售预测问的都是往后:下个月、下季度、未来 30
天成交什么;以前只能用会过期的自定义日期。
- 风险与回滚:只加不改,原有 13
个窗口一字不动。下月、下季度的服务端终点没有现成宏,采用席位批准的“重锚定”:同一个解析器从下月第一天再算一次“下月第一天”,不新增宏
token,也不在 core 里做日期运算。回滚就是 revert。
-
先看:`packages/spec/src/data/date-range-presets.ts`(表和顺序说明)、`packages/core/src/utils/analytics-date-range.ts`(重锚定),以及下面的测量表。
- 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run
src/data/date-range-presets.test.ts`,然后 build spec 后 `pnpm --filter
@objectstack/core exec vitest run
src/utils/analytics-date-range.test.ts`(含上海、纽约 DST、查塔姆群岛行)。
- 需要你做的:现在不用做什么,等 CI 和席位验收。
## What changes
- **Spec** (`packages/spec/src/data/date-range-presets.ts`):
`DATE_RANGE_PRESETS` adds `next_month`, `next_quarter`, `next_30_days`,
named after `last_30_days`'s spelling. `DATE_RANGE_PRESET_MACRO_WINDOWS`
adds their rows in the inclusive last-day convention (commit 80aef80),
and the closed-window rule now covers the forward presets. Every row is
pinned by extent in `date-range-presets.test.ts` (reference day
2026-07-15: August is 31 days, Q4 is 92, `next_30_days` is 31 days like
`last_30_days`).
- **Display order** (the filter bar reads the array in order):
`this_month, last_month, next_month`, `this_quarter, last_quarter,
next_quarter`, then `last_7_days, last_30_days, last_90_days,
next_30_days`. Each forward preset sits in the family it extends, after
the backward member, so all month windows are found in one place and the
rolling group reads backward then forward. The existing 13 keep their
relative order; no forward preset opens a group, because the backward
windows are the ones most filters ask for.
- **`next_30_days` = today plus the 30 days after it** (`['{today}',
'{30_days_from_now}']`), the mirror of `last_30_days`
(`['{30_days_ago}', '{today}']`). It opens on today because a row due
today is still ahead of a forecast.
- **Server** (`packages/core/src/utils/analytics-date-range.ts`):
`PRESET_WINDOW_TOKENS` resolves the three half-open. A bound may now be
`{ token, from }`: resolve `from`, then resolve `token` again with the
reference instant moved into that day (its noon) in the same zone.
`next_month` ends at `{ token: 'next_month_start', from:
'next_month_start' }`, i.e. the month after next; `next_quarter`
likewise. The resolver stands at noon of the anchor day, not its first
instant: where a zone springs forward at 00:00 on a period's first day
(America/Asuncion, 2023-10-01) the day has no midnight, the day-start
instant reads as the day before, and the window came out empty
(measured: `end === start`). Seat ruling on this card thread: re-anchor,
no new macro token (option A of the seat's two).
- **Readers that close over the vocabulary**: the conformance kit
(`analytics-date-range-conformance.ts`),
`analytics-date-range-closed-vocabulary.test.ts` and lint
`validate-preset-comparands.ts` iterate `DATE_RANGE_PRESETS`, so they
take the three without edits. objectql `temporal-comparand-door.ts` does
not iterate the list: it judges a comparand by the field's declared
type, so a new preset name needs nothing there (its test passes
unchanged). Only prose counts ("the 13 declared names", "each of the
thirteen") were made count-free.
- **ui/** (seat-lifted, exactly these): the three labels in all 10 packs
under `ui/packages/i18n/src/locales/` (ar, de, en, es, fr, ja, ko, pt,
ru, zh; zh-Hant has no pack yet, phase 2 of #29428, so none is created);
the three English defaults in `filter-builder.tsx`'s label table
(measured: without them the 29115 test renders the raw keys
`dashboard.filters.range.next_month`, 4 cases red); `next_month_end` and
`next_quarter_end` in the client resolver
`ui/packages/core/src/utils/date-macros.ts` (spec tokens the client did
not resolve; without them the console lowers 下月 to `['2026-08-01',
'{next_month_end}']`); and the two pins that counted 13
(`dashboard-filters.presetWindows-29116.test.ts`,
`filter-builder-relative-dates-29115.test.tsx`).
- **`packages/verify`** (`dashboard-window.ts`, a reader of
`DATE_RANGE_PRESETS`): its fixture rows were written only on days up to
today, so the three forward windows selected no rows and 5 of 15 cases
in `dashboard-window.test.ts` went red. A window whose last day is after
today now also writes its own future edges; the days written for the 13
existing presets are unchanged (15/15 green).
- **Pins**: `packages/spec/src/ui/dashboard.test.ts` counted 13 presets
and 14 default ranges; now 16 and 17. The 29116 test's compareTo case
runs on the 13 retired presets only, with a comment naming #30140.
- **Docs**: `content/docs/ui/dashboards.mdx` preset table; stale "13
presets" / "never after today" prose in `packages/verify/README.md` and
`content/docs/deployment/cli.mdx`; the preset list in
`ui/packages/plugin-dashboard/README.md`; `content/docs/references/**`
regenerated by `gen:docs`; the
`docs/qa/platform-checklist/areas/api-backend.json` item
`api-backend.date-range-preset-matrix` widened to 16 variants (revision
3, `enumSource.expect: 16`).
## Measurement: preset → spec window → server window → resolves?
Reference: spec on 2026-07-15 (UTC days); server on `now`
2026-09-09T12:34:56.789Z unless noted. Server windows are `[start, end)`
instants.
| preset | spec window (inclusive, `$between`) | server half-open tokens
| server window | resolves? |
|---|---|---|---|---|
| `next_month` | `['{next_month_start}', '{next_month_end}']` →
2026-08-01 … 2026-08-31 | `next_month_start` → `next_month_start`
re-anchored on `next_month_start` | 2026-10-01T00:00Z →
2026-11-01T00:00Z | yes, by re-anchoring (no `month_after_next_start`
token exists; `PERIOD_RE` stops at `next_`) |
| `next_quarter` | `['{next_quarter_start}', '{next_quarter_end}']` →
2026-10-01 … 2026-12-31 | `next_quarter_start` → `next_quarter_start`
re-anchored on `next_quarter_start` | 2026-10-01T00:00Z →
2027-01-01T00:00Z | yes, by re-anchoring |
| `next_30_days` | `['{today}', '{30_days_from_now}']` → 2026-07-15 …
2026-08-14 | `today` → `31_days_from_now` | 2026-09-09T00:00Z →
2026-10-10T00:00Z | yes, directly (parametric days resolve to a calendar
day) |
Timezone and DST rows pinned in `analytics-date-range.test.ts` (`#30076`
block):
| preset | now | zone | window | why |
|---|---|---|---|---|
| `next_month` | 2026-01-31T20:00Z | Asia/Shanghai | 2026-02-28T16:00Z →
2026-03-31T16:00Z | the Shanghai day is already Feb 1, so next month is
March |
| `next_month` | 2026-01-31T20:00Z | UTC | 2026-02-01T00:00Z →
2026-03-01T00:00Z | control |
| `next_month` | 2026-10-15T12:00Z | America/New_York |
2026-11-01T04:00Z → 2026-12-01T05:00Z | DST ends Nov 1: start EDT, end
EST |
| `next_quarter` | 2026-12-10T12:00Z | America/New_York |
2027-01-01T05:00Z → 2027-04-01T04:00Z | year rollover, EST start, EDT
end |
| `next_30_days` | 2026-10-20T12:00Z | America/New_York |
2026-10-20T04:00Z → 2026-11-20T05:00Z | window crosses DST end |
| `next_month` | 2026-03-15T00:00Z | Pacific/Chatham | 2026-03-31T10:15Z
→ 2026-04-30T11:15Z | +13:45 then +12:45, non-whole-hour |
| `next_month` | 2023-09-15T12:00Z | America/Asuncion |
2023-10-01T03:00Z → 2023-11-01T03:00Z | springs forward at 00:00 on Oct
1; a midnight anchor gave an empty window |
| `next_quarter` | 2023-08-15T12:00Z | America/Asuncion |
2023-10-01T03:00Z → 2024-01-01T03:00Z | the quarter opens on the gap day
|
The existing `#17341` sweep (every preset, 8 instants × 4 zones) also
holds each new end to "the day after the spec's inclusive last day", and
the tiling test now includes `this_month → next_month` and `this_quarter
→ next_quarter`.
## UI reader measurement
| reader | reads the spec table? | result |
|---|---|---|
| `ui/packages/core/src/utils/dashboard-filters.ts` | yes: imports
`DATE_RANGE_PRESETS` and lowers through
`DATE_RANGE_PRESET_MACRO_WINDOWS` | takes the three with no edit |
| `ui/packages/components/src/custom/filter-builder.tsx` | yes:
`DATE_RANGE_PRESETS.map(...)` for options and label keys | takes the
three; its English defaults table needed the three rows |
| `ui/packages/core/src/utils/date-macros.ts` (client resolver) | no:
its own token table | lacked `next_month_end` / `next_quarter_end`;
added here. `next_week_end` and `next_year_end` are still missing:
follow-up #30134 |
| `ui/packages/types/src/data-protocol.ts:595-610` | no: a hand-kept
union | already lists `next_month`, `next_quarter`, `next_30_days` (plus
undeclared `next_year`, `next_7_days`, `next_90_days`); not edited |
No `domain:ui` follow-up is needed for the preset list itself: both
readers derive from the spec.
## Follow-ups
- #30134 (`domain:ui`, p3): the console's client resolver leaves
`{next_week_end}` and `{next_year_end}` unresolved.
- #30140 (`domain:ui`, p2): dashboard `compareTo` on a forward preset
compares the window with itself. `compare-to.ts` is not touched here.
## Verification
- spec suite (os-verify-lock): 24,399 passed after the dashboard pin
move (811 files); spec typecheck passed.
- core suite: 133 files, 2,970 passed at f7e8b20;
`analytics-date-range.test.ts` 73 at the round-1 head (two Asuncion rows
added). core and lint typecheck passed (after a full `packages/**`
build, 80/80 tasks).
- Readers that iterate the vocabulary: driver-memory date-range
conformance, DST, timezone and arity files (49 passed);
service-analytics conformance and arity (42); verify
`dashboard-window.test.ts` (15); lint
`validate-preset-comparands.test.ts` (29); objectql
`engine-temporal-comparand-door.test.ts` (14); driver-sql
`sql-driver-calendar-day-upper-bound.test.ts` (18); service-analytics
`native-sql-temporal-comparand-decline.test.ts` (8); verify typecheck
passed.
- ui (from the `ui/` root): `dashboard-filters.presetWindows-29116`,
`filter-builder-relative-dates-29115`,
`dashboard-range-preset-labels-4984`, `en-zh-key-parity`: 4 files, 112
passed.
- `pnpm --filter @objectstack/spec check:generated`: all 14 artifacts
current.
- Derived gates: `dispatch-gates --commands` listed 108; all 108 run,
`--ran` reconciles 108/108, 0 NOT-MEASURED. 107 exit 0. `pnpm
check:platform-checklist` exits 1 on one finding that is on `main`
already: `areas/platform-core.json` anchors
`packages/metadata-protocol/src/protocol.ts#assertProtocolCompat`, which
`origin/main`'s `protocol.ts` no longer declares (0 matches at base
`f68b47ca`). This PR's own checklist item passes. `check:generated`
crashed once on heap at 4 GB inside `check:test-typecheck` and passed at
CI's 6 GB (`NODE_OPTIONS=--max-old-space-size=6144`).
- Lint: eslint on every changed file, 0 errors.
- Round 1 (contract review 6634808446): derivation grew by one family,
`pnpm check:cli-examples-parity`, exit 0; the docs gates for the edited
prose (`check:doc-authoring`, `check:docs-transcript-drift`,
`check:doc-anchors`, `check-affected-docs`, `check-drift-comment`,
`check:published-readme-links`, `check:issue-citations`,
`check:docs-spec-enumerations`) exit 0; the ui 29116 test 51 passed.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzj9os3R42oiDRwN6HZ
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 471add3 commit aa57c76
32 files changed
Lines changed: 341 additions & 43 deletions
File tree
- .changeset
- content/docs
- deployment
- references
- api
- data
- ui
- docs/qa/platform-checklist/areas
- packages
- cli/test
- core/src/utils
- lint/src
- spec/src
- data
- ui
- verify
- src
- ui/packages
- components/src
- __tests__
- custom
- core/src/utils
- __tests__
- i18n/src/locales
- plugin-dashboard
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2592 | 2592 | | |
2593 | 2593 | | |
2594 | 2594 | | |
2595 | | - | |
| 2595 | + | |
2596 | 2596 | | |
2597 | 2597 | | |
2598 | 2598 | | |
2599 | 2599 | | |
2600 | | - | |
| 2600 | + | |
2601 | 2601 | | |
2602 | 2602 | | |
2603 | 2603 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
111 | | - | |
| 114 | + | |
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| 383 | + | |
383 | 384 | | |
384 | 385 | | |
| 386 | + | |
385 | 387 | | |
386 | 388 | | |
387 | 389 | | |
388 | 390 | | |
389 | 391 | | |
| 392 | + | |
390 | 393 | | |
391 | 394 | | |
392 | | - | |
| 395 | + | |
393 | 396 | | |
394 | 397 | | |
395 | 398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1477 | 1477 | | |
1478 | 1478 | | |
1479 | 1479 | | |
1480 | | - | |
| 1480 | + | |
1481 | 1481 | | |
1482 | 1482 | | |
1483 | 1483 | | |
| |||
1489 | 1489 | | |
1490 | 1490 | | |
1491 | 1491 | | |
1492 | | - | |
| 1492 | + | |
1493 | 1493 | | |
1494 | 1494 | | |
1495 | 1495 | | |
| |||
1539 | 1539 | | |
1540 | 1540 | | |
1541 | 1541 | | |
| 1542 | + | |
1542 | 1543 | | |
1543 | 1544 | | |
| 1545 | + | |
1544 | 1546 | | |
1545 | 1547 | | |
1546 | 1548 | | |
1547 | 1549 | | |
1548 | | - | |
| 1550 | + | |
| 1551 | + | |
1549 | 1552 | | |
1550 | 1553 | | |
1551 | 1554 | | |
1552 | 1555 | | |
1553 | | - | |
| 1556 | + | |
1554 | 1557 | | |
1555 | 1558 | | |
1556 | 1559 | | |
| |||
1574 | 1577 | | |
1575 | 1578 | | |
1576 | 1579 | | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
1577 | 1586 | | |
1578 | 1587 | | |
1579 | 1588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
0 commit comments