Repository navigation
fix(classes): write_class_map reproduces AutoCAD's AcDb:Classes byte for byte (§10.1, §10.2, #45) - #405
Merged
Conversation
…for byte (§10.1, §10.2, #45) The writer was the inverse of ClassMap::parse and nothing more: the size in bits lacked the 32 real files add, the string-stream trailer was missing, R13 to R15 opened with a BL and a B that §10.1 does not have, the CRC began at the sentinel, the end sentinel and the eight zero bytes after it were absent, pre-R2007 names carried no terminating NUL and the padding bits were clear. examples/probe_class_roundtrip.rs reads each drawing's section, parses it, writes it back for the drawing's own release and compares the bytes. Before: 0 of the 52 pinned drawings match. After: 52 of 52, and 61 of 61 over the whole local corpus cache.
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: 60f75853cd
ℹ️ 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".
# Conflicts: # ARCHITECTURE.md
…ng's code page and fails strict on what it cannot compare (#45) The probe parsed and wrote class names under the default code page, so a pre-R2007 drawing with non-ASCII names measured an encoding mismatch rather than the writer. Both now run inside with_code_page(file.code_page()). --strict stayed green when a drawing could not be opened, its section could not be read, or its classes did not parse, because only a byte difference set the flag. Those are counted separately from a drawing that has no AcDb:Classes section, fail strict, and so does a run in which nothing matched, so a parser regression that empties every class map turns it red.
… Corpus job (#45) The class-table writer's byte-exactness rested on local runs from before builds moved to the runners. The Corpus job now runs the probe on the fetched corpus, fails on a difference, an unreadable drawing or a run in which nothing matched, and uploads class-roundtrip-probe.log in the corpus-measurement artifact. ARCHITECTURE.md names that run as the record and labels the earlier figures as local.
# Conflicts: # ARCHITECTURE.md
DrunkOnJava
enabled auto-merge (squash)
October 27, 2026 22:42
DrunkOnJava
added a commit
that referenced
this pull request
Oct 27, 2026
… and the double-byte round trip (#414) landed
4 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Oct 28, 2026
…10-27 (#416) * docs: bring README, ROADMAP and CHANGELOG up to the landings of 2026-10-27 README's code-page and DXF writer text named work in review that has landed (#371, #380, #382, #384); jev_review.py prose ranked those sentences 0.72 to 0.96. ROADMAP's "where it stands" table was a 2026-10-21 snapshot whose numbers, CI row and release row were all out of date; it now points to the rendered numbers instead of repeating them. CHANGELOG gains #371, #380, #382, #384, #385 and #404. * docs(changelog): record the CI-only merge train (#408) * docs: OBJECTS landed (#372): README, ROADMAP and CHANGELOG * docs: LAYOUT, GROUP and MLINESTYLE (#373), the class map writer (#405) and the double-byte round trip (#414) landed * docs: VISUALSTYLE landed (#413) * docs(readme): name the skipped types still in review without per-type counts; MATERIAL landed (#325) * docs(readme): point to the open decoder PRs instead of a list that each landing makes stale
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
write_class_mapnow writesAcDb:Classesthe way AutoCAD does, byte for byte: on all 61 pinned drawings, R14 to R2018 (the Corpus job's run, reported below), reading the stored section, parsing it and writing it back gives the same bytes. Closes #45.Spec reference
ODA v5.4.1 §10.1 (R13 to R15) and §10.2 (R18 and later), with the fields the spec leaves open taken from AutoCAD's own pinned drawings. #45 and its 2026-10-25 note named some of the departures (the size in bits lacked the 32 real files add, the string-stream trailer was missing, the CRC began at the sentinel, R13 to R15 opened with a
BLand aB, and the R2010 and R2013 CRC rule was unmeasured). The probe settled each against real files and found the rest:RLalong with the stream;BLmaximum and noBbefore the first record;BSlength counts (read_tvdrops it);RSwords (sample_AC1032.dwg: 45,804 bits).The layout table and what each rule rests on is the new
ARCHITECTURE.md§7ax.Test plan
CI is the evidence. The first five items were run locally before builds moved to the GitHub runners; the checks on this head replace them.
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,cargo test --release --all-features(767 library tests, every integration file) andRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurespassed locally;python3 tools/ci/spec_coverage.py --checkandpython3 tools/maintainer/train/arch.py checkpassexamples/probe_class_roundtrip.rswith--stricton every pinned drawing (step "Class table written back byte for byte on every pinned drawing", logclass-roundtrip-probe.login thecorpus-measurementartifact). Its module doc says what it proves. The run on head39fe95b, https://github.com/DrunkOnJava/dwg-rs/actions/runs/40592472261, reports:The earlier figures in this PR (52 of 52 on the drawings pinned then, 61 of 61 over my local corpus cache) were pre-ban local runs;
tools/corpus/pins.tsvnow pins all 61 (acadsharp10,bookviewerapp34,nextgis42,oshw-jetson4,planar-algorithm1) and the CI run above is the record: 61 of 61 match, none differs, fails or cannot be opened. The run'scorpus-measurementartifact holds the whole log, one line per drawing.Before this change the probe, built against the old writer on the previous
mainand run locally on the 52 drawings pinned then, matched 0 of 52, the first differing byte 16 (the size word) on every drawing. That is the only figure here not reproduced by CI, since CI runs the branch's writer only.Where a drawing differs the probe names the first differing byte, the part of the section it falls in and both values.
--strictfails on a difference, on a drawing it cannot open, read or parse, and on a run in which nothing matched, so a parser regression that empties every class map fails the job. Pre-R2007 names are read and written under the drawing's own code page.An independent Python port of the same layout, written from the measured bytes and not from the Rust, also reproduced all eight files it was tried on (local).
Not measured: R13 (AC1012), the corpus holds no AutoCAD-written file; it is written by the R14 rule. The two unknown
BLs of an R2004+ record and theBafter the maximum class number are written as0andtrue; every pinned section matches with those values.Existing tests changed
Two unit tests in
src/classes.rspinned the old layout and move with it (no test added): the empty-table test now expects 51 bytes (sentinel, size, stream, CRC, end sentinel, eight zeros), and the R2010 header test expects the size word 11, the bit size 52 + 32 and a length 10 bytes longer than R2004's (8 of header, 2 of trailer).write_tvalso keeps the code-page encoding from #382 (merged into this branch's base): the encoded bytes now carry the terminating NUL on R2004 and earlier.Source provenance: ODA v5.4.1 §10 and the pinned public drawings (AutoCAD output) read by the probe. No algorithm-description comments from any other project were read, so there is nothing to add to
CLEANROOM.md.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:
CLEANROOM.md).dwg-rsis Apache-2.0 and must remain compatible.My contribution is based on:
CLEANROOM.md.See
CLEANROOM.mdfor the full allowed/forbidden source list and the honest scope of what "clean-room" means for this project.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.
I will sign off commits with
git commit -swhen asked, which adds aSigned-off-bytrailer to the commit message asserting the DCO.