Commit 05c9415
committed
feat(binary): permissive parse + strict save
Splits canonical-doc validation into two modes so the editor and JSON
snapshot dump stay graceful for files with value-level deviations
(out-of-enum, out-of-domain, linked-count drift) while save-back-to-bytes
still rejects committable garbage.
Layering:
- spec/derive-zod adds a `mode: "strict" | "permissive"` option to
toZodSchema. Permissive omits enum-membership refinements, domain bounds,
and the linked-count superRefine; structural refinements (codec range,
bit-width, array length, strictObject keys, integer typing) stay on in
both modes — the doc shape must remain walkable regardless.
- pro/canonical-schemas exposes both proCanonicalSnapshotSchema (strict,
default) and proCanonicalSnapshotSchemaPermissive from one factory.
- pro/canonical-reader and pro/json-snapshot.ts switch to the permissive
schema. Out-of-enum / out-of-domain values now produce a usable canonical
doc instead of being rejected at parse-time. (MAP unchanged: its
canonical layer is hand-written and was already value-level permissive
by design — see the comment at map/canonical-schemas.ts:89.)
- pro/canonical-writer's serializeProCanonicalDocument continues to
validate against the strict schema before serialising — that's now the
singular save gate. New regression test pro-canonical-writer-strict-gate
pins the behaviour.
- pro/index.ts: enumField (which pushed errors on unknown enum values) is
replaced by enumFieldTolerant, which renders "Unknown (N)" inline like
walkStruct already does for spec-driven fields. parseCritter loses the
`errors` parameter; the parser's errors array is now reserved for
structural fatals only (size mismatch, truncation, unknown root type).
- map/parse-helpers.ts: enumField was dead code (no callers); deleted.
map/parse-sections.ts had a post-display scan that re-converted
walkStruct's tolerant "Unknown (N)" rows into errors; deleted, as it was
actively defeating the tolerant design.
- cli: warnings print to stderr but no longer block JSON snapshot output.
The editor's banner infrastructure (errors-container, warnings-container,
renderMessages) was already wired through the init message channel; with
the parser changes it now naturally surfaces graceful-load info without
rendering an empty tree on what were previously fatal-treated value-level
issues.1 parent 1ac6677 commit 05c9415
13 files changed
Lines changed: 489 additions & 290 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
55 | 67 | | |
56 | 68 | | |
57 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 62 | | |
78 | 63 | | |
79 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 56 | | |
64 | 57 | | |
65 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
418 | 418 | | |
419 | 419 | | |
0 commit comments