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

Commit dded788

Browse files
feat(types): the four page: containers take their child list in properties.children, and objectql.zod.ts shares propsBag (objectui#10872, batch 6) (#11222)
Part of #10872 Clause-②: yes **objectui#10872 batch 6: the four `page:` containers take their child list in `properties.children`.** `page:card`, `page:section`, `page:footer` and `page:sidebar` now refuse a node-level `children` by name, and restate `body` with the same message. The message's first sentence names `properties.children`, the member each block's `@objectstack/spec` row declares. Also in this PR, with no behaviour change: `objectql.zod.ts`'s two public-block arms import the one `propsBag` helper instead of keeping a byte copy of it. The card stays open. `record:line_items` (no spec row yet) and the rest of the flat-props / envelope-key batch remain, as the claim and release `5909279008` list them. ## The ruling this executes, and the premises it rests on The seat applied triage's `action:*` answer (`5906817482`: "The `properties` bag is the contract", "B is not taken … a second dialect") to this branch. The ruling holds only on premises 1–4 of the order, so each was measured before the first edit to the four arms. All four hold for all four containers. | # | premise | reading (objectui `origin/main` `cfc9b6db98`, installed `@objectstack/spec` 17.5.0) | holds | |:--|:--|:--|:--| | 1 | the installed spec refuses a node-level `children` on all four | `PageComponentSchema.safeParse({ type, children: [node] })`: `unrecognized_keys` with keys `["children"]` on each of the four. The message reads "Unrecognized key(s) on this page component: `children`. Before ADR-0089 D3a these were dropped silently…". `{ type, properties: { children } }` and a bare `{ type }` both pass. Control: `page:tabs`, `page:header` and `record:details` give the same refusal, so the instrument is live. | yes, 4 of 4 | | 2 | each row declares `children` inside `properties` | `ComponentPropsMap['page:card']` is `PageCardProps`, with keys `title`, `bordered`, `actions`, `children`, `body`, `footer`, `aria`. `actions` and `body` are `[REMOVED]` tombstones, and `body`'s text says "Rename the key to `children`". The other three rows are all `PageContainerProps` (identity checked), whose one key is `children`. Every `children` is `z.array(z.unknown())` and optional, and each row parses `{ children: [node] }`. | yes, 4 of 4 | | 3 | a spec-shaped node renders its children through objectui today | This was a one-off runtime probe, never committed, through the real `SchemaRenderer`, `ActionProvider`, `I18nProvider` and the `@object-ui/components` registry (happy-dom). Each container got two `element:text` markers in `properties.children`. **All four rendered both markers, in order, and the DOM was byte-identical to the node-level spelling.** The roots were `div.rounded-lg.border.bg-card` (card), `section.space-y-4`, the separator-led footer and `aside.flex.flex-col.gap-4`. Control: with no children, the render had 0 markers. The mechanism is `SchemaRenderer`'s `properties` hoist, which copies every bag key except `type` / `id` onto the node the renderer reads. | yes, 4 of 4 | | 4 | no objectui or objectstack writer emits a node-level `children` on the four | Census: `node scripts/body-dialect-census.mjs --keys page:card,page:section,page:footer,page:sidebar,page:tabs,page:accordion,grid,flex,card --json`. **objectui** (9440 files): 7 nodes of the four types carry a node-level `children`, all in the `test` bucket (six `page:section` and one `page:card`, in app-shell render tests). There are 0 in `apps` / `examples` / `content/docs` / `skills` / `packages/*/src`. Lit control: `card` has 88 node-level `children` in `example-app` and `flex` has 251. **objectstack** (`origin/main` `72f8c38201`, `apps` / `examples` / `packages` / `content` archived into the scratchpad, 8379 files): 109 nodes of the four types (83 `page:card`, 20 `page:section`, 1 `page:footer`, 5 `page:sidebar`), and **0** carry a node-level `children`. Lit control: `flex` has 2. The showcase's own `my-work` page writes `page:card` with `properties.children`, and the spec lint's `page-walk` says "`PageComponentSchema` is `.strict()`, so a component carries no `children` key of its own". **Writers read directly:** the page designer's canvas addresses `properties.children` for `page:card` and `page:section` (`childGroups` in `PageBlockCanvas`), and for any block that already carries that array. The inspector writes every prop into `properties` (`patchProp`). The default page synthesizer (`buildDefaultPageSchema`'s `componentNode`) emits `{ type, properties }` and none of the four types. | yes, 4 of 4 | | 5 | `objectBlockPropsBag` is a byte copy of `propsBag` | With only the function name normalised, the two 8-line bodies have the same md5 (`d7a54fe8…`) and `diff` exits 0. Folded: `propsBag` is exported from `public-blocks.zod.ts` and `objectql.zod.ts` imports it. There is no third copy, and the barrel still does not re-export it. | yes | | 6 | `NAMESPACED_REFUSED_AT_TYPE` does not move | The diff of the ratchet file against the base is empty, and `registered-types-validate-ratchet-10859.test.ts` is green in the sweep below. | yes | ## What changed - `packages/types/src/zod/public-blocks.zod.ts` - Each of the four arms declares `children` and `body` as `retirementTombstone` members. Both are fed ONE string from a new local composer, `pageContainerChildListGuidance(type, row)`. This is the objectui#9256 construct with a different message: these blocks do render their child list, so the neither-channel text would be false for them. The first sentence names `properties.children`, the row (`PageCardProps` / `PageContainerProps`) and the node to write. The message also says the spec refuses the node-level spelling, and that the hoist makes the move a no-op at render time. - `propsBag` is exported, and its docblock says it is the one copy, internal, and not re-exported from `index.zod.ts`. - The module docblock's "content channels" section gains a paragraph for the four containers. The flat-key paragraph no longer says a flat `body` on the containers is refused by the base's objectui#6771 retirement, "whose `children` remedy they do render": this diff makes that false. - `packages/types/src/zod/objectql.zod.ts`: the `objectBlockPropsBag` copy is deleted, and `object-metric` and `object-master-detail-form` build `properties` with the imported `propsBag`. - `packages/types/src/__tests__/container-children-channel-10872.test.ts` (new, 102 tests), in four groups: - (a) Refusal, on both faces. `invalid_type` at the key's own path, and a first sentence naming `properties.children`, the block, the row and the node to write. Neither the neither-channel text nor the "Did you mean `body` → `children`?" remedy appears. One string feeds `.describe()` and the issue message, every value is refused, and both keys are members. - (b) Positive controls, on both faces. `properties.children` parses, the bare node parses, the bag spelling parses nested in a `page` while the node-level spelling is refused there at `children.0.children`, and `page:card`'s full row (`title`, `bordered`, `children`, `footer`) parses. - (c) The installed spec. It refuses the node-level spelling and passes the bag spelling, and each row still declares `children`, so the remedy names a real member. - (d) The fold. Both `objectql.zod.ts` arms' `properties` description is word-for-word the helper's text, from the same composer as the `public-blocks.zod.ts` arms. - `.changeset/10872-container-children-channel.md`: `'@object-ui/types': minor`, `Clause-②: yes (narrowing)`, see below. ## Surface beyond the order's file list, each forced by this diff and declared - `content-channel-public-blocks-9256.test.ts`: its "CONTROL — `%s` renders the node's child list, so it still takes `children`" rows asserted that the four ACCEPT a node-level `children`, which is the exact behaviour this batch narrows. The control keeps its purpose, which is to show that a reader keeps its channel. It now asserts `properties.children` parses on the arm and on `AnyComponentSchema`, and that the node-level refusal is not the neither-channel text. Text of the other rows is untouched. - `record-alert-flat-body-remedy-10872.test.ts`: its "CONTROL arm — `page:card` … keeps `BaseSchema`'s objectui#6771 refusal" asserted the old `body` message on `page:card`, which this batch restates. The control moves to `card`, which reads the node-level `children` and keeps the objectui#6771 remedy. It asserts the same three facts, and a comment records the move. - `packages/types/src/zod/README.md`: one sentence. "Every arm except the four `page:` containers … refuses `children` and `body`" would now misdescribe the four, so it gains a sentence saying they refuse both with a message naming `properties.children`. This follows AGENTS.md #2, and batch 5's README hunk was ratified on the same ground. - `.changeset/10872-public-block-zod-arms.md` (pending, batch 1): a dated note only, with the frontmatter untouched. Its flat-props bullet says `children` on the four is "judged against the base's own types", and that `body` on `page:card` is refused "by the base's objectui#6771 retirement". Neither describes the release as a whole any more. This is the dated-note precedent of batches 2–4 on that same file. - `zod-mirror-parity.test.ts`: the four `EXCLUSIONS` reason strings name the new members (text only, the order's allowance). ## Changeset: `minor`, and why - The accept set narrows against `main` on four exported arms: a node-level `children` is refused where it parsed. Hence `Clause-②: yes (narrowing)`. - The arm is `minor`, on the objectui#9256 / batch-5 precedent. This repo forbids `major` in any changeset (one `fixed` group) and spells a narrowing as `minor` with an explicit note. - It is not breaking against the last release. The published `@object-ui/types` 17.6.0 (npm `latest`, 2026-08-24) carries no public-block arm: its dist has 0 hits for `PageCardBlockSchema` / `PageSectionBlockSchema` / `PublicBlockComponentSchema`, against 1 each for the controls `CardSchema` / `FlexSchema`. Its `safeValidateSchema` answers `invalid_union` for `{ type: 'page:section' }`, with or without children and with a bag, and for `page:footer` / `page:sidebar`, while the control `{ type: 'card', children: [...] }` passes. So across the release the accept set only widens. ## Tests (final head `573373f931`, `main` `e6bc087a30` merged in; all heavy runs through `os-verify-lock`) | command | verdict | |:--|:--| | `pnpm --filter '@object-ui/types^...' build` | exit 1 `ERR_PNPM_RECURSIVE_RUN_NO_SCRIPT`. The closure is empty (`@object-ui/types` has no workspace dependency), so nothing ran. Not a red build. | | `pnpm --filter @object-ui/types build` | exit 0, "dist completeness: 1 package(s) complete (136 emitted files verified)" | | `pnpm --filter @object-ui/types type-check` | exit 0: three `tsc` legs, and `tsconfig.test.json --listFilesOnly` lists the three edited or new test files | | `pnpm exec vitest run packages/types/` | exit 0, `Test Files 290 passed (290)`, `Tests 7012 passed (7012)` | | arm-shape consumer sweep, 13 files: every non-`packages/types` hit of `git grep -lw` on `AnyComponentSchema` / `StrictAnyComponentSchema` / `PublicBlockComponentSchema` in tests (the `packages/types` hits run in the row above), plus the app-shell `block-config-schema-parity-8216` oracle, `check-handler-key-read-sites.test.ts` and `registry-inputs-spec-parity.test.ts` | exit 0, `Test Files 13 passed (13)`, `Tests 396 passed (396)`. Includes `registered-types-validate-ratchet-10859.test.ts`. | The same matrix ran green on `8e2dd4e1ed` before the merge of `main`: 290 files / 6984 tests, and the 13-file sweep with 396 tests. **Ablation (proves the pin can fail; nothing permanent left behind).** `node /home/user/objectstack/scripts/ablation-replace.mjs` ran nested four deep in WRAP mode, one leg per arm, each with `--delete` of that arm's two member lines. Each leg reported "ok mutation landed", with the anchor count going from 1 to 0. During the mutation, `grep -c` for the four constants' tombstone calls read 0. The pin files live in `packages/types` and import the arms by relative source path, so there is no `dist/` leg. - Predicted: 60 red in the new pin, from the 16 children-refusal, 16 first-sentence and 16 remedy-text rows (8 + 16 + 16), the 8 one-string rows, the 4 every-value children rows and the 8 nested-page rows. Also predicted: 4 red in the objectui#9256 control, and 0 red among the member, positive-control, spec and fold rows. - Observed: `container-children-channel-10872.test.ts (102 tests | 60 failed)` and `content-channel-public-blocks-9256.test.ts (230 tests | 4 failed)`, which is `Tests 64 failed | 268 passed (332)`. - Restored: each leg printed "ok restored: blob == HEAD (b6d53f2) and `git diff HEAD` is empty", and the outer script's own check read "git diff HEAD empty: yes". ## Gates (head `573373f931`, each exit captured before any pipe) - `node scripts/check-changeset-presence.mjs`: exit 0. "7 source file(s) of 1 released package(s) changed, and this change declares 1 changeset(s): .changeset/10872-container-children-channel.md." - `pnpm changeset:check`: exit 0. "No changeset declares a `major` bump." - `check-changeset-overwrite`: exit 0, report-only. "1 changeset(s) added, 1 modified, 0 deleted"; the modified one is the dated note, and its frontmatter is unchanged. - `check:changeset-claims`: exit 0, report-only. None of the 32 flagged pending changesets names the four containers or the helper. - `check:pending-changeset-literals`: exit 0. - `check:control-bytes`: exit 0, "OK (scanned 9615 tracked text file(s))". A `grep -naP` self-scan over the nine changed files found 0 lines. - `check:new-line-citations`: exit 0, "0 new citation(s)". - `check:handler-key-reads`: exit 0, "OK 139 arm(s) … 57 judged, 0 left unjudged on an arm with an unresolved spread". - All exit 0: `check:spec-symbols`, `check:test-path-roots`, `check:installed-pin-claims`, `check:doc-types`, `check:doc-fences`, `check-doc-links`, `check-type-check-coverage` ("43/43 packages compile their tests"), `check:unreferenced-sources`, and `markdown-test-inputs.mjs --audit` ("107 candidate test files, all adjudicated"). This batch adds no markdown reader. - eslint, narrowed, with `--no-inline-config --format json` over the six changed TS files: 6 files, 0 errors. There are 3 pre-existing `no-explicit-any` warnings outside the hunks. Invariance: `--print-config` shows no `parserOptions.project` / `projectService`, so linting is not type-aware and this diff cannot move a verdict on an untouched file. The repo-wide `pnpm lint` is left to CI. - `check-governed-queue-guard --test` over the nine paths: "NOT GOVERNED". - NOT MEASURED: `check:doc-snippets`, reason "PRECONDITION NOT MET (exit 2)". It needs 34 packages built, and the README change is prose outside any fence. Left to CI. - NOT MEASURED: `check:readme-exports`, reason exit 1, "531 self-import(s) could not be judged … the population COLLAPSED". Other packages' `dist` is missing. Left to CI. ## Serial / overlap `main` moved while this ran: PR objectui#11207 (`app.zod.ts` and its pins) and five others landed. None touches a file of this diff. `git merge-tree` was clean, `main` was merged in (merge, no rebase), and the matrix above was rerun on the merge. The seat named an in-flight branch for objectui#9547 that edits `objectql.zod.ts` (its `onNavigate` region) and `zod-mirror-parity.test.ts` (its own rows). This diff's hunks there are the helper region and the four container rows only. ## Acceptance notes (not filed; for the seat) 1. **The bag's nested nodes are not judged by objectui's validator.** This predates the batch, and the batch makes the bag the only channel on these four. The spec rows type `children` (and `page:tabs` / `page:accordion` `items[].children`) as `z.array(z.unknown())`. So `{ type: 'page:section', properties: { children: [{ type: 'no-such-type-xyz' }] } }` parses green on both faces, and so does a malformed `element:text` there. The same child written at node level was refused (`invalid_union` at `children`). The spec's lint walks those bag arrays by hand (`page-walk`), so `os validate` still judges them. What this batch moves is only which spelling is accepted, not whether nested content is judged by the publish gate. The pre-existing gap belongs in its own card. Dedupe words: `properties.children nested node not validated` · `bag slot children z.array(z.unknown()) objectui validate` · `items[].children unjudged safeValidateSchema`. 2. **The parser tier still accepts the node-level spelling.** `@object-ui/sdui-parser`'s `BASE_PROPS` lists `children`, and `isContainer` authorises it on the four, so the manifest tier and the VS Code validator pass a node-level `children` that both zod faces now refuse. This is batch 3's `record:alert` pattern. The carrier is this card's flat-props / envelope-key batch, whose order names both tiers. ⛔ Not touched here: the order excludes `packages/sdui-parser` and `packages/vscode-extension`. 3. **A committed runtime pin for premise 3 is not in this PR.** Zone 3 suggested one. It would need `@object-ui/react` and `@object-ui/components` in a DOM project, but `@object-ui/types` imports no renderer and its tests run in the `unit` (node) project. Its home would be `packages/components/src/__tests__/`, which is outside the claimed surface. The probe's readings are in premise 3 above. If the seat wants it pinned, a follow-up with that surface is a small test. 4. `skills/objectui/guides/page-builder.md` says the three thin containers "render a `section`, `footer` and `aside` around their `children`". That is prose, true at runtime, and names no node spelling. It is governed, so it is only noted here. --- _Generated by [Claude Code](https://claude.ai/code/session_0122Knsowci76D2rBWReCzzZ)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2e3da72 commit dded788

9 files changed

Lines changed: 376 additions & 37 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@object-ui/types': minor
3+
---
4+
5+
The four `page:` containers take their child list in `properties.children`, the member their `@objectstack/spec` row declares, and refuse a node-level `children` by name: `page:card`, `page:section`, `page:footer` and `page:sidebar` (objectui#10872, batch 6).
6+
7+
**Clause-②: yes (narrowing).** On each of the four zod arms, `children` and `body` are declared as by-name refusals, each kept a member of the arm. Both carry one message per block, which names `properties.children`.
8+
9+
**What it was.** Each arm took `BaseSchema`'s node-level `children` as it was, so `{ "type": "page:section", "children": [ … ] }` parsed green on both faces (`safeValidateSchema`, and so `objectui validate`, and `StrictAnyComponentSchema`). `@objectstack/spec`'s own `PageComponentSchema` refuses that node: a page component has no node-level `children`, and the key is refused as unrecognized (ADR-0089 D3a). So `objectui validate` accepted a page that `os validate` refuses. A flat `body` was already refused, by `BaseSchema` (objectui#6771), but its message sent the author to the node-level `children`.
10+
11+
**What changed, in observable terms.**
12+
13+
- A node-level `children` on any of the four is refused with `invalid_type` at its own path, on both faces and nested in a page.
14+
- `body` is refused as before, at the same path with the same code. The message no longer says "Did you mean `body` → `children`".
15+
- The message's first sentence names `properties.children` and the row that declares it (`PageCardProps`, or `PageContainerProps` for the other three), with the node to write: `{ "type": "page:section", "properties": { "children": [ … ] } }`.
16+
- `properties.children` parses on both faces, as it did. The spec row declares it on all four, and the spec's `PageComponentSchema` passes it.
17+
18+
**Nothing renders differently.** The renderers are not touched and keep reading the node-level `children` and `body` for stored documents. `SchemaRenderer` hoists every `properties` key onto the node before the renderer runs, so a container authored with `properties.children` renders the same child list. The page designer's canvas addresses `properties.children` on these blocks, and the default page synthesizer emits none of them; where the node-level spelling still appears in a tree, `pnpm census:body-dialect --keys page:card,page:section,page:footer,page:sidebar` lists it.
19+
20+
**Why `minor`, and why this breaks no published document.** `minor` follows the objectui#9256 narrowing precedent. This repo's version policy forbids `major` in any changeset (one `fixed` group), and records a narrowing as `minor` with an explicit note like this one. But the narrowing is not breaking against the last release. In `@object-ui/types` 17.6.0 no arm claims these four types, so every document naming one is refused with `invalid_union`: their arms (objectui#10872 batch 1) are unreleased, and ship in the same release as this entry. So no published version ever accepted a node-level `children` on these nodes: across the release, the accept set only widens.
21+
22+
Also in this change, with no behaviour change: `objectql.zod.ts`'s two public-block arms (`object-metric`, `object-master-detail-form`) build their `properties` member with the same `propsBag` helper as the other public-block arms, instead of a byte copy of it. The member's description text is unchanged.
23+
24+
Migration: move the child list into the bag. `{ "type": "page:section", "children": [ … ] }` becomes `{ "type": "page:section", "properties": { "children": [ … ] } }`.

‎.changeset/10872-public-block-zod-arms.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
⚠️ **Dated note, 2026-09-29 — `record:alert`'s flat `body` — objectui#10872 batch 3.** Later in this same release `record:alert`'s arm restates `body` with its own refusal, which names `properties.body`. So the bullet on a prop written directly on the node, where it says "`body` (`page:card`, `record:alert`) is refused on both faces by the base's objectui#6771 retirement", no longer describes the release as a whole: that holds for `page:card` only, and a flat `body` on `record:alert` is still refused on both faces, by the arm's own refusal instead. The bullet's advice, to write a `record:alert` banner's `body` inside `properties`, is what that refusal now says. The rest of this entry is kept as the reading of this change.
2222

2323
⚠️ **Dated note, 2026-09-30 — the six held blocks armed — objectui#10872 batch 4.** Later in this same release `@objectstack/spec` 17.5.0 carries a `ComponentPropsMap` row for `element:definition-list`, `element:repeater`, `action:button`, `action:group`, `action:menu` and `action:icon`, and each is armed from its row (`.changeset/10872-held-public-block-arms.md`). So the last two blocks of the "Not armed in this release" bullet no longer describe the release as a whole: of the held blocks, only `record:line_items` is still refused at `type`. The rest of this entry is kept as the reading of this change.
24+
25+
⚠️ **Dated note, 2026-09-30 — the four `page:` containers' child list — objectui#10872 batch 6.** Later in this same release the arms of `page:card`, `page:section`, `page:footer` and `page:sidebar` refuse a node-level `children` and restate `body`, both with a message that names `properties.children`, the member their spec row declares (`.changeset/10872-container-children-channel.md`). So the bullet on a prop written directly on the node, where it says `children` (`page:card`, `page:section`, `page:footer`, `page:sidebar`) is judged against the base's own type and `body` (`page:card`) is refused by the base's objectui#6771 retirement, no longer describes the release as a whole: on those four, both keys are refused by the arm's own refusal. The rest of this entry is kept as the reading of this change.
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
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+
9+
/**
10+
* objectui#10872 batch 6 — the child list of the four `page:` containers
11+
* (`page:card`, `page:section`, `page:footer`, `page:sidebar`) is
12+
* `properties.children`, and the node-level spelling is refused by name,
13+
* pointed there. The objectui#9256 slices narrowed every OTHER public block,
14+
* whose renderers read neither content channel
15+
* (`content-channel-public-blocks-9256.test.ts`,
16+
* `held-block-content-channels-10872.test.ts`); this file carries only what
17+
* this batch adds.
18+
*
19+
* ## The defect
20+
*
21+
* These four DO render a child list, and each one's `@objectstack/spec` row
22+
* declares it as the `children` member of the props bag (`PageCardProps`;
23+
* `PageContainerProps` for the other three). Their arms took `BaseSchema`'s
24+
* node-level `children` as it was, so `{ "type": "page:section", "children":
25+
* [ … ] }` parsed green on both faces while the spec's own
26+
* `PageComponentSchema` refuses that node as an unrecognized key: `objectui
27+
* validate` accepted what `os validate` refuses. And a flat `body` was refused
28+
* with `BaseSchema`'s objectui#6771 remedy, which points at the node-level
29+
* `children`.
30+
*
31+
* ## What is narrowed
32+
*
33+
* Each arm declares `children` as a by-name refusal and restates `body` with
34+
* the same guidance: two `retirementTombstone` members fed ONE string, both
35+
* kept MEMBERS, as the objectui#9256 arms are — but the string is not the
36+
* neither-channel text, because these blocks render their child list. It
37+
* names where the list goes: `properties.children`. The renderers are not
38+
* touched; they keep reading the node-level spellings for stored documents.
39+
*
40+
* ## Why the remedy is honest, and why this is not a second dialect
41+
*
42+
* The last blocks below re-read the installed spec: its `PageComponentSchema`
43+
* refuses the node-level `children` on all four and passes the bag spelling,
44+
* and each row still declares the `children` member the message names. A spec
45+
* that changes either turns this file red here.
46+
*
47+
* That the bag spelling renders the same page (the child list, in order, with
48+
* DOM byte-identical to the node-level spelling) was measured once through the
49+
* real `SchemaRenderer` and registry, and that no objectui or objectstack
50+
* producer writes the node-level spelling on these four was measured once by
51+
* the committed `census:body-dialect` instrument. Both readings are recorded on
52+
* objectui#10872; nothing in this file re-derives them — `@object-ui/types`
53+
* imports no renderer.
54+
*
55+
* ## The props-bag helper fold
56+
*
57+
* `objectql.zod.ts`'s two public-block arms had a byte copy of
58+
* `public-blocks.zod.ts`'s `propsBag` under another name; they import the one
59+
* helper now. The last block pins that their `properties` member is what it
60+
* was: the same description, from the same composer.
61+
*/
62+
63+
import { describe, expect, it } from 'vitest';
64+
import type { z } from 'zod';
65+
import { ComponentPropsMap, PageComponentSchema } from '@objectstack/spec/ui';
66+
67+
import {
68+
PageCardBlockSchema,
69+
PageSectionBlockSchema,
70+
PageFooterBlockSchema,
71+
PageSidebarBlockSchema,
72+
ObjectMetricBlockSchema,
73+
ObjectMasterDetailFormBlockSchema,
74+
StrictAnyComponentSchema,
75+
safeValidateSchema,
76+
} from '../zod/index.zod.js';
77+
78+
type Issue = { code: string; path: PropertyKey[]; message: string; keys?: string[]; errors?: Issue[][] };
79+
type Result = { success: boolean; error?: { issues: z.core.$ZodIssue[] } };
80+
type Arm = {
81+
safeParse: (v: unknown) => Result;
82+
shape: Record<string, { description?: string } | undefined>;
83+
};
84+
85+
const FACES: ReadonlyArray<readonly [string, (document: unknown) => Result]> = [
86+
['tolerant', (document) => safeValidateSchema(document)],
87+
['strict', (document) => StrictAnyComponentSchema.safeParse(document)],
88+
];
89+
90+
/** One row per narrowed container: its arm, and the spec row's exported name the message cites. */
91+
const ROWS: ReadonlyArray<readonly [type: string, arm: Arm, row: string]> = [
92+
['page:card', PageCardBlockSchema as unknown as Arm, 'PageCardProps'],
93+
['page:section', PageSectionBlockSchema as unknown as Arm, 'PageContainerProps'],
94+
['page:footer', PageFooterBlockSchema as unknown as Arm, 'PageContainerProps'],
95+
['page:sidebar', PageSidebarBlockSchema as unknown as Arm, 'PageContainerProps'],
96+
];
97+
98+
const CHANNELS = ['children', 'body'] as const;
99+
const CONTENT = [{ type: 'element:text', properties: { content: 'measured' } }];
100+
const issuesOf = (result: Result): Issue[] => (result.success ? [] : (result.error!.issues as unknown as Issue[]));
101+
const issueAt = (result: Result, path: string): Issue | undefined =>
102+
issuesOf(result).find((i) => i.path.join('.') === path);
103+
104+
/** Every issue, union branches unfolded and paths made absolute. */
105+
const allIssues = (issues: Issue[] | undefined, prefix: PropertyKey[] = []): Issue[] =>
106+
(issues ?? []).flatMap((issue) => {
107+
const path = [...prefix, ...issue.path];
108+
return [{ ...issue, path }, ...(issue.errors ?? []).flatMap((branch) => allIssues(branch, path))];
109+
});
110+
111+
/** The first sentence of a message — where an author's eye lands. */
112+
const firstSentence = (message: string) => message.slice(0, message.indexOf('. ') + 1);
113+
114+
const CASES = ROWS.flatMap(([type, arm, row]) =>
115+
CHANNELS.map((key) => [`${type}.${key}`, type, arm, row, key] as const));
116+
const FACE_CASES = CASES.flatMap(([label, type, arm, row, key]) =>
117+
FACES.map(([face, judge]) => [`${label} (${face})`, type, arm, row, key, judge] as const));
118+
const FACE_ROWS = ROWS.flatMap(([type]) => FACES.map(([face, judge]) => [`${type} (${face})`, type, judge] as const));
119+
120+
/* ── (a) the node-level child list is REFUSED BY NAME, on both faces ──────── */
121+
122+
describe('objectui#10872 batch 6 — the four `page:` containers refuse a node-level child list', () => {
123+
it('the population is the four containers — a row dropped from the table fails here', () => {
124+
expect(ROWS.map(([type]) => type)).toEqual(['page:card', 'page:section', 'page:footer', 'page:sidebar']);
125+
expect(CASES).toHaveLength(8);
126+
expect(FACE_CASES).toHaveLength(16);
127+
});
128+
129+
it.each(FACE_CASES)('%s is refused with `invalid_type` at the key\'s own path', (label, type, _arm, _row, key, judge) => {
130+
const result = judge({ type, [key]: CONTENT });
131+
expect(result.success, `${label} parsed green — the refusal is not installed`).toBe(false);
132+
expect(issueAt(result, key)?.code).toBe('invalid_type');
133+
});
134+
135+
it.each(FACE_CASES)('%s — the first sentence names `properties.children` and the block', (_label, type, _arm, row, key, judge) => {
136+
const message = issueAt(judge({ type, [key]: CONTENT }), key)!.message;
137+
const lead = firstSentence(message);
138+
expect(lead).toContain('`properties.children`');
139+
expect(lead).toContain(`\`${type}\``);
140+
// The row the member belongs to, so the remedy can be looked up.
141+
expect(lead).toContain(`\`${row}\``);
142+
expect(lead).toContain(`{ "type": "${type}", "properties": { "children": [`);
143+
});
144+
145+
it.each(FACE_CASES)('%s — not the neither-channel text, and not the objectui#6771 remedy it replaces', (_label, type, _arm, _row, key, judge) => {
146+
const message = issueAt(judge({ type, [key]: CONTENT }), key)!.message;
147+
// These blocks render their child list: the objectui#9256 text would say the opposite.
148+
expect(message).not.toContain('reads NEITHER content channel');
149+
// `BaseSchema`'s `body` remedy points at the node-level `children`, refused here too.
150+
expect(message).not.toContain('Did you mean `body` → `children`?');
151+
expect(message).toContain('objectui#10872');
152+
});
153+
154+
it.each(CASES)('%s — ONE string feeds both author-facing channels: the issue message IS the `.describe()` metadata', (_label, type, arm, _row, key) => {
155+
const issue = issueAt(arm.safeParse({ type, [key]: CONTENT }), key)!;
156+
expect(arm.shape[key]?.description).toBe(issue.message);
157+
expect(arm.shape.children?.description).toBe(arm.shape.body?.description);
158+
});
159+
160+
it.each(CASES)('%s — the refusal is about the KEY, not a value domain: every value is refused', (_label, type, arm, _row, key) => {
161+
for (const value of [CONTENT, CONTENT[0], 'text', 42, null, {}, []]) {
162+
expect(issueAt(arm.safeParse({ type, [key]: value }), key)?.code, JSON.stringify(value)).toBe('invalid_type');
163+
}
164+
});
165+
166+
it.each(CASES)('%s — the refusal is a MEMBER of the arm\'s shape', (_label, _type, arm, _row, key) => {
167+
expect(Object.keys(arm.shape)).toContain(key);
168+
});
169+
});
170+
171+
/* ── (b) the positive controls — the remedy parses ────────────────────────── */
172+
173+
describe('objectui#10872 batch 6 — the child list the message names parses', () => {
174+
it.each(FACE_ROWS)('%s — `properties.children` parses, and so does the bare node', (_label, type, judge) => {
175+
const result = judge({ type, properties: { children: CONTENT } });
176+
expect(issuesOf(result).map((i) => `${i.path.join('.')}: ${i.code}`)).toEqual([]);
177+
expect(result.success).toBe(true);
178+
expect(judge({ type }).success).toBe(true);
179+
});
180+
181+
it.each(FACE_ROWS)('%s — nested in a `page`: the bag spelling parses, and the node-level one is refused at its own path', (_label, type, judge) => {
182+
expect(judge({ type: 'page', children: [{ type, properties: { children: CONTENT } }] }).success).toBe(true);
183+
const refused = judge({ type: 'page', children: [{ type, children: CONTENT }] });
184+
expect(refused.success).toBe(false);
185+
const nested = allIssues(issuesOf(refused)).filter((i) => i.path.join('.') === 'children.0.children');
186+
expect(nested.some((i) => i.code === 'invalid_type' && i.message.includes('`properties.children`'))).toBe(true);
187+
});
188+
189+
it.each(FACES)('%s face: `page:card`\'s whole row is still judged in the bag — `title`, `children` and `footer` parse together', (_face, judge) => {
190+
const card = { type: 'page:card', properties: { title: 'Summary', bordered: false, children: CONTENT, footer: CONTENT } };
191+
expect(judge(card).success).toBe(true);
192+
});
193+
});
194+
195+
/* ── (c) the installed spec: the same verdict, and the member the message names ── */
196+
197+
describe('objectui#10872 batch 6 — `@objectstack/spec` refuses the node-level spelling and declares the bag member', () => {
198+
it.each(ROWS.map(([type]) => type))('`%s`: the installed spec refuses a node-level `children` and passes `properties.children`', (type) => {
199+
// CONTROL — the node without it passes the spec's page-component shape,
200+
// so the refusal below is about the one key.
201+
expect(PageComponentSchema.safeParse({ type, id: 'n1' }).success).toBe(true);
202+
const result = PageComponentSchema.safeParse({ type, id: 'n1', children: CONTENT }) as unknown as Result;
203+
expect(result.success).toBe(false);
204+
expect(issuesOf(result).find((i) => i.code === 'unrecognized_keys')?.keys).toContain('children');
205+
expect(PageComponentSchema.safeParse({ type, id: 'n1', properties: { children: CONTENT } }).success).toBe(true);
206+
});
207+
208+
it.each(ROWS.map(([type]) => type))('`%s`: the spec row declares the `children` member the refusal sends the author to', (type) => {
209+
const row = (ComponentPropsMap as unknown as Record<string, { shape: Record<string, unknown>; safeParse: (v: unknown) => Result }>)[type];
210+
expect(Object.keys(row.shape)).toContain('children');
211+
expect(row.safeParse({ children: CONTENT }).success).toBe(true);
212+
});
213+
});
214+
215+
/* ── (d) the props-bag helper fold — no behaviour moves ───────────────────── */
216+
217+
describe('objectui#10872 batch 6 — `objectql.zod.ts`\'s public-block arms use the one `propsBag`', () => {
218+
const descriptionOf = (arm: unknown) => (arm as Arm).shape.properties?.description;
219+
220+
it('the `properties` description is the text the helper composes, word for word', () => {
221+
expect(descriptionOf(ObjectMetricBlockSchema)).toBe(
222+
'The `object-metric` props bag — `@objectstack/spec` `ComponentPropsMap[\'object-metric\']`, by reference. '
223+
+ 'Judged only when present, as the spec\'s props gate judges it.',
224+
);
225+
});
226+
227+
it.each([
228+
['object-metric', ObjectMetricBlockSchema],
229+
['object-master-detail-form', ObjectMasterDetailFormBlockSchema],
230+
] as const)('`%s` — the same composer as the `public-blocks.zod.ts` arms, and the bag stays optional', (type, arm) => {
231+
expect(descriptionOf(arm)).toBe(descriptionOf(PageCardBlockSchema)!.split('page:card').join(type));
232+
expect((arm as unknown as Arm).safeParse({ type }).success).toBe(true);
233+
});
234+
});

‎packages/types/src/__tests__/content-channel-public-blocks-9256.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,15 @@ describe('objectui#9256 public blocks — the carve-outs', () => {
214214
['page:section', PageSectionBlockSchema],
215215
['page:footer', PageFooterBlockSchema],
216216
['page:sidebar', PageSidebarBlockSchema],
217-
] as const)('CONTROL — `%s` renders the node\'s child list, so it still takes `children`', (type, mirror) => {
218-
// Measured in the same run as the rows above: a reader keeps its channel.
219-
expect(issuesOf(mirror as unknown as Mirror, { type, children: CONTENT })).toBeNull();
220-
expect(AnyComponentSchema.safeParse({ type, children: CONTENT }).success).toBe(true);
217+
] as const)('CONTROL — `%s` renders its child list, so it still takes one, in `properties.children`', (type, mirror) => {
218+
// Measured in the same run as the rows above: a reader keeps its channel. Its spelling is the
219+
// spec row's `children` member, in the bag: objectui#10872 batch 6 refuses the node-level one,
220+
// with a message that names the bag member and never this slice's neither-channel text
221+
// (`container-children-channel-10872.test.ts` pins that refusal).
222+
expect(issuesOf(mirror as unknown as Mirror, { type, properties: { children: CONTENT } })).toBeNull();
223+
expect(AnyComponentSchema.safeParse({ type, properties: { children: CONTENT } }).success).toBe(true);
224+
expect(at(issuesOf(mirror as unknown as Mirror, { type, children: CONTENT }), 'children')?.message)
225+
.not.toContain('reads NEITHER content channel');
221226
});
222227

223228
it('a narrowed block nested in a `page` is refused; the same block without a child list parses', () => {

0 commit comments

Comments
 (0)