Skip to content

fix(entities): decode MULTILEADER on R14 to R2007 with §20.4.48's version branches (#229) - #278

Merged
DrunkOnJava merged 5 commits into
mainfrom
fix/229-mleader
Oct 26, 2026
Merged

DrunkOnJava merged 5 commits into
mainfrom
fix/229-mleader

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Decode MULTILEADER on R14, R2000, R2004 and R2007. This reads the R2010+ and -R2007 branches that §20.4.48 and §20.4.86 print, the pre-R2004 CMC, and inline TVs. All 60 R14 to R2007 multileaders of the public corpus were skipped; they now close. Every value compared equals AutoCAD's DXF export of the same drawing, on every release with a twin. The new probe also checks the R2010 to R2018 records the crate already decoded: 0 differences there too. Part of #229.

Spec reference

§20.4.48 MLEADER and §20.4.86 MLeaderAnnotContext:

Where R2010+ only Up to R2007 only
the record's start BS 270 class version
each leader line BS 170, CMC 92, BL 171, BD 40, BL 93
each leader root BS 271
the context's end BS 273, BS 272
after B 293 BS 271, BS 273, BS 272 (and the 17 unnamed bits of §7g) BL arrow heads with a B each, BL block labels with TV, BS, BD each, then B 294, BS 178, BS 179, BD 45

Before R2004 a CMC is the bare BS index (§2.11), and before R2007 the TVs are inline. The readers now share a small Src (string source plus release) instead of a StringReader. MLeader gains legacy: Option<MLeaderPreR2010> for the -R2007 tail. mleader::decode is the inline entry point; dispatch routes the class name on R14 to R2004 and opens the split-stream path to R2007.

Records it was measured on

examples/probe_mleader.rs (new) compares the decoded values with the twin's AcDbMLeader group. It works part by part: the context, each leader root and its lines, and the entity's own fields. Each value is matched against the next group with its code. That covers about 87 values per record: context scale, points, sizes and attachments; the whole text block; base point, direction and vertical; every root and line; and the entity's style fields. On R2000 to R2007 it also covers the -R2007 scalars.

Release Records Close Values compared Differ
R14 15 15 no twin
R2000 15 15 1290 0
R2004 15 15 1365 0
R2007 15 15 1365 0
R2010 / R2013 / R2018 15 each 15 each 1305 each 0

A comparator check: changing one character of a label in a copy of the R2000 twin is reported as exactly one difference.

The releases do not hold identical values. 0xB27 stores content base x 527.42 with attachments 4/0 up to R2007, and 556.64 with 0/8 from R2010. Each release's DXF agrees with its own record, so AutoCAD converts the leader on save, and the probe compares each release with its own twin.

C=~/Library/Caches/dwg-corpus/acadsharp
cargo run --release --example probe_mleader -- $C/sample_AC1014.dwg     # R14: no twin, close only
for v in 1015 1018 1021 1024 1027 1032; do cargo run --release --example probe_mleader -- $C/sample_AC$v.dwg $C/sample_AC${v}_ascii.dxf; done

Coverage, ../../samples

Unchanged (no multileader below R2018 in the 19 files): TOTAL 4256 / 180 / 9 on a main that includes #254.

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

sample_AC1014.dwg   1018 119 105  →  1033 104 105
sample_AC1015.dwg    914  82  51  →   929  67  51
sample_AC1018.dwg    850  74  90  →   865  59  90
sample_AC1021.dwg    834  76  15  →   849  61  15

52-file total: 14935 / 831 / 308 → 14995 / 771 / 308. measure.py check passes. It is 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.48 → closes; docs/spec-coverage.md regenerated.
  • ARCHITECTURE.md: new §7t.
  • The mleader.rs module doc records the branches and the measurement.

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. mleader::tests::pre_r2010_is_unsupported asserted that an R2007 record is refused. The corpus disproves that: all 15 R2007 records close and match their twin.

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 §2.11, §20.4.48 and §20.4.86 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1), including their DXF group codes, 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.

…sion branches (#229)

AutoCAD writes MULTILEADER into every release it saves, a class on R14
to R2004, but the crate decoded it only from R2010, so all 60 R14 to
R2007 multileaders of the public corpus were skipped. §20.4.48 and
§20.4.86 print every branch the earlier releases need: the R2010+ class
version and per-line, per-root and context style fields, and the
-R2007 tail of arrow heads, block labels and four scalars; before R2004
a CMC is a bare index and before R2007 the TVs are inline.

Read that way, all 105 MULTILEADER records close, R14 to R2018, and
every value examples/probe_mleader.rs compares equals the DXF twin on
R2000 to R2018 (0 of 7,935 differ). The unit test that pinned the
R2007 refusal is removed. ARCHITECTURE.md §7t records it; §20.4.48
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 ✅ Completed 2026-10-26T21:58:03.099259Z 0185749 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.

DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
On a loaded machine the governor refused the build of #278 after 600 s and
the train dropped the PR as failed. refresh.sh now exits 75 when the build
log says the governor gave no lease, and train.sh puts the PR back at the
end of the queue, waiting TRAIN_DEFER_SLEEP (600 s) once every queued PR has
been deferred in a row. spec_examples runs from the built binary instead of
cargo run, so only the build can be refused.
# Conflicts:
#	ARCHITECTURE.md
#	docs/data/spec-coverage.tsv
#	docs/spec-coverage.md
#	src/entities/dispatch.rs
#	tools/corpus/baseline.tsv
# Conflicts:
#	ARCHITECTURE.md
#	docs/spec-coverage.md
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