Repository navigation
fix(spec): check:variant-docs reads a z.enum discriminator arm's members into the union key - #29531
Conversation
…ers into the union key Claude-Session: https://claude.ai/code/session_01JQwxbZYuv4NM4LDCUNP3cK Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check
What this run could not see
Coarse fallback — 168 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
|
domain:spec#3 · os-warren · session_01JQwxbahe4v7GBD94QeSnir 维护者速读
席位核对ACCEPT ·
Generated by Claude Code |
|
domain:spec#3 · os-warren · session_01JQwxbahe4v7GBD94QeSnir Landed · 2026-11-02T19:06Z
State change: Generated by Claude Code |
Requested by Warren · project thread
Fixes #29412
Clause-②: no
Metadata-protocol: none
维护者速读
check:variant-docs现在把z.enum判别臂的全部成员读进联合的台账键;唯一受影响的条目从kind:nav改键为kind:field|flow|nav,并在api/metadata-api.mdx补一句点名field/flow两个 kind。packages/spec/scripts/check-variant-docs.mts的armVariants();再看packages/spec/scripts/check-variant-docs.test.ts;最后packages/spec/variant-docs.json的改键。pnpm --filter @objectstack/spec check:variant-docs,预期打印 24 个联合全部通过;--list里 contributions 的键是kind:field|flow|nav。What changes
packages/spec/scripts/check-variant-docs.mts: a new exportedarmVariants()reads the values one arm's discriminator matches. A literal keeps them in the def'svalues; a zod 4z.enumkeeps its members inentries, and the walker never read that field, so an enum arm was left out of the key entirely.armVariants()now reads zod's own parse set (_zod.values, which drops a numeric TypeScript enum's reverse-mapping keys) and falls back to the entries' values. The per-union key building moved into an exportedunionKey(). The sweep moved intomain()and runs only when the file is invoked as a script, so the test can import the two helpers without sweepingsrc/or settingOS_EAGER_SCHEMASin its worker.packages/spec/variant-docs.json: re-keyed the one entry this moves,kind:navtokind:field|flow|nav(GetPackageCustomizationsResponseSchemacontributions). Its note is kept, with the sentence saying the walker cannot read the enum arm replaced by one saying it now does.content/docs/api/metadata-api.mdx(bounded in-place fix, file surface amended in Claim amendment 6582783172): once re-keyed, the gate found that the bound doc never mentionsfield, and thatflowpassed only through an unrelated row (thetypecolumn at line 33). That is the doc owing a re-read, which this change is what surfaces. One sentence now names the kinds: "the fields (kindfield) and flows (kindflow) other installed packages contribute tohotcrm's objects".packages/spec/scripts/check-variant-docs.test.ts(new): pins a fixture union with one enum arm and one literal arm, keyed on all three members; adding a member to the enum arm moves the key; a literal-only control keys as before; non-discriminated schemas answer null; an object-built enum reads its values, not its keys.Why
A discriminated union's ledger key exists so that adding or dropping a variant changes the key and sends the author back to the bound doc. An enum arm's members were never in the key, so a
pagekind added to thefield/flowenum would have left the key atkind:navand the gate green.Tests
check:variant-docs --listonorigin/main94d3e25 vs this head: 24 discriminated unions both times; exactly one key differs (kind:navbecamekind:field|flow|nav). Measured, not assumed: no other union insrc/has an enum arm.scripts/check-variant-docs.test.ts: 7/7 pass.pnpm --filter @objectstack/spec test(local project) at 314f4b3: Test Files 793 passed (793), Tests 23526 passed, 1 todo.pnpm --filter @objectstack/spec typecheckat 314f4b3 (tsc,check:scripts-typecheck,check:test-typecheck): exit 0.--listreading above is the evidence that the reading changed.Acceptance notes
skip-changeset:@objectstack/spec'sfiles[]shipsdist,json-schema,src/**/*.zod.tsand others, notscripts/orvariant-docs.json;content/docs/is no package.packages/spec/src/**/*.zod.tsfile and no strictness-ledger file is touched.Verification
dispatch-gates at 314f4b3: 86 derived, 86 run, all exit 0
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 86 families. 76 exited 0 on the first run; 10 exited 3 (PREREQUISITE NOT MET) on the fresh worktree, the onecheck:docsexit 1 being the missingjson-schematree, a prerequisite and not a finding. Aftergit fetch origin 621a4876andturbo run build --filter='@objectstack/lint...' --filter=@objectstack/objectql --filter=@objectstack/formula --filter='@objectstack/client-react...' --filter=@objectstack/spec, all ten re-ran to exit 0,check:variant-docsamong them on the first run. Reconciliation: "dispatch-gates --ran: 86 derived famil(ies) accounted for — 86 run, 0 NOT-MEASURED".Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (eslint on the two changed scripts files: exit 0; the repo-wide run is CI's).main, one pull request.packages/spectouched: no generated artifact moves (check:docsgreen).content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Dispatched by
domain:spec#3 · os-warren · session_01JQwxbahe4v7GBD94QeSnir; dev = card threadsession_01JQwxbZYuv4NM4LDCUNP3cK.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbZYuv4NM4LDCUNP3cK
Generated by Claude Code