Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 3a3db76

Browse files
feat(types): the object-form zod mirror declares the members its TypeScript twin declared (objectui#6152, round 1) (#11125)
Refs #6152 Clause-②: yes — mirroring a declared key widens both zod faces; removing an unread declared key narrows a published TypeScript type (stated as a break in a `minor` changeset). The PR waits as a draft for the director seat's contract review. > This PR uses only the mirroring half of the Clause-② line above. It narrows no TypeScript declaration. The removals this round measured belong to the `ObjectGridSchema` pair, which moved to the next round (see **Scope** below). ⛔ Draft for the director seat's contract review. Do not mark it ready, and do not enable auto-merge. ## What changed `UnmirroredDeclared['objectql.zod.ts#ObjectFormSchema']` (in `packages/types/src/__tests__/zod-mirror-parity.test.ts`) recorded 21 keys. The published `ObjectFormSchema` TypeScript type invites these keys, but the zod mirror had never heard of them. So the two faces gave different answers: - the tolerant face (`BaseSchema` is `.passthrough()`) kept any value at those keys without judging it; - the strict authoring face (`StrictAnyComponentSchema`) refused the keys, although `tsc` accepts them. That is objectui#5250's M3 class (iii). This round measured every key in the entry and routed each one: - **19 keys MIRRORED** (route a) in `packages/types/src/zod/objectql.zod.ts`. Each is shaped as the TypeScript twin declares it. `nextText` / `prevText` are the spec's `I18nLabelSchema` by reference, because the twin takes `I18nLabel` from the spec. objectui#10993 bound the form's other five label members the same way. - `sections` gets a module-private entry schema, `ObjectFormSectionEntrySchema`, member for member with `ObjectFormSection`. One exception: a `fields` entry stays `z.any()`, as the mirror's existing `customFields` does. `FormFieldSchema` carries its own `KnownDrift` / `UnmirroredDeclared` rows, and binding it here would import that drift. - The object-view `form` slot (`ObjectFormSchema.omit(...)`) inherits all 19 members. - **2 keys LEFT** in the entry, with their routes open: `open` and `submitHandler`. See the open questions. - Ledger: **12 entries / 84 keys → 12 entries / 65 keys**. The split moves from 3 / 37 spec-derived to 3 / 18. Every docblock figure the file pins moved with it, in the prose convention the file uses: the file header, both ledger docstrings, the split, and the totals line. - `object-form-i18n-label-members-10993.test.ts`: its row "`nextText` and `prevText` are not mirrored" asked to move together with the ledger. It now holds all seven label members. - **New pin file**, `packages/types/src/__tests__/object-form-unmirrored-members-6152.test.ts`. For each mirrored key it pins: - the key is a mirror member; - an authored value parses on both the strict face and the tolerant face; - a wrong-typed value is refused at the key on the tolerant face. The file also pins: - the object-view `form` slot; - a section is closed on the strict face; - the catalog document M3 charged now parses strict; - `open` / `submitHandler` stay out of the shape. - **One file outside the claimed surface**: `packages/app-shell/src/views/metadata-admin/previews/__tests__/block-config-schema-parity-8216.test.ts`. Its ledger row `object-form::formType@node` pointed at #6152. It went stale the moment `formType` was mirrored, and its own ratchet turned red: "every ledger row still applies". The row is deleted, with a tombstone comment like the one above it. - A live control re-measures the retired verdict. The node-face ledger is now empty, and an empty ledger reads exactly like a broken oracle. - This is an in-place repair. All four conditions hold: same defect class; a mechanical change the ratchet pinned; no other claim holds the file (the only in-flight PR touching it, #11086, edits the `EXEMPT` block, a separate hunk); same gate family. ⚠️ The claim's file surface needs this path added. - Changeset `.changeset/6152-object-form-unmirrored-members.md`: `@object-ui/types` **minor**. It names every mirrored key and states the tolerant face's new refusal of wrongly typed values as the breaking half. ## Per-key table: `objectql.zod.ts#ObjectFormSchema` Two instruments, both scratch-only (not committed): - **Authored:** an AST/JSON census over every tracked `.json`, the JSON fences in `md`/`mdx`, and TS object literals carrying `type: 'object-form'` (plus the object-view `form` slot). - Positive control: the census sees `objectName` / `mode` on the same nodes (catalog 2, fences 3, in-code 12 src). - **Read:** a TypeScript type-checker census. It finds every property read, `in` check and destructure whose receiver resolves to `ObjectFormSchema`, including plugin-form's mapped `LocalizedObjectFormSchema`. - Positive controls: `objectName` 32 reads, `mode` 28. - Its first run read `mode` = 0 and was discarded as a broken instrument: it could not see through the mapped type. The fix resolves property symbols to their declaration. - A cast read is invisible to the checker, so the three cast reads were found by hand and are quoted as such. "spec" is `@objectstack/spec` 17.4.0: `CPM` = `ComponentPropsMap['object-form']`, `FV` = `FormViewSchema`. | key | authored (documents · in-code src) | read site (symbol · quoted expression) | spec | route | | --- | --- | --- | --- | --- | | `formType` | catalog `plugin-form/object-form-tabbed-sections.json`; fences in `api/schema-reference.md` (also its object-view `form` slot) and `plugins/plugin-form.mdx` · 9 hosts | `ObjectForm` · `schema.formType` (the variant fork) | CPM | a · mirrored | | `sections` | same catalog doc + 2 fences · 5 hosts | `ObjectForm` · `schema.sections`; `ObjectView` · `schema.form?.sections` | CPM | a · mirrored | | `defaultTab` | catalog tabbed-sections doc | `ObjectForm` · `defaultTab: schema.defaultTab` | CPM | a · mirrored | | `tabPosition` | none | `ObjectForm` · `tabPosition: schema.tabPosition` | CPM | a · mirrored (read; protocol-authorable) | | `allowSkip` | tests only | `ObjectForm` · `allowSkip: schema.allowSkip` | CPM | a · mirrored (read; protocol-authorable) | | `showStepIndicator` | fence in `plugins/plugin-form.mdx` | `ObjectForm` · `showStepIndicator: schema.showStepIndicator` | CPM | a · mirrored | | `nextText` | none | `ObjectForm` · `nextText: schema.nextText` | CPM (I18nLabel) | a · mirrored by reference | | `prevText` | none | `ObjectForm` · `prevText: schema.prevText` | CPM (I18nLabel) | a · mirrored by reference | | `splitDirection` | none | `ObjectForm` · `splitDirection: schema.splitDirection` | CPM | a · mirrored (read; protocol-authorable) | | `splitSize` | none | `ObjectForm` · `splitSize: schema.splitSize` | CPM | a · mirrored (read; protocol-authorable) | | `splitResizable` | none | `ObjectForm` · `splitResizable: schema.splitResizable` | CPM | a · mirrored (read; protocol-authorable) | | `drawerSide` | fence in `api/schema-reference.md` (object-view `form` slot) · `FieldDesigner` | `ObjectForm` · `drawerSide: schema.drawerSide` | CPM | a · mirrored | | `drawerWidth` | 0 documents · `FieldDesigner` | `ObjectForm` · `drawerWidth: schema.drawerWidth` | CPM | a · mirrored (read; protocol-authorable) | | `modalSize` | 0 documents · `useActionModal`, `ObjectManager` | `ObjectForm` · `modalSize: schema.modalSize` | CPM | a · mirrored (read; protocol-authorable) | | `modalCloseButton` | none | `ObjectForm` · `modalCloseButton: schema.modalCloseButton` | CPM | a · mirrored (read; protocol-authorable) | | `mobile` | none | `ObjectForm` · `const mobileOpts = schema.mobile` | CPM | a · mirrored (read; protocol-authorable) | | `buttons` | form-view metadata relayed: `RecordFormPage` (`formDef.buttons`), `ObjectView` (`schema.form?.buttons`) | `ObjectForm` · `foldFormButtons`: `(schema as { buttons?: … }).buttons` (a cast read) | FV only | a · mirrored; spec half reported below | | `defaults` | relayed the same way (`formDef.defaults`, `schema.form?.defaults`) | `ObjectForm` · `foldFormButtons`: `(schema as { defaults?: … }).defaults` (a cast read) | FV only | a · mirrored; spec half reported below | | `subforms` | relayed: `RecordFormPage` / `ScreenView` (`objectDef.form?.subforms`), `ObjectView` (`schema.form?.subforms`) | `ObjectForm` · `(schema as any).subforms?.length` (a cast read) | FV only | a · mirrored; spec half reported below | | `open` | in-code only: `AppContent`, `useActionModal`, `ObjectManager`, `FieldDesigner`, the BYO example · 0 documents | `ObjectForm` · `open: schema.open` (drawer and modal arms) | neither (CPM refuses it) | b · **not mirrored**; open question 1 | | `submitHandler` | in-code only: `MasterDetailForm` (`submitHandler: submitViaBatch`) · 0 documents | `ObjectForm` · `await schema.submitHandler(writePayload)` | neither (CPM refuses it) | handler · **not mirrored**; open question 1 | "protocol-authorable" is stated because it is a judgment call the director may overrule. Eleven of the mirrored keys have zero document occurrences in this repository (`allowSkip` appears in tests only; `drawerWidth` and `modalSize` are written only by in-code hosts). They are read, and the spec publishes each as an author-facing member of `ComponentPropsMap['object-form']`. - They are not route (b): the protocol models each as authored metadata, and nine of them have no writer at all (not even a synthesising one). - They are not route (c): they are read. - They are not route (d): none is a second spelling. So the #6170 family rule, "the exported type aligns to the measured authored+read set", keeps them declared, and mirroring is what closes declared ≠ enforced for them. ## Scope: stopped at the `ObjectFormSchema` pair boundary The dispatch allowed this: "If round 1 becomes too large to review as one PR, stop at a pair boundary, with `ObjectFormSchema` first". The two remaining pairs were measured in full and are handed to the next round as a worklist. They were not implemented, for three reasons: - `ObjectGridSchema`'s mirrors include `bulkActionDefs` (a nested `BulkActionDef` / `BulkActionParam` shape whose `visible` indexes the spec's slot type) and `conditionalFormatting` (the two-arm rule union the `ListViewSchema` mirror spells inline). - Its removal half narrows a published TypeScript type. That needs a runtime inertness reading AGENTS.md requires, and a rewrite of `p1-spec-alignment.test.ts`, which writes all three keys. - That is a second contract-review question, not more of this one. ### `objectql.zod.ts#ObjectGridSchema`: measured, not implemented Measured with the same two instruments. "spec" is `ComponentPropsMap['object-grid']`, a strict object. | key | authored | read site | spec | route (proposed) | | --- | --- | --- | --- | --- | | `aggregations` | none | `ObjectGrid` · `aggregations: schema.aggregations` | yes | a | | `bulkActionDefs` | relayed from named views: `ObjectView` · `tableRelay.bulkActionDefs` | `ObjectGrid` · `Array.isArray(schema.bulkActionDefs) ? schema.bulkActionDefs : []` | yes | a (nested mirror) | | `conditionalFormatting` | relayed (`tableRelay.conditionalFormatting`) | `ObjectGrid` · `conditionalFormatting: schema.conditionalFormatting as unknown[] \| undefined` | yes | a | | `grouping` | relayed (`tableRelay.grouping`) | `ObjectGrid` · `schema.grouping?.fields` | yes | a, by reference (the twin takes `GroupingConfig` from the spec) | | `navigation` | tests only | `ObjectGrid` · `navigation: schema.navigation` | yes | a, by reference (`ViewNavigationConfig` is the spec's `NavigationConfig`) | | `operations` | fences in `README.md` and `api/schema-reference.md` | `ObjectGrid` · `'operations' in schema ? schema.operations : undefined`; `ObjectView` · `schema.table?.operations` | yes | a | | `reorderableColumns` | none | `ObjectGrid` · `reorderableColumns: schema.reorderableColumns ?? false` | yes | a | | `rowColor` | relayed (`tableRelay.rowColor`) | `ObjectGrid` · `useRowColor(schema.rowColor)` | yes | a, by reference | | `rowHeight` | relayed (`tableRelay.rowHeight`) | `ObjectGrid` · `resolveRowHeightMode(schema.rowHeight)` | yes | a | | `singleClickEdit` | fence in `plugins/plugin-grid.mdx` | `ObjectGrid` · `singleClickEdit: schema.singleClickEdit ?? true` | yes | a | | `resizableColumns` | fence in `api/schema-reference.md` | `ObjectGrid` · `schema.resizable ?? schema.resizableColumns ?? true` | yes, as "Alternate spelling of `resizable`" | **d** · alias retirement; spec-modelled, so the spec half forks; open question 2 | | `emptyState` | tests only (`p1-spec-alignment.test.ts`, `object-view-table-slot-10976.test.ts`) | **none** on the grid (checker census 0; the `emptyState` reads in `ListView` / `ObjectView` are on other types) | no (strict refusal) | **c** · retire (`?: never` + `retirementTombstone`) | | `rowSpecActions` | tests only | **none** (checker 0, source grep 0) | no | **c** · retire, naming `rowActions` | | `bulkSpecActions` | tests only | **none** (checker 0, source grep 0) | no | **c** · retire, naming `bulkActions` | ⚠️ The three route-(c) rows are source/checker readings. AGENTS.md says a zero from a source read does not answer "no renderer reads this key". The round that removes them owes a runtime probe first: a real `SchemaRenderer` and registry, varying only that key. ### `navigation.zod.ts#PaginationSchema`: measured, not implemented | key | authored | read site | spec | route | | --- | --- | --- | --- | --- | | `currentPage` | catalog `components-basic-pagination/basic-pagination.json` and `with-item-count.json`; `apps/site` playground | `pagination` renderer · `schema.currentPage \|\| schema.page \|\| 1` | no pagination component in the spec | **d** · a second spelling of the mirrored `page` (the twin calls `page` the "Legacy page property"); open question 3 | ## Acceptance: objectui#5250 M3 class (iii), re-run This used a scratch port of PR #11069's `findUndeclaredKeys` (⛔ not committed; none of #11069's wiring). It ran over the SHIPPED face: `StrictAnyComponentSchema` from a freshly built `packages/types/dist`. The corpora were those of `scripts/measure-strict-authoring-face.mjs` (catalog, docs JSON fences, apps plus `packages/*/examples`), plus `examples/**/*.json`. Class (iii) = membership of the `UnmirroredDeclared` ledger in the same tree, which tsc reconciles against the compiler measurement. | reading | documents judged | strict-refused | strict-only | refusal pairs | class (iii) pairs · occurrences · strict-only | | --- | --: | --: | --: | --: | --- | | before (`fe41dc76a`, base ledger) | 620 | 190 | 121 | 109 | **10 · 15 · 13** | | after (this branch) | 620 | 186 | 117 | 103 | **4 · 5 · 3** | The before reading reproduces M3's published class (iii) exactly: 10 pairs, 15 occurrences, 13 strict-only. It is the positive control for the port. - **The six pairs that left:** `object-form` · `formType`, `sections`, `defaultTab`, `showStepIndicator`; `object-view` · `form.formType`, `form.drawerSide`. - **The four that remain** are the next round's: `object-grid` · `operations`, `singleClickEdit` (route a) and `resizableColumns` (route d); `pagination` · `currentPage` (route d). - **No refusal pair appeared.** The before/after diff of all refusal pairs has deletions only. So closing `sections` surfaced no nested refusal in the corpora. - **Tolerant-face verdicts are unchanged:** 69 tolerant-refused documents on both readings. ## Ablations Predictions were written to a scratch file before each run. Each mutation went through objectstack's `scripts/ablation-replace.mjs` in wrap mode, on committed code (HEAD `78b4eee67`): - the anchor had to hit exactly once; - the blob change is proven on disk; - the restore is proven by blob equality with HEAD and an empty `git diff HEAD`; - the tree was porcelain-clean afterwards. The subject resolves to `src` (relative imports; the root vitest alias maps `@object-ui/types/zod` to `packages/types/src/zod/index.zod.ts`), so no `dist` leg exists. | ablation (route) | predicted | observed | | --- | --- | --- | | **A1**: delete `formType` from the mirror; ledger untouched (route a) | tsc exit 2, `TS2322` at `assertionUnmirroredMatchesLedger` naming the pair; 5 red in the 6152 pin file; 2 red in block-config 8216; parity runtime half green | **as predicted**: tsc exit 2 with `Type '"objectql.zod.ts#ObjectFormSchema"' is not assignable to type 'never'` at `assertionUnmirroredMatchesLedger`; vitest 7 failed / 107 passed. The 7 are the member, both-faces, wrong-typed, object-view slot and catalog rows, plus 8216's "no control writes a name its oracle refuses" and its new node-face control. The parity runtime file stayed green. | | **A2**: put `formType` back into the ledger while the mirror keeps it, a stale ledger key (the ledger half) | tsc exit 2 at the same assertion; parity runtime red on the objectui#8222 / #8243 / #7279 figure pins | tsc **as predicted**. Runtime: 2 red, "the split figures and the totals the header writes down equal the ledger" (objectui#7279) and "both ledger docstrings state the key total" (objectui#8243). ⚠️ **One pin fewer than predicted:** objectui#8222's pin does not read `UnmirroredDeclared`'s key total. It defers that figure to objectui#7279's pin by design, and #7279's pin reads the file-header bullet too. | ## Gates (at HEAD `78b4eee67`, exit codes captured before any pipe) | gate | exit | verdict line | | --- | --: | --- | | `pnpm --filter @object-ui/types type-check` (`tsc --noEmit && … tsconfig.examples.json && … tsconfig.test.json`) | 0 | no diagnostics | | `pnpm exec vitest run packages/types/ …/block-config-schema-parity-8216.test.ts` (root form) | 0 | `Test Files 283 passed (283)` · `Tests 6555 passed (6555)` | | readers' suites: `packages/plugin-form/` + the `ObjectView` form-slot tests + `RecordFormPage` tests | 0 | `Test Files 149 passed (149)` · `Tests 1765 passed \| 1 skipped` | | zod-face consumers: `examples/schema-catalog/test/`, app-shell `previews/__tests__/`, `packages/cli/src/__tests__/`, four `apps/console` contract tests | 1 → 0 | first run red only on the stale 8216 row (fixed above); 8216 re-run `Tests 15 passed (15)` | | `pnpm --filter @object-ui/types lint` · `pnpm --filter @object-ui/app-shell lint` | 0 · 0 | `0 errors`; no finding on a changed line (the 7 warnings in touched files sit on untouched lines) | | `check-changeset-presence` · `-no-major` · `-fixed` · `-overwrite` | 0 ×4 | declares `.changeset/6152-object-form-unmirrored-members.md` · no major | | `check:changeset-claims` · `check:pending-changeset-literals` | 0 · 0 | report-only; the self-contradiction reading passes | | `check:control-bytes` · `check:new-line-citations` | 0 · 0 | `OK` · `0 new citation(s)` | | `check:spec-symbols` · `check:test-path-roots` · `check-type-check-coverage` | 0 ×3 | `0 untriaged collisions` · `OK` · `43/43 packages compile their tests` | | `check:handler-key-reads` · `check:element-data-source-declaration` · `check:unreferenced-sources` | 0 ×3 | OK | | `check-governed-queue-guard --test` (the 6 changed paths) · `--self-test` | 0 · 0 | `NOT GOVERNED` · self-test OK | **NOT MEASURED locally:** - **app-shell's `tsconfig.test.json` type-check.** Reason: its dependency closure's `dist` is not built in this worktree. The one edit there calls the file's own `judge(schema: unknown, name: string)` with a string. Declared to CI. - **The repo-wide `pnpm lint`.** CI's. - **`pnpm check`,** the CLI self-check in `lint.yml`. It is advisory (exit 0 unless a JSON file is unreadable), and the M3 re-run shows tolerant verdicts unchanged across the corpora. Declared to CI. - **`check:doc-snippets`.** No docs fence is touched. No TypeScript type was narrowed, so no downstream type-check is owed. ## Open questions (in the round report on #6152, with options) 1. **`submitHandler` and `open`.** - `submitHandler`: objectui#6182 rules it runtime-only (function arm). But `RuntimeOnlyDeclared`'s shape pin admits `/^on[A-Z]/` spellings only. - `open`: a host-driven boolean. It is not callback-shaped, so it is not that ledger's either. - Recommended: widen the shape pin to a named allow-list by ruling. 2. **`ObjectGridSchema.resizableColumns`**: canonical `resizable` (the spec's own description, the renderer's first read, the twin's `@deprecated`). The spec half forks to objectstack. 3. **`PaginationSchema.currentPage`**: canonical `currentPage`, and `page` retires. Evidence: the renderer's first read, the twin's primary member, and the only authored spelling. ## Remaining rounds (not this PR) - **This card's leftovers:** - `objectql.zod.ts#ObjectGridSchema` (14; worklist above); - `navigation.zod.ts#PaginationSchema` (1; route d); - `objectql.zod.ts#ObjectFormSchema` (`open`, `submitHandler`; open question 1). - **The other pairs:** - `data-display.zod.ts#DataTableSchema` (17) - `views.zod.ts#DetailViewSchema` (11) - `form.zod.ts#FormSchema` (8) - `complex.zod.ts#ChatbotSchema` (3) - `reports.zod.ts#ReportComponentSchema` (3) - `complex.zod.ts#ChatbotFloatingSchema` (2) - `form.zod.ts#FormFieldSchema` (1; objectui#11070 in flight re-derives its half) - `form.zod.ts#LabelSchema` (1) - **Spec-derived, routed to #2231 and ⛔ not a local edit:** `complex.zod.ts#DashboardWidgetSchema` (2). ## Acceptance notes - **Producer boundary, per objectui#6170's binding check.** - `@objectstack/spec` 17.4.0's `ComponentPropsMap['object-form']` refuses `buttons`, `defaults` and `subforms` with `unrecognized_keys` (measured). Its `FormViewSchema` declares all three. - objectui's `object-form` reads them: `RecordFormPage` relays a form view's values onto the node. - The local half is mirrored here. The spec half forks to the spec lane and is reported to the seat, ⛔ not edited here. - **A `sections[].fields` entry is judged nowhere on this key** (`z.any()`, the `customFields` precedent). It becomes judgeable when `FormFieldSchema`'s own ledger rows close. - **This PR overlaps two in-flight PRs,** objectui#11070 (PR #11115) and objectui#11073 (PR #11086), in `objectql.zod.ts` and `zod-mirror-parity.test.ts`. - No hunk touches their keys or ledger rows. - #11115's docstring edits rewrite the same `UnmirroredDeclared` totals line (`**12 entries / 84 keys** — …`), so whichever PR lands second merges `main` and re-derives that line. - With both applied it reads 12 / 65 with the split 4 / 19 spec-derived, 8 / 46 local. #11115 moves `FormFieldSchema`'s one key into the spec-derived half. - `origin/main` moved three commits past `fe41dc76a` during this round, none touching this diff's files. No merge was needed. ## Round 2: `main` merged after PR #11115 (objectui#11070), figures re-derived Written 2026-09-30T08:17Z by the dispatched dev, session `https://claude.ai/code/session_012UwY3ahMixEFkfTUxMVkYm`. Two things opened this round. PR #11115 landed on `main` as `b0a05dda1`, and the maintainer ruled on this PR's pending-changeset edit: 「改成追加说明 (Recommended)」 (seat comment `5904913872` on objectui#6152). The director's PASS (`5904218639`) was given at `a5884b403`. This round moves the head, so that PASS is spent and `needs:contract-review` is back on this PR for a new record. The director's earlier deferral (`5903664978`) was answered by the base-merge commit `f78dc3602`, the head `5904218639` reviewed. No rebase and no force-push: three commits on top of `a5884b403`, each pushed fast-forward. | commit | what | | --- | --- | | `f3e9d830f` | merge of `main` `b0a05dda1` (parents `a5884b403`, `b0a05dda1`) | | `4ed5adf6f` | the dated note appended to `.changeset/10993-object-form-i18nlabel.md` | | `8f9bb76f6` | the dated note appended to `.changeset/7200-object-form-section-style-keys-undeclared.md` (see **The pending-changeset re-read** below) | ### The merge: two conflict hunks, one file Merging `b0a05dda1` conflicted only in `packages/types/src/__tests__/zod-mirror-parity.test.ts`, in two docblock hunks of the `UnmirroredDeclared` split section. The ledger itself (`interface UnmirroredDeclared`) and `SPEC_DERIVED_PAIRS` merged without a conflict: - PR #11115 added `form.zod.ts#FormFieldSchema` and `objectql.zod.ts#ObjectKanbanSchema` to `SPEC_DERIVED_PAIRS` and changed no ledger key; - this branch took nineteen keys off the `ObjectFormSchema` entry. 1. **The SPEC-DERIVED split bullet.** - This branch read "(3 entries, 15 keys) — it was 3 / 34 until objectui#6152 round 1 …". - `main` read "(4 entries, 35 keys) — it was 3 / 34 until objectui#11070 …". - Merged: both history sentences kept, newest first, in landing order (objectui#11068, then objectui#11070, then this PR). It now reads "(4 entries, 16 keys) — it was 4 / 35 until objectui#6152 round 1 … It was 3 / 34 until objectui#11070 … It was 3 / 37 until objectui#11068 …". 2. **The totals line and the sentence before it.** - This branch read "… objectui#6152 round 1 then MIRRORED nineteen of that entry's keys … **12 entries / 62 keys** — 3 / 15 spec-derived, 9 / 47 local." - `main` read "… and objectui#11070 moved `FormFieldSchema`'s entry (one key) the same way … **12 entries / 81 keys** — 4 / 35 spec-derived, 8 / 46 local." - Merged: both sentences kept, in landing order. "that entry's" became "`ObjectFormSchema`'s", because `main`'s sentence now stands between it and its antecedent. The line reads **12 entries / 62 keys — 4 / 16 spec-derived, 8 / 46 local**. The figure sites that merged without a conflict were each checked against the same measurement: - the file-header `UnmirroredDeclared` bullet (12 entries / 62 keys, from this branch); - both ledger docstrings (62 keys, from this branch); - the LOCAL split bullet (8 entries, 46 keys, with `main`'s objectui#11070 history sentence). The two other auto-merged files move separate hunks: - `objectql.zod.ts`: `main`'s hunks there (among them `dataSource` on `ObjectFormSchema` and its siblings) do not overlap this branch's; - `block-config-schema-parity-8216.test.ts`: `main` empties the `EXEMPT` table, and this branch's ledger-row hunk is untouched. ### The figures, measured on the merged ledger A scratch reader (⛔ not committed) parsed `interface UnmirroredDeclared` and `SPEC_DERIVED_PAIRS` at four trees. The file's own pin, objectui#7279's "the split figures and the totals the header writes down equal the ledger", re-derives the merged row on every run and is green at `4ed5adf6f`. | tree | ledger | spec-derived | local | | --- | --- | --- | --- | | merge base `c2a8d23c6` | 12 / 81 | 3 / 34 | 9 / 47 | | this branch before the merge, `a5884b403` | 12 / 62 | 3 / 15 | 9 / 47 | | `main`, `b0a05dda1` | 12 / 81 | 4 / 35 | 8 / 46 | | **merged, `4ed5adf6f`** | **12 / 62** | **4 / 16** | **8 / 46** | ⚠️ This corrects the prediction in **Acceptance notes** above: "12 / 65 with the split 4 / 19 spec-derived, 8 / 46 local". That prediction was written before the base-merge round brought in objectui#11068, which closed three `ObjectGridSchema` keys (84 → 81 on `main`). So the measured total and the measured spec-derived half are each three keys lower. The paragraph above is left as written; this section supersedes its figures. ### The pending objectui#10993 changeset: restored, then appended Per the ruling, the line this PR rewrote is back to `main`'s bytes, and the correction is an appended, dated note: - the merge commit `f3e9d830f` takes `main`'s blob for `.changeset/10993-object-form-i18nlabel.md` (its diff against `b0a05dda1` on that path is empty); - `4ed5adf6f` appends one blank line and one paragraph, "**Correction, 2026-09-30 (objectui#6152).** …". It says `nextText` and `prevText` are now mirrored (PR #11125), by the same reference to the spec's `I18nLabelSchema`; - `git diff b0a05dd --numstat` on the path reads 2 added, 0 deleted. The frontmatter is byte-identical, and `main`'s blob is an exact byte prefix of the new one (`cmp`). This PR's own changeset, `.changeset/6152-object-form-unmirrored-members.md`, states no ledger figure, so nothing in it moved with the merge. It is not edited. ### The pending-changeset re-read (the `changeset-claim-re-read` request on this PR, `5894373256`) That comment asked this PR to re-read the 31 pending changesets that name a file it touches, against its diff. This round did, on the net diff against `main`. Each body was searched for the `ObjectFormSchema` / `object-form` members this PR moves (the nineteen mirrored keys, `open`, `submitHandler`, `sections`) and for `UnmirroredDeclared` figures, and every hit was read in its paragraph. - **One claim goes false when this PR lands:** `.changeset/7200-object-form-section-style-keys-undeclared.md`. It gives, as its reason for not using a never-typed tombstone, that "`ObjectFormSchema` in `zod/objectql.zod.ts` does not declare `sections`", "so there is no parse door to refuse at". This PR mirrors `sections` with a closed entry. - Measured with a scratch probe (⛔ not committed) at `4ed5adf6f`: the strict face refuses `{ sections: [{ label, className, fields }] }` as `unrecognized_keys` at `sections.0` naming `className`. The tolerant face accepts it and drops the key. The control without `className` parses on both. - On `main`, `ObjectFormSchema`'s mirror has no `sections` member; its `objectName` member is found by the same read, as the control. - **The remedy follows the same ruling as step 2:** `8f9bb76f6` appends one dated note ("**Correction, 2026-09-30 (objectui#6152).** …"), 2 added / 0 deleted against `b0a05dda1`. The frontmatter and every existing line are byte-identical: `HEAD`'s blob before the append is an exact byte prefix of the new one. Card objectui#7200 is closed (completed 2026-09-02), so no open claim holds that file. - ⚠️ This path is outside this card's claimed file surface. It is an in-place repair: same defect class as step 2; a mechanical shape the maintainer's append-only ruling pins; no other claim on the file; the same changeset gate family. The claim's file surface needs this path added. - **The other 30 hold.** 22 carry none of those tokens. The 8 that do describe one of three things: - other pairs: `ObjectGanttSchema`, `ObjectViewSchema`, `ObjectGridSchema.title`, the tree-view and chatbot slots; - `ObjectFormSchema.recordId` or `onStepChange`, members this PR does not move; - a ledger figure as a dated "X to Y" move. objectui#6150's "`RuntimeOnlyDeclared` is now a SUBSET of `UnmirroredDeclared`" still holds at pair level: its three pairs (`DataTableSchema`, `FormSchema`, `DetailViewSchema`) are all `UnmirroredDeclared` entries on the merged ledger. ### Ablation A3: a wrong total in the docblock turns the figure pin red Predictions were written to a scratch file before the run. The mutation went through objectstack's `scripts/ablation-replace.mjs` in wrap mode, on committed code (HEAD `4ed5adf6f`). It put the predicted-but-wrong spec-derived figure back into the totals line: "4 / 16 spec-derived" → "4 / 19 spec-derived". | leg | predicted | observed | | --- | --- | --- | | mutation on disk | anchor 1 → 0, replacement 0 → 1, the blob changes | as predicted; blob `ed320c3c755d` → `1e6b780b577f` | | `tsc -p packages/types/tsconfig.test.json` | exit 0: the type-level assertions read key sets, not prose | exit 0, no diagnostics | | `vitest` on `zod-mirror-parity.test.ts` | exit 1, exactly one red: objectui#7279's "the split figures and the totals the header writes down equal the ledger" | exit 1, `1 failed \| 36 passed (37)`, that test. Its diff: `totalsLine.specDerived.keys` is 16 in the ledger and 19 in the header | | restore, by state | blob equals the HEAD blob; `git diff HEAD` empty | blob `ed320c3c755d` equals HEAD's; `git diff HEAD` 0 bytes; `git status --porcelain` 0 lines | No `dist` leg exists: the parity file reads its own source off disk and compiles against `src`. ### Gates on the merged tree (exit codes captured before any pipe) The head is `8f9bb76f6`. Every row was read there except the readers' suites, which were read at `4ed5adf6f`. The one commit between the two only appends a paragraph to `.changeset/7200-object-form-section-style-keys-undeclared.md`, and no test names that file (`git grep` outside `.changeset/`: 0 hits; `check:pending-changeset-literals` green). | gate | exit | verdict line | | --- | --: | --- | | `pnpm --filter @object-ui/types type-check` (`tsc --noEmit && tsc -p tsconfig.examples.json && tsc -p tsconfig.test.json`) | 0 | no diagnostics | | `pnpm exec vitest run packages/types/` | 0 | `Test Files 285 passed (285)` · `Tests 6602 passed (6602)` | | app-shell `block-config-schema-parity-8216.test.ts` | 0 | `Tests 15 passed (15)` | | readers' suites (at `4ed5adf6f`): `packages/plugin-form/`, the three `ObjectView` form-slot tests, the two `RecordFormPage` tests | 0 | `Test Files 158 passed (158)` · `Tests 1817 passed \| 1 skipped (1818)` | | `check-changeset-presence` · `-no-major` · `-fixed` | 0 ×3 | declares `.changeset/6152-object-form-unmirrored-members.md` · no major · fixed group OK | | `check-changeset-overwrite` | 0 | report-only. It names the two pending changesets this round appends to, `10993-object-form-i18nlabel.md` and `7200-object-form-section-style-keys-undeclared.md`; each declares the same packages at the same levels at base and now | | `check:changeset-claims` · `check:pending-changeset-literals` | 0 · 0 | report-only · `No test source names a pending changeset` | | `check:control-bytes` · `check:new-line-citations` | 0 · 0 | `OK` · `0 new citation(s)` | | `check-governed-queue-guard --test` (the 8 paths of the diff against `main`) | 0 | `NOT GOVERNED` | **NOT MEASURED locally:** - the package `lint` runs and the repo-wide `pnpm lint`. This round edits two docblock comments and appends two changeset paragraphs. CI's. - app-shell's `tsconfig.test.json` type-check. CI's, as in round 1. The director's other answers in `5904218639` ③ go to later rounds on their own PRs, not this one: the `RuntimeOnlyDeclared` named allow-list, `resizableColumns` → `resizable`, and `currentPage` canonical. --- _Generated by [Claude Code](https://claude.ai/code/session_012UwY3ahMixEFkfTUxMVkYm)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6479086 commit 3a3db76

8 files changed

Lines changed: 384 additions & 51 deletions

‎.changeset/10993-object-form-i18nlabel.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ An `object-form` whose `title`, `description`, `submitText`, `cancelText`, `next
1919
**Types.** In `@object-ui/types`, `ObjectFormSchema.title`, `.description`, `.submitText`, `.cancelText`, `.nextText`, `.prevText` and `.successMessage` widen from `string` to `I18nLabel`, matching the spec row. The zod mirror's `title`, `description`, `submitText`, `cancelText` and `successMessage` widen from `z.string()` to the spec's `I18nLabelSchema`, by reference, so `safeValidateSchema` accepts a locale map on them; a number is still refused at the member. `nextText` and `prevText` stay unmirrored, as before. Code that writes these members compiles unchanged. Code that reads one of them off an `ObjectFormSchema` and uses it as a `string` no longer compiles: resolve it first, for example with `pickLocalized` from `@object-ui/i18n`.
2020

2121
**Clause-②: yes** — seven members of the exported `ObjectFormSchema` type, and five members of its zod mirror, widen from a string to `I18nLabel`, and the registration's `inputs` for the seven keys widen from `'string'` to `['string', 'object']`. Nothing that was accepted before is refused now.
22+
23+
**Correction, 2026-09-30 (objectui#6152).** The **Types** paragraph above says `nextText` and `prevText` stay unmirrored. That was true when this change was written, and it no longer is: objectui#6152 (PR #11125) mirrors both, by the same reference to the spec's `I18nLabelSchema`, so `safeValidateSchema` now judges them as it judges the other five: a locale map is accepted, and a number is refused at the member.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
'@object-ui/types': minor
3+
---
4+
5+
feat(types): the `object-form` zod mirror declares the members its TypeScript twin already declared (objectui#6152, round 1)
6+
7+
`ObjectFormSchema` in `@object-ui/types` (`objectql.ts`) declared a set of members that its zod
8+
mirror in `@object-ui/types/zod` had never heard of. Every one of them is read by the `object-form`
9+
renderer (`ObjectForm` in `@object-ui/plugin-form`). The two published faces answered differently:
10+
11+
- the tolerant validator (`AnyComponentSchema`, `safeValidateSchema`) kept any value at those keys
12+
without examining it, so `{ "formType": "carousel" }` parsed green and the form fell back to its
13+
simple layout;
14+
- the strict authoring face (`StrictAnyComponentSchema`) refused the keys outright, although the
15+
published TypeScript type invites them.
16+
17+
The mirror now declares each member, shaped as the TypeScript type declares it:
18+
19+
- `formType`, `sections`, `defaultTab`, `tabPosition`;
20+
- `allowSkip`, `showStepIndicator`, `nextText`, `prevText` (the last two are `@objectstack/spec`'s
21+
`I18nLabel`, by reference, like the form's other five label members);
22+
- `splitDirection`, `splitSize`, `splitResizable`;
23+
- `drawerSide`, `drawerWidth`, `modalSize`, `modalCloseButton`;
24+
- `mobile`, `buttons`, `defaults`, `subforms`.
25+
26+
The `object-view` node's `form` slot is this mirror minus `type`, `objectName` and `mode`, so it
27+
gains the same members.
28+
29+
What an author sees change:
30+
31+
- **Strict authoring face.** A document using any of these keys is no longer refused for them. The
32+
catalog's tabbed-sections form, for example, now parses strict.
33+
- **Tolerant face (breaking for invalid documents).** A value of the wrong type at one of these keys
34+
is now refused at the key, where it used to be kept unexamined. Examples are an unknown `formType`,
35+
a string `splitSize`, or a `subforms` entry without `childObject`. A section entry is judged
36+
member by member. Its `fields` entries are not judged here, which is the same policy as the
37+
mirror's existing `customFields`. On the strict face a section is also closed, so an undeclared
38+
section key is named there. `@object-ui/types` is in the fixed release group, so this ships as a
39+
minor bump, per the repository's version policy.
40+
41+
Two members of the same TypeScript type are deliberately not mirrored:
42+
43+
- `submitHandler` is a function slot, and a string handler dialect is ruled out (objectui#6182);
44+
- `open` is a boolean that only in-code hosts set.
45+
46+
Their routes are open on objectui#6152. No TypeScript declaration changed.

‎.changeset/7200-object-form-section-style-keys-undeclared.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ carrying either key was already ignored.
3232
**Migration.** Remove the two keys from any `ObjectFormSection` literal; they did nothing.
3333
Style sections through the host application's own CSS or the form ROOT `className`.
3434
Section *layout* stays authorable through `columns`.
35+
36+
**Correction, 2026-09-30 (objectui#6152).** The paragraph above gives, as the reason no `?: never` tombstone was used, that `ObjectFormSchema` in `zod/objectql.zod.ts` does not declare `sections`. That was true when this change was written, and it no longer is: objectui#6152 (PR #11125) mirrors `sections`, and each entry is judged member by member against `ObjectFormSection`. So a section now has a parse door. The strict authoring face (`StrictAnyComponentSchema`) refuses a section `className`, or any other key the entry does not declare, by name (`unrecognized_keys` at the section's path). The tolerant face (`AnyComponentSchema`) accepts the document and drops that key from its parsed output. The TypeScript change above is unaffected.

‎packages/app-shell/src/views/metadata-admin/previews/__tests__/block-config-schema-parity-8216.test.ts‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ const EXEMPT: Readonly<Record<string, { reason: string; card: string }>> = {
194194
* that stops applying is as red as a violation that is missing one.
195195
*
196196
* `face` scopes the row to the oracle that reports it, and it is load-bearing
197-
* rather than decoration: `object-form.formType` is a NODE-face declaration gap
198-
* while the SPEC face declares the key perfectly well, and an unscoped row
199-
* would absorb a future spec-face violation on the same name.
197+
* rather than decoration: `object-form.formType` was a NODE-face declaration gap
198+
* while the SPEC face declared the key perfectly well (until objectui#6152 round
199+
* 1 closed it — see the note inside the ledger), and an unscoped row would have
200+
* absorbed a future spec-face violation on the same name.
200201
*/
201202
const LEDGER: ReadonlyArray<{ block: string; path: string; face: OracleFace; card: string; why: string }> = [
202203
// `object-kanban::limit@spec` stood here until @objectstack/spec 17.4.0. It was
@@ -208,14 +209,13 @@ const LEDGER: ReadonlyArray<{ block: string; path: string; face: OracleFace; car
208209
// declared `limit` upstream, which is the maintainer's option-A ruling on
209210
// objectui#8172, and the row went stale. Deleted rather than kept: a row that
210211
// no longer describes a violation is as red here as a violation with no row.
211-
{
212-
block: 'object-form',
213-
path: 'formType',
214-
face: 'node',
215-
card: 'objectui#6152',
216-
why:
217-
'A declaration gap on the passthrough face only: the TS `ObjectFormSchema` declares `formType`, the spec declares it, PageBlockCanvas reads it, and the zod mirror omits it. objectui#6152 already carries this exact row in its UnmirroredDeclared table (objectql.zod.ts#ObjectFormSchema), so this ledger points there rather than opening a second card over the same debt.',
218-
},
212+
//
213+
// `object-form::formType@node` stood here too, pointing at objectui#6152: the
214+
// TS `ObjectFormSchema` and the spec both declared `formType`, PageBlockCanvas
215+
// read it, and the zod mirror omitted it. objectui#6152 round 1 declared it on
216+
// the mirror (with the other members that pair's `UnmirroredDeclared` entry
217+
// recorded), the "every ledger row still applies" pin below turned red as
218+
// written, and the row went.
219219
];
220220

221221
const ledgerId = (r: { block: string; path: string; face: OracleFace }) => `${r.block}::${r.path}@${r.face}`;
@@ -448,4 +448,18 @@ describe('BLOCK_CONFIG ↔ node-schema parity — the ratchet (objectui#8216)',
448448
expect(bogus.success).toBe(false);
449449
expect(bogus.error.issues.flatMap((i: any) => i.keys ?? [])).toContain('notAKanbanKey');
450450
});
451+
452+
it('the NODE-face ledger is empty too, and the row it last carried is re-measured', () => {
453+
// Same non-vacuity problem as the spec face above, on the other oracle: an
454+
// empty node-face ledger reads exactly like a node-oracle lookup that found
455+
// nothing. The live control re-measures `object-form::formType@node`, the
456+
// row objectui#6152 round 1 retired by declaring the key on the mirror.
457+
expect(LEDGER.filter((r) => r.face === 'node').map(ledgerId)).toEqual([]);
458+
const form = NODE_ORACLES['object-form'];
459+
expect(form, 'the object-form node oracle must resolve, or the verdicts below prove nothing').toBeDefined();
460+
expect(judge(form, 'formType')).toBeUndefined();
461+
// …and the same oracle still reports an undeclared name, so the line above is
462+
// not satisfied by an oracle that stopped judging.
463+
expect(judge(form, 'notAnObjectFormKey')?.kind).toBe('MISSING');
464+
});
451465
});

‎packages/types/src/__tests__/object-form-i18n-label-members-10993.test.ts‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
*
1414
* ## The zod mirror
1515
*
16-
* The mirror declares five of the seven, and it used to declare them
17-
* `z.string()`: a map the row and the renderer both accept was refused with
18-
* `invalid_type` at the member. Each is now the spec's `I18nLabelSchema` by
19-
* reference. The rows below are behavioural: a map and a string parse, and a
20-
* number is still refused AT THE MEMBER, so the widening is exactly one arm and
21-
* not an opening. `nextText` and `prevText` are not mirrored (they stay in this
22-
* pair's `UnmirroredDeclared` entry in `./zod-mirror-parity.test.ts`), and a
23-
* row records that here so the ledger and this file cannot disagree silently.
16+
* This card found the mirror declaring five of the seven, as `z.string()`: a map
17+
* the row and the renderer both accept was refused with `invalid_type` at the
18+
* member. Each became the spec's `I18nLabelSchema` by reference. The rows below
19+
* are behavioural: a map and a string parse, and a number is still refused AT
20+
* THE MEMBER, so the widening is exactly one arm and not an opening. The other
21+
* two, `nextText` and `prevText`, stayed in this pair's `UnmirroredDeclared`
22+
* entry (`./zod-mirror-parity.test.ts`) until objectui#6152 round 1 mirrored
23+
* them by the same reference, so all seven rows now run here; the last row
24+
* holds the shape to the seven, so the ledger and this file cannot disagree
25+
* silently.
2426
*
2527
* ## The TypeScript face
2628
*
@@ -48,8 +50,11 @@ export type assertionLabelMembersAreI18nLabel = [
4850
Expect<Equal<ObjectFormSchema['successMessage'], I18nLabel | undefined>>,
4951
];
5052

51-
/** The five members the mirror declares. */
52-
const MIRRORED = ['title', 'description', 'submitText', 'cancelText', 'successMessage'] as const;
53+
/**
54+
* The seven members the mirror declares: five since this card, `nextText` and
55+
* `prevText` since objectui#6152 round 1.
56+
*/
57+
const MIRRORED = ['title', 'description', 'submitText', 'cancelText', 'successMessage', 'nextText', 'prevText'] as const;
5358

5459
/** A minimal document the mirror accepts. */
5560
const BASE = { type: 'object-form', objectName: 'order', mode: 'create' } as const;
@@ -87,13 +92,11 @@ describe('object-form — the I18nLabel members on the zod mirror (objectui#1099
8792
expect(parsed.success).toBe(false);
8893
});
8994

90-
it('`nextText` and `prevText` are not mirrored, so the mirror does not judge them', () => {
91-
// Recorded, not endorsed: the pair's `UnmirroredDeclared` entry carries both
92-
// keys, and this row goes red when either is mirrored, so the two records
93-
// move together.
95+
it('all seven `I18nLabel` members are mirrored (objectui#6152 round 1 added `nextText` / `prevText`)', () => {
96+
// This row stood as "`nextText` and `prevText` are not mirrored" while the
97+
// pair's `UnmirroredDeclared` entry carried both; objectui#6152 round 1 moved
98+
// both records together, as the row asked.
9499
const shape = ObjectFormMirror.shape as Record<string, unknown>;
95-
expect('nextText' in shape).toBe(false);
96-
expect('prevText' in shape).toBe(false);
97100
for (const key of MIRRORED) expect(key in shape, key).toBe(true);
98101
});
99102
});
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*
8+
* objectui#6152 round 1 — the `ObjectFormSchema` members the TypeScript face
9+
* declared and the zod mirror had never heard of.
10+
*
11+
* ## The defect
12+
*
13+
* `UnmirroredDeclared['objectql.zod.ts#ObjectFormSchema']` in
14+
* `zod-mirror-parity.test.ts` recorded keys `../objectql.ts` invites an author
15+
* to write and `../zod/objectql.zod.ts` did not declare. Two faces paid for it:
16+
*
17+
* - the TOLERANT face (`BaseSchema` is `.passthrough()`) kept any value at
18+
* those keys unexamined, so `{ formType: 'carousel' }` parsed green and
19+
* `ObjectForm` fell through to its simple layout;
20+
* - the STRICT authoring face (`StrictAnyComponentSchema`, objectui#8345,
21+
* derived from the mirrors) refused the keys outright, although `tsc`
22+
* accepted them — objectui#5250's M3 class (iii), the refusals
23+
* `objectui validate` would print wrongly once it judges strict.
24+
*
25+
* Each key was measured before it was mirrored: authored (a document, the
26+
* object-view `form` slot, or a form view relayed into the node), and READ by a
27+
* shipped renderer (`ObjectForm` in `@object-ui/plugin-form`). The readings are
28+
* in objectui#6152's round-1 report; this file pins the result, not the census.
29+
*
30+
* ## What each row asserts
31+
*
32+
* - a VALID authored value parses on BOTH faces — the strict leg is the one
33+
* that moved (refused → accepted), the tolerant leg shows the shape is not a
34+
* broken schema;
35+
* - a WRONG-TYPED value is refused AT THE KEY on the tolerant face — the leg
36+
* that moved the other way (kept unexamined → refused).
37+
*
38+
* `open` and `submitHandler` stay out of the mirror on purpose (their routes are
39+
* open on objectui#6152; objectui#6182 rules out a string handler), and a row
40+
* holds them out so a later card cannot mirror them without that ruling.
41+
*/
42+
import { describe, it, expect } from 'vitest';
43+
import { readFileSync } from 'node:fs';
44+
import { fileURLToPath } from 'node:url';
45+
import { dirname, join } from 'node:path';
46+
47+
import { ObjectFormSchema as ObjectFormMirror } from '../zod/objectql.zod.js';
48+
import { AnyComponentSchema, StrictAnyComponentSchema } from '../zod/index.zod.js';
49+
50+
const HERE = dirname(fileURLToPath(import.meta.url));
51+
const REPO_ROOT = join(HERE, '..', '..', '..', '..');
52+
53+
/** A minimal document both faces accept; every row below is a delta on it. */
54+
const BASE = { type: 'object-form', objectName: 'order', mode: 'create' } as const;
55+
56+
/** Each mirrored key: one authored value, and one value its declaration refuses. */
57+
const ROWS: ReadonlyArray<{ key: string; valid: unknown; wrong: unknown }> = [
58+
{ key: 'formType', valid: 'wizard', wrong: 'carousel' },
59+
{
60+
key: 'sections',
61+
valid: [
62+
{ name: 'basics', label: 'Basics', columns: 2, fields: ['name', { name: 'email', type: 'email' }] },
63+
{ group: 'contact_info', pane: 'secondary', visibleWhen: { dialect: 'cel', source: 'record.kind == "b2b"' } },
64+
],
65+
wrong: 'basics',
66+
},
67+
{ key: 'defaultTab', valid: 'basics', wrong: 3 },
68+
{ key: 'tabPosition', valid: 'left', wrong: 'middle' },
69+
{ key: 'allowSkip', valid: true, wrong: 'yes' },
70+
{ key: 'showStepIndicator', valid: false, wrong: 'no' },
71+
{ key: 'nextText', valid: { en: 'Next', fr: 'Suivant' }, wrong: 42 },
72+
{ key: 'prevText', valid: 'Back', wrong: 42 },
73+
{ key: 'splitDirection', valid: 'vertical', wrong: 'diagonal' },
74+
{ key: 'splitSize', valid: 40, wrong: '40%' },
75+
{ key: 'splitResizable', valid: false, wrong: 'false' },
76+
{ key: 'drawerSide', valid: 'left', wrong: 'center' },
77+
{ key: 'drawerWidth', valid: '40%', wrong: 40 },
78+
{ key: 'modalSize', valid: 'lg', wrong: 'huge' },
79+
{ key: 'modalCloseButton', valid: false, wrong: 'no' },
80+
{ key: 'mobile', valid: { stickyActions: true, stepper: 'auto', stepperMinFields: 6 }, wrong: { stepper: 'sometimes' } },
81+
{ key: 'buttons', valid: { submit: { show: true, label: 'Save' }, reset: { show: false } }, wrong: { submit: { show: 'yes' } } },
82+
{ key: 'defaults', valid: { status: 'open', priority: 2 }, wrong: ['status'] },
83+
{ key: 'subforms', valid: [{ childObject: 'order_line', minRows: 1 }], wrong: [{ relationshipField: 'order' }] },
84+
];
85+
86+
describe('objectui#6152 round 1 — `object-form` members the mirror now declares', () => {
87+
it('CONTROL: the minimal document parses on both faces', () => {
88+
expect(AnyComponentSchema.safeParse(BASE).success).toBe(true);
89+
expect(StrictAnyComponentSchema.safeParse(BASE).success).toBe(true);
90+
});
91+
92+
it.each(ROWS)('`$key` is a member of the mirror', ({ key }) => {
93+
expect(key in (ObjectFormMirror.shape as Record<string, unknown>)).toBe(true);
94+
});
95+
96+
it.each(ROWS)('an authored `$key` parses on the strict face and the tolerant face', ({ key, valid }) => {
97+
const doc = { ...BASE, [key]: valid };
98+
const strict = StrictAnyComponentSchema.safeParse(doc);
99+
expect(strict.success, JSON.stringify(strict.error?.issues)).toBe(true);
100+
const tolerant = AnyComponentSchema.safeParse(doc);
101+
expect(tolerant.success, JSON.stringify(tolerant.error?.issues)).toBe(true);
102+
});
103+
104+
it.each(ROWS)('a wrong-typed `$key` is refused at the key on the tolerant face', ({ key, wrong }) => {
105+
const parsed = ObjectFormMirror.safeParse({ ...BASE, [key]: wrong });
106+
expect(parsed.success).toBe(false);
107+
for (const issue of parsed.error?.issues ?? []) expect(issue.path[0]).toBe(key);
108+
});
109+
110+
it('the object-view `form` slot takes the same members (it is this mirror minus the identity keys)', () => {
111+
const doc = { type: 'object-view', objectName: 'order', form: { formType: 'drawer', drawerSide: 'left', sections: [{ fields: ['name'] }] } };
112+
const strict = StrictAnyComponentSchema.safeParse(doc);
113+
expect(strict.success, JSON.stringify(strict.error?.issues)).toBe(true);
114+
expect(AnyComponentSchema.safeParse({ ...doc, form: { formType: 'carousel' } }).success).toBe(false);
115+
});
116+
117+
it('a section is a closed shape on the strict face: an undeclared section key is named there', () => {
118+
// `className` is deliberately undeclared on `ObjectFormSection` (objectui#7200).
119+
const strict = StrictAnyComponentSchema.safeParse({ ...BASE, sections: [{ name: 'a', className: 'p-4', fields: ['a'] }] });
120+
expect(strict.success).toBe(false);
121+
expect(JSON.stringify(strict.error?.issues)).toContain('"className"');
122+
});
123+
124+
it('the catalog document objectui#5250 M3 charged with three of these keys now parses on the strict face', () => {
125+
const doc = JSON.parse(readFileSync(join(REPO_ROOT, 'examples/schema-catalog/src/schemas/plugin-form/object-form-tabbed-sections.json'), 'utf8'));
126+
// Non-vacuity: the document really carries the keys this row is about.
127+
expect(Object.keys(doc)).toEqual(expect.arrayContaining(['formType', 'defaultTab', 'sections']));
128+
const strict = StrictAnyComponentSchema.safeParse(doc);
129+
expect(strict.success, JSON.stringify(strict.error?.issues)).toBe(true);
130+
});
131+
132+
it('`open` and `submitHandler` stay out of the mirror until their routes are ruled', () => {
133+
const shape = ObjectFormMirror.shape as Record<string, unknown>;
134+
expect('open' in shape).toBe(false);
135+
expect('submitHandler' in shape).toBe(false);
136+
});
137+
});

0 commit comments

Comments
 (0)