Skip to content

feat(streaming): walk a whole R2007 file with every checksum checked before its bytes are handed out (#205) - #340

Merged
DrunkOnJava merged 22 commits into
mainfrom
feat/streaming-r2007
Oct 27, 2026
Merged

DrunkOnJava merged 22 commits into
mainfrom
feat/streaming-r2007

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Walks a whole R2007 (AC1021) file through one fixed-size, resumable, no_std walker, streaming::R2007Walker: the file header, the page map, the section map and every data page of every section, with every codeword, CRC-64 and checksum checked before any byte of a page is handed out (#205, goal: R2007 in the streaming grammar).

Spec reference

ODA v5.4.1 §5.1–§5.4 (container), §5.10 (LZ), §5.11 (CRC seed bits), §5.12 (CRC-64), §5.13 (Reed-Solomon), §5.4.1 (page checksum). Design in docs/streaming/README.md ("The whole R2007 file"); measured rules and a new finding in ARCHITECTURE.md §7aa (data pages are not bounded by the section's 0xF800 maximum: 70,912 bytes and 273 codewords in sample_AC1021.dwg; every CRC/seed/byte-order reading was measured on the pinned drawings, 0 matches for the nearest wrong readings).

  • The section map is the outer loop (R2007 data pages have no header), so pages come out in section order; for each page reference the walker scans the page map for the page's entry. No section table, no page index, no limit.
  • A page is never held: a Gather demand names the 255 strided bytes of one codeword; the §5.10 decoder (own file, bounded 64 KiB window, permuted 32-byte literal blocks) pauses between any two bytes.
  • Each page is walked twice (verify: all syndromes, stored CRC-64, decode to the declared size with the decompressed CRC-64 or §5.4.1 checksum; then emit). The legacy reader checks none of it.
  • DWGR checkpoint (<= 2 * 64 KiB + 8 KiB), self-contained, geometry derived on restore, restored in wasm32.
  • Shared files touched: mod.rs (modules, exports, six StreamError variants), byte_source.rs (poll_gather, poll_r2007_walk, a gather window in FileSource), wasm_resume.rs/.mjs (run_r2007, resume_r2007; the checkpoint region grew to 160 KiB), no_std.rs, streaming.yml, .gitignore, spec-coverage row for §5.

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, python3 tools/ci/spec_coverage.py --check, python3 tools/maintainer/train/arch.py check
  • The whole Streaming E2E sequence locally (every existing verifier unchanged and passing, plus the two new ones): verify_r2007.py (11 files: the 8 pinned R2007 drawings, 7 nextgis and sample_AC1021.dwg, and 3 files tools/streaming/r2007_ref.py builds from the spec; 113 sections, 152 pages, 4,966 data codewords, 3,067,696 bytes; every output line and byte equal to an independent Python parse and to r2007::Container; fixed and 128 proptest chunk schedules; 729 fresh-process resume stops covering all six stages, both passes of each reader and nine decoder modes; 495 bit flips, 495 truncations, a wrong identity and 123 resealed forgeries rejected, 180 resealed mutations without a panic; 41 real-file corruptions and 44 built-file rule breaks each end in their named error with exactly the walk before them printed) and verify_wasm_r2007.py (247 native checkpoints finished in a wasm32 kernel, 247 kernel checkpoints byte-identical to the native ones and finished natively, 83 refusals).
  • Reproduce the check table: python3 tools/streaming/probe_r2007_checks.py <the eight pinned R2007 drawings>.
  • Throughput (cargo run --release --example stream_r2007_timing -- <file> 15, in memory, best of 15): 70.7 MB/s of section bytes (53.6 MB/s of file) on sample_AC1021.dwg against 327 and 247 MB/s for the legacy reader, which verifies nothing and decodes each page once; 179 against 1,160 MB/s on arc_2007.dwg.
  • No unit tests added; no existing test adapted.

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:

  • No Autodesk DWG SDK source (RealDWG, ObjectARX, ObjectDBX) or NDA-protected Autodesk documentation was consulted or imported.
  • No Open Design Alliance Teigha / Drawings SDK source was consulted or imported. The ODA's public Open Design Specification for .dwg files PDF is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

My contribution is based on the ODA's Open Design Specification for .dwg files (v5.4.1), read from the PDF (§5.2, §5.3, §5.4, §5.4.1, §5.10 to §5.13, including its printed CRC tables and pseudo-code), on this crate's existing r2007, r21_lz and reed_solomon modules, and on measurements of the pinned corpus. No algorithm-description comments from any other project were read.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T00:15:18.653304Z f478495 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8939a7683

ℹ️ 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".

Comment thread src/streaming/r2007_checkpoint.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: feef7176e8

ℹ️ 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".

Comment thread src/streaming/r2007.rs Resolved
Comment thread examples/stream_r2007_timing.rs Resolved
Comment thread src/byte_source.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09aa59cd03

ℹ️ 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".

Comment thread src/streaming/r2007.rs Resolved
Comment thread tools/streaming/wasm_resume.rs Resolved
Comment thread tools/streaming/probe_r2007_checks.py Resolved
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 27, 2026 00:15
@DrunkOnJava
DrunkOnJava merged commit a315f04 into main Oct 27, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/streaming-r2007 branch October 27, 2026 00:23
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant