Milestone 8 of 10

Round-trip the complete corpus

Recover every file independently and prove exact length, bytes, digest, strict text, code order, and encoder-decoder dictionary agreement.

The codec's claim is exact recovery for each source file, not merely a valid container. Compare every recovered identity and representation field.

Goal

Recover every corpus file independently and prove exact byte count, bytes, SHA-256 digest, strict text, code order, and encoder/decoder final-size agreement.

Inputs

Use source inventory, document codes, encoder and decoder traces, per-document .lmpc files, payload and container read-back records, and source identities. After container and payload parsing, decode codes, require recovered byte count to equal declared original length, and decode recovered bytes with strict UTF-8.

Deliverables

Implement recovery comparison in src/main.py or a clearly separated helper. Produce output/round_trip_results.csv with document ID, source and recovered byte lengths, byte equality, source and recovered digests, digest equality, strict-text equality, code equality, encoder/decoder final sizes, and status.

Checks

Check empty, ASCII, repeated, non-repeated, newline, punctuation, underscore, and multi-byte Unicode files. Verify recovered bytes, digest, decoded text, length, code order, and final dictionary size agree exactly. Check empty source ratios remain a later explicit null case and that a matching length alone never counts as recovery.

Corrupt one payload or recovered byte in a separate fixture and confirm the comparison reports mismatch. Check invalid recovered UTF-8, input immutability, independent per-document state, and no cross-document dictionary phrases.

Workspace

Keep corpus recovery and exact comparison in src/main.py or its helper. Read all source and codec artifacts without mutation. Write round-trip results only; do not calculate size audits yet.

Hints

HintCompare bytes before text
Digest and compare the recovered byte sequence first, then decode it strictly. Equal decoded text can hide a byte boundary mistake only when the source comparison is skipped.
HintCheck the declared length
Require recovered length to equal the payload's original length before calling the round trip successful.
HintKeep failures visible
A failed decoder or invalid recovered text must produce a failure record, never a partially recovered success.

Review

Trace one document from source digest through payload, codes, recovered bytes, and decoded text. Which comparison would catch a changed byte that preserved length?

How to check your work

Checks compare round-trip rows, digests, bytes, text, codes, and final sizes with the fixtures. The supplied fixture requires every identity and representation field to agree.