Repository navigation
Commit 4db6fd7
feat(dispatch-gates): a change to FieldSchema's key set derives the three closure pins outside spec (#37046)
<!-- claude-projects-attribution: {"github_login":"huangyiirene"} -->
_Requested by **Irene** · [project
thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67x8Be2AAcUBhodBsvnWLd3Xs)_
Fixes #36483
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户无感:这是开发者本地自查清单工具的改动,改了字段定义的键集合时,本地清单会多列出三项该跑的测试。
- 为开发工具链补洞:此前给字段新增键时本地全绿、云端测试却红,两次各白费一轮。
- 出错最多是本地清单多列或漏列这三项测试,云端测试照旧兜底,可随时直接撤回。
- 要你做什么:这是受管的工具文件,需要你审核后亲手合并或入队。
## What changes
A diff that changes **FieldSchema's key set** now derives the three
tests outside `packages/spec` that pin that whole set, so the local
sweep owes what CI's Test Core shards will check:
- `pnpm --filter @objectstack/driver-sql exec vitest run
src/builtin-column-collision.test.ts` (FIELD_KEY_STORAGE_CLASS equals
the schema's keys, both ways)
- `pnpm --filter @objectstack/metadata-core exec vitest run
src/object-schema-fls-references.test.ts` (FIELD_REFERENCE_POSITIONS
classifies every key)
- `pnpm --filter @objectstack/metadata-protocol exec vitest run
src/protocol.meta-types-degenerate-derivation.test.ts` (the `field`
property count)
How (the card's first arm; the second arm, moving the pins next to the
schema, is package code outside this instrument):
- `dispatch-gates.data.mjs`: a new `CHANGE_KIND_ROWS` row
`field-schema-key-set` carrying the three tests as package-test subset
gates (`ciJob: 'Test Core'`, `ciRunner`, `ciSubset`), the shape of the
`spec-migration-entry` precedent, so each goes STALE when Test Core
stops running the package test task or the pinned file moves. Each `why`
states its measured build prerequisite. New
`FIELD_SCHEMA_KEY_DECLARATIONS` names where the key set is declared:
`FieldSchema` (second argument of its `strictObject` call) and
`MetadataProtectionFields` (spread into the shape). The row's deletion
criterion is added to the change-kind list.
- `dispatch-gates.mjs`: the predicate `changesFieldSchemaKeySet` reads
the **diff**, like the README claim net: it compares the declaration's
top-level members at the merge base (the existing `readReadmeNetBase`
reader) with the working tree. Two small readers back it:
`objectLiteralMembers` (depth-1 members over `maskCommentsAndLiterals`,
spreads kept as one member) and `declaredKeySet`. A created or deleted
file, or a declaration the reader cannot find, derives the row (reads
wide, never quiet).
- `dispatch-gates.self-test.mjs`: a new section (40 cases, all fast
tier) plus a census line pin moved 753 -> 755 by the two new import
lines.
Why diff-read and not a path match on `field.zod.ts`: over the month to
a73edb3, 48 first-parent commits touched `field.zod.ts`. 9 of them
changed the key set, and each of those 9 also moved the driver-sql
table, which pins the set both ways. Replaying this predicate over all
48 (base = parent, head = commit) fires on exactly those 9. A path match
would have named the three suites (and a metadata-protocol closure
build) 48 times to catch 9.
### Read first (by risk)
1. `scripts/pm/dispatch-gates.mjs`, `objectLiteralMembers`: the depth
scan. A wrong member list makes the row quiet or noisy. The live census
case holds it equal to the driver's table (87 = 87).
2. `scripts/pm/dispatch-gates.mjs`, `changesFieldSchemaKeySet`: the
unchanged-file branch returns false, so a surface the PM names before
code exists derives nothing (see Acceptance notes).
3. `scripts/pm/dispatch-gates.data.mjs`, the new row's three `why`
texts: the build prerequisites are measured, not inferred.
### Two-minute verification
Add a line `probeKey: z.boolean().optional(),` to FieldSchema's shape in
`packages/spec/src/data/field.zod.ts`, then run `node
scripts/pm/dispatch-gates.mjs --commands
packages/spec/src/data/field.zod.ts`. Expect 80 commands, the three
`vitest run src/...` lines among them. Change only a comment instead and
expect 77, none of them. Then `git checkout HEAD --
packages/spec/src/data/field.zod.ts`.
## Tests
<details><summary>Instrument battery and fast self-test, at head
81d3d66</summary>
- `pnpm check:pm-dispatch-gates` (detached, per the file header) -> `✓
dispatch-gates self-test (fast tier): 2313 cases pass; 9 slow section(s)
deferred.` `EXIT=0`. On a dev box the gate runs the fast tier by design;
CI runs both. The new cases are all fast tier.
- The first fast run before the census fix: `1 of 2313 case(s) failed`.
The census pins `scripts/pm/dispatch-gates.mjs:753
inherited-population`, and the two new import lines moved it to 755. Pin
moved with its comment line.
</details>
<details><summary>The three gates run as spelled, green on main (through
os-verify-lock)</summary>
- driver-sql, on a tree with **no dist at all** (no build): `Test Files
1 passed (1)`, `Tests 11 passed (11)`, `VERDICT command-exit 0`. This
confirms "needs NO build".
- metadata-core, same unbuilt tree: `Error: Cannot find package
'@objectstack/spec/data'`, `VERDICT command-exit 1`. This confirms it
reads the built dist.
- `pnpm --filter '@objectstack/metadata-protocol^...' build`: `VERDICT
command-exit 0` (1m49s, shared box). Then metadata-core: `Tests 63
passed (63)`, exit 0. metadata-protocol: `Tests 18 passed (18)`, exit 0.
</details>
<details><summary>Before / after, through the real CLI (mutation via
scripts/ablation-replace.mjs, restored to HEAD)</summary>
- origin/main a73edb3, `--commands
packages/spec/src/data/field.zod.ts`: `77 command(s) ... 7 by change
KIND`, none of the three tests. main's data module names none of the
three files (`grep -c` = 0).
- Head, with a FieldSchema key added (anchor 1 -> 0, blob 1539de5 ->
da36b936): `80 command(s) ... 10 by change KIND`, and the three lines
are present. In the same leg the driver-sql pin reds on the mutant:
`unclassified FieldSchema key(s): expected [ 'probeAblationKey' ] to
deeply equal []`, `1 failed | 10 passed`. Restored: `blob == HEAD
(1539de5) and git diff HEAD is empty`.
- Control, comment-only edit to the same file: `77 command(s)`, zero
`vitest run src/` lines. Restored the same way.
</details>
## Acceptance notes
- **Dispatch-time asymmetry, deliberate.** At claim time the PM's
derivation names a surface before any code exists, so the file is
unchanged and the row stays quiet there. It fires in the dev's own
re-derivation off the merge base (`--commands` with no paths), and
`--ran` reconciliation then refuses a record that is missing one of the
three. This is the README claim net's posture. Falling back to a path
match is ruled out in the row's deletion criterion.
- **Wider family, not built:** `CARD_PROPERTY_COUNTS` also counts
object, flow, page, agent and other types. A key added to `ObjectSchema`
(and others) reds the same metadata-protocol control, with no derivation
either. The three commits the replay did not fire on (related lists,
field groups, a nested column table) were object-key changes of exactly
that shape. This row is `field` only.
- **Other readers of `FieldSchema.shape`, measured and not named:**
`packages/lint/src/validate-expressions.test.ts`,
`packages/lint/src/validate-security-posture.test.ts` and
`packages/cli/test/data-model-rules.test.ts` check that a key they read
is declared, or that one spelling is absent. A new key cannot red them,
so they are not this row. The two
`builtin-column-storage-attributes.test.ts` files mention
`FieldSchema.shape` only in a comment.
- **Reader limits stated:** a comma inside two-parameter type arguments
at the literal's own depth reads as a separator, but it never opens a
member. A key moved from the top level into a nested schema in the same
file reads as a removal, which is the correct answer. Key reorder
derives nothing, because no pin reads order.
- **Not measured locally:** the slow tier of the dispatch-gates
self-test (CI runs it), `test:repo` (CI-owned).
## Verification
- Derived set on this branch (`node scripts/pm/dispatch-gates.mjs
--commands`, no paths, tree 81d3d66): 63 commands, matching the
dispatch reading. All 63 run locally, each exit 0 (`check:i18n-coverage`
first answered exit 3 PREREQUISITE NOT MET; after the build it names, it
answered `OK (14 config(s), 585 baselined untranslated string(s), none
new)`). `--ran`: `63 derived famil(ies) accounted for — 63 run, 0
NOT-MEASURED`. `check:nul-bytes` OK; `overlap-check` VERDICT clean.
- No changeset: the diff is `scripts/pm/**` only, the root package is
private, and no published package's `files[]` lists `scripts/pm`. The
`skip-changeset` label goes on with this create (the Check Changeset job
wants a changeset or that label).
- Tier H (a governed surface: `scripts/pm/dispatch-gates.mjs`). Left
draft, not enqueued.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01J8VVAnRb4CkaDphxuAQgMn)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7b56b3a commit 4db6fd7
3 files changed
Lines changed: 297 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
977 | 977 | | |
978 | 978 | | |
979 | 979 | | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
980 | 992 | | |
981 | 993 | | |
982 | 994 | | |
| |||
1341 | 1353 | | |
1342 | 1354 | | |
1343 | 1355 | | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
1344 | 1383 | | |
1345 | 1384 | | |
1346 | 1385 | | |
| |||
1380 | 1419 | | |
1381 | 1420 | | |
1382 | 1421 | | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
1383 | 1444 | | |
1384 | 1445 | | |
1385 | 1446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
491 | 492 | | |
492 | 493 | | |
493 | 494 | | |
| |||
508 | 509 | | |
509 | 510 | | |
510 | 511 | | |
| 512 | + | |
511 | 513 | | |
512 | 514 | | |
513 | 515 | | |
| |||
12157 | 12159 | | |
12158 | 12160 | | |
12159 | 12161 | | |
| 12162 | + | |
| 12163 | + | |
| 12164 | + | |
| 12165 | + | |
| 12166 | + | |
| 12167 | + | |
| 12168 | + | |
| 12169 | + | |
| 12170 | + | |
| 12171 | + | |
| 12172 | + | |
| 12173 | + | |
| 12174 | + | |
| 12175 | + | |
| 12176 | + | |
| 12177 | + | |
| 12178 | + | |
| 12179 | + | |
| 12180 | + | |
| 12181 | + | |
| 12182 | + | |
| 12183 | + | |
| 12184 | + | |
| 12185 | + | |
| 12186 | + | |
| 12187 | + | |
| 12188 | + | |
| 12189 | + | |
| 12190 | + | |
| 12191 | + | |
| 12192 | + | |
| 12193 | + | |
| 12194 | + | |
| 12195 | + | |
| 12196 | + | |
| 12197 | + | |
| 12198 | + | |
| 12199 | + | |
| 12200 | + | |
| 12201 | + | |
| 12202 | + | |
| 12203 | + | |
| 12204 | + | |
| 12205 | + | |
| 12206 | + | |
| 12207 | + | |
| 12208 | + | |
| 12209 | + | |
| 12210 | + | |
| 12211 | + | |
| 12212 | + | |
| 12213 | + | |
| 12214 | + | |
| 12215 | + | |
| 12216 | + | |
| 12217 | + | |
| 12218 | + | |
| 12219 | + | |
| 12220 | + | |
| 12221 | + | |
| 12222 | + | |
| 12223 | + | |
| 12224 | + | |
| 12225 | + | |
| 12226 | + | |
| 12227 | + | |
| 12228 | + | |
| 12229 | + | |
| 12230 | + | |
| 12231 | + | |
| 12232 | + | |
| 12233 | + | |
| 12234 | + | |
| 12235 | + | |
| 12236 | + | |
| 12237 | + | |
| 12238 | + | |
| 12239 | + | |
| 12240 | + | |
| 12241 | + | |
| 12242 | + | |
| 12243 | + | |
| 12244 | + | |
| 12245 | + | |
| 12246 | + | |
| 12247 | + | |
| 12248 | + | |
| 12249 | + | |
| 12250 | + | |
| 12251 | + | |
| 12252 | + | |
| 12253 | + | |
| 12254 | + | |
| 12255 | + | |
| 12256 | + | |
| 12257 | + | |
| 12258 | + | |
| 12259 | + | |
| 12260 | + | |
| 12261 | + | |
| 12262 | + | |
| 12263 | + | |
| 12264 | + | |
| 12265 | + | |
| 12266 | + | |
| 12267 | + | |
| 12268 | + | |
| 12269 | + | |
| 12270 | + | |
| 12271 | + | |
| 12272 | + | |
| 12273 | + | |
| 12274 | + | |
| 12275 | + | |
| 12276 | + | |
| 12277 | + | |
| 12278 | + | |
| 12279 | + | |
12160 | 12280 | | |
12161 | 12281 | | |
12162 | 12282 | | |
| |||
12226 | 12346 | | |
12227 | 12347 | | |
12228 | 12348 | | |
| 12349 | + | |
12229 | 12350 | | |
12230 | 12351 | | |
12231 | 12352 | | |
| |||
0 commit comments