Repository navigation
Commit df8d020
feat(spec): export isListComparandOperator from @objectstack/spec/data; flow record nodes read it instead of a local copy (#29570)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ83ALm8EpEcYUomnqmETUEW1)_
Fixes #29419
Clause-②: yes
Metadata-protocol: none
## 维护者速读
- 改了什么:`@objectstack/spec/data` 新增导出谓词
`isListComparandOperator(op)`,对声明列表比较值的字段运算符(`$in` / `$nin` /
`$between`)答 true,其余答 false;流程记录节点(`crud-nodes.ts`)改为导入它,删掉本地那份
`LIST_COMPARAND_OPERATORS` 副本及其对账测试。
- 为什么改:#29404 的合约评审 should-fix 2:执行器持有一份运算符拆分的副本,靠一条行为对账测试保持一致;现在只有 spec
一处来源,对账断言随谓词搬进 `packages/spec`。
- 风险与回滚:纯新增导出(加宽),执行器的接受与拒绝行为不变;两份集合本身仍不导出。回滚即撤销本 PR。
-
先看:`packages/spec/src/data/filter-comparand-operators.ts`(谓词与改写的模块说明),`packages/spec/src/data/filter-comparand-operators.test.ts`(对账断言的新家),`packages/services/service-automation/src/builtin/crud-nodes.ts`(导入替换)。
- 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run
src/data/filter-comparand-operators.test.ts`,预期 1 个测试文件、2 个用例全部通过。
- 需要你做的:无,席位落地。
## What changes
- **`isListComparandOperator(op: string): boolean`**
(`packages/spec/src/data/filter-comparand-operators.ts`), exported from
`@objectstack/spec/data` (`packages/spec/src/data/index.ts`, a named
re-export). It answers whether a `$`-spelled field operator declares a
LIST comparand, reading the same `LIST_COMPARAND_OPERATORS` set the
comparand-type face reads. TSDoc is one sentence.
- **Why a predicate and not the set.** The card allows either. A
published `ReadonlySet` is still a live `Set` at run time: a caller that
cast and mutated it would change what every comparand face in
`packages/spec` judges. The predicate publishes the answer and keeps
both sets module-private. The module docblock's section "Why it is NOT
in the `data` barrel" is rewritten to say what the barrel now publishes
from the file and why the sets stay out.
- **`packages/services/service-automation/src/builtin/crud-nodes.ts`**:
`operandValueRefusal` asks `isListComparandOperator(last)`; the local
`LIST_COMPARAND_OPERATORS` and its docblock are removed, and the
function docblock names the spec predicate. An import swap, nothing
else.
- **Retired test**: `crud-filter-guard.test.ts` "every declared operator
whose comparand is a list takes an evaluated list, and no other does",
plus its now-unused `FieldOperatorsSchema` import. Its assertion, every
operator `FieldOperatorsSchema` declares is a list operator exactly when
its enforced slot takes a list, now lives in
`packages/spec/src/data/filter-comparand-operators.test.ts`, against the
predicate the executor calls. That is the same assertion at a layer
closer to the code. The executor's own use of the predicate stays pinned
by the file's remaining list-operator cases (see the ablation below).
- **Generated**: `packages/spec/api-surface/data.json` and
`packages/spec/export-origins/data.json` gain the one row each.
- **Changeset**:
`.changeset/29419-list-comparand-operator-predicate.md`, `patch` for
`@objectstack/spec` and `@objectstack/service-automation`, carrying both
declaration lines.
## Tests
- New `packages/spec/src/data/filter-comparand-operators.test.ts` (2
cases), importing through the `data` barrel: the predicate answers
`true` exactly for each declared operator whose `FieldOperatorsSchema`
slot accepts a two-item list (with a control that the grammar declares
more than ten operators, and the derived list pinned to `$between`,
`$in`, `$nin`), and `false` for undeclared spellings (`in`, `between`,
`$and`, `$or`, `$not`, `$IN`, the empty string, `has`).
- `crud-filter-guard.test.ts` loses the one retired case: 66 to 65.
- **Forced test edits:** none beyond the retirement above.
## Acceptance notes
- **Changeset level.** The claim assumed a spec minor. AGENTS.md
Post-Task Checklist step 3 ties the level to `Metadata-protocol` alone,
and `none` takes `patch`, so both packages ship `patch`.
- **File surface addition.** The new spec test file is outside the
claim's listed surface. It is where the retired reconciliation lands, so
I added it here.
- **Other local copies, not touched.**
`packages/drivers/driver-sql/src/sql-driver.ts` and
`packages/plugins/plugin-security/src/rls-check-stored-form.ts` each
hold their own `LIST_COMPARAND_OPERATORS` (`$in`, `$nin`, `$between`).
Both equal the spec set today, and neither is in this card's scope. Not
filed: there is no defect, only a possible follow-up to read the new
predicate.
- `packages/spec/src/data/filter-comparand-shape.ts` keeps its own
module-private `LIST_COMPARAND_OPERATORS` map (operator to authoring
spellings). It is a different shape, unchanged.
- No `protocol.ts` file is touched.
## Verification
Readings on head `e5b9d970c` (`6e184de6c` merges `origin/main`
`390bd2aed`, then the artifact regeneration), except where a line names
`4cc2f8814`, the pre-merge head.
<details><summary>Tests and typecheck</summary>
- Under the verify lock on `4cc2f8814`: `turbo run build
--filter='@objectstack/service-automation^...'` 31/31 tasks; `vitest
run` in `packages/services/service-automation`: 262 files / 3394 tests
passed; `pnpm --filter @objectstack/service-automation typecheck` exit 0
(`VERDICT command-exit 0`).
- Under the verify lock on `e5b9d970c`: spec
`filter-comparand-operators`, `filter-comparand-type`,
`filter-comparand-shape` tests: 3 files, 166 passed, 1 todo;
`crud-filter-guard.test.ts`: 65 passed; `pnpm --filter @objectstack/spec
typecheck` and `pnpm --filter @objectstack/service-automation typecheck`
exit 0 (`VERDICT command-exit 0`).
- `pnpm --filter @objectstack/spec check:generated` after a spec build
on `e5b9d970c`: all 14 artifacts up to date.
- `test:repo` is not run locally (no file of that project changed); it
is CI's `Test Core`.
</details>
<details><summary>Ablations</summary>
Each through `scripts/ablation-replace.mjs` (anchor hit once, blob
changed, restored to the HEAD blob, `git status` clean after), on
`4cc2f8814`. Both tests import the code under test from source, so no
`dist` leg applies.
- `isListComparandOperator` made to answer `false` for `$between`:
`filter-comparand-operators.test.ts` 1 failed / 1 passed of 2.
- `crud-nodes.ts` made to treat `$nin` as a scalar operator:
`crud-filter-guard.test.ts` 4 failed / 61 passed of 65 (the three "an
evaluated list at a list operator's comparand passes" cases and the
empty-entry refusal).
</details>
<details><summary>Derived gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` derived 84 families on
`e5b9d970c`; all 84 ran there, each exit 0, with exit codes captured
before any pipe. `--ran` reconciliation: "84 derived, 84 run, 0
NOT-MEASURED, 0 UNRUN", exit 0.
- On `4cc2f8814` the same 84 ran. `check:dual-build-cjs-loads` exited 3
there (PREREQUISITE NOT MET: no `dist/` for packages outside this diff's
closure), and `check-plugin-teardown-shape --self-test` exited 3 until
its pinned fixture commit was fetched into the shallow clone, then
exited 0.
- The repo-wide families (`pnpm lint` first among them) are CI's.
</details>
Dogfood battery: not run (no `!` in the title and no `(narrowing)` arm).
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(The predicate is a constant lookup beside the constant it reads.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` is CI's.
- [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.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbZwoKyGHFx3aiQohjE)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1a95c74 commit df8d020
8 files changed
Lines changed: 75 additions & 39 deletions
File tree
- .changeset
- packages
- services/service-automation/src/builtin
- spec
- api-surface
- export-origins
- src/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
395 | 394 | | |
396 | 395 | | |
397 | 396 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | 397 | | |
415 | 398 | | |
416 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | 152 | | |
163 | 153 | | |
164 | 154 | | |
| |||
168 | 158 | | |
169 | 159 | | |
170 | 160 | | |
171 | | - | |
172 | | - | |
173 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
174 | 164 | | |
175 | 165 | | |
176 | 166 | | |
| |||
184 | 174 | | |
185 | 175 | | |
186 | 176 | | |
187 | | - | |
| 177 | + | |
188 | 178 | | |
189 | 179 | | |
190 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
| 937 | + | |
937 | 938 | | |
938 | 939 | | |
939 | 940 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
| 923 | + | |
923 | 924 | | |
924 | 925 | | |
925 | 926 | | |
| |||
| 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 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
0 commit comments