Skip to content

fix(entities): read §20.4.41's version-2 SAB envelope to its terminator (#228) - #283

Merged
DrunkOnJava merged 3 commits into
mainfrom
fix/228-acis
Oct 26, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
fix/228-acis

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Read version-2 ACIS envelopes. §20.4.41 says a binary (SAB) file follows with no length, and that it ends with a fixed terminator. The decoder refused version 2 outright, so the two 3DSOLIDs and one REGION of each of ACadSharp's R2004, R2007 and R2010 saves errored. All 9 now close. Part of #228; DIMSTYLE and HATCH follow, and VIEW is the oracle lane's.

Spec reference

§20.4.41 REGION (37), 3DSOLID (38), BODY (39), version 2: "Immediately following will be an acis file. Header value of 'ACIS BinaryFile' indicates SAB, otherwise it is a text SAT file. No length is given. SAB files will end with End\x0E\x02of\x0E\x04ACIS\x0D\x04data. SAT files must be parsed to find the end."

The envelope reader now reads a version-2 SAB file byte by byte up to that terminator. A version-2 text SAT file is refused with Unsupported rather than scanned for an end the spec says needs a parser, and any version other than 1 or 2 is a SectionMap error.

Records it was measured on

Release 3DSOLID 0xD65, 0xD6A REGION 0xD69
R2004 close close
R2007 close close
R2010 close close

Every SAB file opens with ACIS BinaryFile and ends on the terminator, and the record closes exactly at the data-stream boundary after the §20.4.41 tail. That tail is identical across the three releases, handle by handle: wireframe point 0xD65 (17.78, −220.85, 2.5), 0xD69 (24.99, −220.40, 0), 0xD6A (31.69, −220.11, 2.19); 4 isolines; no wires; no silhouettes. The SAB files themselves differ only in their ACIS file-version bytes and length (7,620 bytes for 0xD65 on R2004, 7,660 on R2007/R2010), since AutoCAD writes the ACIS version each target release reads. R2013 and later keep the SAB stream in the data-storage section (§7h) and were already closing.

C=~/Library/Caches/dwg-corpus/acadsharp
for v in 1018 1021 1024; do cargo run --release --example probe_decode_errors -- $C/sample_AC$v.dwg 3DSOLID; cargo run --release --example probe_decode_errors -- $C/sample_AC$v.dwg REGION; done   # 0 erroring

Coverage, ../../samples

Unchanged, TOTAL 4256 / 180 / 9 (the 19-file corpus holds ACIS only on R2018, in the data store).

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

sample_AC1018.dwg   850 74 90  →  853 74 87
sample_AC1021.dwg   834 76 15  →  837 76 12
sample_AC1024.dwg   851 57 15  →  854 57 12

measure.py check passes. Regenerated in the serial rebase.

Class census and reference closure

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

Docs

  • docs/data/spec-coverage.tsv §20.4.41 partial → closes; docs/spec-coverage.md regenerated.
  • ARCHITECTURE.md: new §7u. The three_d_solid.rs module and function docs record version 2.

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; adds none. three_d_solid::tests::version_two_is_refused asserted that a version-2 envelope is refused. The corpus disproves that: nine version-2 SAB records close.

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.41 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1), which gives both the SAB header and its terminator, and on the corpus bytes. 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.

…or (#228)

§20.4.41 gives a version-2 ACIS envelope as a SAB file written with no
length, opening with "ACIS BinaryFile" and ending with
End\x0E\x02of\x0E\x04ACIS\x0D\x04data. The decoder refused version 2, so
the two 3DSOLIDs and one REGION of each of ACadSharp's R2004, R2007
and R2010 saves errored. Read to the terminator, all nine close, and
the §20.4.41 tail after each is identical across the three releases. A
version-2 text SAT envelope, which the spec says needs a parser, is
refused. The unit test that pinned the version-2 refusal is removed.
ARCHITECTURE.md §7u records it; §20.4.41 moves to closes.
@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 🔄 Running since 2026-10-26T14:30:54.004146Z 7fb785b 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
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