Add cross-impl coercion conformance + unify roundtrip harnesses - #11
Open
namingbe wants to merge 1 commit into
Open
Add cross-impl coercion conformance + unify roundtrip harnesses#11namingbe wants to merge 1 commit into
namingbe wants to merge 1 commit into
Conversation
The roundtrip suite only ever sees valid input, so coercion (decoding raw byte sequences) was never cross-checked: champernowne-fixed is a Python-built, already-valid fixed point, and roundtripping it exercises zero coercion. Add scripts/coercion.sh + per-impl harnesses (.github/coercion/): each implementation coerces the enum corpus and raw champernowne.nsv via encode(decode(x)) and emits a sha256 manifest; the coercion-compare CI job diffs the manifests across Python/JS/Java/Scala/Rust — the cross-impl consensus is the oracle, no single implementation is trusted. Each run also asserts its output is a fixed point and that champernowne's coercion reproduces the committed champernowne-fixed.nsv byte for byte. A second, stream mode feeds the enum corpus (which includes unterminated inputs the roundtrip suite never sees) through each implementation's resumable Reader + Writer; coercion-compare-stream is expected red until reader EOF semantics are aligned (Python/JS emit the incomplete trailing row where Java/Rust/Scala buffer it, and the JS streaming Reader corrupts empty rows) — it exists to keep that divergence visible. Also rewrite Roundtrip.scala to use batch encode/decode like every other roundtrip harness (streaming coverage now lives in the coercion stream mode). Its champernowne-size batch decodes need -Xmx12g, since nsv-scala's decode materializes per-char tuples. Verified locally: batch manifests are byte-identical across Python/JS/Java/Scala/Rust on enum + full raw champernowne, every impl reproduces champernowne-fixed.nsv, and the documented stream split reproduces (Java=Rust=Scala; Python diverges on 970 unterminated inputs; JS on 1038). https://claude.ai/code/session_012yq2rjyRY1SRcsY5hnsjzk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The roundtrip suite only ever sees valid input, so coercion (decoding raw byte sequences) was never cross-checked: champernowne-fixed is a Python-built, already-valid fixed point, and roundtripping it exercises zero coercion.
Add scripts/coercion.sh + per-impl harnesses (.github/coercion/): each implementation coerces the enum corpus and raw champernowne.nsv via encode(decode(x)) and emits a sha256 manifest; the coercion-compare CI job diffs the manifests across Python/JS/Java/Scala/Rust — the cross-impl consensus is the oracle, no single implementation is trusted. Each run also asserts its output is a fixed point and that champernowne's coercion reproduces the committed champernowne-fixed.nsv byte for byte.
A second, stream mode feeds the enum corpus (which includes unterminated inputs the roundtrip suite never sees) through each implementation's resumable Reader + Writer; coercion-compare-stream is expected red until reader EOF semantics are aligned (Python/JS emit the incomplete trailing row where Java/Rust/Scala buffer it, and the JS streaming Reader corrupts empty rows) — it exists to keep that divergence visible.
Also rewrite Roundtrip.scala to use batch encode/decode like every other roundtrip harness (streaming coverage now lives in the coercion stream mode). Its champernowne-size batch decodes need -Xmx12g, since nsv-scala's decode materializes per-char tuples.
Verified locally: batch manifests are byte-identical across Python/JS/Java/Scala/Rust on enum + full raw champernowne, every impl reproduces champernowne-fixed.nsv, and the documented stream split reproduces (Java=Rust=Scala; Python diverges on 970 unterminated inputs; JS on 1038).
https://claude.ai/code/session_012yq2rjyRY1SRcsY5hnsjzk