Skip to content

test(fixtures): run the specification's own worked examples through the crate (#107) - #280

Merged
DrunkOnJava merged 3 commits into
mainfrom
test/107-spec-examples
Oct 26, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
test/107-spec-examples

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Runs every worked example and printed table of the ODA specification through the crate's public code (examples/spec_examples.rs, a new step in CI's Test job), on fixtures quoted verbatim from the PDF with page numbers (tests/fixtures/spec-examples/), regenerated and audited by tools/spec/extract_examples.py. Closes #107.

Spec reference

ODA Open Design Specification for .dwg files v5.4.1 (sha256 973628f3…f504b): §2.2, §2.3, §2.6, §2.7, §2.13, §2.14, §3.2.6, §4.1, §4.7, §5.10.1, §9, §10.1 and every §20.4.N.1 example.

What was collected, and what the crate reproduces

Spec Collected Crate path Reproduced
§2.2 BS, §2.3 BL, §2.6 MC ×3, §2.7 MS, §2.13 H, §2.14.1 CRC layout (p7-15) 8 bit streams BitCursor 8 / 8, each consuming exactly the printed stream
§2.14.1, §2.14.2 (p15-18) CRC-8 and CRC-32 tables crc::crc8, crc::crc32 256 / 256 each
§3.2.6 (p20) locator-CRC XOR values crc::r13_locator_seed 4 / 4
§4.1 (p23) magic sequence cipher::magic_sequence the 92 printed bytes
§3.2.6, §9, §10.1 (p21, 70, 80, 84) 5 sentinels reader and streaming constants 7 / 7 constants
§4.7 (p34) 2 literal lengths, 2 long compression offsets lz77::decompress and streaming::Lz77Decoder 4 / 4 in both
§5.10.1 (p54-55) 32-row literal copy table r21_lz::decompress 32 / 32
§9 (p80-83) complete R14 file header, 0x245 bytes R13R15Header, crc8, streaming::FlatWalker, HeaderVars locator CRC, section CRC, sentinels, walker, and the first four BDs equal §9's printed defaults
§20.4.N.1 (p109-240) 78 R13/R14 object records in 77 sections ObjectWalker, decode_from_raw 78 / 78 type, length, handle, CRC; 44 close on their own RL boundary, 17 error, 4 have no decoder, 13 are class-numbered (walk and CRC only)

91 worked examples and 6 tables in all. The spec prints no decoded values for the §20.4 dumps, so "close" there is the crate's boundary check on the spec's bytes. r14-objects.tsv's expect column holds each outcome, and the example fails when any moves in either direction.

Disagreements and how each was resolved

To decide spec erratum vs. crate bug for the §20.4 records, each failing record was decoded with the spec's own R13-R14 field list. It closed exactly on 16 of the 18 records that erred when this was written, so those are crate bugs; the other 2 (RADIUS, TOLERANCE) close only with a correction to the spec, so they are spec errata that the crate also misreads. It also closes on the MINSERT and SHAPE examples, which have no decoder.

Spec errata (recorded in ARCHITECTURE.md §7k):

  • §2.3, p8: says "reading 5 longs"; the stream and its parse hold four.
  • §4.1, p23: prints 92 of the 0x6C bytes it says to XOR; its own generator gives the rest.
  • §20.1, p101: states no seed for the record CRC; all 78 examples use 0xC0C1.
  • §20.4.28, p126: RADIUS omits the BD leader length that DIAMETER prints; its example closes only with it.
  • §20.4.49, p155: TOLERANCE's text is a TV, not a BS, and the R13-R14 record has one more leading BD; its example closes only with both.

Crate disagreements (decoder code, so filed or commented rather than fixed here):

Found alongside, not a worked example: #275 (new). src/reed_solomon.rs decodes R2007 system pages with 0x11D, §5.13's data-page polynomial; on line_2007.dwg's header page all three codewords verify under §5.13's system polynomial 0x169 and none under 0x11D. The reader does not call the module. The fix will be a separate PR.

When a decoder PR moves an example

Once this is on main, CI's Test job fails any PR that changes a §20.4 example's outcome until its expectations are updated. One command does it:

cargo run --release --example spec_examples -- --update

It rewrites each moved expect cell in r14-objects.tsv, the matching "The spec's own example …" sentence in docs/data/spec-coverage.tsv, and docs/spec-coverage.md (through tools/ci/spec_coverage.py --write), then lists what moved. Commit those files in the same PR. A record that newly errors is written error #? and keeps failing until its tracking issue is filled in, so a regression cannot be recorded silently.

Measured on every open decoder PR's head (#249 and #258 at their own heads, since they conflict with main): none turns a closing example into an error, and these flip from error to closes. Whichever lands second runs --update.

PR Examples that flip to closes
#263 (merged; recorded here), #279 §20.4.60 VIEW
#267 §20.4.9 INSERT; §20.4.23, .24, .25, .26, .28, .29 dimensions; §20.4.32 3DFACE
#262 §20.4.49 TOLERANCE
#261 §20.4.46 MTEXT
#258 §20.4.3 TEXT, §20.4.4 ATTRIB, §20.4.5 ATTDEF
#249 §20.4.47 LEADER
#247, #252, #264, #270, #278, #281 none

With all of them in, the §20.4 examples move from 44 close / 17 error (on main with #263) to 58 / 3. The three left are #272, #273 and #274.

What does not run, and why

docs/data/spec-coverage.tsv notes now give each exercised section's result; no state changes, since states are defined over corpus records. Its page column agrees with the PDF's section headings on all 139 rows.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --release --all-features
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • cargo +1.85 build --release --all-features --example spec_examples
  • cargo run --release --example spec_examples: OK: 417 checks, every result matches its fixture (on main at 2a219bd, with fix(tables): read the pre-R2007 VIEW record as §20.4.60 gives it #263)
  • --update: a no-op on this tree; a simulated flip is rewritten and the docs come back byte for byte; a simulated regression is written error #? and fails
  • python3 tools/spec/extract_examples.py --pdf <spec.pdf> --check: ok (every fixture equals the PDF; every hand-transcribed quote is on its page)
  • python3 tools/ci/spec_coverage.py --check
  • No new unit tests; no src/ change.

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. This matters because dwg-rs is Apache-2.0 and must remain compatible.

My contribution is based on:

No other project's code or comments were read.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the
Developer Certificate of Origin 1.1.
Specifically, I affirm that the contribution is my own work (or rightfully
licensed to me) and that it can be distributed under the project's Apache-2.0
license.

@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-26T11:46:23.950243Z 36fde6e 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
DrunkOnJava force-pushed the test/107-spec-examples branch 2 times, most recently from 0171209 to 807c58c Compare October 26, 2026 11:44
…he crate (#107)

examples/spec_examples.rs runs every worked example and printed table of ODA spec v5.4.1 through the crate's public code: the §2 bit streams, the §2.14 CRC tables, §3.2.6, §4.1, §4.7, §5.10.1, the §9 R14 header dump and the 78 §20.4 R13/R14 object dumps. The fixtures quote the PDF verbatim with page numbers; tools/spec/extract_examples.py regenerates and audits them. CI's Test job runs it, and r14-objects.tsv's expect column fails the run when any outcome moves.

Five spec errata are recorded in ARCHITECTURE.md §7k; the crate disagreements are tracked in #71, #226, #227, #256, #272, #273 and #274.
@DrunkOnJava
DrunkOnJava force-pushed the test/107-spec-examples branch from 807c58c to 36fde6e Compare October 26, 2026 11:45
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 11:53
@DrunkOnJava
DrunkOnJava merged commit 4354527 into main Oct 26, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the test/107-spec-examples branch October 26, 2026 12:00
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.

The spec's worked examples as fixtures

1 participant