Skip to content

fix(entities): read TOLERANCE's §20.4.49 version branch the right way up (#226) - #262

Merged
DrunkOnJava merged 3 commits into
mainfrom
fix/226-tolerance
Oct 26, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
fix/226-tolerance

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Read TOLERANCE with §20.4.49's version branch the right way up. The unknown short, height and dimgap are R13-R14 only, and the DIMSTYLE handle is not a data-stream field. The 9 TOLERANCE records that errored on ACadSharp's R14, R2000 and R2004 saves now close. All 21 TOLERANCE records of the public corpus close, and on R2000 to R2018 their values equal the DXF twin. With #258 (TEXT/ATTRIB/ATTDEF) and #261 (MTEXT) this finishes #226.

Closes #226 (once #258 and #261 are merged; this PR is queued after them).

Spec reference

§20.4.49 TOLERANCE (46): R13-R14 only an unknown short, BD height and BD dimgap; then on every release 3BD insertion point, 3BD x direction, 3BD extrusion and the TV text; the DIMSTYLE handle is in the handle data.

The inline reader that serves R13 to R2004 had the branch upside down. It read the short only on R2007+ and the height and dimgap on every release, then read the handle inline, past the data-stream boundary. The R2007+ split-stream reader had already measured that those three fields are absent from R2007 on.

Records it was measured on

examples/probe_tolerance.rs (new) reports closure. It also compares insertion point, x direction, extrusion and text with the AcDbFcf group of the DXF twin by handle. Caret escapes are undone; omitted groups are counted, not assumed.

Release Records Close Values compared Differ
R14 3 3 no twin
R2000 to R2018 3 each 3 each 12 each 0

On R14 the three leading fields are 10 10 10 on all three records, the zero code of BS and BD. Their widths close the record, but their values corroborate nothing, and R14 has no twin.

C=~/Library/Caches/dwg-corpus/acadsharp
cargo run --release --example probe_tolerance -- $C/sample_AC1014.dwg
for v in 1015 1018 1021 1024 1027 1032; do cargo run --release --example probe_tolerance -- $C/sample_AC$v.dwg $C/sample_AC${v}_ascii.dxf; done

Coverage, ../../samples

Unchanged, TOTAL 3911 / 525 / 9. The 19-file corpus holds TOLERANCE only on R2018.

Public corpus: tools/corpus/baseline.tsv (regenerated, committed)

-sample_AC1014.dwg   acadsharp AC1014  676 461 105 ...
+sample_AC1014.dwg   acadsharp AC1014  679 461 102 ...
-sample_AC1015.dwg   acadsharp AC1015  914  82  51 ...
+sample_AC1015.dwg   acadsharp AC1015  917  82  48 ...
-sample_AC1018.dwg   acadsharp AC1018  850  74  90 ...
+sample_AC1018.dwg   acadsharp AC1018  853  74  87 ...

The 52-file total goes from 13781 / 1985 / 308 to 13790 / 1985 / 299 on its own. It will be regenerated on top of #258 and #261 in the serial rebase.

Class census and reference closure

Unchanged on all 19 files of ../../samples and in the 52-row baseline's census and closure columns.

Docs

  • docs/data/spec-coverage.tsv §20.4.49 → closes with the measurement; docs/spec-coverage.md regenerated.
  • ARCHITECTURE.md: new §7p.
  • src/entities/tolerance.rs: cites §20.4.49 (was "§19.4.44"). The struct docs say which fields are R13-R14 only, and that dimstyle_handle is not read.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test --release --all-features (real-file tests ran against ../../samples)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • tools/corpus/measure.py check passes against the committed baseline
  • Removes 1 existing unit test and changes 1; adds none. tolerance::tests::roundtrip_tolerance_r2010_includes_unknown_short is removed. It asserted an R2010 unknown short, height and dimgap that the split-stream reader and the corpus show are absent. roundtrip_tolerance_r2000 now builds the R13-R14 shape it was already writing: it writes the short, decodes as R14 and no longer writes an inline handle. Its two assertions on that handle are gone, because the handle is not a data-stream field. Its value assertions are unchanged.

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 §20.4.49 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1), on the corpus bytes, and on AutoCAD's DXF exports of the same drawings, read as data files (ACadSharp samples/ at c30a97ce, MIT, pinned by #225). No third-party 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.

… up (#226)

§20.4.49 makes TOLERANCE's unknown short, height and dimgap R13-R14
only, which the R2007+ split-stream reader had already measured. The
inline reader for R13 to R2004 had it upside down: the short only on
R2007+, the height and dimgap everywhere, then the DIMSTYLE handle read
inline past the data-stream boundary. Read as printed, the list closes
on all 21 TOLERANCE records of the public corpus, R14 to R2018, and the
insertion point and text equal AutoCAD's DXF export on R2000 to R2018.

The unit test that pinned the R2010 short, height and dimgap is
removed; the R2000 roundtrip now builds the R13-R14 shape it was
writing. examples/probe_tolerance.rs reproduces it; ARCHITECTURE.md
§7p records it.
@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-26T13:04:41.654840Z 5c781fb 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.

# Conflicts:
#	ARCHITECTURE.md
#	docs/data/spec-coverage.tsv
#	docs/spec-coverage.md
#	tools/corpus/baseline.tsv
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 13:05
@DrunkOnJava
DrunkOnJava merged commit 0504f01 into main Oct 26, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/226-tolerance branch October 26, 2026 13:17
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.

TEXT, MTEXT, ATTDEF, ATTRIB and TOLERANCE error on 199 R14 to R2004 records of the public corpus

1 participant