Repository navigation
feat(streaming): walk the R13-R2000 container with byte-demand states - #240
Merged
Merged
Conversation
FlatWalker continues from the §3.2 file header through the §9 header-variable and §10.1 class sections and the §23.1 object map, following every entry to its §20.1 record. Each transition declares its exact offset and remaining demand; state is fixed-size (under 512 bytes, no allocation) and compiles in the no_std/wasm32 kernel. Index bytes are verified before use: each map chunk is CRC-checked in a storage-free pass, then re-read to decode entries and visit records. Payload is handed to the caller provisionally and committed by the Section or Object step after its size, CRC, sentinel, type and handle checks. Every mismatch is a typed terminal error. WalkCheckpoint embeds the header checkpoint (replayed on restore) and the walk cursors, which must form a reachable state over the verified locators. stream_walk is the entry point; --legacy prints the legacy reader's handle-map walk in the same shape. verify_walk.py runs it on the canonical R2000 fixture and every R14/R2000 file in the pinned nextgis/dwg_samples commit (3,546 records): the output equals an independent framing parse and the legacy reader, holds under fixed and proptest chunk schedules, resumes in a fresh process at every feed of the canonical file and 66 per real file with no source re-read or duplicate output, and rejects 25 corruptions per file and every corrupt, truncated or resealed-inconsistent checkpoint. It runs in the required Streaming E2E job. The canonical R2000 fixture now frames its header-variable section and an empty class section, so the strict walk accepts it end to end. Refs #205, #206, #207, #210
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 09:44
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
streaming::FlatWalkercontinues the bounded byte-demand grammar from the §3.2 file header through the §9 header-variable and §10.1 class sections and the §23.1 object map, following every map entry to its §20.1 record and checking its framing, CRC, type and handle. Advances #205, #206, #207 and #210; none of them closes.Spec reference
ODA Open Design Specification for .dwg files v5.4.1, §3.2 (file header and locators), §9 (header variables), §10.1 (classes), §20.1 (object records), §23.1 (object map). The framing enforced, confirmed on real files before coding (recorded in
docs/streaming/audit.md):RLsize, data,RSCRC seeded 0xC0C1 over size and data, end sentinel; the locator size must be 38 plus the data size.MSsize (at most two words), data, little-endian CRC over theMSbytes and data; then type (BS), the R2000RLand the handle, which must equal the map's.Commit contract (audit decision 7): index bytes are verified before anything is derived from them, so each map chunk is read twice (a CRC-only pass with no storage, then a decoding pass); payload is handed to the caller provisionally and committed only by the
SectionorObjectstep after its checks. Every mismatch is a typed terminalStreamError. State is fixed-size (464 bytes measured on aarch64, compile-time bounded at 512) with no allocation, and compiles in theno_std, no-allocator kernel natively and forwasm32-unknown-unknown.WalkCheckpoint(at most 256 bytes) embeds the header checkpoint, replayed on restore, and the walk cursors, which must form a reachable state over the verified locators.The canonical R2000 fixture now frames its header-variable section and an empty class section, so the strict walk accepts it end to end.
Test plan
Measured on the rebased commit (one commit on
main):cargo run --release --example build_fixturesregenerates every fixture byte-identically to this commit.python3 tools/streaming/check_invariants.pyand both kernel builds (rustc ... tools/streaming/no_std.rs, native and--target wasm32-unknown-unknown).python3 tools/streaming/verify.py(header acceptance, unchanged) andpython3 tools/streaming/verify_walk.py target/debug/examples/stream_walk target/debug/examples/streaming_schedules: the canonical R2000 fixture and every R14 and R2000 file atnextgis/dwg_samples@ff05d5a(14 files, fetched by sha256 fromtools/streaming/walk-corpus.json, never committed): 3,546 records. For each file the walk's whole output equals an independent Python framing parse and the legacy reader's handle-map walk (handle, offset, size, type, payload CRC-32); seven fixed chunk schedules reproduce it; 128 proptest schedules on three files. Fresh-process resume at every feed of the canonical file (104 stops) and 66 sampled feeds ofline_R14andline_2000: source reads and output of the two processes concatenate to the uninterrupted run's (no re-read, no duplicate output). 227 bit flips, 227 truncations and 14 resealed forgeries of a walk checkpoint rejected; 25 corruptions per file (flipped, resealed, truncated and short-transport) end in the named error with only the valid prefix committed.-D warnings, all targets) andcargo doc -D warningslocally; the full OS/MSRV matrix runs in CI.Not measured: a real R13 file, files larger than about 160 KB, and throughput.
CI note. The
Streaming E2Ejob now fetches the 14 pinned nextgis R14/R2000 files by hash at run time. They are pins of the sameff05d5acommit the corpus-CI lane (#95) is pinning; the two manifests are to converge in that lane's PR. CLAUDE.md's "CI reads no real DWG file" stops being true when this lands (the coordinator is updating it).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.