This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
Commit 7d074ba
fix(types): objectui validate judges every node inside a page container's properties.children and items[].children, at the positions the platform walks (objectui#11223) (#11267)
Fixes #11223
Clause-②: no (narrowing)
`safeValidateSchema` (what `objectui validate` runs) and
`StrictAnyComponentSchema` now judge each component nested in a page
container's props bag. They judge it at the positions the page walk that
`@objectstack/spec` exports descends, and report each issue at the
nested node's real path.
The `Clause-②: no (narrowing)` line is copied from the PM claim
`5917605842`. Before, a document whose nested bag child was malformed
parsed on both faces; now it is refused. Nothing that was refused before
is accepted, and no export moves. Changeset:
`.changeset/11223-nested-page-children-judged.md`, `'@object-ui/types':
minor`.
## The positions are read from the spec, not written here
I measured the installed `@objectstack/spec` 17.5.0 before writing
anything:
- `COMPONENT_CHILD_KEYS` and `mapComponentTree` (the conversions walk)
are module-private. They sit in the bundled dist, and no entry's export
list names them.
- `walkAddressedPageComponents` IS exported, from
`@objectstack/spec/system`. Its contract calls it "THE one traversal"
behind `translatePage` and the platform CLI's i18n extractor. It
descends `properties.children` and `properties.items[].children`,
matched by shape.
- `@objectstack/lint` is not a dependency of `packages/types`, and this
PR does not add one.
So `packages/types/src/zod/nested-component-walk.ts` hands each node to
that walk and reads back what it visited. The walk gives its visitor no
path. Its contract does say that the visitor's return value replaces the
node, at the node's own position, in the tree it rebuilds. So the
visitor returns a marker, and a scan of the rebuilt tree reads each
marker's position back. The scan does not depend on key names, and the
module names no bag key.
## What changed
- `packages/types/src/zod/nested-component-walk.ts` is new. It is
internal, and the barrel does not re-export it. It holds three things:
- `nestedComponentsOf(node)`: the node's direct nested components, each
with its path.
- `nestedComponentJudgment(judge)`: a check. It parses each nested
component with the judge and re-issues that parse's issues under the
component's path. It runs even when the node refused something of its
own (zod `when`).
- `rebindNestedComponentJudgment`: the same check, bound to a derived
face's judge.
A guard across calls stops a JavaScript value that nests a component
inside itself from recursing without end.
- `packages/types/src/zod/index.zod.ts`: the `AnyComponentSchema`
initializer carries that check, with the union itself as the judge. So
it applies at every depth, including under a node-level child slot.
- `packages/types/src/strict-authoring-face.ts`: the walker swaps that
check for one bound to its own twin of the union
(`rebindNestedJudgments`). On the strict face, a nested component is now
judged strictly. Without the swap, the strict face would consult the
tolerant union one bag down, which is the closure limit its docblock
names. The docblock now says which closure is re-pointed and why.
- Pins:
`packages/types/src/__tests__/nested-page-children-11223.test.ts` and
`packages/cli/src/__tests__/validate-nested-bag-children-11223.test.ts`.
- Docs: `content/docs/utilities/cli.mdx` (a new "What is judged"
section) and `packages/types/src/zod/README.md` ("Nested Validation").
Not touched: `public-blocks.zod.ts`, `objectql.zod.ts`, `base.zod.ts`,
`imported-defaults-8317.test.ts` and
`packages/cli/src/utils/unbindable-text-expressions.ts`.
## Before and after
Before, measured at `ae0b9d390` with a one-off probe through the real
faces, every one of these rows parsed on BOTH faces:
- the four `properties.children` containers and the two
`properties.items[].children` containers;
- each of those with a malformed child (`content: 7` plus an undeclared
`bogus`), and each with an unknown nested `type`;
- `page:card` with a malformed child in `properties.footer`.
The node-level control, the same child in `grid.children`, was refused.
After, every bag row is refused on both faces. Examples:
- `invalid_union` at `properties.children.0.properties.content`;
- `unrecognized_keys` (`bogus`) at `properties.children.0.properties`;
- `invalid_union` at `properties.items.0.children.0.type`, with "No
matching discriminator". `objectui validate` prints it as "No arm
accepts type ..." at the nested node, with the nearest accepted types.
`page:card` with a malformed footer child still parses. The Acceptance
notes explain why.
## Pins (`nested-page-children-11223.test.ts`, 45 rows)
- (a) Six containers on both faces, 12 rows, each with a malformed child
and with an unknown nested `type`. The child sits second in its list, so
the index in the reported path is measured. Every issue must land under
the child's path.
- (b) Controls: a valid nested page (card, tabs and accordion inside a
section) parses on both faces. The nesting is also judged two bag levels
down, and under a node-level child slot.
- (c) The strict face refuses an undeclared node key one bag down, by
name, at `properties.children.0`. The tolerant face passes it, as it
does at the root.
- (d) Parity. A probe whose props bag answers ANY key with marked
components reads off the installed walk every position it descends,
without naming any key. Then: `nestedComponentsOf` reaches a component
at each of those positions; each position is one a row of (a) judges;
and `nestedComponentsOf` equals the walk's direct visits, in order and
by identity. If the spec's walk gains a position, objectui walks it the
same day, and the coverage row goes red until a row of (a) judges it.
- (e) The footer gap (see the Acceptance notes). This row goes red the
day the exported walk descends `properties.footer`.
- (f) A self-nesting JavaScript value gets a verdict instead of
overflowing the stack.
The CLI pin covers `objectui validate` at the public door: the nested
path line, the "No arm accepts type" note with the nearest types, and
"Schema is valid!" for a valid nested page.
## Ablation
Both legs ran on committed code. Each mutation went through
objectstack's `scripts/ablation-replace.mjs`: the anchor hit once, and
the blob changed. Each restore was proven: the blob equals HEAD, and
`git diff HEAD` is empty.
1. Remove the check from `AnyComponentSchema`: 33 failed, 15 passed
across the two pin files (48 rows). Every nested-refusal row went red:
all of (a), the depth and child-slot rows of (b), the strict refusal in
(c), both rows of (f), and two CLI rows. Nothing else went red; the
controls, the parity walk rows and the footer-gap rows stayed green.
2. Remove the strict walker's rebinding: 1 failed, 44 passed. Exactly
the strict face's nested unknown-key refusal, (c), went red.
## Verification, on head `eebfc2765` (the merge below)
- `pnpm --filter @object-ui/types type-check` (src, examples and tests
projects): exit 0.
- `pnpm --workspace-concurrency=2 --filter '@object-ui/cli^...' build`,
then `pnpm --filter @object-ui/cli type-check`: exit 0.
- `pnpm exec vitest run packages/types/src/` in five chunks: 7419
passed, 0 failed. `packages/cli/src/`: 338 passed. The whole root
`scripts/__tests__/` in three chunks: 5371 passed, 2 skipped, 0 failed.
Each chunk ran under `timeout 300` with the verbose reporter.
- `pnpm exec eslint` on the five changed TypeScript files: exit 0.
- These exited 0: `check-changeset-presence`, `check-control-bytes`,
`check-new-cross-file-line-citations` (0 new), `markdown-test-inputs
--audit`, `check:pending-changeset-literals`, `changeset:check`,
`check:doc-fences`, `check:doc-types`, `check:doc-example-ids` and
`check:doc-example-readers`.
- Measured at `c7f883f9c`, before the merge; the merge changed none of
this diff's files except the zod README's neighbouring section.
`check:doc-snippets` and `check:doc-examples` stopped with exit 2,
PREREQUISITE NOT MET: they need their 34-package build. Their CI runs
are the verdict. As a stand-in, the README snippet compiles under `tsc
--strict` against the built `@object-ui/types` dist.
- Also at `c7f883f9c`: `check:spec-floors` exited 1, and every finding
was `no-artifact` for a package this run did not build. It read
`./system` at the declared floor 17.5.0 and reported nothing for
`@object-ui/types`. The full verdict is CI's.
## Serial constraint
Seat 1's serial note `5917593110` put this card after objectui#10872
batch 8. That PR landed as `54a78308a` (#11260) during this run. This
branch merges main at that commit (`eebfc2765`), and I re-read the arms
there. Batch 8 adds `responsiveStyles` through `PUBLIC_BLOCK_ENVELOPE`
and leaves every `propsBag` and child-list member as it was, so the walk
is unaffected. This PR edits neither `public-blocks.zod.ts` nor
`objectql.zod.ts`.
## Acceptance notes
- **Premise correction.** The card and triage `5913780517` say
objectstack's `packages/lint/src/page-walk.ts` walks exactly
`properties.children` and `properties.items[i].children`. It also walks
`properties.body` and `properties.footer`, both at the 17.5.0 tag
(`0f6dcac5e9`) and at objectstack main (`33b6e8bec`). The spec's
exported walk does not; its contract says "`body` / `footer` are
deliberately still not descended".
- **The gap that leaves.** `page:card`'s row declares `footer` as a
component slot ("Card footer components (slot)"), `PageCardRenderer`
draws it, and the lint walk descends it. The exported walk does not. So
a malformed component in a card footer is still accepted on both faces.
Pin (e) holds this. It goes red the day the walk descends the footer,
and nothing else in this repository needs to change then. I report it
for routing in the dev report; I did not write the position here by
hand.
- Entries the walk does not visit (strings, numbers, `null`, nested
arrays) are not judged, as the walk's own contract says. objectui's
node-level child slots accept the same primitives.
- The judgment lives on the union. A container's own arm schema parsed
alone (`PageSectionBlockSchema.safeParse`) does not judge its bag
children. `safeValidateSchema`, `StrictAnyComponentSchema` and every
node-level child slot do.
- A nested component's issues come from a separate parse of that
component. So a per-call error map passed to the outer `safeParse` does
not reach their messages. Nothing in this repository passes one to these
faces.
- For objectui#11170: the position walk lives in
`packages/types/src/zod/nested-component-walk.ts`, as
`nestedComponentsOf(node)`. It is internal today. `packages/cli` can use
it after a one-line re-export from `index.zod.ts`, which is that card's
decision.
- **New runtime read.** `@object-ui/types/zod` now imports a value from
`@objectstack/spec/system`; before, the package re-exported only a type
from it. `check:spec-floors` read `./system` at floor 17.5.0 and
reported nothing for this package. The console already routes
`@objectstack/spec/system` into `vendor-objectstack`.
`check:eager-closure` and `check:node-esm-load` need a whole-workspace
build, so their verdicts are CI's. As a stand-in, at `c7f883f9c`, a Node
ESM import of the built `@object-ui/types/zod` from `packages/cli`
loaded, and it refused a nested unknown type at
`properties.children.0.type`.
- The CLI guide's "Reading a failure" section still describes the
root-level union report from before objectui#8498. This PR does not
change it. Carrier: none.
---
_Generated by [Claude
Code](https://claude.ai/code/session_011p7ikEivgXefNDaE5S5Uec)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent fc65038 commit 7d074ba
8 files changed
Lines changed: 756 additions & 2 deletions
File tree
- .changeset
- content/docs/utilities
- packages
- cli/src/__tests__
- types/src
- __tests__
- zod
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
0 commit comments