|
49 | 49 | * type-checks its tests through `tsconfig.test.json`, so re-widening the |
50 | 50 | * declaration fails the build on the unused directive. A green `vitest` run is |
51 | 51 | * NOT evidence about them — type assertions are erased before it runs. |
| 52 | + * |
| 53 | + * ⚠️ AMENDED by objectui#6152 round 4: "type-level only" now holds on a `chatbot` |
| 54 | + * node alone. That round minted the `FloatingChatbotConfig` mirror on the |
| 55 | + * `chatbot-floating` twin — the registration that reads `floatingConfig` — with |
| 56 | + * the `retirementTombstone()` half this file's tripwire asked for, so a |
| 57 | + * `chatbot-floating` node refuses `triggerIcon` at runtime as well. The runtime |
| 58 | + * section below pins the two twins apart. |
52 | 59 | */ |
53 | 60 |
|
54 | 61 | import { describe, it, expect } from 'vitest'; |
@@ -128,69 +135,88 @@ describe('the `triggerIcon` tombstone makes authoring a `tsc` error', () => { |
128 | 135 | }); |
129 | 136 | }); |
130 | 137 |
|
131 | | -/* ── the runtime channel: DELIBERATELY unchanged, and a tripwire if that ends ─ */ |
| 138 | +/* ── the runtime channel: unchanged on `chatbot`, refused on `chatbot-floating` since objectui#6152 round 4 ─ */ |
132 | 139 |
|
133 | 140 | // Both faces declare `floatingConfig` — `ChatbotSchema` always did, and |
134 | 141 | // objectui#7655 declared it on `ChatbotFloatingSchema`, the face of the one |
135 | | -// registration that reads it — and NEITHER twin has an arm for it, so the |
136 | | -// tripwire parses both nodes, each through its own twin. |
137 | | -describe.each([ |
138 | | - ['chatbot', ChatbotSchema], |
139 | | - ['chatbot-floating', ChatbotFloatingSchema], |
140 | | -] as const)('there is NO zod refusal on a `%s` node, and that is deliberate (objectui#7654)', (type, twin) => { |
| 142 | +// registration that reads it. Until objectui#6152 round 4 NEITHER twin had an arm |
| 143 | +// for it, and this file's runtime half pinned that on both, as a TRIPWIRE: whoever |
| 144 | +// minted a `FloatingChatbotConfig` mirror had to add the `retirementTombstone()` |
| 145 | +// half for `triggerIcon` in the same change, and flip these controls rather than |
| 146 | +// delete them into a vacuum. Round 4 minted it on the `chatbot-floating` twin only |
| 147 | +// (that registration reads the key; `chatbot`'s never does), so the two twins are |
| 148 | +// now pinned apart. |
| 149 | +describe('there is NO zod refusal on a `chatbot` node, and that is deliberate (objectui#7654)', () => { |
141 | 150 | const node = { |
142 | | - type, |
| 151 | + type: 'chatbot', |
143 | 152 | messages: [{ id: 'm1', role: 'user' as const, content: 'hi' }], |
144 | 153 | }; |
145 | 154 |
|
146 | | - it(`a ${type} node carrying \`floatingConfig.triggerIcon\` still parses GREEN`, () => { |
147 | | - // `FloatingChatbotConfig` has NO zod mirror: `floatingConfig` sits in the |
148 | | - // `UnmirroredDeclared` ledger (`zod-mirror-parity.test.ts`, under both |
149 | | - // `complex.zod.ts#ChatbotSchema` and, since objectui#7655, |
150 | | - // `complex.zod.ts#ChatbotFloatingSchema`), and `BaseSchema` is |
151 | | - // `.passthrough()`, so the whole object rides through unvalidated. This was |
152 | | - // green before the tombstone and is green after it — the retirement changed |
153 | | - // the TypeScript face only, and this pins that it changed no parse outcome. |
154 | | - // |
155 | | - // ⚠️ TRIPWIRE: if objectui#6152 ever mints a `FloatingChatbotConfigSchema` |
156 | | - // and wires it onto these twins as the `floatingConfig` arm, the assertion |
157 | | - // that fires is the SHAPE PIN at the foot of this block — the one reading |
158 | | - // `shape.floatingConfig` — and NOT this line. Measured on objectui#7678's |
159 | | - // base, arm injected on both twins and restored under a trap: a |
160 | | - // house-style non-strict `z.object` mirror reds the shape pin ONLY (2 |
161 | | - // failures, one per twin) and leaves this parse-green line GREEN, because |
162 | | - // a non-strict object accepts `triggerIcon` and strips it, so `success` |
163 | | - // stays `true`; a `z.strictObject` mirror reds both (4 failures). Either |
164 | | - // shape trips the file — that is the intended signal, not a nuisance: |
165 | | - // whoever lands the mirror must add the `retirementTombstone()` half for |
166 | | - // `triggerIcon` at the same time, and flip these controls rather than |
167 | | - // delete them into a vacuum. |
168 | | - const result = twin.safeParse({ |
| 155 | + it('a chatbot node carrying `floatingConfig.triggerIcon` still parses GREEN', () => { |
| 156 | + // `ChatbotSchema.floatingConfig` stays in the `UnmirroredDeclared` ledger |
| 157 | + // (`zod-mirror-parity.test.ts`): the `chatbot` registration never reads it, so |
| 158 | + // objectui#6152 round 4 did not mirror it. `BaseSchema` is `.passthrough()`, |
| 159 | + // so the whole object rides through unvalidated on this twin. |
| 160 | + const result = ChatbotSchema.safeParse({ |
169 | 161 | ...node, |
170 | 162 | floatingConfig: { title: 'Chat', triggerIcon: 'Sparkles' }, |
171 | 163 | }); |
172 | 164 | expect(result.success).toBe(true); |
173 | 165 | }); |
174 | 166 |
|
175 | 167 | it('a live `floatingConfig` parses green too — the non-vacuity control', () => { |
176 | | - const result = twin.safeParse({ |
| 168 | + const result = ChatbotSchema.safeParse({ |
177 | 169 | ...node, |
178 | 170 | floatingConfig: { title: 'Chat', triggerSize: 56 }, |
179 | 171 | }); |
180 | 172 | expect(result.success).toBe(true); |
181 | 173 | }); |
182 | 174 |
|
183 | 175 | it('the mirror really has no `floatingConfig` key at all', () => { |
184 | | - // The load-bearing fact behind everything above, asserted rather than |
185 | | - // assumed: a key the mirror declares would appear in its shape. |
186 | | - // |
187 | | - // ⚠️ This is also the assertion the objectui#6152 TRIPWIRE fires through: |
188 | | - // under a house-style non-strict mirror it reds HERE and nowhere else in |
189 | | - // this file. The measurement is recorded at that comment, above. |
190 | | - const shape = (twin as unknown as { shape: Record<string, unknown> }).shape; |
| 176 | + // The load-bearing fact behind the two lines above, asserted rather than |
| 177 | + // assumed: a key the mirror declares would appear in its shape. This is the |
| 178 | + // assertion the TRIPWIRE fires through if this twin ever gains the arm. |
| 179 | + const shape = (ChatbotSchema as unknown as { shape: Record<string, unknown> }).shape; |
191 | 180 | expect(shape.floatingConfig).toBeUndefined(); |
192 | 181 | // Lit control: a key the mirror DOES declare is present, so the reading |
193 | 182 | // above is a measurement and not an empty object. |
194 | 183 | expect(shape.messages).toBeDefined(); |
195 | 184 | }); |
196 | 185 | }); |
| 186 | + |
| 187 | +describe('a `chatbot-floating` node REFUSES `floatingConfig.triggerIcon` at runtime (objectui#6152 round 4 minted the mirror)', () => { |
| 188 | + const node = { |
| 189 | + type: 'chatbot-floating', |
| 190 | + messages: [{ id: 'm1', role: 'user' as const, content: 'hi' }], |
| 191 | + }; |
| 192 | + |
| 193 | + it('`floatingConfig.triggerIcon` is refused at its own path, and the refusal says the key was never read', () => { |
| 194 | + // The flipped tripwire: this line used to assert `success: true`. |
| 195 | + const result = ChatbotFloatingSchema.safeParse({ |
| 196 | + ...node, |
| 197 | + floatingConfig: { title: 'Chat', triggerIcon: 'Sparkles' }, |
| 198 | + }); |
| 199 | + expect(result.success).toBe(false); |
| 200 | + const issues = (result.error?.issues ?? []).filter((i) => i.path.join('.') === 'floatingConfig.triggerIcon'); |
| 201 | + expect(issues.length, JSON.stringify(result.error?.issues)).toBe(1); |
| 202 | + expect(issues[0].code).toBe('invalid_type'); |
| 203 | + expect(issues[0].message).toContain('objectui#7654'); |
| 204 | + }); |
| 205 | + |
| 206 | + it('a live `floatingConfig` parses green — the non-vacuity control', () => { |
| 207 | + const result = ChatbotFloatingSchema.safeParse({ |
| 208 | + ...node, |
| 209 | + floatingConfig: { title: 'Chat', triggerSize: 56 }, |
| 210 | + }); |
| 211 | + expect(result.success).toBe(true); |
| 212 | + }); |
| 213 | + |
| 214 | + it('the mirror declares `floatingConfig`, and its `triggerIcon` is a MEMBER tombstone, not an undeclared key', () => { |
| 215 | + const shape = (ChatbotFloatingSchema as unknown as { shape: Record<string, unknown> }).shape; |
| 216 | + expect(shape.floatingConfig).toBeDefined(); |
| 217 | + const inner = (shape.floatingConfig as { unwrap: () => { shape: Record<string, unknown> } }).unwrap().shape; |
| 218 | + expect(inner.triggerIcon).toBeDefined(); |
| 219 | + // Lit control: a live member sits beside it. |
| 220 | + expect(inner.triggerSize).toBeDefined(); |
| 221 | + }); |
| 222 | +}); |
0 commit comments