Commit 9826516
committed
feat(types)!: bind the component union in the getter, and narrow the chatbot arm
Implements decision batch #93 (objectui#8344 comment 5585333656), items F2, F3,
F5 and the stale-text half of items 8/9. Changeset text is NOT yet updated in
this commit; its three false "by ruling" attributions are the next push.
F3 — the tree-shake leak. `base.zod.ts` now imports `AnyComponentSchema` and
reads that binding INSIDE `SchemaNodeSchema`'s `z.lazy` getter. The option-array
write, `defineNodeComponentUnion` and its identity assertion are gone with it.
`"sideEffects": false` stays true and untouched: this module performs no
load-time write at all now. Measured, not assumed — this repo's own Vite/rollup
lib build, an entry importing ONLY `CardSchema`:
before this commit 370,652 raw / 113,887 gzip, no fill, nested off-spec
node ACCEPTED — the redirect silently inert
after 1,147,266 raw / 342,193 gzip, nested off-spec node
REFUSED — the union is retained because the binding is read
A graph that never evaluates the barrel now throws `ReferenceError: Cannot
access 'BaseSchema' before initialization` at import instead of quietly
answering as `main`. That is the ruled behaviour, and its cost is paid here: 102
`packages/types` test files entered at a category module and now carry a
barrel-first import. Whole unit project after the fix: 989 files, 16,837 tests,
0 failures.
F2 — the chatbot widening, eliminated rather than declared. The arm the getter
installs is `AnyComponentSchema.superRefine(...)`, which checks a nested
`chatbot` node's `body` against `BaseSchemaCore.shape.body`. The root mirror is
untouched, so a root `chatbot` with a record `body` still parses and the same
node one slot down does not. Both directions pinned, plus a non-vacuity leg and
a leg asserting the refusal names `body`. The discrimination objectui#8498 added
survives the wrapper (`propValues` intact), so a nested refusal still costs one
arm.
F5 — depth on the redirected path: 276 / 3,626 / 8,404 / 14,610 / 22,244 chars
at depths 0-4, all refused, none throwing. New pins cover depths 0-4 through
`safeValidateSchema`, a linear-growth ceiling at depth 4, and a legal-leaf
control.
Items 8/9 — `any-component-union-fanout.test.ts`'s rationale said a nested
document is "simply ACCEPTED"; corrected in place. The pin's identity-leg
comment and header now describe THIS head. The objectui#7918 row returns to
`TDZ_BOUND`: the getter builds the node union per call again, so
`getter() === getter()` is FALSE, and `unstableLazyExports` reads 8 again.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CZY49skxUBYyJcdnTcYPrE1 parent 05efe7d commit 9826516
104 files changed
Lines changed: 654 additions & 205 deletions
File tree
- packages/types/src
- __tests__
- zod
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
0 commit comments