Repository navigation
feat(streaming): assemble R2004 sections from their data pages with byte-demand states - #299
Merged
Merged
Conversation
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
force-pushed
the
feat/streaming-r2004-sections
branch
from
October 26, 2026 13:25
8c81bc7 to
392aed1
Compare
…yte-demand states R2004SectionWalker takes one section description from the map walk, then one page at a time from its caller, which holds the page index: demand() answers NextPage between pages and begin_page(entry, reference) hands it the page map's entry and the section map's reference. Each page is read twice, as the system pages are: a pass that checks the masked 0x20-byte header's own checksum, then every header field against what the caller said, then the data checksum over the stored bytes, keeping nothing; then a pass through the §4.7 decoder (or a copy, for a stored section) that hands out section bytes in order, at most 256 per step. Nothing is derived from a page before its checksums pass. Bytes no page covers (a page starting further on, a section that lists no page) are handed out as holes and read as zeros; a page at or past the section's end is walked and checked and gives nothing; an encrypted section is refused. State is fixed (bounded at WINDOW + 1024 in the no_std kernel, native and wasm32); R2004SectionCheckpoint holds the section, the page in hand, the cursors and the decoder, and restore requires a reachable state. The §4.6 header is not laid out as section_map::DataPageHeader labels it: the start offset is 8 bytes at 0x10, the header checksum is at 0x18 (§4.2 over the header, its field zeroed, seeded with the data checksum) and the data checksum at 0x1C (seed 0), and 0x0C is the page's size on disk, not the decompressed size. examples/probe_data_page_header counts every reading on all 580 data pages of the 28 pinned R2004-family drawings and the four fixtures (ARCHITECTURE.md §7n) and runs with --strict in the Corpus job. The struct is left as it is. stream_r2004_sections walks the maps and then every section, printing lines that do not depend on the chunking; --out writes the sections and --legacy assembles them with read_section_payload. verify_sections.py runs it on the four canonical R2004-family fixtures, the 21 pinned nextgis files and a file it builds (holes, a zero page, a section with no page, stored and compressed sections): every line and byte equals an independent Python assembly and the legacy reader (332 pages, 313 sections); five fixed and 128 proptest schedules; fresh-process resume at every step of the R2018 fixture and about 80 stops of each of three real files and the built one, with all six checkpoint kinds and source reads and output concatenating exactly; bit flips, truncations, a wrong identity and twenty resealed forgeries rejected; nine corruptions per band and five on the built file ending in their named error. It runs in the required Streaming E2E job. Refs #205, #207
DrunkOnJava
force-pushed
the
feat/streaming-r2004-sections
branch
from
October 26, 2026 13:26
392aed1 to
115147d
Compare
DrunkOnJava
enabled auto-merge (squash)
October 26, 2026 13:30
This was referenced Oct 26, 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
R2004SectionWalkerwalks one section's data pages (§4.6) after the page map and section map walk: it checks each page's masked header and both checksums, runs the stored bytes through the streaming LZ77 decoder (or copies them for a stored section) and hands out the assembled section in order, with exact byte demand per transition, fixed state and a checkpoint that resumes in a fresh process. Refs #205, #207.Spec reference
ODA v5.4.1 §4.5 (section map), §4.6 (data pages), §4.2 (page checksum), §4.7 (LZ77). A format finding: the §4.6 header is not laid out as
section_map::DataPageHeaderlabels it (start offset is 8 bytes at 0x10, the header checksum is at 0x18 seeded with the data checksum at 0x1C, and 0x0C is the page's size on disk, not the decompressed size). Measured on all 580 data pages of the 28 pinned R2004-family drawings and the four canonical fixtures; table in ARCHITECTURE.md §7n, reproduced byexamples/probe_data_page_header.rs --strict(now a step of the Corpus job).section_map::DataPageHeaderis left as it is.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features,cargo +1.85 check --all-featurespython3 tools/streaming/check_invariants.pyandtools/streaming/no_std.rsnative and wasm32 (new size boundsWINDOW + 1024for the walker and its checkpoint)cargo test --release --all-features(existing suites; no test added or changed)tools/streaming/verify_sections.pyon the four canonical R2004-family fixtures, the 21 pinned nextgis files and a file it builds (holes, a zero page, a section with no page, stored and compressed sections, padded and exact last pages): every output line and assembled byte equals an independent Python assembly and the legacy reader (332 pages, 313 sections); fixed and 128 proptest schedules; fresh-process resume at every step of the R2018 fixture and about 80 stops of each of three real files and the built one, all six checkpoint kinds, source reads and output concatenating exactly; bit flips, truncations, a wrong identity and 20 resealed forgeries rejected; nine corruptions per band and five on the built file end in their named error. Wired into the Streaming E2E job (sections-evidence.json).sample_AC1018.dwg, whose AcDb:Template section declares bytes and lists no page): same result.Source-provenance declaration
By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:
CLEANROOM.md).dwg-rsis Apache-2.0 and must remain compatible.My contribution is based on: