Skip to content

fix(fixtures): write the R2000 file-header CRC and end sentinel - #215

Merged
DrunkOnJava merged 1 commit into
mainfrom
fix/canonical-r2000-header
Oct 26, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
fix/canonical-r2000-header

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

The canonical R2000 fixture generator now writes the §3.2 file-header CRC and end sentinel, so synthetic_2000.dwg passes the strict streaming header reader. Closes #214.

Spec reference

ODA Open Design Specification for .dwg files v5.4.1, §3.2.6: "RS: CRC for BOF to this point", seed 0, XORed with 0xA598 for three locators, followed by the 16-byte sentinel 95 A0 4E 28 99 82 1A E5 5E 41 E0 5F 9D 3A 4D 00.

build_flat_fixture wrote the locator table into a zeroed buffer and never emitted either field, so the fixture stored 0000 where the calculation gives 0x7813.

  • The generator writes the CRC (crc::crc8 over bytes 0..52, XOR crc::r13_locator_seed(3)) and streaming::END_SENTINEL.
  • streaming::END_SENTINEL is public; the streaming reader uses crc::r13_locator_seed instead of a private copy of the seed table.
  • Regenerating changes only bytes 52–68 of synthetic_2000.dwg. Offsets, the five entities and the R2004-family fixtures are byte-identical.
  • tools/streaming/verify.py reads the canonical fixture through the strict header entry point at every chunk size from 1 to 32.
  • Docs: the fixture README says what is and is not valid about this file; the streaming README and task ledger record the fix and the custody handoff noted on Epic: streaming-native DWG reader with portable state and enforced chunk bounds #204.

Test plan

  • cargo fmt --all -- --check
  • clippy on the lib and both changed examples, -D warnings (full matrix in CI)
  • Streaming acceptance (verify.py on the built stream_header and streaming_schedules): passed, including the new canonical case, header AC1015, locators [0,256,64] [1,0,0] [2,594,18]
  • coverage_report tests/fixtures/canonical: 25 / 0 / 0, every handle-map entry resolved
  • no_std and wasm32 kernel builds, check_invariants.py
  • No new unit tests.

Only the file header is valid in the spec sense here. The header-variable block is still placeholder zeros, locator 1 points at no class section, object-map and record CRCs are still wrong, and no AutoCAD build has opened the file; those follow in separate PRs.

The first run's Criterion benches vs main baseline failure was runner variance against a baseline cached on other hardware; #217 fixed the gate, and this branch is rebased onto it for a same-host measurement.

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-26T01:19:48.838048Z 6205f6b 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.

DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
The gate compared a PR run against a criterion baseline cached from the
last push to main. Hosted runners differ in CPU, so whenever the two ran
on different hardware every bench moved by a constant factor the
confirmation re-run cannot clear. PR #215 touched no benchmarked code
and still failed with lz77_decompress and stage1_build_section
1.35-1.78x slower on both passes; four dependabot PRs that only bumped
action versions failed the same way on October 21.

A PR run now checks out its merge-base with main in a second worktree,
benches it as baseline `main` into the same target directory, then
benches the merge commit as `pr`, so the ratio and absolute floor judge
code rather than hardware. Stale criterion output restored by
rust-cache is removed first. The baseline cache steps are gone; a push
to main just runs the benches. run-benches.sh skips a target the tree
being benched does not declare, so it also runs on an older merge-base.
build_flat_fixture wrote the §3.2 locator table into a zeroed buffer and
never emitted the CRC or the 16-byte end sentinel, so the canonical
synthetic_2000.dwg carried 0000 where the spec calculation gives 0x7813.
The generator now writes both, using the crate's own r13_locator_seed and
the sentinel constant the streaming header reader validates against; the
streaming reader drops its private copy of the seed table.

Regenerating changes only bytes 52-68 of synthetic_2000.dwg; offsets,
the five entities and the other four fixtures are unchanged. The
streaming acceptance run now reads that fixture through the strict
header entry point at every chunk size from 1 to 32 bytes.

Closes #214
@DrunkOnJava
DrunkOnJava force-pushed the fix/canonical-r2000-header branch from b914c29 to 6205f6b Compare October 26, 2026 01:17
@DrunkOnJava
DrunkOnJava merged commit cc64157 into main Oct 26, 2026
23 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/canonical-r2000-header branch October 26, 2026 08:42
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.

Canonical R2000 fixture omits the required file-header CRC and sentinel

1 participant