Repository navigation
feat(streaming): walk the R2004 page map and section map with byte-demand states - #276
Merged
Merged
Conversation
DrunkOnJava
force-pushed
the
feat/streaming-r2004-maps
branch
from
October 26, 2026 11:28
5ac0c8e to
5a0cf63
Compare
…mand states R2004MapWalker continues from the §4.1 header into the two system pages: the §4.4 section page map at the header's address, then the §4.5 section map at the address its page-map entry gives. Each page is read twice, as the flat walk reads an object-map chunk twice: a pass that checks the §4.3 checksum and keeps nothing, then a pass through the §4.7 decoder that commits one record per step. demand() distinguishes source reads (at most 64 bytes ahead of the decoder) from pumps of output already decoded, and poll_r2004_maps drives both. State is fixed (bounded at WINDOW + 1024 in the no_std kernel, native and wasm32) and the walker holds no map; R2004MapCheckpoint embeds the header and decoder checkpoints and cursors that must form a reachable state. Checked, because every real file and the fixtures agree: system page type, compression and extent; page sizes non-zero multiples of 0x20; the page map's own entry at the header's address; an entry for the section map id; the section map header constants; description flags, page size and name; rising whole-page start offsets; exact decoded sizes. Sequential page numbers, the unknown longs and page extents inside the file are not checked, since real files do not follow them. stream_r2004_maps is the entry point; --legacy prints the legacy page map and section info in the same shape. verify_maps.py runs it on the four canonical R2004-family fixtures and the 21 pinned nextgis R2004, R2010 and R2013 files (371 pages, 306 sections, 321 section pages): equal to an independent Python parse and the legacy reader under fixed and 128 proptest schedules; fresh-process resume at every step of two files and sampled steps of two more with no read beyond the two designed passes; bit-flipped, truncated, wrong-identity and resealed checkpoints rejected; eight corruptions per release band, including record faults reached past the checksum by rewriting LZ77 literal bytes and resealing, each ending in its named error. It runs in the required Streaming E2E job. Refs #205, #207
DrunkOnJava
force-pushed
the
feat/streaming-r2004-maps
branch
from
October 26, 2026 11:52
5a0cf63 to
fb3949a
Compare
DrunkOnJava
marked this pull request as ready for review
October 26, 2026 11:52
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb3949a34a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
With every section record read, record_need is zero and the walker decoded into an empty slice to reach the terminator. If the section count understated the records, the decoder still had literal or copy output to give, made no progress into that empty slice, and every demand stayed Pump: the walk never ended. With no record open, the page must already have produced its declared size; otherwise it is MapLength at once. verify_maps.py adds a section count one short and a count of zero, reached past the checksum by rewriting the literal count byte and resealing; both end in MapLength on the canonical R2004 fixture and one file per release band. The verifier's per-run timeout drops to 120 s so a hang fails fast. Reported by the review on #276.
DrunkOnJava
enabled auto-merge (squash)
October 26, 2026 12:07
This was referenced Oct 27, 2026
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::R2004MapWalkerwalks the R2004-family §4.4 section page map and §4.5 section map with byte-demand states on the §4.7 decoder, checksum-verifying each system page before deriving anything from it and committing one record per step. Advances #205 (R2004+ container walk) and #207 (combined walk checkpoints); neither closes.Rests on #260 (the §4.1 header grammar), #255 and #266 (real page checksums in the canonical fixtures), all on
main.Spec reference
ODA Open Design Specification for .dwg files v5.4.1: §4.2 (section page checksum), §4.3 (system page header and two-stage checksum), §4.4 (section page map; addresses accumulate from 0x100; gap entries carry four more longs), §4.5 (section map header and descriptions, page references), §4.7 (decoder).
Each system page is read twice, as the flat walk reads an object-map chunk twice (audit decision 7): a checksum pass that keeps nothing, then a decode pass.
demand()returnsRead(source bytes, at most 64 ahead of the decoder),Pump(output already decoded; no source bytes) orDone, so a compressed byte that expands into several records still yields one record per step. Checks enforced, each measured on every real file and the fixtures first: system page type, compression 2 and extent; page sizes non-zero multiples of 0x20; the page map's own entry at the header's address and large enough; an entry for the section map id; section map header (count, 2, 0x7400, 0, …); description compression (1, 2), encryption (0–2), page size, printable name; rising whole-page start offsets; exact decoded sizes. Not enforced, because real files don't follow them: sequential page numbers, the "unknown" longs, page extents inside the file. The walker holds no map; the index is the caller's. State bounded atWINDOW + 1024in theno_stdkernel (native and wasm32);R2004MapCheckpoint(DWGM, about 50 KB at most) embeds the header checkpoint (replayed) and the decoder checkpoint, and its cursors must form a reachable state.Test plan
python3 tools/streaming/verify_maps.py target/debug/examples/stream_r2004_maps target/debug/examples/streaming_schedules: four canonical R2004-family fixtures and the 21 pinned nextgis R2004/R2010/R2013 files (fromlz77-corpus.json). 371 page entries, 306 section descriptions, 321 section page references; every line equals an independent Python parse, every record the legacysection_mapreader; five fixed schedules and 128 proptest schedules on three files reproduce it. Fresh-process resume at every step ofsynthetic_2018(173) andline_2004(316), sampled steps ofline_2010andline_2013: reads and output of the two processes concatenate to the uninterrupted run's. 606 bit flips, 606 truncations, a wrong identity and ten resealed unreachable states rejected for a mid-walk checkpoint. Eight corruptions per band (both checksums, page map type, page size off 0x20, page map off its own entry, section map header constant, a description field, a file cut inside the page map) end in their named errors; record faults get past the checksum by rewriting LZ77 literal bytes and resealing the page.sample_AC1032.dwg(124 records equal to legacy).check_invariants.py, kernel builds native and wasm32, fmt, clippy-D warnings,cargo doc -D warnings.Not covered: data pages (§4.6) and section assembly, R2007, throughput.
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.