Skip to content

fix(entities): R13 takes the R13-R14 branch of TEXT, VIEWPORT, TRACE, DIMSTYLE and LEADER (#119) - #355

Open
DrunkOnJava wants to merge 47 commits into
mainfrom
fix/r13-later-decoders
Open

DrunkOnJava wants to merge 47 commits into
mainfrom
fix/r13-later-decoders

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

R13 takes the R13-R14 branch of TEXT (so ATTRIB and ATTDEF), VIEWPORT, TRACE, the R13/R14 DIMSTYLE block and LEADER, and skips LEADER's end point projection, which §20.4.47 files under "R14+" (#119). Before this, 439 records of the 22 pinned R13 drawings errored in decoders main gained after #323's branch began (#258, #297, #249); the AutoCAD-written R13 drawings found since (#345) error far more: 7,354 records on the 122 US Forest Service drawings and 13,182 on the 68 distinct drawings of Autodesk's own R13 discs. None errors on any other release, and after this PR none errors on R13. Stacked on #323 (its commits come first; the diff of this PR alone is the last commits).

Spec reference

ODA v5.4.1 §20.4.3 (TEXT), §20.4.4, §20.4.5, §20.4.36 (TRACE: SOLID's stream), §20.4.38 (VIEWPORT ENTITY: every field after the height is "R2000+"), §20.4.47 (LEADER: Endptproj "R14+", DIMGAP "R13-R14 Only"), §20.4.68 (DIMSTYLE's "R13 & R14 Only" block), §2.8 and §2.10 (BT and BE). Findings and evidence: ARCHITECTURE.md §7av and the notes of docs/data/spec-coverage.tsv. Boundaries only, as in #323: no AutoCAD DXF of an R13 drawing exists, so no row changes state.

What changes

  • text.rs, viewport.rs, dispatch.rs (the DIMSTYLE arm) and leader.rs ask is_r13_r14() instead of testing == Version::R14 / matches!(.., Version::R14). On R13 LEADER's end_point_projection is the zero vector and no bits are read for it.
  • trace::decode_for: TRACE shares SOLID's stream, and trace::decode never took the version, so TRACE kept the R2000+ forms of BT and BE on R13 and R14 (the bug feat(container): open and walk AC1012 (R13), pinned on 22 real drawings (#119) #323 fixed for SOLID, ARC, CIRCLE, POINT and the polylines).
  • Five more guards that main gained after the swaps above tested R14 alone where their comment says "R13 and R14", and now read is_r13_r14(): dxf_entities::writes, the layer and VPORT guards of dxf_tables.rs, entity_refs and DIMSTYLE's decode_with_vars. Not measured: they act only when an R13 drawing is converted to DXF, and no R13 drawing has a DXF twin nor does any CI step convert one; they are a sweep result, not a count.
  • Six probes (probe_mtext, probe_xrecord, probe_material, probe_acis_records, probe_visualstyle_layout, trace_table_entry) get the same swap, so they stop treating R13 as R2000+.
  • New examples/probe_r13_census.rs: per record type, the records, drawings, and how many decoded, errored or had no decoder; non-zero exit when a drawing does not open or has no walk.
  • tools/corpus/baseline.tsv: the decoded and errored columns of the 22 R13 rows, nothing else.

Sweep for R14-only tests

On current main plus #323 the only R13-R14 branches still written as R14-only were TEXT, VIEWPORT, DIMSTYLE, LEADER and TRACE. The remaining Version::R14 in src/ is intentional: DICTIONARY's unknown byte (§20.4.44, R14 only), the R14 header variable table, and the version identity matches (file_writer.rs, classes.rs, header_vars.rs, dwg_write.rs). Of the open PRs only #319 adds one: ACAD_TABLE's read_head tests matches!(version, Version::R14) for three BD scales its §20.4.96.1 head gives "on R13 and R14". None of the R13 drawings declares an ACAD_TABLE class (ACadSharp's R14 sample holds two), so that branch cannot be measured on R13. Per the coordinator's plan I did not touch #319's branch: once #319 and #323 are on main, this PR gets one more commit swapping that test for is_r13_r14().

Evidence

coverage_report over the 74 pinned drawings (measure.py check against the baseline on this branch passes; against #323's baseline it differs only in the 22 R13 rows):

Release Decoded before Decoded after Skipped Errored before Errored after
R13 (22 drawings) 27,254 27,693 21 439 0
R14 to R2018 unchanged unchanged unchanged 0 0

Errored on R13 before, by type: ATTRIB 179 of 187, ATTDEF 57 of 57, DIMSTYLE 161 of 161 (all 22 drawings), LEADER 42 of 42 (21 Sovol drawings). The 21 skipped are the Sovol SUN class records.

The AutoCAD-written R13 sets, which the 22 are not (coverage_report on lower-cased copies, because .DWG names were skipped until #353):

US Forest Service R6 library, 122 drawings (public domain; to be pinned) Autodesk's R13 discs, 68 distinct drawings (local evidence only, never fetched or committed)
decoded before / after 337,778 / 345,132 97,549 / 110,731
skipped (both runs) 104 (VP_ENT_HDR) 57 (VP_ENT_HDR 52, a custom OBJECT_PTR 3, MINSERT 2)
errored before / after 7,354 / 0 13,182 / 0

Forest Service errors before, by type: TEXT 7,016 (of 7,066), DIMSTYLE 126 (of 126), LEADER 116 (of 116), VIEWPORT 52 (of 52), ATTDEF 41 (of 41), TRACE 3 (of 165). On the discs: ATTRIB, TEXT, ATTDEF, DIMSTYLE and VIEWPORT. So TEXT, VIEWPORT and TRACE are measured on R13 directly (the 22 pinned drawings hold none of them). The per-drawing sha256s of the discs are in docs/data/r13-autodesk-discs.tsv (#323).

  • LEADER Endptproj: probe_leader closes all 42 Sovol LEADER records and exits 0 on all 22 R13 drawings. Control, with the three BDs read on R13 as on every other release: none of the four LEADERs of JXHMP4602-01005-b closes (three stop on a reserved 11 BD tag, one has 6 bits left where 8 are wanted). The control was a temporary switch in the decoder, removed again.
  • R14 and later are unchanged: measure.py check passes with R14 to R2018 rows untouched; the DXF oracle ratchet reports no agreeing count below the baseline; probe_header_vars exits 0 on all 74. The R14 corpus also holds 29 TEXT, 5 ATTDEF, 4 ATTRIB, 20 DIMSTYLE, 6 VIEWPORT and 1 LEADER record, all decoding.

Reproduce:

python3 -I tools/corpus/fetch.py --dest ../dwg-corpus
cargo build --release --features dxf-reader --example coverage_report \
    --example probe_leader --example probe_r13_census --example dxf_oracle --example probe_header_vars
python3 -I tools/corpus/measure.py run --corpus ../dwg-corpus --bin target/release/examples --out r.json
python3 -I tools/corpus/measure.py check --results r.json
for f in ../dwg-corpus/sovol/*.dwg; do target/release/examples/probe_leader "$f"; done
target/release/examples/probe_r13_census ../dwg-corpus/sketchup/Cabin.dwg ../dwg-corpus/sovol/*.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 +1.85 check --all-features
  • cargo test --release --all-features --no-fail-fast: no unit test added, none touched.
  • Shown on real files: the 74-drawing run above, the two AutoCAD-written sets, the LEADER probe with its control, the census, the DXF oracle ratchet and probe_header_vars.

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) and on byte-level inspection of public drawings, read only through this crate and its probes. The Autodesk disc drawings were read as data files only (their sha256s are recorded, nothing else of them); no reading of another DWG implementation's comments was needed, and nothing needs adding to CLEANROOM.md.

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.
…riters (#119, #345)

Autodesk's own R13 discs pad 0000 in 196 of 263 headers and 1111 in 6.
What holds on every AutoCAD-written header: 195 slots, a section of exactly
ceil(bits / 8), three or four locators and a real preview. The Sovol files
are not AutoCAD's on the extra header byte, the blank preview and the
R2007+ SUN object. The byte after 18 in section 26's tail varies on
Autodesk's own files, so Cabin's 18 30 is not evidence against AutoCAD.
…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.
@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-27T19:06:59.226043Z a198afa 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.

…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.
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