Skip to content

Add cross-impl coercion conformance + unify roundtrip harnesses - #11

Open
namingbe wants to merge 1 commit into
masterfrom
claude/nice-bell-r8sdhr
Open

Add cross-impl coercion conformance + unify roundtrip harnesses#11
namingbe wants to merge 1 commit into
masterfrom
claude/nice-bell-r8sdhr

Conversation

@namingbe

@namingbe namingbe commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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

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
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.

2 participants