Repository navigation
feat(streaming): walk a whole R2004-family file behind one checkpoint - #312
Merged
Merged
Conversation
R2004Walker is the map walker and the section walker behind one state and one checkpoint, for a caller with no page index. A walker with fixed state cannot hold the page index, so it does not walk in section order. Pass A is the map walk: each section description goes into a fixed table of at most 64 slots (SectionTableFull beyond) and is handed to the caller, and each page reference is counted and folded into a digest. Pass B reads the page map again entry by entry and walks every data page it lists in the order it gives: the page's checksummed header names its section and its place in it, which is all the section walker needs, so nothing but the table is needed. Bytes come out tagged with their section and offset and the consumer scatters them. At the end every section's pages must be the pages its references listed: the count and the digest (a wrapping sum of a splitmix64 mix of page number, start offset and data size) of the references equal those of the pages the page map held. A page missing, walked twice, unlisted or in the wrong place changes it, whatever order the page map holds them in; it is an integrity check on checksummed headers, not a security boundary. A page's data size is the length of its stored bytes, so it is not bounded by the section's size; a padded last page's bytes past the end are decoded and dropped. R2004WalkCheckpoint (DWGF, about 100 KB: two decoder windows) holds the table and the two walkers' checkpoints and is self-contained: restore needs the source identity and nothing else, and requires a reachable state (both walkers validated by their own restore, then the table, the stage against the map walker's mode and refs left, and the page in hand against the table). The map walker gains a pages-only mode (never in its checkpoint) for the second pass. stream_r2004_file is the entry point (--out writes sections sparsely and prints section_done; --legacy assembles them with read_section_payload). verify_file.py runs it on the four canonical R2004-family fixtures, the 21 pinned nextgis files (321 pages, 306 sections) and a file it builds with its pages in section order, reversed and shuffled: every line and byte equals an independent Python assembly and the legacy reader; 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 ones, all six stages, source reads and output concatenating exactly; bit flips and truncations, a wrong identity and 50 resealed forgeries rejected; six corruptions per band and six on the built file ending in their named error. The wasm32 kernel gains resume_file and run_file: about 60 native checkpoints per file restored in wasm from the checkpoint alone finish equal to the native resume, and the kernel's own checkpoint at the same step is byte-identical to the native one in every case and resumes natively. Both run in the required Streaming E2E job. Refs #205, #207
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: 23c2a269c4
ℹ️ 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".
…ncate new section files on resume, escape section names A DWGF checkpoint taken at Verify or Done omitted the map walker, and with it the only copy of the verified file header, so header() went from Some to None across a restore. Those stages now keep the header checkpoint alone (a finished map pass has nothing to resume) and restore requires it. stream_r2004_file opened the output file of a section described after a resume without truncating it, so stale bytes in an older file survived in the section's holes; a section described by this process now always starts empty, and only files of sections described before the checkpoint are kept. Section names went into the JSON lines unescaped, so a name with a quote or a backslash, which the map walker admits, broke the output. The file, sections and maps examples and the wasm kernel escape both characters. verify_file.py checks that the header printed after a resume from every stage equals the uninterrupted run's and starts every stop with stale output in each section file; the built file names a section with a quote and a backslash, which every verifier now reads back through json.loads. Reported by the review on #312.
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
R2004Walkerwalks a whole R2004-family file behind one state and one self-contained checkpoint: the header, the page map and the section map fill a fixed section table, then every data page the page map lists is walked in page-map order, with its bytes tagged by section and offset. No page index is the caller's; a section's pages are accounted for against its section map references by count and digest. Refs #205, closes the checkpoint half of #207.Spec reference
ODA v5.4.1 §4.1, §4.3–§4.6 walks only (no new format feature). Design per the integrator's sign-off on #207: pass A is the map walk (section table of at most 64 slots,
SectionTableFullbeyond; references counted and folded into a splitmix64 digest of page number, start offset and data size); pass B re-reads the page map (a map-walker pages-only mode that is never in its checkpoint) and walks each data page through the section walker, started from the page's checksummed header. At the end every section's seen count and digest must equal its reference count and digest (SectionDigest), so a page missing, walked twice, unlisted or in the wrong place is caught whatever order the page map holds them in; the digest is an integrity check, not a security boundary. One deviation from the sign-off, agreed there: a page's data size is its stored length (padded for stored sections, compressed for LZ77), so it is not bounded by the section size; bytes past the section's end are decoded and dropped.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-features,cargo test --release --all-features(no test added or changed),check_invariants.py,spec_coverage.py --check,no_std.rsnative and wasm32 with new bounds2 * WINDOW + 8192for the walker and its checkpoint.tools/streaming/verify_file.pyon the four canonical R2004-family fixtures, the 21 pinned nextgis files (321 pages, 306 sections) and a file it builds with its pages in section order, reversed and shuffled: every printed line and assembled byte equals an independent Python assembly and the legacyread_section_payload; 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 ones (all six stages, source reads and output concatenating exactly, section bytes equal after resume); bit flips at every byte and every truncation of a small checkpoint, 100 sampled of each for a walking one, a wrong identity and 50 resealed unreachable states rejected; six corruptions on the fixture and one real file per release band (both checksums, page type, a section the map does not describe, a start offset the map does not list, a data size) and six on the built file (page missing from the page map, listed twice, an unlisted page of a known and of an unknown section, 65 sections, an encrypted section) end in their named error.resume_fileandrun_file; about 60 nativeDWGFcheckpoints per file restored in the kernel from the checkpoint alone (no page index, no section list) finish equal to the native resume at kernel read sizes 1, 7, 64 and 256; the kernel's own checkpoint at the same step is byte-identical to the native one in every case (55 to 62 per file) and resumes natively; sampled bit flips and a wrong identity are refused by the kernel. Under node, not a browser.verify_maps.pyandverify_sections.pypass unchanged on the modified map walker (newpages_onlyfield, never serialized). Also run locally with the 7 further ACadSharp drawings (625 pages, 423 sections including shuffled-build files): same result.file-evidence.json,wasm-evidence.json).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: