|
33 | 33 | * |
34 | 34 | * ## Transform — what a fence becomes before a schema can judge it |
35 | 35 | * |
36 | | - * TypeScript and JSON fences are parsed with the TypeScript compiler's parser |
37 | | - * (never executed) and object/array literals are STATICALLY EVALUATED; YAML |
38 | | - * fences go through `yaml`. The supported shapes, by name: |
| 36 | + * TypeScript and JSON fences are parsed with the TypeScript parser through |
| 37 | + * `scripts/ts-parse.mjs` (never executed; a body that does not parse is a |
| 38 | + * reported miss, never a recovered tree) and object/array literals are |
| 39 | + * STATICALLY EVALUATED; YAML fences go through `yaml`. Supported shapes: |
39 | 40 | * |
40 | 41 | * factory-call `defineX({...})` anywhere in the fence (outermost only) |
41 | 42 | * create-call `X.create({...})`, `XSchema.parse({...})` |
|
45 | 46 | * bare-literal a fragment that IS one object/array literal (`{...}`) |
46 | 47 | * yaml-doc each YAML document |
47 | 48 | * |
| 49 | + * A fence that reads as none of them whole is split at blank lines and each |
| 50 | + * chunk tried alone (the catalog writes alternatives one after another). |
48 | 51 | * Inside a literal: same-fence `const` bindings are followed; `Field.<kind>(…)` |
49 | 52 | * is called for real on the spec's own pure helper; everything else that is not |
50 | 53 | * a literal (a call, a function, a template with substitutions, a property |
|
59 | 62 | * ## Mapping — which schema judges which example |
60 | 63 | * |
61 | 64 | * In order: (1) the code's own claim — the factory or constructor it calls, |
62 | | - * or the type it is annotated with (FACTORY_TARGETS; a type `T` → the exported |
63 | | - * `TSchema`); (2) an explicit `os:check-yaml <decl>` marker; (3) for a fragment, |
64 | | - * KEY OWNERSHIP — the one registry metadata type (or the stack) whose object |
65 | | - * shape declares every top-level key; zero or several owners is a coverage |
66 | | - * miss. A fragment is judged PARTIALLY: each present key against that key's |
67 | | - * own member schema, so an omitted required key is never a red there. Headings |
68 | | - * are not used: they name topics, not shapes. |
| 65 | + * or the spec type it is annotated with (FACTORY_TARGETS; a type `T` → the |
| 66 | + * exported `TSchema`, unless `T` is imported from outside the spec or listed in |
| 67 | + * TYPE_NOT_A_SPEC_SHAPE); (2) an explicit `os:check-yaml <decl>` marker; (3) for |
| 68 | + * a fragment, KEY OWNERSHIP (`resolveOwner`): tier 1, the one registry |
| 69 | + * metadata type (a union kind through each option; tombstone keys claim |
| 70 | + * nothing) or the stack whose shape declares every top-level key, judged |
| 71 | + * PARTIALLY so an omitted key is never a red; tier 2, only when tier 1 finds no |
| 72 | + * owner, the one exported named object schema the fragment is a COMPLETE |
| 73 | + * instance of, judged whole. Zero or several owners is a coverage miss. |
| 74 | + * Headings are not used for mapping: they name topics, not shapes. |
| 75 | + * |
| 76 | + * Two pre-parse steps mirror what the runtime itself does, so the judge does |
| 77 | + * not report a shape the platform accepts: a stack's map-format collections are |
| 78 | + * normalized to arrays (`normalizeStackInput`), and every component node's |
| 79 | + * `properties` is judged by its `ComponentPropsMap` row — the dispatch |
| 80 | + * `check-yaml-examples` ports from the authoring gate, ported here unchanged. |
69 | 81 | * |
70 | 82 | * ## Verdicts kept apart |
71 | 83 | * |
72 | 84 | * STRUCTURAL RED the schema refuses what was read: `unrecognized_keys` |
73 | 85 | * (a wrong or retired key), `invalid_type`/`invalid_union` |
74 | 86 | * (wrong nesting or shape), `invalid_value`, `too_small`, a |
75 | 87 | * refinement (`custom`) — reported per Zod code. |
76 | | - * COVERAGE MISS the transform could not produce a judgeable value. |
| 88 | + * COUNTER-EXAMPLE code the text shows to say it is wrong (`isCounterExample`) |
| 89 | + * — counted as refused (the text confirmed) or accepted (a |
| 90 | + * semantic ❌), never a red and never a replay signature. |
| 91 | + * COVERAGE MISS the transform or the mapping produced nothing to judge. |
77 | 92 | * |
78 | 93 | * ## The replay (REPLAY_SET) |
79 | 94 | * |
|
0 commit comments