Skip to content

Commit 8096ec9

Browse files
committed
docs(skills): teach the {current_iso_week} period key in the query filter rules
The Date Macros section of the published query skill listed the date macros and the session tokens only. It now names the period key beside them: the YYYY-Www value, the text-field-only rule, the INVALID_FILTER / 400 refusal on date, datetime and time fields, and the two date-only surfaces that refuse it. Five restatements in the same section pay first; the ratchet row moves by the measured remainder. One eval case pins the text-field / date-field split. Claude-Session: https://claude.ai/code/session_01L6bhgTRf6qBRCqPh4JZaZL Co-authored-by: Claude <noreply@anthropic.com>
1 parent 598a34d commit 8096ec9

3 files changed

Lines changed: 42 additions & 11 deletions

File tree

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,21 @@ export const CEILINGS = new Map([
13701370
// paragraph (home: SKILL.md, String Operators) and a second `$between` Date
13711371
// example (home: the operator table's `$between` row). Arithmetic in bytes:
13721372
// 9925 -> 9892 (-33 net) -> ceil(9892 / 4) = 2473; headroom 0 tokens.
1373-
['skills/objectstack-query/rules/filters.md', 2473],
1373+
// 2473 -> 2596 (#35496): the `{current_iso_week}` period key in § Date Macros
1374+
// (its `YYYY-Www` value, the text-field-only rule, the `INVALID_FILTER` / 400
1375+
// refusal on date / datetime / time fields, the two date-only surfaces that
1376+
// refuse it) and the client resolver that covers all three vocabularies.
1377+
// Raise path the standing ruling 「A:先削重复,余额按实测提高」 (ruling record
1378+
// 6513306068, letter B). PAID DOWN FIRST — five restatements cut in the same
1379+
// section: the wrapper regex beside the prose that already says both
1380+
// spellings parse, the code comment repeating the sentence above its block,
1381+
// the second date-macro comparison in the session-token example (the week key
1382+
// takes its place), the two per-vocabulary predicates (one predicate answers
1383+
// for all three) and the driver sentence's list of value kinds. Arithmetic in
1384+
// bytes: 9876 landed -> 10382, +506 -> 127 tokens, the row's 4 tokens of
1385+
// headroom absorbed, ceiling +123, pinned AT the measurement.
1386+
// ceil($(wc -c < skills/objectstack-query/rules/filters.md) / 4) == ceil(10382 / 4)
1387+
['skills/objectstack-query/rules/filters.md', 2596],
13741388
['skills/objectstack-query/rules/pagination.md', 1382],
13751389

13761390
// objectstack-ui `rules/` — the five files the #14296 item 1 split created.

‎skills/objectstack-query/evals/filters-pagination-search.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@
9090
"must_contain": ["timezone: 'Asia/Taipei'", "dateGranularity: 'month'", "zonedDateBucketing", "in memory", "in the database"],
9191
"must_not_contain": ["date_trunc"]
9292
}
93+
},
94+
{
95+
"id": 10,
96+
"prompt": "A dashboard widget over `supply_plan` must always show the current week. `plan_week` is a text field holding ISO week keys such as `2026-W47`; `ship_date` is a date field. Write the widget filter on `plan_week`, then the same week as a filter on `ship_date`.",
97+
"expected_output": "`{ plan_week: '{current_iso_week}' }` — the period-key token resolves to today's ISO week key (`YYYY-Www`, workspace time zone, Monday-start weeks), so it matches a text field that stores those keys. It is text, not a date: on `ship_date` it is refused (`INVALID_FILTER` / 400), so the date field takes the week's boundaries, `{ ship_date: { $gte: '{current_week_start}', $lte: '{current_week_end}' } }`. No hand-computed key or date, which would freeze into the metadata.",
98+
"files": [],
99+
"assertions": {
100+
"must_contain": ["plan_week: '{current_iso_week}'", "{current_week_start}", "{current_week_end}"],
101+
"must_not_contain": ["{current_week}", "ship_date: '{current_iso_week}'"]
102+
}
93103
}
94104
]
95105
}

‎skills/objectstack-query/rules/filters.md‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ pages — cannot run code, so they use **date macro tokens** instead
152152
(defined in `@objectstack/spec` `data/date-macros.zod.ts`):
153153

154154
```typescript
155-
// List-view / dashboard filter values
156155
where: {
157156
signal_at: { $gte: '{30_days_ago}' },
158157
published_at: { $gte: '{last_quarter_start}' }
@@ -164,24 +163,33 @@ where: {
164163
`{next_year_start}` (and bare aliases like `{month_start}`).
165164
- **Parameterised tokens:** `{N_<unit>_ago}` / `{N_<unit>_from_now}` with
166165
units `minute|hour|day|week|month|year` — e.g. `{2_weeks_from_now}`.
167-
- **Both spellings parse:** `{today}` and `${today}` are the same token
168-
(`DATE_MACRO_WRAPPED_RE` is `/^\$?\{([a-zA-Z0-9_]+)\}$/`, and the context
169-
tokens share it).
166+
- **Both spellings parse:** `{today}` and `${today}` are the same token, in
167+
every vocabulary here.
168+
169+
**Period key** (`PERIOD_KEY_TOKENS`, not a date macro): `{current_iso_week}`
170+
is today's ISO week key, `YYYY-Www`, in the workspace time zone — Monday-start
171+
weeks, the ISO week-year at year edges (2027-01-01 is `2026-W53`). It is text,
172+
for a text field storing week keys. A `date` / `datetime` / `time` field
173+
refuses it (`INVALID_FILTER` / 400) like the literal key — use
174+
`{current_week_start}` / `{current_week_end}` there — as do a date dashboard
175+
filter's `defaultValue` and `calendar.initialDate`; a text dashboard filter
176+
may default to it. There is no last- or next-week key.
170177

171178
**Session tokens:** the same value positions accept `{current_user_id}` and
172179
`{current_org_id}` (defined in `data/context-tokens.zod.ts`) — the signed-in
173180
user's id and the active organization id.
174181

175182
```typescript
176-
where: { owner_id: '{current_user_id}', close_date: { $gte: '{current_year_start}' } }
183+
where: { owner_id: '{current_user_id}', cost_week: '{current_iso_week}' }
177184
```
178185

179186
**Scope:** tokens expand on **both** sides of the wire — client-side by
180-
`resolveDateMacros()` / `resolveContextTokens()` in `@object-ui/core`,
187+
`resolveFilterPlaceholders()` in `@object-ui/core` (`resolveDateMacros()`,
188+
`resolvePeriodKeyTokens()` and `resolveContextTokens()` in one call),
181189
server-side by `resolveFilterTokens()` in `@objectstack/core`, wired into the
182190
ObjectQL read AND write paths (`find`/`findOne`/`count`/`aggregate`/`update`/
183-
`delete`) plus the analytics dataset executor. The driver only ever sees ISO
184-
strings and concrete ids. So use tokens in a hand-issued engine query too:
191+
`delete`) plus the analytics dataset executor. The driver only ever sees
192+
resolved values. So use tokens in a hand-issued engine query too:
185193
computing "today" at module load freezes the date into the built artifact.
186194

187195
A **flow node's** `config.filter` takes these tokens too. What a dropped
@@ -200,8 +208,7 @@ indistinguishable from "there is no data". Near-misses, not tokens:
200208
(a real `titleFormat` interpolation) and `{organization_id}` (the column name);
201209
the error names the correction. A value that merely *contains* braces is left
202210
untouched — `'user-{current_user_id}'` is a literal. Check a spelling with
203-
`isDateMacroToken(tok)` / `isContextToken(tok)` from `@objectstack/spec/data`,
204-
WITHOUT braces.
211+
`isKnownFilterToken(tok)` from `@objectstack/spec/data`, WITHOUT braces.
205212

206213
**`*_end` is a calendar DAY; an upper bound means the WHOLE day.**
207214
`<= {current_year_end}` already reaches the final instant of Dec 31

0 commit comments

Comments
 (0)