Skip to content

Restore the full StringEscapeRoundtrip threshold via total nibble division - #807

Merged
jasisz merged 1 commit into
mainfrom
feat/definitional-hex-and-full-escape-threshold
Aug 8, 2026
Merged

Restore the full StringEscapeRoundtrip threshold via total nibble division#807
jasisz merged 1 commit into
mainfrom
feat/definitional-hex-and-full-escape-threshold

Conversation

@jasisz

@jasisz jasisz commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Bytes.highNibble / Bytes.lowNibble become Int.div(value, 16) / Int.mod(value, 16). The literal-divisor rule types both as plain Int and lowers them to the Euclidean intrinsics, so the sixteen-branch comparison ladder that existed only to avoid the Result path is gone. Same function count, same allInRange / fromList gating shape, so the wasm-gc packed-sequence recognizer and the (12 certified, 90 source-level-only) certificate KPI are unchanged.

Bytes.byteToHex is now definitionally hexDigit (v / 16) + hexDigit (v % 16), so the synthesized control-escape lemma closes for any octet in one simp instead of a by_cases arm per nibble. The escaped-string roundtrip detector accepts control thresholds 1..=256 again (the Bytes.fromList payload range), where it had been narrowed to 1..=32.

New lake-gated spec lean_proves_full_octet_escape_threshold_when_lake_is_available: a wire format that hex-escapes every octet (threshold 256, terminator/escape introducer above it) certifies universal:true, sorries:0. With the gate put back at 32 the same fixture falls to a caught sorry.

Tests run locally: full proof_spec (228, includes the JSON example and both existing escape-roundtrip laws), cert_decode_spec, cert_whole_module_guard_iso, the json --certify KPI test, wasm_gc_packed_sequence, wasm_gc_spec, stdlib_spec (VM + wasm-gc + wasip2), rust_codegen_regression incl. ignored, bytes/sha256 subsets of rust_codegen_differential / wasip2_codegen_regression / wasip2_tcp / wasm_gc_codegen_regression, eval_spec, --lib, plus the Dafny backend on the embedded-bytes fixture (38 verified, 0 errors).

🤖 Generated with Claude Code

…ision

`Bytes.highNibble` and `Bytes.lowNibble` are now `Int.div(value, 16)` and
`Int.mod(value, 16)`. A syntactic nonzero literal divisor already types as
plain Int and lowers to the Euclidean intrinsics, so the sixteen-branch
comparison ladder the nibbles used to avoid the Result path is no longer
needed on any backend. The module keeps the same functions and the same
smart-constructor gating shape, so the packed-sequence recognizer and the
certificate KPI denominator are unchanged.

With the ladder gone, `Bytes.byteToHex` unfolds definitionally to
`hexDigit (v / 16) + hexDigit (v % 16)`, so the synthesized control-escape
lemma closes for the whole octet range in one `simp` instead of enumerating
one `by_cases` arm per nibble. The escaped-string roundtrip detector accepts
control thresholds 1..=256 again — the `Bytes.fromList` payload range — where
it had been narrowed to 1..=32.

A new lake-gated proof spec pins the recovered range: a wire format that
hex-escapes every octet (threshold 256, terminator and escape introducer
above it) certifies universal and sorry-free. The existing threshold-32 laws,
including the JSON example, stay green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jasisz
jasisz merged commit 29c6cfd into main Aug 8, 2026
35 checks passed
@jasisz
jasisz deleted the feat/definitional-hex-and-full-escape-threshold branch August 8, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant