Skip to content

feat(entities): route MINSERT (8) and decode §20.4.10's grid fields (#141) - #410

Open
DrunkOnJava wants to merge 56 commits into
mainfrom
fix/minsert-dispatch
Open

DrunkOnJava wants to merge 56 commits into
mainfrom
fix/minsert-dispatch

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

§20.4.10 and a decoder row in docs/spec-coverage.md claimed a MINSERT decoder (insert.rs), but no dispatch arm routed type 8, so the walk skipped every MINSERT record. insert::decode_minsert now reads the INSERT fields and then BS columns, BS rows, BD column spacing and BD row spacing, as §20.4.10 prints them, and the dispatcher routes the type (#141). Stacked on #355 (and so on #323): its commits come first; the MINSERT work is the commits feat(entities): route MINSERT, the adapted test, and docs: which drawings prove MINSERT.

Spec reference

ODA v5.4.1 §20.4.10 (MINSERT: the §20.4.9 INSERT fields, then BS 70, BS 71, BD 44, BD 45). R13-R14 write the three scales as plain BDs and R2000+ as BB data flags, which insert::decode already handles for INSERT.

Evidence

No MINSERT record is in the pinned corpus, so the evidence is the spec's own example and two local-only drawings:

  • The spec's own R14 example (§20.4.10.1): examples/spec_examples moves it from unhandled to closes on the record's boundary (tests/fixtures/spec-examples/r14-objects.tsv updated with --update, one cell).
  • Autodesk's own R13 sample STRUCTUR.dwg (sha256 a3210d7c1954eb9924b5786491dd08f26ec018bdfefe0ce63c7c8651210fa1ca, on all five R13 install-disc images; local evidence only per Griffin, never fetched by CI or committed, ARCHITECTURE.md §7au): both of its MINSERT records decode and close on their R13 boundaries. dump_decoded_entities (which gains a MINSERT arm) prints them as 2 and 3 columns with column spacings 0.256592 and 0.304431, row count 0 and row spacing 0. Across the five disc images the type appears as 10 records in 5 drawings, all one distinct drawing; 0 errored.
  • Where the disc drawings come from (so the evidence can be reproduced; local evidence only, never pinned, fetched by CI or committed): five third-party disc images on archive.org, auto-cad_202406 (AutoCAD-R13.ISO, AutoCAD-R13-C3.ISO, AutoCAD-R13-C4.ISO), acadr13de (R13c4a_update.iso, the German C4a update) and autocad.7z (autocad-r13-c4-beta4.iso). archive.org serves a file inside an image at https://archive.org/download/<item>/<iso>/<path with / as %2F>; STRUCTUR.dwg is at https://archive.org/download/auto-cad_202406/AutoCAD-R13.ISO/ACADCOM%2FSAMPLE%2FSTRUCTUR.DWG (377,049 bytes, sha256 above) and at the same path on the other four images. docs/data/r13-autodesk-disc-sources.tsv (new here) lists all 263 AC1012 drawings of the five images with item, ISO, path, size, sha256 and URL (68 distinct by sha256, listed in docs/data/r13-autodesk-discs.tsv). The images were never downloaded whole, so an ISO's own sha256 is not recorded (archive.org lists md5 and sha1 per file at https://archive.org/metadata/<item>). Each of the 263 drawings was fetched one request apiece on 2026-10-26 and matched its sha256; whether the items are still downloadable has not been re-tested since.
  • No pinned drawing moves: with this arm, measure.py check against the unchanged baseline passed (measured locally before the no-local-builds rule; CI's Corpus job is the gate now), so no pinned drawing holds a type 8 record, and the DXF oracle ratchet reports no agreeing count below its baseline.
  • docs/data/spec-coverage.tsv row 20.4.10 says which drawings prove it and keeps the state decoder: the only real records are local-only, and a closes state needs a corpus record.

One existing test is adapted, none added: fixed_entity_label_covers_every_body_arm listed code 0x08 among the codes that must have no label (it asserted MINSERT unhandled, the behaviour this PR disproves); 0x08 leaves that list.

Also in this branch, because main added exhaustive Version matches after Version::R13 existed: probe_dxf_entities, probe_dxf_classes and probe_dxf_tables map R13 to no DXF writer, as R14 (clippy --all-targets otherwise fails to compile them; the same fix #323 needs for probe_dxf_header).

Reproduce (on a machine with the discs; the spec-example run is in CI's Test job):

cargo run --release --example spec_examples
cargo run --release --features dxf-reader --example dump_decoded_entities -- STRUCTUR.dwg

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features, cargo test --release --all-features --no-fail-fast, cargo +1.85 check --all-features, spec_examples, spec_coverage --check, arch.py check, the corpus check, the DXF oracle ratchet and the header probe all passed locally on this head before Griffin's 2026-10-27 rule that tests and builds run only on GitHub runners; CI is the gate from here.
  • No unit test added; one existing test adapted (above).

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 (sha256 973628f3...504b) is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, or any copy of its example files) was consulted or imported.

My contribution is based on the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1), section 20.4.10, and on byte-level inspection of a drawing read as a data file through this crate and its probes; no other DWG implementation's source or comments were consulted.

Developer Certificate of Origin

I affirm that the contribution complies with the Developer Certificate of Origin 1.1.

… R13-R15 container (#119)

R13 shares the flat section-locator container, the unframed object stream
and the R13-R14 branches of the entity and object prologues with R14, so
every test the crate wrote as 'is R14' for one of those branches becomes
is_r13_r14().
…es, so its size field reaches 2034 (#213)

The walk refused any chunk whose size field passed 2032. That rejected 7
of 22 real R13 drawings and the AutoCAD-saved R14 and R2000 drawings of
ACadSharp, which hold chunks of 2033 and 2034 bytes. The streaming E2E
now walks one of each against an independent framing parse and the
legacy reader.
…§2.10)

The helpers read the R2000+ flag-then-value forms on every release, which
only agrees with the R13-R14 form when thickness is 0 and the extrusion is
(0,0,1). Measured on Cabin.dwg: 18 LINE and 2 POLYLINE_2D records with a
non-default thickness or extrusion now end exactly on their RL boundary.
The synthetic R14 LINE of tests/integration_legacy_container.rs wrote the
one-bit defaults the old reader assumed; it writes the BD and 3BD §2.8 and
§2.10 print.
§20.4.44 prints 'R14 Only' for the RC after Numitems; R13 writes nothing
there. 88 R13 DICTIONARY records missed their RL boundary (by 8 bits
when the dictionary is empty).
…over the R13-R14 branches added since (#119)

header_vars.rs matched Version exhaustively, so the R13 variant needs its
own arm: the table already carries the R13 rows. MTEXT's and LWPOLYLINE's
R13-R14 branches (#261, #264) were written as 'is R14'. Cabin.dwg's 195
header slots end on the stated size; the probe also reports the 21 Sovol
headers, which hold 84 bits more than any table reads.
, #119)

The 21 Sovol R13 drawings write the four 'R14+' unknown shorts of §9 (each
-1; §9 says they 'do not seem to be required') after the R13 slots, and size
the header one byte past the byte holding the last slot, so the R13 rows
left 84 bits and the Corpus job's header probe failed on them. An AC1012
header whose R13 rows leave a whole byte or more is now read with the R14
rows and may end one byte before its data; Cabin.dwg and every other release
read as before. All 22 R13 headers, 199 slots on the Sovol drawings, now
decode to the stated size.
… header-variable failure (#119)

The header-variable arm printed FAIL without setting the exit status, so a
drawing that passed the framing checks but did not decode to its stated end
reported success. Every failure line now goes through one emit that sets it,
including a file that fails to open and a missing object map or header.
Conflicts: ARCHITECTURE.md (the R13 section is 7ac, after main's 7ab),
docs/data/spec-coverage.tsv and docs/spec-coverage.md (my row notes appended
to main's, §3 and §23 kept), src/entities/dispatch.rs (main's R13/R14
DIMSTYLE arm kept as main wrote it; the BT/BE decode_for routing kept), and
tools/corpus/baseline.tsv regenerated: main's rows unchanged, 22 R13 rows
added.
…LE and LEADER (#119)

TEXT (and so ATTRIB and ATTDEF), VIEWPORT, the R13/R14 DIMSTYLE block and
LEADER tested the R13-R14 branch as Version::R14 only, so every R13 record
of ATTRIB, ATTDEF, DIMSTYLE and LEADER took the R2000+ field list and
missed its boundary: 439 errored records across the 22 R13 drawings, none
on any other release.

LEADER's Endptproj is "R14+" in section 20.4.47: R13 skips it and the
field is the zero vector there. Read on R13, none of the 42 Sovol LEADERs
closes; skipped, all 42 do.
… the R14 files (#119)

baseline.tsv: the decoded and errored columns of the 22 R13 rows, nothing
else. ARCHITECTURE.md 7ad, spec-coverage notes for 20.4.3, 20.4.4, 20.4.5,
20.4.38, 20.4.47 and 20.4.68.
…R14 (#119)

#320 matched Version exhaustively; the AC1012 variant it was written
without made clippy --all-targets fail on the merged tree.
…cator layout still waits for Autodesk's discs (#345)
…sha256 and what was read (#119, #345)

Griffin decided on 2026-10-26 that these drawings are measured and cited,
never pinned, fetched by CI or committed. docs/data/r13-autodesk-discs.tsv
has one row per distinct drawing; the ARCHITECTURE section cites the 3- and
4-locator layouts, the 195-slot ceil(bits / 8) header, the padding spread and
the real previews from it.
…does (#119)

trace::decode never took the version, so TRACE kept the R2000+ flag-then-
value forms of thickness and extrusion on R13 and R14: the 3 TRACE records
of the US Forest Service R13 drawings errored. SOLID got decode_for in the
R13 reader; TRACE shares SOLID's stream (section 20.4.36) and takes it too.
…141)

Section 20.4.10 and a decoder row in the coverage page claimed a MINSERT
decoder, but no dispatch arm routed the type, so the walk skipped every
MINSERT. insert::decode_minsert reads the INSERT fields, then BS columns, BS
rows, BD column spacing and BD row spacing. The spec's own R14 example moves
from unhandled to closes on its boundary; 2 MINSERT records on Autodesk's
install discs (local evidence) close; no pinned drawing moves.
…119)

#371 matched Version exhaustively; the AC1012 variant it was written
without made clippy --all-targets fail on a tree with Version::R13.
…XF writer, as R14 (#119)

Both match Version exhaustively, so clippy --all-targets fails on a tree
with Version::R13, as it did for probe_dxf_header and probe_dxf_entities.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T19:14:35.893433Z ca6c127 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 627abecc93

ℹ️ 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".

Comment thread src/version.rs
return Err(Error::NotDwg { got: *magic });
}
Ok(match magic {
b"AC1012" => Self::R13,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep R13 conversions out of the handle-based DXF exporter

For an R13 drawing with a closed header and decoded layers, accepting AC1012 also enables a DXF conversion path that cannot read its entity references. src/dxf_entities.rs::writes excludes only Version::R14, so src/dxf_convert.rs::convert_dwg_to_dxf selects the handle-based exporter for R13. However, src/tables/block_record.rs::handle_stream_start returns None for R13 records: neither the modern trailer nor RawObject::obj_size_bits supplies an anchor. Consequently, entity_refs fails for every entity, the exporter skips all geometry, and the converter returns without using its primitive fallback. Extend the exporter eligibility guard to exclude R13 until its handle references are supported.

Useful? React with 👍 / 👎.

…ies and probe_dxf_tables map R13 to no DXF writer, as R14 (#119)

Main matches Version exhaustively in the three probes, so clippy
--all-targets does not compile them once Version::R13 exists.
dxf_entities::writes, the layer and VPORT guards of dxf_tables, entity_refs
and DIMSTYLE's decode_with_vars tested Version::R14 alone where the comment
says R13 and R14. Not measured: they act only when an R13 drawing is
converted to DXF, and none has a DXF twin.
… evidence can be reproduced (#141, #345)

docs/data/r13-autodesk-disc-sources.tsv: the archive.org item, ISO file, path in
the ISO, size, sha256 and URL of each of the 263 AC1012 drawings on the five
disc images, recorded as local evidence only (never pinned, fetched by CI or
committed). The MINSERT coverage note cites STRUCTUR.dwg's URL.
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
* fix(ci): hold a stacked PR until the older PR it builds on lands

A PR stacked on an older open PR targets main but holds that PR's commits. When the train held the
older PR on a review thread it went on to the next one: landed first, that PR would have carried the
older one's work into main under its own title (#337 over #335, #339 over #337 were drafted by hand
to stop it), and its refresh merged main over the older PR's commits, so after that PR landed its
merge base no longer applied and a lane had to merge it by hand. The train now sends such a PR to
the end of the queue while an older open PR (a lower number) shares commits with it that main does
not have. On the queue of 2026-10-28: #324 waits for #323, #355 for #324, #356 for #355, #410 for
#356, #412 for #410, #339 for #337 and #341 for #339; #323, #337, #389 and #296 wait for nothing.

* fix(ci): check every open PR, skip landed work, and defer on a failed lookup

The stack check listed at most 200 open PRs, only those targeting main, treated any shared commit as
outstanding even when it belonged to a PR that had already landed by squash, and let a PR through
when a fetch or gh call failed. It now fetches every PR head to refs/train/pr/<n> in the main clone,
pages through all open PRs whatever they target, ignores a shared commit that a merged PR's head
holds, and returns 2 on any failed lookup, which sends the PR to the end of the queue. Checked in a
scratch repository (two PRs built on a landed PR do not wait for each other; a PR built on another
waits for it; a failing gh returns 2) and on the live queue, where the R13 and unp stacks give the
same order as before.

* fix(ci): count only PRs merged into main as landed when checking a stack

A PR merged into a feature branch has merged_at set too, so its commits were treated as landed and a
newer PR holding them went ahead of the open PR they were waiting in. The exemption now takes only
PRs whose base is main. All 187 merged PRs so far target main, so the live order is unchanged.

This branch has not been deployed

No deployments
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