Repository navigation
Commit e71ecc1
docs(skills): teach that a column with no value fails an ordering filter, and where a per-measure filter runs (#34014)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9NXd2SJ1z5XQzawbhD1qEaF)_
Fixes #33868
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:查询技能新增一条规则「没有值的列(null
或缺失)不满足任何大小比较(`$gt/$gte/$lt/$lte/$between`)」,并改正了「带 filter
的度量一定走内存」这句已过时的话(声明 `aggregationFilter` 的驱动在数据库里算),另加一条评测用例。
- 为什么改:#33854 已改变运行时行为;不教的话,作者和 AI 会以为 `amount $lte 0`
也会把没填金额的记录算进去,仪表盘上的数字会被误读,且技能还在说一句已经不成立的话。
- 风险与回滚:只改技能文档、一条 eval 和一个 changeset,不动运行时代码;回滚即 revert 本 PR。
- 先看:`skills/objectstack-query/rules/aggregation.md`(Filtered
Aggregation 提示块,措辞最接近契约承诺)→ `rules/filters.md`(新规则一节,以及为付账删掉的两处重复)→
`evals/filters-pagination-search.json` 第 8 条。
- 两分钟验证:`node scripts/check-skills-token-ratchet.mjs`,预期全绿,filters.md 显示
`2473 / 2473`、aggregation.md 显示 `2264 / 2357`。
- 需要你做的:批准本 draft(受管面 Tier H)。
## What changes
The query skill now teaches two things PR #33854 made true, and drops
one sentence it made false.
`skills/objectstack-query/rules/filters.md` (published, English):
- **New section "A column with no value fails every ordering test"** (it
replaces "Prefer `$null` to a bare `null` comparand", whose rule is kept
as its last sentence): `$gt` / `$gte` / `$lt` / `$lte` / `$between`
never match a row whose column is null or absent, in `where`, an
aggregation's `filter` and `having` alike; `{ amount: { $lte: 0 } }`
skips the rows with no amount, and an `$or` with `{ amount: { $null:
true } }` keeps them. `null` is not an ordering comparand (`{ $gte: null
}` is refused `INVALID_FILTER` / 400).
- **Paid for in the same file** by two restatements: the
case-sensitivity paragraph, whose rule `SKILL.md` § String Operators
carries ("compare CASE-SENSITIVELY; `$icontains` is the case-INSENSITIVE
twin (ASCII folding only)"), now a one-line pointer; and the second Date
example (`$between` over two `Date`s), whose home is the operator
table's `$between` row plus the `$gte: new Date(…)` example kept
directly above it. Lost with no home: the `café` / `CAFÉ` illustration
of ASCII-only folding (the rule survives in SKILL.md).
`skills/objectstack-query/rules/aggregation.md`:
- **§ Filtered Aggregation:** the callout no longer says any filtered
measure "forces the in-memory path — no driver compiles a conditional
aggregate, and one reached directly refuses `NOT_IMPLEMENTED`". A driver
that declares `supports.aggregationFilter` (`driver-sql`; `driver-turso`
outside remote mode) runs the filter in the database whenever the
aggregate itself is pushed down (a date bucket under a non-UTC
`timezone`, or a granularity the driver does not bucket natively, keeps
the whole call in memory: `tzRequiresInMemory` and
`allStructuredSupported` sit in the same route condition), compiled as
that datasource's `where` is: it answers what the same condition answers
there (text by the database collation) and is refused where it is (the
pinned case: a `{ $field }` comparison on a column the object does not
declare, `INVALID_FILTER` / 400). On any other driver the engine reads
the scoped rows and evaluates the filter itself; no answer is promised
beyond that. A column with no value fails its ordering tests either way.
- **§ HAVING:** `avg` / `min` / `max` over no values is `null`, so
`having: { average: { $lte: 0 } }` drops that group.
`skills/objectstack-query/evals/filters-pagination-search.json`: case 8,
one aggregate call returning the total and the count of deals whose
`amount` is zero or less, where a deal with no amount must count.
`must_contain`: `filter`, `$or`, `$lte: 0`, `$null: true`;
`must_not_contain` is empty, so no correct answer that restates the rule
can trip it. Spliced with the file's hand formatting kept.
`skills/objectstack-ui/rules/dashboards.md` is untouched: it never
states how a measure filter is evaluated (it only lists "measure-scoped
filters" as fitting a dataset).
`.changeset/33868-skills-no-value-ordering-measure-filter.md`:
`'@objectstack/skills': patch`.
Every taught fact is read from origin/main at or after `0ac112fc`:
- `packages/objectql/src/having-filter.ts`:
`NULL_IS_NOT_ORDERED_OPERATORS = new Set(['$gt', '$gte', '$lt', '$lte',
'$between'])`; in `checkCondition`, `if (value === undefined &&
!NO_VALUE_ANSWERED_BY_OPERATOR.has(op)) return false;` then `if (value
=== null && NULL_IS_NOT_ORDERED_OPERATORS.has(op) &&
!orderingComparandHoldsNull(op, target)) return false;`. Pinned by
`having-filter-null-ordering.test.ts` (each face, and the empty-group
`having`) and
`packages/rest/src/aggregate-measure-filter-pushdown.test.ts` ("a NULL
amount fails an ordering filter on both paths").
- `packages/spec/src/data/filter.zod.ts` ("null is NOT a comparand: null
is not ordered — state absence with the null predicate instead") and
`filter-comparand-shape.ts` (`nullOrderingComparandError`,
`INVALID_FILTER` / 400).
- `packages/objectql/src/engine-delete-and-aggregate.ts`: `const
aggregationFilterNative = drv?.supports?.aggregationFilter === true;`
and the `(!hasAggregationFilter || aggregationFilterNative)` route
condition.
- `packages/drivers/driver-sql/src/sql-driver.ts` (`aggregationFilter:
true`); `packages/drivers/driver-turso/src/turso-driver.ts`
(`aggregationFilter: false` in remote mode);
`packages/spec/src/data/driver.zod.ts` (the bit's describe text: text
compares by the backend collation as in `where`).
- `packages/rest/src/aggregation-filter-where-doors.test.ts`: the
`where` twin and the per-aggregation filter of `{ created_at: { $ne: {
$field: 'photo' } } }` on an audit-opt-out object both answer `{ status:
400, code: 'INVALID_FILTER' }` on driver-sql.
### Size readings (tree objectstack-ai/objectstack, origin/main bc6b7ff
→ head d47493b)
| Reading | Before | After |
|:--|--:|--:|
| `rules/filters.md` lines / bytes / tokens | 211 / 9925 / 2482 | 209 /
9892 / 2473 (row re-locked 2482 → 2473 at the measurement) |
| `rules/aggregation.md` lines / bytes / tokens | 262 / 8381 / 2096 |
270 / 9053 / 2264 (ceiling 2357, row unchanged) |
| `evals/filters-pagination-search.json` lines / bytes / tokens | 75 /
5464 / 1366 | 85 / 6422 / 1606 (eval fixture, measured, not ratcheted) |
| All 11 `skills/*/SKILL.md` lines | 4596 | 4596 (none touched) |
| Whole bundle, ratcheted (authored) tokens / ceilings | 187685 / 194017
| 187844 / 194008 (+159 / -9) |
| Whole bundle, eval fixtures tokens | 46508 | 46748 (+240) |
| Whole bundle total tokens | 245988 | 246387 (+399) |
`scripts/check-skills-token-ratchet.mjs`: the `filters.md` row is
re-locked at its measured 2473 (review N3), with the arithmetic and each
cut's home in the row comment; no other row moves.
## Tests
No code changed, so there is nothing to ablate. Gate readings are under
Verification.
## Acceptance notes
- **Build tier, declared:** `dispatch-gates --tier` puts `skills/**` at
the contract-review tier (clause ①). This card thread is served below it
and cannot switch its own model, so (as the claim records) the authoring
and the commit ran in an isolated os-dev subagent pinned to the
contract-review tier inside this worktree; the merge of main, relay
writes, gates and report ran in the thread.
- **Not taught, on purpose:** what `$ne` / `$nin` / `$notContains`
answer on a column with no value (each answers a column with no value by
its own arm, `NO_VALUE_ANSWERED_BY_OPERATOR`). It is a standing rule
this card did not change; the card's list of unchanged operators also
omits `$empty`, which the code keeps in the same set.
- **Refusal wording:** the skill names only the pinned refusal case. A
plain undeclared key (`{ nope: 1 }`) answers `INVALID_FIELD`, not
`INVALID_FILTER`, on both positions (row 4 of
`aggregation-filter-where-doors.test.ts`), so "undeclared column ⇒
`INVALID_FILTER`" is not written bare.
- **NOT MEASURED:** `driver-mongodb` own `where` on a null column with
`$lte` (no pin read; it rests on BSON type bracketing). `driver-memory`
own `find` is pinned by
`memory-matcher-null-value-and-comparand.test.ts` (#13553), per review
6897568297.
- Review round 1 (record 6897568297): S1 (pushdown clause), N1 ("no
values") and N3 (row re-lock) taken in one commit, `b87277b6`, authored
at the contract-review tier like the first; N2 left as is.
- Main was merged before each gate run (`a7754819`, `d47493ba`) so the
derivation read a current tree.
## Verification
All readings are at head `d47493ba` (`git rev-parse --short HEAD` after
the last commit), tree objectstack-ai/objectstack.
- Package build closure: `turbo run build --concurrency=2
--filter='./packages/**'` under `os-verify-lock.sh`, `VERDICT
command-exit 0` (held 5m35s, after the first merge; the second merge
touched only `scripts/pm/**` and `.claude/**`, nothing built).
- Acceptance gates: `check:skill-docs` ✅ "Skill docs in sync";
`check:skill-refs` ✅ "9 generated files in sync with packages/spec";
`check:skill-examples` ✅ "346 prose examples type-check across 3
surface(s)"; `check-skills-token-ratchet` ✓ "57 authored bundle file(s)
within their ceilings", rows `2473 / 2473` and `2264 / 2357`.
- `dispatch-gates --ran`: "63 derived famil(ies) accounted for — 63 run,
0 NOT-MEASURED (a DERIVED zero)" (63, not 45: the ratchet script is now
in the diff, so its families and `check:pm-dispatch-gates` are derived).
Three extra runs are recorded outside the derivation
(`check:skill-docs`, `check:skill-refs`, `check:skill-examples`).
- CI families outside the derived list are left to this PR's check-runs.
<details><summary>Derived gate list, 63 + 3, exit codes captured before
any pipe</summary>
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-declaration-mirrors.mjs :: exit 0
node scripts/check-declaration-mirrors.mjs --self-test :: exit 0
node scripts/check-doc-route-spelling.mjs --advisory :: exit 0
node scripts/check-doc-route-spelling.mjs --self-test :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-self-test-wired.mjs :: exit 0
node scripts/check-self-test-wired.mjs --self-test :: exit 0
node scripts/check-self-test-workflow-commands.mjs :: exit 0
node scripts/check-self-test-workflow-commands.mjs --self-test :: exit 0
node scripts/check-skills-token-ratchet.mjs :: exit 0
node scripts/check-skills-token-ratchet.mjs --self-test :: exit 0
node scripts/check-whole-set-label-write.mjs :: exit 0
node scripts/check-whole-set-label-write.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/bare-root-worklist.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0
pnpm check:agent-test-spelling :: exit 0
pnpm check:bash32-floor :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-command-ids :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:corpus-claim-drift :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:entry-guard :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:parse-guard :: exit 0
pnpm check:pm-dispatch-gates :: exit 0
pnpm check:pm-governed-merges :: exit 0
pnpm check:pm-skill-id-lint :: exit 0
pnpm check:pnpm-filter-targets :: exit 0
pnpm check:pnpm-flag-spellings :: exit 0
pnpm check:published-files :: exit 0
pnpm check:ratchet-remedy-authority :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:role-word :: exit 0
pnpm check:scripts-symbol-anchors :: exit 0
pnpm check:skill-compatibility :: exit 0
pnpm check:skill-frame-sync :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:skill-links :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm --filter @objectstack/spec check:skill-docs :: exit 0
pnpm --filter @objectstack/spec check:skill-refs :: exit 0
pnpm --filter @objectstack/spec check:skill-examples :: exit 0
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmQokeaWJKGm2S7ZrDA)_
<!-- signed: domain:skills#2 · os-steve ·
session_01ADHkmRxXmVQ41fqnaTPGAv -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1b9c73a commit e71ecc1
5 files changed
Lines changed: 54 additions & 22 deletions
File tree
- .changeset
- scripts
- skills/objectstack-query
- evals
- rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1085 | 1085 | | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | | - | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
1089 | 1095 | | |
1090 | 1096 | | |
1091 | 1097 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 29 | + | |
| 30 | + | |
34 | 31 | | |
35 | 32 | | |
36 | 33 | | |
| |||
124 | 121 | | |
125 | 122 | | |
126 | 123 | | |
127 | | - | |
| 124 | + | |
128 | 125 | | |
129 | | - | |
130 | | - | |
131 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
| |||
138 | 143 | | |
139 | 144 | | |
140 | 145 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
| |||
0 commit comments