Repository navigation
feat(streaming): verify the R2004-family file header with byte-demand states - #260
Merged
Merged
Conversation
DrunkOnJava
force-pushed
the
feat/streaming-r2004-header
branch
from
October 26, 2026 11:01
f4b6fa3 to
afeb314
Compare
3 tasks done
… states R2004HeaderParser reads the first 0x100 bytes of an AC1018, AC1024, AC1027 or AC1032 file under the flat header's contract: exact demands, partial feeds kept, invalid delivery rejected without mutation, terminal errors, and no output until every §4.1 check passes. It enforces the long 0x80 at 0x28; the decrypted block's file ID, CRC-32 and fixed fields at 0x0C, 0x10, 0x14, 0x44, 0x48 and 0x4C; the 0x14 trailing magic bytes; a page map on a 0x20 boundary inside the source; and a non-zero second-header address inside the source. Failures name the field's file offset (R2004Field) or the CRC (R2004HeaderCrc). It compiles in the no_std, no-allocator kernel natively and for wasm32, bounded at 512 bytes; R2004Checkpoint (DWG4, at most 316 bytes, bounded at 336) is restored by replay. stream_r2004 is the entry point; --legacy prints the legacy header's fields under the same keys. verify_r2004.py runs it on the four canonical R2004-family fixtures and the 21 pinned nextgis R2004, R2010 and R2013 files: every header equals an independent Python parse and the legacy reader, under 33 chunk schedules and 128 proptest schedules on three files, and a cut at each of the 256 header bytes is Truncated. Twelve corruptions per release band end in their named error with nothing printed; fresh-process resume at all 257 positions reads each byte once; corrupt, truncated and wrong-identity checkpoints are rejected and a failure snapshot restores its failure. It runs in the required Streaming E2E job. Refs #205
DrunkOnJava
force-pushed
the
feat/streaming-r2004-header
branch
from
October 26, 2026 11:26
afeb314 to
940a337
Compare
DrunkOnJava
marked this pull request as ready for review
October 26, 2026 11:26
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
DrunkOnJava
enabled auto-merge (squash)
October 26, 2026 11:39
DrunkOnJava
added a commit
that referenced
this pull request
Oct 28, 2026
… to what landed (#205, #206, #207) (#400) The ledger stopped at the header and the R13-R2000 walk, and the README's checkpoint contract described the header checkpoint alone and said full object and decompression checkpoints remain open. Both now cover the ten checkpoint kinds on main and the walkers of #240, #246, #260, #276, #299, #312, #333, #340 and #363, the perf series #360 to #366, and cite the evidence files of Streaming E2E run 40532346151. What was not measured is marked NOT MEASURED.
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.
Summary
streaming::R2004HeaderParserverifies the R2004-family file header (AC1018, AC1024, AC1027, AC1032) with the same byte-demand, checkpoint and no-allocation contract as the flat header. It is the entry of the R2004+ container walk (#205); the page-map and section walk is not in this PR.Spec reference
ODA Open Design Specification for .dwg files v5.4.1, §4.1, with §4.3's 0x20 page boundary for the page-map address. Enforced: plain 0x28 = 0x80; decrypted file ID, CRC-32 (CRC field zeroed, "the CRC calculation takes into account all of the 0x6c bytes"), fixed fields at 0x0C, 0x10, 0x14, 0x44, 0x48, 0x4C; the 0x14 trailing magic bytes; a page map on a 0x20 boundary with its header inside the source; a non-zero second-header address inside the source. A failing field is
R2004Field(file offset), a CRC mismatchR2004HeaderCrc. Plain bytes the spec calls zero but real files fill (0x15–0x17, 0x2C–0x7F) and the "unknown" decrypted 0x24 are not enforced. State is bounded at 512 bytes and theDWG4checkpoint at 336 (at most 316 on the wire), both in theno_stdkernel, native andwasm32-unknown-unknown.Rests on #259 (the writer fix that makes the canonical fixtures carry the §4.1 fixed fields) and #255, both on
main.Test plan
python3 tools/streaming/verify_r2004.py target/debug/examples/stream_r2004 target/debug/examples/streaming_schedules: the four canonical R2004-family fixtures and the 21 pinned nextgis R2004/R2010/R2013 files. Every header equals an independent Python §4.1 parse and the legacyheader::R2004Headerfields; chunk sizes 1–32 and a mixed schedule with Pending polls reproduce it; 128 proptest schedules on each of three files; a cut at each of the 256 header bytes isTruncated. On the canonical R2004 fixture and one real file per release band, twelve corruptions (three magics, 0x28, file ID, CRC, two fixed fields, trailer, page map past the end and off its boundary, second header past the end) each end in their named error with nothing printed. Fresh-process resume at all 257 positions reads each byte exactly once. Bit flips at every byte (160), every truncation and a wrong identity are rejected for a mid-header checkpoint; a failure snapshot restores its failure.sample_AC1032.dwg(Establish the provenance of sample_AC1032.dwg, the one R2018 file #96) parses and matches the legacy fields.cargo doc -D warnings, kernel builds,check_invariants.py,build_fixturesbyte-identical.Source-provenance declaration
Clean-room declaration. All code in this PR was written from scratch. The only sources consulted were this repository and the ODA's public Open Design Specification for .dwg files v5.4.1. No Autodesk SDK, ODA SDK (Drawings / Teigha), LibreDWG or other copyleft DWG implementation source, and no decompilation, was consulted. Spec citations are in the diff.