This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(types,components): the zod mirrors stop authoring defaults - #8299
Merged
os-zhuang merged 4 commits intoSep 7, 2026
Merged
Conversation
A `.default(v)` on a zod mirror member is not documentation: `parse` SUBSTITUTES `v` into the output when the key is absent, so one authored document took two shapes depending on whether it had been through `safeValidateSchema` — and where the mirror and the renderer disagreed, the mirror silently won. ContainerSchema.maxWidth mirror 'lg' container.tsx ?? 'xl' FlexSchema.align mirror 'center' flex.tsx || 'start' Ruled by the director seat (decision batch #69, 2026-09-07, maintainer reply 「其他同意」): a validator validates, it does not write values into an author's document. The renderer's fallback is the single authoritative default, the JSDoc `@default` describes it, and the mirror carries none. Removes all 41 `.default()` call sites under `packages/types/src/zod/` (layout 22, crud 11, form 5, views 2, app 1). Every one was spelled `.optional().default(v)`, so the accept set is untouched — this narrows `parse` OUTPUT only. Reconciles the third face objectui#8229 found: `flex`'s registration seeded `defaultProps.align: 'center'`, the value its own renderer never applies. Two derived pins land with it: the mirror carries no `.default()` CALL SITE (parsed, not grepped — four legitimate docblock mentions survive and a text pin would be red on landing), and every `defaultProps`/fallback pair in flex.tsx and stack.tsx agrees. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QtGhnU3WnnWyiWeYQhw2aX
…-mirrors-stop-authoring-defaults
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
…-mirrors-stop-authoring-defaults
This was referenced Sep 7, 2026
…he mirror, not the renderer Contract-review patch round for PR #8299. The 41-site removal, both pins, the accept-set claim and the `flex.tsx` value are unchanged — the review reproduced all of them. What failed was four written statements the tree contradicts. 1. THE CHANGESET STATED A FALSE MEASUREMENT. "Rendering does not change … the two that disagreed were the bug" quoted a 7-key triage sample as if it were the population. Auditing all 22 layout keys against their renderers finds SIX disagreements: container.maxWidth, flex.align, grid.columns (3 vs `let baseCols = 2`), text.variant ('body' vs none), resizable.withHandle (true vs a bare forward that draws no grip) and page.template ('default' vs a pageType dispatch). The note now says that, and says plainly that the change is BREAKING for consumers that read `result.data`. 2. RULING NOTE 3(ii) WAS MEASURED AGAINST THE WRONG REFERENCE. The tags were compared with the value the MIRROR used to write; the ruling asks for the RENDERER's fallback, which is the whole point of option 乙. Re-measured against the renderer, all 41 keys: 19 agree, 2 are deliberately untagged (#7361/#7734), 16 have no registered renderer reading them at all, and 4 misdescribed the renderer. Those four are corrected here — `grid.columns` 3 -> 2, and `text.variant` / `resizable.withHandle` / `page.template` lose their tag for prose naming the read site, the shape #7361 established for a value no renderer applies. The pin follows: `layout-default-jsdoc-7361.test.ts` gains four derived rows (both sides read off disk, with positive controls) and a discrimination control — that docblock's prose quotes the retired `@default 'body'`, so the tag extractor is shown ignoring a backtick-quoted mention while still seeing a real tag next door. The 33 rows it does not reach are declared as a named narrowing in the PR body and filed as objectui#8318. 3. Two shipped `text.tsx` docblocks said the mirror declares/publishes `.default('body')`. This PR is what made them false; both now say so in the past tense. 4. `flex.tsx:145` cited the pin as `.test.tsx`; the file is `.test.ts`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QtGhnU3WnnWyiWeYQhw2aX
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
os-zhuang
marked this pull request as ready for review
September 7, 2026 11:50
os-zhuang
deleted the
claude/issue-7735-zod-mirrors-stop-authoring-defaults
branch
September 7, 2026 12:06
This was referenced Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7735
Implements the director ruling on #7735 (decision batch #69, 2026-09-07; maintainer reply 「其他同意」), option 乙. A validator validates; it does not write values into an author's document. The renderer's fallback is the single authoritative default, the JSDoc
@defaultdescribes it, and the zod mirror carries none.The defect
.default(v)on a mirror member is not documentation —parseSUBSTITUTESvinto the output when the key is absent. One authored document therefore took two shapes depending on whether it had been throughsafeValidateSchema, and where the two faces disagreed the mirror silently won:ContainerSchema.maxWidth'lg'container.tsx:26?? 'xl'FlexSchema.align'center'flex.tsx:18|| 'start'review asked for the rest and the answer is six: auditing all 22 layout keys
against their renderers adds
grid.columns(mirror3/grid.tsx's ownlet baseCols = 2),text.variant('body'/ none — a bare node, objectui#6942),resizable.withHandle(true/ forwarded bare, soundefineddraws NO grip) andpage.template('default'/ a null template falls through to thepageTypedispatch, and
'default'is a realTEMPLATE_REGISTRYkey, so the substitutionreally did skip that dispatch). A consumer that renders
result.datasees adifferent result on all six.
Measured on the built face before the change, and again after:
The population — the ruling's arithmetic, re-derived
The ruling says "45
.default()sites across the seven*.zod.tsfiles". Re-derived onorigin/mainfc32921with the TypeScript AST rather than a text search: 41 real call sites in 5 files. Four of the 45 text matches are prose inside docblocks, and the two files carrying them have nothing to remove..default(textlayout.zod.tscrud.zod.tsform.zod.tsviews.zod.tsapp.zod.tsobjectql.zod.tscomplex.zod.tsbase.zod.tsThis confirms the PM's count exactly.
objectql.zod.tsandcomplex.zod.tsare untouched — editing them to reach "45" would have been inventing a diff.result.dataStated plainly here as well as in the changeset:
validateSchema/safeValidateSchemano longer substitute, so for a document that omits one ofthese 41 keys the key is now absent from the parsed output. Every one of the
41 changes output; six of them change rendering for a consumer that renders
result.data(the table above). Readers of a parsed default must apply their ownfallback. The accept set is untouched — nothing that parsed before is refused now.
Accept set: unchanged, and that was checked rather than assumed
.default()can carry optionality as well as a value: a member written.default(x)with no.optional()is optional because of the default, and removing it naively makes the key required — a silent accept-set narrowing on a published surface, which this ruling did not authorise. All 41 were spelledTYPE.optional().default(v).describe(…), so 0 of 41 were carrying optionality. Nothing that parsed before is refused now. This narrowsparseOUTPUT only, which is the conformance limb of clause ②, not clause ② itself.Consumer census — execution note 1
The only risk of option 乙 is a consumer that reads a substituted default off
result.data. Measured, not assumed. Count: 0.Four modules import
@object-ui/types/zodoutside tests:packages/cli/src/commands/check.tssafeValidateSchema(content).successonlypackages/cli/src/commands/validate.tsresult.data.{type,id,label,title,children}— none ever carried a defaultpackages/plugin-map/src/ObjectMap.tsxObjectMapConfigSchema.safeParse(config)for.success/.error; returns the rawconfig, discarding.data.ObjectMapConfigSchemalives inobjectql.zod.ts, which had 0 call sitesscripts/measure-strict-authoring-face.mjskeyProbetwin is rebuilt withz.any().optional()leaves, so defaults never reach it;undeclaredKeyswalksObject.keys(input), so extra keys in the parse output are invisible to it either way. Not wired into any gate or workflow⭐ The render path never ran this validator at all — the open question os-sam raised in comment 5564118219 ("whether any document parse goes through
ContainerSchema's zod mirror in practice").SchemaRenderercallsvalidateSchemafrom@object-ui/core, a structural validator returning{valid, errors}with no zod, no.dataand no substitution. The mirror's.default()only ever reached documents put through@object-ui/types/zoddeliberately — the CLI and external consumers.Empirically: 6 105 tests across
packages/types,packages/components,packages/cli,examples/schema-catalogandscripts/pass unchanged. Not one asserted a substituted default.Pin (i) — and the trap in the ruling's wording
⛔ Pin (i) is not a text search. Worded literally as the ruling puts it — "no
.default(underpackages/types/src/zod/**" — it is red on the day it lands, because the four docblock mentions are legitimate prose that survives the change, and the only way to make such a pin green would be to delete real prose.packages/types/src/__tests__/zod-mirror-authors-no-defaults-7735.test.tsparses instead:X.default(…)CallExpression underpackages/types/src/zod/**— comments are not in the AST, so prose is invisible by construction;stackas the never-authored control;It also carries the positive controls that keep a null result meaningful: the AST walker is shown finding
.describe()on the very chains.default()used to sit in, and the discrimination itself is asserted — some mirror file still mentions.default(in prose, every such file has 0 call sites, and the text count exceeds the call count. That gap is the control.packages/components/src/renderers/layout/__tests__/registration-defaults-match-renderer-8229.test.tsis pin (ii): it re-derives everydefaultProps/fallback pair inflex.tsxandstack.tsxoff disk and fails if any diverges.Both pins were ablated — they discriminate
Run from the committed tree, each leg proving the mutation reached disk before the run and that the restore was verified by blob hash, not by an exit code:
What this does NOT reach — measured, and it is a real residue
Removing all 41 does not make
safeValidateSchemastop substituting. 57ZodDefaultnodes remain reachable from the published barrel afterwards, and — by the same call-site census that proves the mirror authors none — every one of them is inside a subschema imported by reference from@objectstack/spec:So the "one authored document, two shapes" defect survives on those keys. Those values are written in
@objectstack/specand cannot be removed from this repository — restating them locally to strip them would be the "narrower than the contract it implements" shapecomplex.zod.tsalready records twice. The pin documents the boundary and asserts the residue is non-zero as a floor, not a ratchet (the exact figure moves with every spec bump); what it does hold constant is the attribution. Recorded on #7735 for triage; ⛔ not filed as a card from here.#8229 — fully covered, and its census reproduces
⭐ #8229 is fully covered by this PR. Nothing of it narrows into a follow-up, so its author can mark it done once this lands. Its
defaultProps.alignface is reconciled ('center'→'start', the valueflex.tsx:18actually applies) and pin (ii) is a standing gate over exactly the surface it measured, so nothing of it narrows into a follow-up.Its bounded census reproduces exactly: re-deriving it mechanically over
flex.tsx+stack.tsxgives 8 comparable pairs, 1 disagreement —flex.align— matching its table row for row.Out of scope — noted, not filed
Re-deriving that same comparison repo-wide found 55 comparable pairs and 7 disagreements: the
flex.alignrow fixed here, plus six more.defaultPropsrenderers/action/action-bar.tsxvariant'outline''ghost'renderers/action/action-button.tsxsize'md''default'renderers/action/action-group.tsxsize'sm''default'renderers/basic/pagination.tsxtotalPages101renderers/form/file-upload.tsxbuttonText'Choose files''DROP PAYLOAD OR CLICK TO UPLOAD'plugin-markdown/src/index.tsxcontent''⛔ Not touched, and deliberately not filed as defects. They are not six more instances of this bug:
defaultPropsis a designer seed as much as a default claim —pagination'stotalPages: 10andflex's own three-buttonchildrenarray are seeds, not statements about what a key means when omitted — and whether the two roles may legitimately diverge is exactly the question #4631 is holding,pm:on-hold. Widening pin (ii) repo-wide would have decided that question by gate rather than by ruling. Recorded here for whoever takes #4631.Ruling note 3(ii) — re-measured against the renderer, and four tags corrected
⭐ The first version of this PR reported note 3(ii) as already satisfied. That was
measured against the wrong reference and the contract review was right to fail it.
Each JSDoc
@defaultwas compared with the value the mirror used to write; theruling asks for the renderer's fallback, which is the entire point of option 乙 —
the renderer is now the authoritative face, so a tag agreeing with the mirror proves
only that the docs copied the mirror. All four tags corrected below had matched the
mirror exactly, which is precisely why a mirror-referenced check called the face clean.
Re-measured against the renderer, all 41 de-defaulted keys:
The four corrections, each following #7361's own rule (a tag states what the renderer
applies; where it applies nothing, the honest form is the absence of a tag plus prose
naming the read site):
GridSchema.columns@default 3@default 2+ prose naminggrid.tsx'sbaseColsTextSchema.variant@default 'body'text.tsxand objectui#6942ResizableSchema.withHandle@default truePageNodeSchema.template@default 'default'resolveTemplateand thepageTypefall-through19 of the agreeing rows were confirmed too, 13 by the
schema.x ?? 'lit'sweep and 6by hand where the renderer uses another shape —
container.centered(!== false),card.hoverable/card.clickable(|| isClickable/|| !!props.onClick),aspect-ratio.ratio(|| 16 / 9),separator.orientationandicon.size(forwardedbare, the primitive's own default is what the tag names).
The pin, and the narrowing it does not reach
packages/types/src/__tests__/layout-default-jsdoc-7361.test.tsgains the four rows —same file, same rule, one instrument. Both sides are read off disk, every extraction has
a positive control, and the file now covers 8 rows plus 2 negative controls.
It also gains a discrimination control that is not hypothetical:
TextSchema.variant'snew prose quotes the retired
@default 'body', so the text is in the file while themember publishes no tag. The pin asserts both — the extractor sees the quoted mention
and still returns an empty tag list, and it still finds a real tag on a neighbouring
member. Without it, "the tag list is empty" could have been passing because the
extractor had quietly stopped matching anything.
stay unpinned. That is a measured decision: these renderers do not express defaults
uniformly, and a generic
schema.x || 'lit'sweep is blind to every shape that matters —it scores
grid.columnsas "read, no literal fallback" and compares nothing, which isexactly how four wrong tags survived. A general instrument would have to model an
initialiser (
let baseCols = 2), a!== falseread, a bare forward whose default is theabsence of an affordance, and a registry lookup returning
null— and it would have todecide what "the renderer for this type" means when two files register
'text'withnon-overlapping
variantvocabularies (renderers/basic/text.tsxandrenderers/basic/elements.tsxboth do). Filed as #8318 with the full 16-key list andboth open questions; not decided here.
Ablation — the four new rows discriminate
Verification (patch round, head
d28d27a)pnpm --filter @object-ui/types --filter @object-ui/components run type-checkDone) —tsconfig.test.jsonis in the run, and it caught a real error in the pin during round 1, so the test files are demonstrably in the programpnpm --filter @object-ui/types --filter @object-ui/components run lintlayout.ts0/0, the extended pin 0/0,text.tsx0 errors / 1 pre-existing warning,flex.tsxthe samepnpm exec eslint . --no-inline-config --format jsonpnpm exec vitest run packages/types/ packages/cli/ examples/schema-catalog/ scripts/pnpm exec vitest run packages/components/check:comment-mask-corpus·check:unused-depscheck:sdui-registration-pinsa6ac2bb;d28d27a. Every linepackages/componentschanged since is a comment (git diff a6ac2bb -- packages/componentshas no non-comment+/-line), so the bundle's registration set cannot have moved. Falsifiable: a red run of this gate on this branch reopens it. CI re-measurescheck:comment-mask-corpuscheck:control-bytes·check:doc-types·check:doc-snippets·check:doc-fences·check:spec-symbols·check:phantom-deps·check:handler-key-reads·check:unreferenced-sources·check:published-tsconfig-exclude·check:readme-exports·check:entry-guard·check:dist-completeness· changeset-presence · changeset-no-majorEvery exit code was captured to disk before any output was read.
origin/mainmerged at3c6394c; the suite above was re-run on the merged heada6ac2bb.needs:contract-reviewis attached per the ruling's note 4 — the conformance limb (output shape narrows, accept set untouched), not clause ②.🤖 Generated with Claude Code
https://claude.ai/code/session_01QtGhnU3WnnWyiWeYQhw2aX
Generated by Claude Code