Milestone 7 of 10
Wrap and validate versioned codec files
Apply the LMP version and payload-length boundary independently to every document and reject each outer-container failure before payload decoding.
Each document gets its own versioned codec file. Validate the outer boundary before interpreting the inner payload.
Goal
Wrap each payload in the accepted FILE-15 container, save independent per-file artifacts, and test every outer magic, version, length, truncation, and trailing byte failure.
Inputs
Use valid DTC1 payloads, accepted container version, and positive payload
bound. The outer layout is:
bytes 0..2 magic b"LMP"
byte 3 container version, from 0 through 255
bytes 4..7 payload length as an unsigned four-byte big-endian integer
remaining exact codec payload bytes
Read checks truncated header, magic, accepted version, truncated payload, and trailing container bytes in that order before parsing codec fields. The configuration imposes a smaller positive payload bound before allocation.
Deliverables
Implement src/container.py. Write one exact .lmpc binary file per source
document, with digest and container metadata containing magic, version, declared
and actual payload lengths, document identity, and codec identity.
Checks
Check exact header bytes, unsigned big-endian length, accepted version, deterministic independent files, payload bound, and source identity. Exercise truncated header, changed magic, unsupported version, truncated payload, declared-length mismatch, trailing container bytes, and excessive payload.
Check outer failures occur before payload decoding, payload bytes pass through unchanged, and source records remain immutable. Do not infer a version or layout from content.
Workspace
Keep outer wrapping and validation in src/container.py. Write per-document
binary files and rejection evidence. Do not perform the complete corpus recovery
yet.
Hints
HintKeep boundaries separate
HintUse the declared length
HintOne file per document
Review
Take a valid payload and append one byte to its container. Which outer check rejects it, and why must the payload parser never see that byte?
How to check your work
Checks compare per-document .lmpc bytes, digests, metadata, and failure reasons with
the fixtures. The supplied fixture applies one exact versioned outer format.