Repository navigation
Commit 89364b4
feat(spec): {current_iso_week} defaults a week-keyed filter to the current ISO week (#35391)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg6v19uPsX6gX42G8tGcvvzb)_
Fixes #34938
Clause-②: yes (widening: the closed filter-placeholder vocabulary gains
one token)
Metadata-protocol: added
Skills-docs: follow-up owed — skills/objectstack-query/rules/filters.md
(its "Date Macros" section lists the filter-placeholder vocabulary; it
should name `{current_iso_week}` as a period key that is text, not a
date)
## 维护者速读
- 用户看到的变化:看板的文本筛选可以把默认值设成「本周」,每次打开自动填入当前周号(如
2026-W47),筛选框里直接显示周号;写死的周号照旧可用。
- 为什么:按周号存数据的应用以前只能写死某一周,下周就过期;按您「加一个固定占位符」的裁定执行。
-
如果判断错:只影响用了这个占位符的筛选;跨年那几天周号若算错,看板会落到相邻的一周。误用在日期字段上会直接被拒绝并提示,不会悄悄给出错误结果。
- 需要您做的:无。
## What changes
- **Spec.** `PERIOD_KEY_TOKENS = ['current_iso_week']`,
`isPeriodKeyToken` and `PERIOD_KEY_TOKEN_DESCRIPTIONS` in
`data/date-macros.zod.ts`. It is a sibling list, not a member of
`DATE_MACRO_TOKENS`, so `isDateMacroPlaceholder`, a date dashboard
default and a calendar `initialDate` still refuse it.
`classifyFilterToken` answers a new kind, `period-key`;
`isKnownFilterToken` knows it. The dashboard `defaultValue` TSDoc and
describe name the text-filter use.
- **Server.** `resolveFilterTokens` (`@objectstack/core`) resolves it
with `bucketDateKey(now, 'week', ctx.timezone)`, the same label the
analytics week bucket groups by: ISO-8601, Monday start, the ISO
week-numbering year at the year edges, today in the workspace zone. The
unknown-token message names it.
- **Client.** `resolvePeriodKeyTokens` (`@object-ui/core`) carries the
same rule; the client cannot import `@objectstack/core`, so the two
copies are held equal by one 16-row parity table that both sides run.
`resolveFilterPlaceholders` and `resolveDashboardFilterDefs` call it, so
a text (or any non-date) filter opens with the resolved key in the box;
a `date` / `dateRange` default is left to its own normalizer and refused
there as before.
- **Lint.** No logic change: `{current_iso_week}` is a known token, so
`filter-token-unknown` no longer flags it. The rule's explanation said
"exactly two vocabularies", which this change made false; it now lists
the period keys.
- **Docs.** A new "Defaulting to the Current ISO Week" section in the
dashboards guide (with a type-checked example); the analytics and
plugin-view placeholder paragraphs name the token; the date-macros and
dashboard reference pages and the `data` api-surface / export-origins
shards are regenerated.
## Tests
All runs below were at `f3bf7beb08`; the only later commit,
`fa840834a0`, edits the changeset text alone, and the families that read
it were re-run there.
- New pins: the 16-row parity table (year edges 2020-12-31,
2021-01-03/04, 2024-12-30, 2025-12-29, 2026-12-31, 2027-01-01/03/04, and
zone rows for Tokyo, New York, Los Angeles and Shanghai) in core
`filter-tokens.test.ts` and in ui `date-macros.test.ts`; a sibling of
the spec-parity test for `PERIOD_KEY_TOKENS`; the classify / known-token
/ near-spelling cases in spec; the dashboard schema (date filter
refuses, text filter keeps both spellings and a literal key); the lint
no-finding cases; the dashboard-filter seeding cases (text, untyped,
`${…}`, select, zone, literal key, embedded text, a date filter left
raw).
- Every test file that reads a touched symbol, per package: spec 10
files / 1046 tests, core 6 / 392, lint 7 / 334, objectql 8 / 222,
service-analytics 6 / 326 (+20 skipped), service-automation 1 / 65,
driver-memory 2 / 78, driver-sql 2 / 79 (+2 skipped), formula 1 / 52,
platform-objects 1 / 18, app-showcase 1 / 3, ui (core, plugin-dashboard,
plugin-designer, grid, list, view, react, console, app-shell) 28 / 437
(+6 skipped). All passed.
- Typecheck: `@objectstack/spec`, `@objectstack/core`,
`@objectstack/lint` `typecheck` and `@object-ui/core` `type-check`
(which compiles its tests) all exit 0.
<details>
<summary>Test run readings</summary>
```text
READER spec exit 0 :: Test Files 10 passed (10) Tests 1046 passed (1046)
READER core exit 0 :: Test Files 6 passed (6) Tests 392 passed (392)
READER lint exit 0 :: Test Files 7 passed (7) Tests 334 passed (334)
READER objectql exit 0 :: Test Files 8 passed (8) Tests 222 passed (222)
READER analytics exit 0 :: Test Files 6 passed (6) Tests 326 passed | 20 skipped (346)
READER automation exit 0 :: Test Files 1 passed (1) Tests 65 passed (65)
READER drvmem exit 0 :: Test Files 2 passed (2) Tests 78 passed (78)
READER drvsql exit 0 :: Test Files 2 passed (2) Tests 79 passed | 2 skipped (81)
READER formula exit 0 :: Test Files 1 passed (1) Tests 52 passed (52)
READER platobj exit 0 :: Test Files 1 passed (1) Tests 18 passed (18)
READER showcase exit 0 :: Test Files 1 passed (1) Tests 3 passed (3)
ui readers: Test Files 28 passed (28) Tests 437 passed | 6 skipped (443)
os-verify-lock: VERDICT command-exit 0 (each of the three runs)
typecheck: TC spec=0 core=0 lint=0 ; @object-ui/core type-check VERDICT command-exit 0
```
</details>
## Acceptance notes
- **The temporal-comparand door, measured as asked.** The dispatch asked
what the door answers when the token meets a date or datetime column.
Measured with `engine.find` on the SQL driver (SQLite) and the in-memory
driver, which answered the same; now pinned to 2026-11-19. It is **not
refused and not read as a date: the key reaches the driver and is
compared as text**. Before this change the same query answered
`FILTER_TOKEN_UNKNOWN` / 400.
- `placed_on` (date) `$eq` gives `[]`, `$gte` gives `[]`, and `$lt`
returns every row.
- `opened_at` (datetime) answers the same; `opens_at` (time) `$gt` gives
`[]`.
- The literal `"2026-W47"` on the same columns is refused
`INVALID_FILTER` / 400.
The door steps around every placeholder as written, and after resolution
it judges only `date-macro` kinds. The context tokens
(`{current_user_id}` on a date column) already behave this way. Per the
dispatch the door was not widened. The docs say to use the token only on
fields that store week keys. The fix belongs in the core
temporal-comparand step-around: judge period-key and context
placeholders as written, and step around only date macros. It is
reported to the seat to file.
- **compareTo.** A chart's previous-period series (the compare-to shift)
does not shift a period key, so the comparison series filters the same
week. Not measured in a UI; reported, not changed.
- **Placeholders only as the whole value.** The token resolves only as a
whole value. `'week {current_iso_week}'` is left as written, like every
other placeholder.
- **Lint does not read dashboard defaults.** Lint does not walk
`globalFilters[].defaultValue`. A typo there, such as
`{currentIsoWeek}`, surfaces only at query time, as
`FILTER_TOKEN_UNKNOWN` / 400.
- **Files outside the claim's surface.**
- `packages/lint/src/rule-explanations.ts`: its text became false with
this change.
- `ui/packages/core/src/utils/filter-tokens.ts`: the client's sibling
resolver.
- `content/docs/data-modeling/analytics.mdx` and
`content/docs/frontend/plugins/plugin-view.mdx`: the other
filter-placeholder paragraphs.
- No path under `skills/**` changed; no generator wrote there.
## Verification
- Derived gate families (`dispatch-gates.mjs --commands`, 120 families)
ran locally. 118 exited 0 and 2 are NOT MEASURED; the reconciliation
reads `✓ dispatch-gates --ran: 120 derived famil(ies) accounted for —
118 run, 2 NOT-MEASURED`.
- `check:skill-examples` first refused with exit 3 because
`@objectstack/client-react` had no dist. After building it, the gate
exits 0: 346 examples type-check, including the new dashboards example.
- NOT MEASURED: `check:dual-build-cjs-loads`. It needs every workspace
package's dist, which is a whole-repo build, left to CI.
- NOT MEASURED: `vitest run scripts/` (ui). 170 of 171 files passed. The
one failure, `unit-registry-absence-collision`, was caused by an unbuilt
`@objectstack/client`; after building it, that file passes 15/15.
- `check:generated` is green after `gen:api-surface`,
`gen:export-origins` and `gen:docs`. ui `check:new-line-citations`
reports 0 new citations, and `overlap-check` merges cleanly.
- CI runs the full lint farm and the full package suites.
<details>
<summary>Gate readings</summary>
```text
dispatch-gates: gate list derived from the tree of 'objectstack-ai/objectstack' at commit fa84083
Run reconciliation — 120 derived, 118 run, 2 NOT-MEASURED, 0 UNRUN.
check:skill-examples (rerun): ✅ 346 prose examples type-check across 3 surface(s)
check:dual-build-cjs-loads: PREREQUISITE NOT MET — this gate reads built output, and some package has no dist/.
VERDICT new-cross-file-line-citations: 0 new citation(s), enforcement report-only -> exit 0
overlap-check: VERDICT clean exit 0
```
</details>
## Fix round (contract review 7003932618)
Head `6b8fc7b563`. It supersedes the "temporal-comparand door"
acceptance note above: the door now refuses the token on temporal
columns.
- **S1, closed in this PR.** The core predicate
`isUninterpretableTemporalComparand` no longer steps around a
`period-key` placeholder; it judges it as written. `{current_iso_week}`
is not a calendar day, an instant or a wall clock, so on a `date`,
`datetime` or `time` column it now gets the same refusal as the literal
`"2026-W47"`: `INVALID_FILTER` / 400, before any driver read.
- The narrowest correct place is the core predicate, the one rule both
callers ask. The engine door (`where`, per-aggregation filter and
`having`) and the analytics raw-SQL decline therefore move together;
`judgeResolvedToken` gains only a docblock clause.
- The record validator's write door already refused every placeholder
through its own `readable` gate, so its verdicts do not change.
- Date macros, unknown placeholders and the context tokens are still
stepped around. The context-token half stays with #35394.
- **Docs and changeset.** The dashboards guide, the changeset and the
spec module doc now say the key is refused on a date, datetime or time
field, and the date-macros reference page is regenerated. They used to
say it was compared as text and gave the wrong answer.
- **N1.** The changeset now carries the sentence "A consumer that
switches exhaustively on `kind` gets a compile error until it handles
the new kind."
- **N2.** Dropped, as the seat instructed. `flow-value-slot-template.ts`
is not touched.
- **N3.** The lint `filter-token-unknown` hints and the inline comment
now name the week key `{current_iso_week}` and the three vocabularies.
Both hint lines stay one line of at most 200 characters (186 and 176).
### Pins
- **Core predicate** (`temporal-comparand.test.ts`). The predicate
refuses every `PERIOD_KEY_TOKENS` member in both spellings, plus the
literal key, on all three kinds. As controls, `{current_week_start}`,
`{today}`, `{30_days_ago}` and the unknown `{current_iso_wek}` are still
stepped around.
- **Engine door, recording driver**
(`engine-temporal-comparand-door.test.ts`).
- Refused with `INVALID_FILTER` / 400 and no driver read: `$eq` / `$lt`
/ `$gte` / `$gt`, implicit equality and an `$in` member, on `due_on`
(date), `created_date` (datetime) and `opens_at` (time), in both
spellings.
- Positive controls in the same test: a text `$eq` and an implicit
equality return the W47 row; a text `$contains` reaches the driver as
`2026-W47`; `{current_week_start}` on a date column resolves to
`2026-11-16` and returns the W47 row.
- **REST query door over SqlDriver**
(`data-temporal-write-real-day-iso.test.ts`).
- The SQLite cell always runs; the PostgreSQL cell is a named skip
unless `OS_TEST_POSTGRES_URL` is set.
- On `placed_on`, `opened_at` and `slot`, `$eq` / `$lt` / `$gte` in both
spellings answer 400 `INVALID_FILTER` naming the field, with no read of
the object.
- As controls, a text `$eq` and `$contains` return the W47 row, and
`{current_week_start}` on the date field returns it too.
- **InMemoryDriver** has no live pin in this PR. A new test file that
imports `@objectstack/driver-memory` needs a census ruling
(`scripts/driver-memory-census.ledger.json`), which a dev does not make.
The refusal sits in front of every driver, and the recording-driver pin
asserts that no driver read happens. The pre-fix reading on
InMemoryDriver matched SQLite.
<details>
<summary>Ablation of the new arm (once): pins red, then restored to the
HEAD blob</summary>
```text
ablation-replace: anchor "if (placeholder !== null && placeholder.kind !== 'period-key') return false;" x1 (before)
ablation-replace: replace "if (placeholder !== null) return false;" x0 -> x1
ablation-replace: blob 7032d83 -> 1d48a87164838ef451874f607946b6ec6ae27b30
pnpm --filter @objectstack/core build; ablation-dist-preflight --absent: marker absent from all 20 built files
PIN core exit 1 :: Tests 1 failed | 27 passed (28) date {current_iso_week}: expected false to be true
PIN objectql exit 1 :: Tests 1 failed | 14 passed (15) due_on $eq {current_iso_week}: expected null not to be null
PIN rest exit 1 :: Tests 1 failed | 6 passed | 7 skipped (14) placed_on $eq {current_iso_week}: expected 200 to be 400
restore: git checkout HEAD -- (absolute path); HEAD blob 7032d83 == disk blob 7032d83; git diff HEAD empty
pnpm --filter @objectstack/core build; ablation-dist-preflight: marker present in 2 built files; tree clean against HEAD
PIN core exit 0 :: Tests 28 passed (28)
PIN objectql exit 0 :: Tests 15 passed (15)
PIN rest exit 0 :: Tests 7 passed | 7 skipped (14)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details>
<summary>Readers and gates at 6b8fc7b</summary>
```text
READER core Test Files 3 passed Tests 214 passed
READER objectql Test Files 14 passed Tests 297 passed
READER rest Test Files 4 passed Tests 26 passed | 18 skipped
READER analytics Test Files 10 passed Tests 353 passed | 6 skipped
READER lint Test Files 2 passed Tests 45 passed
READER spec Test Files 2 passed Tests 56 passed
typecheck core / lint / objectql / rest: exit 0
spec check:generated: exit 0 after gen:docs
dispatch-gates --ran: 123 derived famil(ies) accounted for — 120 run, 3 NOT-MEASURED
NOT-MEASURED check:dual-build-cjs-loads (needs every package dist), check:type-check-debt (its re-measure queues a whole-repo build), ui vitest run scripts/ (no ui file changed this round)
overlap-check: VERDICT clean exit 0
```
</details>
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbSphdunq2aJq7ktuY -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 338448e commit 89364b4
31 files changed
Lines changed: 931 additions & 52 deletions
File tree
- .changeset
- content/docs
- data-modeling
- frontend/plugins
- references
- data
- ui
- ui
- packages
- core/src/utils
- lint/src
- objectql/src
- rest/src
- spec
- api-surface
- export-origins
- src
- data
- ui
- ui/packages/core/src/utils
- __tests__
| 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 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
259 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
332 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
333 | 334 | | |
334 | 335 | | |
335 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
67 | 105 | | |
68 | 106 | | |
69 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | | - | |
| 327 | + | |
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
642 | 678 | | |
643 | 679 | | |
644 | 680 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
115 | 125 | | |
116 | 126 | | |
117 | 127 | | |
| |||
123 | 133 | | |
124 | 134 | | |
125 | 135 | | |
| 136 | + | |
126 | 137 | | |
127 | 138 | | |
128 | 139 | | |
129 | 140 | | |
| 141 | + | |
130 | 142 | | |
131 | 143 | | |
132 | | - | |
| 144 | + | |
133 | 145 | | |
134 | 146 | | |
135 | 147 | | |
| |||
185 | 197 | | |
186 | 198 | | |
187 | 199 | | |
188 | | - | |
189 | | - | |
| 200 | + | |
| 201 | + | |
190 | 202 | | |
191 | 203 | | |
192 | 204 | | |
| |||
446 | 458 | | |
447 | 459 | | |
448 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
449 | 475 | | |
450 | 476 | | |
451 | 477 | | |
| |||
501 | 527 | | |
502 | 528 | | |
503 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
504 | 537 | | |
505 | 538 | | |
506 | 539 | | |
| |||
0 commit comments