Repository navigation
feat(streaming): stream the object records of an R2004-family file (#205) - #333
Conversation
) R2004ObjectWalker is the whole-file walker with AcDb:AcDbObjects framed into records in section order: each record's MS, R2010 MC, payload, CRC, type and handle, with fixed state and a self-contained checkpoint. The payload (the bytes the legacy RawObject::raw holds) is handed out as it arrives and committed by an Object step after the CRC, type and handle checks. Records come out in stream order with the handle they carry; the AcDb:Handles map is not read and nothing is indexed. The walker refuses an object page the page map lists out of order or a hole (ObjectsOrder) rather than keep an index; every pinned drawing lists them in order. Measured on the 28 pinned R2004-family drawings (8,007 records): the records tile the section exactly after the 4-byte 0x0DCA prologue, every record's CRC (seed 0xC0C1, MS through the last payload byte, MC included) verifies, and every MC is at most 8 times the payload; three other CRC readings agree with none (ARCHITECTURE.md 7v). The legacy walker never checked the CRC. Running the R13 to R2000 walk on two 1.3 MB drawings found that it refused an object map chunk over 2,032 bytes. A chunk's size counts its own two bytes, so AutoCAD's full chunk is 2,034 (2,033 and 2,034 in sample_AC1014.dwg and sample_AC1015.dwg); the walk failed on both with MapChunk. The limit is 2,034 now and both drawings are in verify_walk.py (1,242 and 1,047 records equal to the legacy reader's). R2004ObjectCheckpoint (DWGO, about 100 KB) holds the file walker's checkpoint, the object section's id, the framer's cursors and the section bytes not yet framed; restore requires a reachable state (the framer's CRC is recomputed where its bytes are held, its MC re-read, the section checked against the table and the unframed bytes against the section walker's cursor). The wasm kernel gains run_objects and resume_objects. verify_objects.py: every printed line equals an independent Python framing of the independently assembled section, the AcDb:Handles map and the legacy reader, on the four fixtures and the 28 drawings; fixed and proptest chunk schedules; real object sections repacked at page sizes from 4 bytes and with other sections' pages interleaved; fresh-process resume at 1,374 stops including every framer stage and an MS and an MC split across pages; bit flips, truncations and 118 resealed forgeries of checkpoints; 47 corrupt object sections each ending in its named error with exactly the records before it. verify_wasm_objects.py restores native checkpoints in the wasm32 kernel and the kernel's own in the native build, byte-identical in 611 of 611. Both run in the Streaming E2E job (timeout 30 minutes).
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: c653daccbf
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 738051036a
ℹ️ 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".
…etic and reject an MC of 2^64 (#205) A forged but CRC-valid DWGO checkpoint could overflow u8 arithmetic in the framer's reachable-state check (words 1 with a field length of 255) or reach positions near u64::MAX, and an MC whose tenth byte held more than one payload bit decoded to a small value because the shift dropped it. The check now bounds every field before it computes with it, the stream length is bounded at 2^62 (more is CounterOverflow), the wrapper checks the framer first, and an MC of 2^64 or more is RecordHeader, both when read and when re-read from a checkpoint. verify_objects.py forges each case (158 resealed forgeries now) and corrupts a real record's MC to 2^64 (49 corrupt sections).
…is not caught by at restore (#205)
… 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.
Summary
Stream the object records of an R2004-family file out of the whole-file walker (#205): each record's
MS, R2010MC, payload, CRC, type and handle, with fixed state, byte-demand boundaries and a self-contained checkpoint that restores in wasm32. Along the way the R13 to R2000 walk's object map chunk limit was wrong and is fixed.What changed
src/streaming/records.rs(new):ObjectFramer, the record framing;RecordFormat(R14, R2000 to R2007, R2010+).flat.rsnow uses itsprologueinstead of a private copy.src/streaming/r2004_objects.rs(new):R2004ObjectWalker,ObjectStep,ObjectDemand. The object section's data is framed in section order; every other section's data passes through. Records are emitted in stream order with the handle they carry; theAcDb:Handlesmap is not read and nothing is indexed.R2004ObjectCheckpoint(DWGO, incheckpoint.rs),byte_source::poll_r2004_objects,examples/stream_r2004_objects.rs, size asserts intools/streaming/no_std.rs.verify_objects.py,verify_wasm_objects.py, wasm exportsrun_objectsandresume_objects; both wired into the Streaming E2E job (timeout raised), withobjects-corpus.json(the seven ACadSharp R2004-family drawings, cross-checked againstpins.tsv).FlatWalkeralready emitted each record's payload provisionally and committed it atStep::Object(feat(streaming): walk the R13-R2000 container with byte-demand states #240), so those bodies were met. The change there is a bug found by running larger files (below) and two 1.3 MB drawings added toverify_walk.py(walk-acadsharp-corpus.json).Findings (ARCHITECTURE.md §7ac)
MSthrough the last payload byte,MCincluded) verifies, and everyMCis at most 8 times the payload. Three other CRC readings agree with none. The legacy walker never checked the CRC.AcDb:AcDsPrototype_1bis the only section of any drawing listed out of order. The walker refuses an out-of-order object page (ObjectsOrder) rather than keep an index; supporting it would need a bounded multi-pass walk and is not claimed.FlatWalkerrefused an object map chunk over 2,032 bytes. A chunk's size counts its own two bytes, so AutoCAD's full chunk is 2,034 (2,033 and 2,034 insample_AC1014.dwgandsample_AC1015.dwg). The walk failed on both withMapChunk; the evidence had stopped at 160 KB. Fixed; 1,242 and 1,047 records now equal the legacy reader's. The fix is one constant insrc/streaming/flat.rs: the legacy reader (handle_map.rs,object.rs,reader.rs) is untouched, so no corpus count moves and the Corpus job's baseline is unchanged.Test plan
No unit tests. Evidence is E2E, on real drawings, with repeatable artifacts (
objects-evidence.json,wasm-objects-evidence.json,walk-evidence.jsonand the schedule logs):cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features,cargo test --release --all-features(existing suites, none adapted or added): pass.python3 tools/streaming/check_invariants.pyand theno_std.rsbuilds, native and wasm32: pass.verify_objects.py(command in docs/streaming/README.md, 32 files = 4 fixtures + 28 pinned drawings, 8,027 records): output equal to the independent framing, theAcDb:Handlesmap and the legacy reader; 4 fixed and 128 proptest schedules; built files at page sizes from 4 bytes; 1,374 fresh-process resumes (every framer stage, 37 inside anMS, 18 inside anMC); 1,500 checkpoint bit flips and truncations and 158 resealed forgeries rejected; 49 corrupt object sections each ending in its named error.verify_wasm_objects.py: 611 native checkpoints restored in the wasm32 kernel and the kernel's own in the native build, byte-identical in 611 of 611; 83 forgeries refused.verify_walk.pywith the two 1.3 MB drawings: 17 files pass;verify_wasm.py(the existing three walks, rebuilt kernel): 16 cases pass.tools/corpus/fetch.py --dest ~/Library/Caches/dwg-corpus) and its 19-file local subset (byte-identical to pinned files,../../samples).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. No Autodesk SDK, ODA Teigha/Drawings SDK or GPL DWG implementation source was consulted or imported. My contribution is based on the ODA's Open Design Specification for .dwg files (v5.4.1) and on measurements of the pinned public drawings; no algorithm-description comments from other projects were read.