Commit 998b484
vcl-ut #25 P5b (step 1): C-ABI wire codec for Statement
The marshalling layer between the trusted Rust parser (P5a) and the
Idris2 certifier. Adds, in the standalone vcltotal-parse crate:
- WIRE-FORMAT.adoc: normative spec for a deterministic, versioned,
length-prefixed binary TLV (magic "VCLW" + u16 ver). Discriminants
reuse Grammar.idr's *ToInt maps where they exist (modality/agent/
epReq/epistemicOp) and Types.idr safetyLevelToInt, so the P5b-step-2
Idris2 decoder is a direct match. Chosen over CBOR: no dependency /
no extra trust surface, fully auditable, byte-exact.
- src/wire.rs: to_wire / from_wire for the full Statement AST. Same
SPARK-grade posture as the parser (crate lint-set): to_wire total +
deterministic (canonical one-byte-string-per-value); from_wire
TOTAL — bounds-checked cursor, no panic, no unbounded pre-allocation
from untrusted counts (anti-OOM), every malformed input a typed
WireError.
Machine witnesses (tests/wire.rs, proptest 2048 cases):
- roundtrip: from_wire(to_wire(s)) == s over arbitrary Statements
(bijection on the Rust AST mirror).
- decoder_total_on_garbage / _with_valid_header: arbitrary bytes
never panic — Ok/Err only (trusted-boundary totality contract).
- encoder_deterministic; golden vectors incl. bit-exact non-finite
float preservation (inf structural, NaN by bits).
Verified standalone, CI-faithful (--manifest-path --locked):
clippy --all-targets -D warnings clean (SPARK lint set), 17/17 tests
(6 lib + 5 parse + 6 wire), fmt clean.
Step 2 (separate): the total Idris2 decoder of this identical format
into Grammar.idr's certified Statement, %default total, no proof
escape, with shared golden vectors for cross-language conformance —
gated by the proof-corpus CI (now healthy post-#24).
Stacked on the P5a branch. Refs #25.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 598df32 commit 998b484
4 files changed
Lines changed: 1297 additions & 0 deletions
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
0 commit comments