Repository navigation
feat(entities): decode the §20.4.41 ACIS record and settle the AcDs marker - #67
Merged
Merged
Conversation
…arker REGION (37), 3DSOLID (38) and BODY (39) are one entry in the ODA specification and one field list here. The crate read only the ACIS envelope's first bit; the rest of §20.4.41 — the wireframe / point / isoline block, the wire and silhouette structures, the second ACIS-empty bit and the R2007+ trailing BL — is now decoded, and the three types dispatch through the boundary-checked entity path. All three ACIS records of the corpus (sample_AC1032.dwg 3DSOLID 0xD65 / 0xD6A, REGION 0xD69, R2018) set the R2013+ `has AcDs binary data` bit, so their SAB stream is a data record in the data-storage section (§24.2.2.3) and no inline envelope is written. After the spec's grammar they carry 137 further bits: seven whose tokenisation the corpus cannot separate, a 16-byte revision GUID, and a BL. The list closes at delta 0 on all three, corroborated by three real coordinate triples at y ≈ -220, `num isolines = 4` (AutoCAD's ISOLINES default) on every record, and a valid RFC-4122 version-4 UUID at the one 128-bit alignment all three share. That closes #54. The `has AcDs binary data` flag is followed by nothing: common_entity.rs and objects/modern.rs now agree on 0 bits, and the 16 bits four R2018 LAYOUT records need moved into acad_layout.rs as LAYOUT's own data-store block, still closing all 31 corpus LAYOUTs. tables/modern.rs keeps its RC — that path also omits the BL reactor count, so its accounting has a second unresolved variable. Two spec-conformance fixes fell out of the same section: the envelope now reads the `B unknown` bit between the empty bit and the version, and its block loop terminates on a zero block size instead of a fabricated per-block flag. Version 2 (a raw ACIS file with no length) is refused rather than mis-stepped. Measured on the 19-file corpus: | slice | before | after | |---|---|---| | R2018 (AC1032) × 1 | 762 / 80 / 0 / 90.5% | 765 / 77 / 0 / 90.9% | | aggregate | 2187 / 191 / 0 / 92.0% | 2190 / 188 / 0 / 92.1% | Closes #61 Closes #54 Claude-Session: https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_0977bd8f-924a-4bbd-887f-c2f036d78fb2) |
This was referenced Aug 30, 2026
Closed
4 of 6 tasks
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
Decodes the whole §20.4.41 ACIS record —
REGION(37),3DSOLID(38),BODY(39) — and uses the three records that carry it to settle the width of the R2013+has AcDs binary datamarker (#54), which this crate had been reading three different ways.Spec reference
§20.4.41 REGION (37) / 3DSOLID (38) / BODY (39) prescribes one record shape for all three, and §24.2.2.3 explains what R2013 changed: "For each ACIS entity (REGION, 3DSOLID), a data record is created with the SAB stream of the object." The geometry payload leaves the entity record and becomes a data record in
AcDb:AcDsPrototype_1b, flagged by the record'shas AcDs binary databit.The field list
The corpus holds exactly three ACIS records, all in
sample_AC1032.dwg(R2018), and all three set that bit. Measured from bit 82 — where the common entity preamble ends on all three — to each record's data-stream boundary:The inline ACIS envelope is absent: only two bits stand between the preamble and the point, and both are 1.
0xD65(17.7767…, -220.8501…, 2.5)833111a1-b7ac-4dd4-824d-78b33668f9e70xD69(24.9857…, -220.4000…, 0)2b80e3b3-b594-475e-8593-6a36b15e79450xD6A(31.6857…, -220.1073…, 2.1902…)f21ff2a0-ff9c-4ed1-9b2e-7a1e6518d595Four corroborations independent of the arithmetic:
y ≈ -220,xstepping17.8 → 25.0 → 31.7. Every rejected candidate produced1e+88-scale doubles instead.num isolinesis 4 on all three — AutoCAD's defaultISOLINESvalue.4, variant bits10). Scanning every 128-bit window of all three records,data_end - 130is the only alignment where all three satisfy both; three independent windows doing that by chance is 1 in 2^18.Only the width of the seven bits before the GUID is measured. The three records agree on
1, 0for the first two slots and differ after, soB, BB, BB, BBis a labelling, not a measurement, and the module says so. The per-wire and per-silhouette payloads are stepped exactly but not surfaced — no corpus record carries any, so structs for them would be API no byte has exercised.The #54 arbitration
#52 measured 16 bits after the flag on four LAYOUT records;
tables/modern.rsmeasured anRCon DIMSTYLE;common_entity.rsread 0, untested, because no entity record whose field list closed had ever set the bit. These three ACIS records are that missing case.examples/probe_acis_records.rsre-reads the preamble at each candidate width and runs §20.4.41 from wherever it lands:colour 0x0100, lts 1.0, invis 0, lw 0x1DBDpattern11)colour 0xEE10, lts 0(or1.5e119),lw 0x10 / 0x12 / 0xBCBoth halves fail together at every non-zero width. At 0 bits the preamble decodes exactly the values every other entity in the file carries — BYLAYER colour
0x0100, linetype scale1.0, invisibility0, lineweight0x1D; at 16 bits it decodes none of them, and the field list is then short of its boundary.Verdict: the flag is a flag — nothing follows it.
common_entity.rsandobjects/modern.rsnow agree on 0 bits. The 16 bits four R2018 LAYOUT records need moved intosrc/objects/acad_layout.rsas LAYOUT's own two-byte data-store block at the head of its §20.4.84 list, still conditional on the flag and still closing all 31 corpus LAYOUT records.tables/modern.rskeeps itsRC: that path also omits theBL num_reactorsthe object path reads, so its bit accounting has a second unresolved variable and is out of scope here. Three record types needing three different widths is itself the argument that the width belongs to the record, not to the flag.Two spec-conformance fixes that fell out
The envelope reader carried two departures from §20.4.41 that no corpus record had ever reached:
B unknownbit betweenACIS emptyandBS versionwas not read at all;B has_more_blocksflag before eachBL block size, where the spec terminates the loop on a block size of0and has no such flag.Both are corrected, and version 2 — "immediately following will be an acis file … no length is given" — is now refused rather than mis-stepped. Four surface tests that had written the old shape are updated.
Measured coverage
cargo run --release --example coverage_report -- ../../samples, 19-file corpus, re-measured on the merged tree (origin/main=7418d25, merge is a no-op — already up to date):7418d25)Zero errored records, before and after. Every previously-closed decoder still closes, including all 31 LAYOUT records after their 16 bits were relocated.
Test plan
cargo fmt --all -- --checkpassescargo clippy --all-targets --all-features -- -D warningspassescargo test --releasepasses — 741 lib tests (+7), all integration suites greenRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurespassescargo deny check allpassescargo +1.85.0 test --no-runpasses (MSRV)BitWriterround-trip tests for the data-store record, the inline-envelope record, exact wire/silhouette stepping, and the absurd-count rejectionsample_ac1032_acis_records_close_on_their_boundarypinsin_data_store,num_isolines == 4,y ≈ -220, and the RFC-4122 version/variant nibbles of each GUIDSource-provenance declaration
Clean-room declaration. I certify that:
CLEANROOM.md— the ODA's freely-redistributable Open Design Specification for .dwg files v5.4.1 (§20.4.41 for the record shape, §24.2.2.3 for the data-storage semantics, §20.4.1 for the common entity data) and the bytes of publicly-available DWG files. In particular I did not consult Autodesk SDK source, ODA SDK (Drawings SDK / Teigha) source, LibreDWG source, decompilations of Autodesk or ODA binaries, or any copyleft-licensed DWG implementation code.unknown_*; only their width is claimed.CLEANROOM.mdrecords this.By submitting this PR I also certify compliance with the Developer Certificate of Origin 1.1.
Closes #61
Closes #54
https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C
Note
Medium Risk
Changes bit accounting on common entity/object prefixes and adds substantial ACIS field parsing; misalignment would corrupt geometry, but decoders self-check against data-stream boundaries and corpus tests pin the three R2018 ACIS records and LAYOUT closure.
Overview
Implements the full §20.4.41 record for REGION, 3DSOLID, and BODY (shared
modelerpath): wireframe/isoline tail, optional inline SAT envelope, and the measured R2013+ data-store block (revision GUID) whenhas AcDs binary datais set. 3DSOLID, REGION, and BODY are now first-classDecodedEntityvariants with boundary-checkeddecode_recordon R2010+.#54: The R2013+
has AcDs binary databit is treated as a flag with no following bits on the entity path (common_entity). The 16 bits previously consumed inobjects/modernfor LAYOUT move intoacad_layoutas a conditional two-byteds_blockat the start of §20.4.84; object prefix only records the flag viahas_ds_binary_data.ACIS envelope reading is aligned with the spec: read the unknown
B, terminate the version-1 block loop onBL == 0(nohas_more_blocks), and reject version 2 instead of guessing length.Adds
probe_acis_records, real-DWG regression onsample_AC1032.dwg, and updates coverage docs (2190 decoded / 188 skipped / 92.1% aggregate; R2018 765 / 77 / 90.9%).Reviewed by Cursor Bugbot for commit b28f62d. Configure here.