Skip to content

Commit d280de9

Browse files
docs: stale prose on summary currency, the temporal-comparand door and analytics filters now says what the code does (#35806)
repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoK8YCcS3hkJHvVLxZNeiKG8)_ Fixes #35409 Fixes #34611 Fixes #35522 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:两条拒绝提示改了措辞(汇总字段币种拒绝时点明子字段缺什么;日期过滤值无法识别时说明会按文本比较、可能选中全部或零行),其余是注释、升级说明和文档文字,行为不变。 - 为什么做:三张文字跟进卡(汇总币种、日期过滤值校验、分析过滤注释与仪表盘文档),旧文字比代码说得窄或说错了,AI 和开发者读到会写错。 - 出错会怎样:只影响提示和文档措辞,不改任何接受或拒绝的范围,直接撤回即可。 - 要你做什么:它更正了一条属于收窄的未发布升级说明(35394),合并队列守卫因此要你在 GitHub 上点一次 Approve;之后席位自主落地。 - 席位意见:通过,没有必改项(席位记录见本 PR 评论)。 ## What changes Text only. No accepted value, key, answer or code path moves; two refusal messages change words. ### #35409 — summary `dynamic` currency (spec, ui/fields) The doors admit a `dynamic` summary over any child `currency` field in `dynamic` mode (`isTenantCurrencyAmount`, `packages/spec/src/data/record-currency-path.ts:229-232`; read by `stack.zod.ts:5033` and `objectql/src/record-currency-aggregate-door.ts:87`). - N2: module header says "three predicates" (`isRecordCurrencyCodeField` :50, `storedHomeAmountSourceOf` :207, `isTenantCurrencyAmount` :229). - N3: the (d) fallback arm now names what a `currency` child lacks (`record-currency-path.ts:265-270`, used at :282): `fixed` with no `defaultCurrency` code, or a `currencyMode` outside `dynamic` / `fixed` / `record`. A non-`currency` child keeps its old words ("is a 'number' field, …"), so the existing pins in `record-currency-guards.test.ts:1229-1230,1328` and `currency-summary-home-rollup.test.ts:181,203` are unchanged and green. One new case pins the two new arms by subject. - N4: upgrade-guide entry `18.summary-dynamic-currency-rollup-home-amount-judged-as-served.ts` states the admitted set (surface, replacement, reason). Its `reason` keeps the present-tense rule ("Both doors now admit it only there") apart from the history: before the entry, `defineStack` judged it (then admitting a stored home amount alone) and the engine registry judged only `record` roll-ups. Its acceptance step now saves over "a child field that is not a `currency` field in `dynamic` mode (a `fixed` EUR amount, a plain number or a formula)". The comments in `ui/packages/fields/src/currency.ts`, `index.tsx` and `widgets/SummaryField.tsx` say the same. - Skills text is out of scope (governed; seat 5 files it). ### #34611 — analytics filter-normalizer comments and `dashboards.mdx` - N1: the `const` arm JSDoc and the `collectFilterLeaves` comment in `filter-normalizer.ts` now give the full reason. `lowerFilterCondition` (`packages/spec/src/data/filter-lowering.ts:445-470`) wraps every `$nin` outside a `$not` in the NULL escape (`nullEscape`, :435), whose `notSet` leaf names the member. Inside a `$not` it takes that escape when a row with no value satisfies every operator of the spec, and otherwise a `$null: false` requirement, either as its own conjunct or the enclosing one (`requiredFields`, :182). `$null: false` normalizes to a `set` leaf (`filter-normalizer.ts:1214`). Measured on the built spec at this head: `{$not:{f:{$nin:[],$gt:5}}}` lowers to `{$not:{$and:[{f:{$null:false}},{f:{$nin:[],$gt:5}}]}}`. - N2: left as it is. The `#34514` changeset has been released: its sentence is in `packages/services/service-analytics/CHANGELOG.md:126`, and the changeset file is gone from `.changeset/`. The card's own rule applies ("otherwise fix the docs only"). - D1: the 1,000-record bullet in `content/docs/ui/dashboards.mdx` now says a single-valued relation "usually" runs as a subquery, and names the id-read cases that `content/docs/protocol/objectql/query-syntax.mdx:703-732` lists, a multi-valued relation (on every driver) first. It also had a MongoDB clause that disagreed with both `query-syntax.mdx:709-714` and the code. On a read verb (`aggregate` included, `relation-filter-lowering.ts:356`), a single-valued relation condition on a driver without `readableIdsLeaf` (MongoDB, OData) is refused before any read (`relationReadDriverRefusal`, :370). It is not id-read under the cap. The bullet now says so, in the capability's terms: "a driver that cannot run it in one read". ### #35522 — temporal-comparand door prose (objectql, core, lint, spec) The rule, per kind, is `PLACEHOLDER_AT_THE_TEMPORAL_RULE` in `packages/core/src/utils/temporal-comparand.ts:292-298`, applied at :364-365: - a date macro is stepped around, then judged by its year once resolved; - a period key and a context token are judged as written; - an unknown or record-context token is left to the resolver. Each named sentence now states that rule: - `temporal-comparand-door.ts`: the module Scope note and the resolved-token section. - `engine-top-level.ts`: the one comment above `assertTemporalComparandsInterpretable`. - `engine-delete-and-aggregate.ts`: the per-aggregation comment from comment 7013425050, plus the same sentence on `having` in that file. - `core/src/utils/import-coerce.ts`: the `readTimeOfDayCell` note. Every placeholder is refused there first, by `classifyFilterToken` (:361). - `spec/src/data/filter-number-comparand-declared-type.ts`: the tokens section. The resolved forms now include the period key's ISO week key (`filter-tokens.ts`, the period-key resolver). - `lint/src/validate-rls-predicate-enforceability.ts`: which code a placeholder gets with no caller. The card names it under `packages/objectql/src/validation/`, but the file lives at `packages/lint/src/`. On a temporal field a period key or a context token answers `INVALID_FILTER` from the door. On a number or a boolean field every placeholder does: the number door (`filter-number-comparand-declared-type.ts:351`) and its boolean arm (`filter-boolean-comparand-declared-type.ts:234`, wired under the number door in `engine-top-level.ts`). Otherwise the resolver decides (`filter-tokens.ts:491-528`). - N4: the junk-literal consequence (`temporal-comparand-door.ts:748-750`) now reads "As written it would reach the driver and be compared as text: it may select every row, none or the wrong ones (or raise a database error), an answer indistinguishable from a real one." Neither "every row or none" nor "a 200" is exact: on a `date` field a partial day such as `'2026-06'` selects a subset, and PostgreSQL raises a database error for text on a `date` column (the measurement at :144). The `having` twin (:827-830) says the same of the groups: "As written it would be compared with each group as text: it may keep every group, none or the wrong ones (or raise a database error), an answer indistinguishable from a real one." The comments that quoted the old phrase (module note, `MisreadClass` doc, year-class comment) are updated. The two `not.toContain` pins in `engine-temporal-comparand-door.test.ts` and `engine-temporal-year-range.test.ts` now name the new phrase, so they are not vacuous. A positive pin on the junk cells (`engine-temporal-comparand-door.test.ts`, the card's comparands test) holds them to it. - N6: see DELIBERATE CORRECTION below. ### DELIBERATE CORRECTION — `.changeset/35394-context-token-temporal-door.md` This changeset is pending (it is still in `.changeset/`). Its analytics read-scope bullet now reads: "a scope that compares a `date`, `datetime` or `time` field with a context placeholder is now refused at compile". The predicate judges a context token as written on all three kinds (`temporal-comparand.ts:292-298`), and the same changeset's own BREAKING line already names all three. `check-empty-changeset` is red for this note by design. The confirming record is the dispatching seat's (landing-operations.md). ### Changeset `.changeset/t1-stale-prose.md` bumps `patch` for `@objectstack/spec`, `objectql`, `core`, `lint`, `service-analytics` and `@object-ui/fields`. It carries the two declaration lines. ## Tests <details><summary>Rework runs at 1965e42 (the L2 should-fixes S1 to S3, nits N1 and N5)</summary> - `pnpm --filter '@objectstack/service-analytics^...' --filter '@objectstack/lint^...' build`, then `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/migrations src/data/currency-summary-home-rollup.test.ts`: Test Files 6 passed (6), Tests 220 passed (220). - `pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-temporal-comparand-door.test.ts src/engine-temporal-year-range.test.ts src/filter-refusal-prescription-cap.test.ts src/engine-aggregate-having-temporal-door.test.ts src/engine-aggregate-positions.test.ts`: Test Files 5 passed (5), Tests 142 passed (142). - `typecheck` for spec, objectql, lint and service-analytics: all Done. Lock verdict: command-exit 0. - Ablation of the moved junk pin (`scripts/ablation-replace.mjs` on `temporal-comparand-door.ts`, the new message line put back to the old "selecting every row or none" phrase): the anchor went 1 → 0 and the blob 22fbb45 → 4960e73e. The card's comparands test went red (Tests 1 failed, 15 passed), then the file was restored and its blob equals HEAD, with `git diff HEAD` empty. </details> <details><summary>Local runs at a555ecc</summary> - `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/data/currency-summary-home-rollup.test.ts src/migrations`: Test Files 6 passed (6), Tests 220 passed (220). - `pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/record-currency-guards.test.ts src/engine-temporal-comparand-door.test.ts src/engine-temporal-year-range.test.ts src/filter-refusal-prescription-cap.test.ts`: Test Files 4 passed (4), Tests 132 passed (132). - `typecheck` for spec, objectql, core, lint and service-analytics: all Done. `@object-ui/fields` `type-check` was NOT MEASURED locally: the `ui/` deps are unbuilt in this container (TS2307 on `@object-ui/components` and others, in files this diff does not touch). CI `Type Check UI` covers it. - Ablation of the N3 message (`scripts/ablation-replace.mjs`, anchor `is ${defect}, not a` → `is ${kind}, not a`): the anchor went 1 → 0 and the blob c0ea2ce → 67a4d5c7. The new case went red (Tests 1 failed, 21 passed), then the file was restored and its blob equals HEAD, with `git diff HEAD` empty. </details> ## Acceptance notes - Contract review PASS at a555ecc (comment 7035670717): S1 to S3 and nits N1 and N5 are folded in at 1965e42. N2, N3, N4 and N6 are left as they are. S4 (the "resolves to an id or a date" sentences) is filed as its own card. - `overlap-check`: merges cleanly with `origin/main` and with #34817 (`engine-top-level.ts`). It reports a conflict with #35129, the Version Packages PR, on the pending 35394 changeset. That conflict is the expected delete-vs-modify shape for a pending note. - `engine-top-level.ts:962-963` (number door comment) says every placeholder resolves "to an id or a date". A period key resolves to a week key. That comment is outside the one edit allowed on this file, so it is left; the same sentence in `filter-number-comparand-declared-type.ts` is corrected. ## Verification Two minutes: `pnpm --filter @objectstack/spec exec vitest run src/data/currency-summary-home-rollup.test.ts`. Expect 22 passed, including "a `currency` child that is neither `dynamic` nor a well-formed `record` / `fixed` …". Read first: 1. `packages/spec/src/data/record-currency-path.ts`: the `defect` hunk. It is the only new branch. 2. `packages/objectql/src/temporal-comparand-door.ts`: the junk message at :747. 3. `content/docs/ui/dashboards.mdx`: the rewritten bullet. L2 owed: `packages/spec/src/**` is in the diff, so one `CONTRACT_REVIEW_TIER` review is owed. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb)_ --- Body refreshed 2026-11-20T10:13Z for the should-fix rework (contract review 7035670717: S1–S3, N1, N5), head 1965e42. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9d07723 commit d280de9

18 files changed

Lines changed: 180 additions & 80 deletions

‎.changeset/35394-context-token-temporal-door.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ The engine's judge-only admission runs the same door, and so do two of its reade
2222

2323
- `IObjectQLEngine.judgeFilter` answers `{ ok: false, code: 'INVALID_FILTER', status: 400 }` for this spelling on a temporal field. With a session it answered `{ ok: true }`; without one it answered `FILTER_TOKEN_UNRESOLVED`.
2424
- Lint's row-scope predicate rule (`rls-predicate-unenforceable`) still refuses a predicate such as `due_on < '{current_user_id}'`. The finding now quotes `INVALID_FILTER / 400` with the hint to rewrite the comparison, where it quoted `FILTER_TOKEN_UNRESOLVED / 400` with the hint to write the caller's value as a `current_user` key.
25-
- Analytics read-scope admission: when the analytics service asks the engine to admit an object's read scope, a scope that compares a `date` or `datetime` field with a context placeholder is now refused at compile, `READ_SCOPE_COMPILE_FAILED` (500, fail-closed). After the upgrade, a dashboard or analytics query over such an object answers 500 until that clause is rewritten as below.
25+
- Analytics read-scope admission: when the analytics service asks the engine to admit an object's read scope, a scope that compares a `date`, `datetime` or `time` field with a context placeholder is now refused at compile, `READ_SCOPE_COMPILE_FAILED` (500, fail-closed). After the upgrade, a dashboard or analytics query over such an object answers 500 until that clause is rewritten as below.
2626

2727
The fix for an author: compare the date field against a date (a `YYYY-MM-DD` day, an ISO-8601 instant, or a date macro such as `{30_days_ago}`), and compare the user or organization id against the field that holds it, such as `owner_id`. In a row-level-security predicate, write `owner == current_user.id`.

‎.changeset/t1-stale-prose.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@objectstack/objectql': patch
4+
'@objectstack/core': patch
5+
'@objectstack/lint': patch
6+
'@objectstack/service-analytics': patch
7+
'@object-ui/fields': patch
8+
---
9+
10+
docs: stale prose on summary currency, the temporal-comparand door and analytics filters now says what the code does
11+
12+
Clause-②: no
13+
Metadata-protocol: none
14+
15+
No accepted value, key or answer moves. Two refusal messages change their words:
16+
17+
- A `currencyMode: 'dynamic'` summary over a child `currency` field that is neither `dynamic` nor a well-formed `record` / `fixed` (a stored `fixed` field with no `defaultCurrency`, or a `currencyMode` outside the three) is still refused, and the refusal now names what the child lacks: "is a 'currency' field in `fixed` mode with no `defaultCurrency` code (the currency it is fixed to is missing)", or "is a 'currency' field whose `currencyMode` 'X' is none of `dynamic`, `fixed` and `record`". Before, it said only "is a 'currency' field, not a `currency` field in `dynamic` mode".
18+
- The temporal-comparand door's refusal of a comparand no temporal rule reads (`'not-a-date'`, the preset name `'last_30_days'`) now ends "As written it would reach the driver and be compared as text: it may select every row, none or the wrong ones (or raise a database error), an answer indistinguishable from a real one." Before, it said the comparison would "compare false for EVERY row", which was wrong for `$lt` and others that selected every row, for a partial day such as `'2026-06'` that selected a subset, and on PostgreSQL, which raised a database error. Its `having` twin says the same of the groups it would keep, where it said "no group or every group, a 200".
19+
20+
The upgrade-guide entry `summary-dynamic-currency-rollup-home-amount-judged-as-served` now states the admitted set as both doors enforce it: a `dynamic` summary may roll up any child `currency` field in `dynamic` mode, a stored home amount included. Source comments and published docblocks that said every `{placeholder}` is stepped around by the temporal door now state the per-kind rule: a date macro is stepped around and judged by its year once resolved, a period key and a context token are judged as written, and an unknown or record-context token is left to the resolver.

‎content/docs/ui/dashboards.mdx‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -577,14 +577,18 @@ the base rows whose relationship points at a record it returned:
577577
unfiltered set.
578578
- A related field the caller cannot read is refused (`403 PERMISSION_DENIED`), as
579579
filtering on it directly would be.
580-
- On a SQL datasource the related condition runs inside the same statement, as
581-
a subquery, so the number of matching related records is not limited. Where
582-
the engine reads the matching related ids first instead (a related object on
583-
another datasource, a federated one, or a driver that compiles no subquery,
584-
such as MongoDB; the full list is in
585-
[Query Syntax](/docs/protocol/objectql/query-syntax)), more than 1,000 of them
586-
are refused (`400 INVALID_FILTER`), never truncated. Narrow the related
587-
condition.
580+
- On a SQL datasource a condition through a single-valued relation usually
581+
runs inside the same statement, as a subquery, so the number of matching
582+
related records is not limited. Where the engine reads the matching related
583+
ids first instead (a multi-valued relation, on every driver; a related object
584+
on another datasource, a federated one, one whose reads an object-scoped
585+
middleware or an `afterFind` hook shapes, or one read under different driver
586+
options than the queried object, its tenant scope most commonly; the full
587+
list is in [Query Syntax](/docs/protocol/objectql/query-syntax)), more than
588+
1,000 of them are refused (`400 INVALID_FILTER`), never truncated. Narrow the
589+
related condition. On a driver that cannot run it in one read (MongoDB,
590+
OData), a condition through a single-valued relation is refused before
591+
anything is read (`400 INVALID_FILTER`), naming the two-step route.
588592
- These are refused (`400 INVALID_FIELD`) rather than answered differently: a
589593
path of four or more relationships (`line.plan.order.customer.tier`), a
590594
related-field condition under `$not` (write `$ne` / `$nin` inside the

‎packages/core/src/utils/import-coerce.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,10 @@ function pad2(n: number): string {
348348
* read back unchanged, and it reads `07/15/2026 10:00` through `Date.parse`
349349
* in the host's zone and rolls `2026-02-30T10:00:00Z` over to March 2, both of
350350
* which the verdict refuses. A `{placeholder}` is filter vocabulary, which the
351-
* verdict steps around rather than judges, so it is refused here, as the write
352-
* door refuses it.
351+
* verdict does not refuse whole: it steps around a date macro and an unknown or
352+
* record-context token, and judges only a period key and a context token as
353+
* written. So every placeholder is refused here first, by
354+
* `classifyFilterToken`, as the write door refuses it.
353355
*
354356
* This replaced a private pattern with no fractional part, which refused the
355357
* `10:00:00.250` that `/export` writes for a `time` with milliseconds, so such

‎packages/lint/src/validate-rls-predicate-enforceability.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,17 @@
202202
* app-staged set holds app data this rule cannot know: measured,
203203
* `close_date in current_user.holidays` lowered with the probe string is
204204
* refused by the temporal door, while with `[]` it is admitted.
205-
* - **With what context:** none. A `{placeholder}` string in a predicate
206-
* therefore answers `FILTER_TOKEN_UNRESOLVED` (known) or
207-
* `FILTER_TOKEN_UNKNOWN` (unknown) — the engine's own semantics for a filter
208-
* judged with no caller. An RLS predicate names the caller as `current_user.*`.
205+
* - **With what context:** none, so a `{placeholder}` string in a predicate
206+
* answers as the engine answers a filter judged with no caller. The
207+
* field-aware doors run first: on a `date`, `datetime` or `time` field a
208+
* period key or a context token is judged as written and answers
209+
* `INVALID_FILTER` (the temporal door), and on a number or a boolean field
210+
* every placeholder does (the number door and its boolean arm). Otherwise
211+
* the resolver answers: a
212+
* context token or a record-context token `FILTER_TOKEN_UNRESOLVED`, an
213+
* unknown one `FILTER_TOKEN_UNKNOWN`, while a date macro and a period key
214+
* resolve with no caller (a date macro then judged by its year). An RLS
215+
* predicate names the caller as `current_user.*`.
209216
* - **When:** only when every pass above left this clause clean, so one
210217
* defect earns one finding.
211218
*

‎packages/objectql/src/engine-delete-and-aggregate.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,10 @@ export class DeleteAndAggregateFacet {
11881188
// bound in a `where` was refused 400 — measured on the base on
11891189
// driver-memory and driver-sql, through the engine and REST.
11901190
// Before the token resolver below, as there, so a `{placeholder}`
1191-
// is stepped around and resolved (or refused) a moment later.
1191+
// is judged by its kind as there: a date macro is stepped around
1192+
// and judged by its year once resolved, a period key or a context
1193+
// token is judged as written, and an unknown or record-context
1194+
// token is left to the resolver, which refuses it a moment later.
11921195
// [#20334] Rooted at this position too: the refusal said
11931196
// `at where.placed_on.$gt`.
11941197
assertTemporalComparandsInterpretable(
@@ -1454,9 +1457,11 @@ export class DeleteAndAggregateFacet {
14541457
// group with a 200). Both `applyHaving` doors below read `ast.having`, so
14551458
// one call covers the native and the rows path, before any driver read.
14561459
// After every `having` door above, as `where`'s resolution follows its
1457-
// doors: the temporal door steps around a `{placeholder}` exactly as
1458-
// `where`'s does (so, as there, the resolved value is judged only for
1459-
// its year, by the resolution stage — #20844), and the other doors
1460+
// doors: the temporal door judges a `{placeholder}` by its kind exactly
1461+
// as `where`'s does (a date macro stepped around, so, as there, its
1462+
// resolved value is judged only for its year, by the resolution stage —
1463+
// #20844; a period key or a context token judged as written; an unknown
1464+
// or record-context token left to this resolver), and the other doors
14601465
// judged a string that resolves to a string.
14611466
{
14621467
const havingColumnTypes = aggregatedRowColumnTypes(query.groupBy, query.aggregations, declaredFields);

‎packages/objectql/src/engine-temporal-comparand-door.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ describe('[#8690] the temporal-comparand door at the engine collection point', (
197197
expect(err!.message).toContain('created_date');
198198
expect(err!.message).toContain(comparand);
199199
expect(err!.message).toMatch(/NOT applied/);
200+
// The junk class's consequence, the phrase the misread and year classes
201+
// are pinned NOT to carry: compared as text, every row, none or the wrong ones.
202+
expect(err!.message).toContain('compared as text: it may select every row, none or the wrong ones');
200203
// And no driver read happened — the refusal precedes the driver.
201204
expect(reads).toHaveLength(0);
202205
}
@@ -446,8 +449,8 @@ describe('[#20549] the comparand door refuses what the write door refuses — a
446449
expect(err!.message).toContain(`'${field}'`);
447450
expect(err!.message).toMatch(/NOT applied/);
448451
// Not junk: the rule READ it, as the wrong value, so the refusal does
449-
// not claim it would have compared false for every row.
450-
expect(err!.message, `${field} ${value}`).not.toContain('compare false for EVERY row');
452+
// not claim the junk class's "compared as text: it may select every row, none or the wrong ones".
453+
expect(err!.message, `${field} ${value}`).not.toContain('compared as text: it may select every row, none or the wrong ones');
451454
}
452455
}
453456
expect(reads, 'every refusal precedes the driver').toHaveLength(0);

‎packages/objectql/src/engine-temporal-year-range.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ describe('[#20264] the temporal-comparand door — a year outside the kind\'s ye
221221
expect(reads, 'every refusal precedes the driver').toHaveLength(3);
222222
});
223223

224-
it('the refusal names the year class, not "compares false for every row"', async () => {
224+
it('the refusal names the year class, not the junk class\'s "every row, none or the wrong ones"', async () => {
225225
const err = await refusalOf(engine.find('ledger', { where: { opened_at: { $gt: Y10000 } } }));
226226
expect(err!.message).toContain("'opened_at'");
227227
expect(err!.message).toContain('where.opened_at.$gt');
228228
expect(err!.message).toContain('1000 to 9999');
229-
expect(err!.message).not.toContain('compare false for EVERY row');
229+
expect(err!.message).not.toContain('compared as text: it may select every row, none or the wrong ones');
230230
// A `date` keeps its own years in its words.
231231
const day = await refusalOf(engine.find('ledger', { where: { placed_on: { $gt: Y10000 } } }));
232232
expect(day!.message).toContain('0001 to 9999');

‎packages/objectql/src/engine-top-level.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,11 @@ export function lowerWhereFilterArray<T extends object | undefined>(
952952
// asks "can that column's storage rule READ this value".
953953
// It must run BEFORE `resolveWhereTokens` (which is downstream of every
954954
// caller of this function) because the refusal has to precede the driver —
955-
// hence the door steps around `{placeholder}` strings rather than judging
956-
// them; the token resolver refuses the unknown ones a moment later, loudly.
955+
// hence the door judges a `{placeholder}` by its kind rather than as the
956+
// value it resolves to: a date macro is stepped around (judged by its year
957+
// once resolved), a period key or a context token is judged as written, and
958+
// an unknown or record-context token is left to the token resolver, which
959+
// refuses it a moment later, loudly.
957960
assertTemporalComparandsInterpretable(object, operation, schema, where);
958961
// [#20351] The NUMBER-comparand declared-type door, fifth on the same seam
959962
// and fifth question about the same predicate: is this string a number the

‎packages/objectql/src/temporal-comparand-door.ts‎

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@
9090
* it in passing"); measured, `$gte ""` binds as `''` and returns every
9191
* non-null row — 51 of 51, not the 38 the card's table records, which is a
9292
* transcription error its own prose corrects.
93-
* - **`{placeholder}` strings are stepped around**, not judged. This gate runs
94-
* BEFORE `resolveWhereTokens` (which is where it must run — the refusal has
95-
* to precede the driver), so judging one would refuse `{30_days_ago}`, the
96-
* platform's own correct spelling. Unknown tokens keep their existing loud
97-
* refusal one layer down, and [#20844] a known one is judged once resolved,
98-
* by its year alone (below).
93+
* - **A `{placeholder}` is judged per kind** (`@objectstack/core`'s
94+
* `PLACEHOLDER_AT_THE_TEMPORAL_RULE`, one row per `classifyFilterToken`
95+
* kind). This gate runs BEFORE `resolveWhereTokens` (which is where it must
96+
* run — the refusal has to precede the driver). A date macro is stepped
97+
* around, because judging it as written would refuse `{30_days_ago}`, the
98+
* platform's own correct spelling; [#20844] it is judged once resolved, by
99+
* its year alone (below). [#34938] A period key (`{current_iso_week}`) and
100+
* [#35394] a context token (`{current_user_id}`) are judged AS WRITTEN: each
101+
* resolves to text no temporal rule reads (a week key, an id), so each takes
102+
* the refusal its literal takes. An unknown or a record-context token is
103+
* stepped around and left to the resolver, which refuses it by name
104+
* (`FILTER_TOKEN_UNKNOWN` / `FILTER_TOKEN_UNRESOLVED`, 400).
99105
* - **Non-string comparands are not judged, save the year classes.** A number
100106
* is epoch milliseconds and a `Date` is an instant; the `datetime` and `time`
101107
* rules read both, [#20480] a `time` column only when the instant's UTC year
@@ -140,7 +146,8 @@
140146
*
141147
* These are not junk: the rule reads each one, as the wrong value, so each
142148
* answered rows. Their refusal says so in its own words ({@link misreadClassOf})
143-
* rather than in the junk class's "compare false for EVERY row".
149+
* rather than in the junk class's "compared as text: it may select every row,
150+
* none or the wrong ones".
144151
*
145152
* ## [#20480] An instant on a `time` column outside the four-digit years
146153
*
@@ -188,8 +195,8 @@
188195
*
189196
* ## [#20844] A relative-date placeholder, judged by its year once resolved
190197
*
191-
* The door steps around a `{placeholder}`, so the year range never saw what
192-
* one resolved to. Measured before this on InMemoryDriver and SqlDriver on
198+
* The door steps around a date macro, so the year range never saw what one
199+
* resolved to. Measured before this on InMemoryDriver and SqlDriver on
193200
* SQLite, through `engine.find` and `POST /data/:object/query`, a `datetime`
194201
* field and two rows, one in 2026 and one in 1500:
195202
*
@@ -623,8 +630,8 @@ function yearClassOutside(kind: 'date' | 'datetime', value: unknown): YearClass
623630
/**
624631
* [#20549] A comparand the storage rule READS, but not as the value it names —
625632
* the two readings the write door refused first, and `@objectstack/core`'s one
626-
* rule now refuses at both doors. Such a comparand does not compare false for
627-
* every row, as junk does: it answers rows, the wrong ones. Each class says
633+
* rule now refuses at both doors. Such a comparand is not junk, which no rule
634+
* reads at all: it is read, as the wrong value, and answers the wrong rows. Each class says
628635
* why, and what the value would have done, per position.
629636
*/
630637
interface MisreadClass {
@@ -712,10 +719,11 @@ export function assertTemporalComparandsInterpretable(
712719
const hit = findUninterpretableTemporalComparand(schema, where, path);
713720
if (!hit) return;
714721
// [#20240] [#20264] A comparand whose year falls outside the kind's years
715-
// gets words that say so. It does not compare false for every row as junk
716-
// does: its text orders as no day or instant does, so it answers the WRONG
717-
// rows (or, on PostgreSQL, a database error) — or [#20280], for a `datetime`
718-
// in 0001..0999, it names a year MySQL's `DATETIME` does not document.
722+
// gets words that say so. It is not junk, which is compared as text and may
723+
// select every row, none or the wrong ones: its text orders as no day or
724+
// instant does, so it answers the WRONG rows (or, on PostgreSQL, a database
725+
// error) — or [#20280], for a `datetime` in 0001..0999, it names a year
726+
// MySQL's `DATETIME` does not document.
719727
// [#27173] Each arm: the verdict, the prescription, then the consequence.
720728
const yearClass = yearClassOf(hit);
721729
if (yearClass) {
@@ -738,8 +746,8 @@ export function assertTemporalComparandsInterpretable(
738746
`${operation}('${object}'): filter on '${hit.field}' compares a declared ${hit.kind} `
739747
+ `field against ${preview(hit.value)} at ${hit.path}, which is not a ${hit.kind} value `
740748
+ `this platform can interpret. ${REMEDY[hit.kind]} The filter was NOT applied. As written `
741-
+ 'it would reach the driver, compare false for EVERY row, and return 200 with an empty '
742-
+ 'result — indistinguishable from "there is no data".',
749+
+ 'it would reach the driver and be compared as text: it may select every row, none or the '
750+
+ 'wrong ones (or raise a database error), an answer indistinguishable from a real one.',
743751
);
744752
}
745753

@@ -817,8 +825,9 @@ export function assertHavingTemporalComparandsInterpretable(
817825
throw invalidFilterError(
818826
`aggregate('${object}'): ${column} compares against ${preview(hit.value)} at ${hit.path}, `
819827
+ `which is not a ${hit.kind} value this platform can interpret. ${REMEDY[hit.kind]} The `
820-
+ '`having` was NOT applied. Compared with each group as written, it would keep no group or '
821-
+ 'every group, a 200 indistinguishable from a real answer.',
828+
+ '`having` was NOT applied. As written it would be compared with each group as text: it may '
829+
+ 'keep every group, none or the wrong ones (or raise a database error), an answer '
830+
+ 'indistinguishable from a real one.',
822831
);
823832
}
824833

0 commit comments

Comments
 (0)