Skip to content

feat(dxf): score MULTILEADER in the value oracle (§20.4.48) - #385

Merged
DrunkOnJava merged 3 commits into
mainfrom
feat/dxf-oracle-mleader
Oct 27, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
feat/dxf-oracle-mleader

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

The value oracle scores MULTILEADER (§20.4.48, decoded by #229) against AutoCAD's DXF export: 90 records, R2000 to R2018.

The export nests the record in marker groups (300 CONTEXT_DATA{ to 301, 302 LEADER{ to 303, 304 LEADER_LINE{ to 305) whose fields reuse each other's codes (90, 91, 92, 290, 291, 40, 10, 11, 170, 171, 271 to 273). Each part is scored within its own groups: the context before and after its leader roots, each root before and after its lines, each line, and the entity's tail. Colours are the CMC's 32-bit word (before R2004 the DWG holds the bare index, as MLEADERSTYLE does). The has-block bit, which the DWG stores only on a multileader without text, and the R2013-only leader-extended flag, are scored only where the DWG holds them.

Spec reference

Spec §20.4.48 MULTILEADER and §20.4.86 MLeaderAnnotContext (embedded in it). Before and after, on the 49 drawing pairs:

Records Equal Default Different DWG only Not decoded
before (main) 90 paired, listed under "Paired records no scorer covers: no scorer yet" - - - - -
after 90 8532 0 3 495 1686

The 3 differences are the one finding, filed as #381: the text background colour of three R2000 records (handles 0xB22, 0xB23, 0xB24 of sample_AC1015.dwg). The R2000 record holds the colour as a bare BS index (9); the export writes the true colour 0xC2C8C8C8 that the R2004 to R2018 saves hold in full, and those 45 records equal. The decoder is right (the record closes on its boundary with the index read); the two files hold different amounts of information, as for LAYER's true colour (#245). The oracle leaves the three scored different; it does not map the index onto the word.

The 495 DWG-only values are measured export behaviour, not scorer gaps: the per-line style fields (170, 92, 171, 40, 93) of R2010+ lines, which the export omits (45 records x 5), the decoder's unnamed MC and B (R2010+), the pre-R2010 arrow-head and block-label lists, and the text's trailing flag. On R2010+ the export still writes the -R2007 block (294, 178, 179, 45) that the DWG no longer holds; those are not-decoded.

tools/oracle/baseline.tsv gains the 602 new rows; no existing row changes (the ratchet against main's baseline passes). The §20.4.48 row of docs/spec-coverage.md says what the oracle measured; its state stays closes.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test --release --all-features, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features, python3 tools/ci/spec_coverage.py --check
  • Real files, no new unit tests. The oracle over the pinned corpus reproduces the committed TSV and passes its ratchet against main's baseline:
cargo run --release --features dxf-reader --example dxf_oracle -- <corpus-dir> \
    --baseline tools/oracle/baseline.tsv --tsv oracle.tsv --details
cmp oracle.tsv tools/oracle/baseline.tsv

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. This matters because dwg-rs is Apache-2.0 and must remain compatible.

My contribution is based on:

  • The ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1);
  • Public reverse-engineering notes, research papers, or blog posts cited inline;
  • Reading algorithm-description comments (not executable code) in permissively-licensed projects (MIT / Apache / BSD) to resolve spec ambiguities — disclose any such reading in this PR body so it can be recorded in CLEANROOM.md.

No such reading was needed: the mapping is the DXF Reference's AcDbMLeader groups, read from AutoCAD's own exports as data.

See CLEANROOM.md for the full allowed/forbidden source list and the honest scope of what "clean-room" means for this project.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the
Developer Certificate of Origin 1.1.
Specifically, I affirm that the contribution is my own work (or rightfully
licensed to me) and that it can be distributed under the project's Apache-2.0
license.

I will sign off commits with git commit -s when asked, which adds a
Signed-off-by trailer to the commit message asserting the DCO.

Refs #99, #102, #147, #381.

The MULTILEADER decoder (#229) is now compared with AutoCAD's export field
by field. The export nests the record's parts in marker groups
(300 CONTEXT_DATA{ to 301, 302 LEADER{ to 303, 304 LEADER_LINE{ to 305)
that reuse each other's codes, so the oracle scores each part within its
own groups: the context before and after its leader roots, every root
before and after its lines, every line, and the entity's tail. Colours
are the CMC's 32-bit word, a bare index before R2004 as MLEADERSTYLE.
The has-block bit the DWG stores only without text, and the R2013-only
leader-extended flag, are scored only where the DWG holds them.

On the 49 drawing pairs: 90 records, R2000 to R2018 (15 per release),
8532 values equal the export and 3 differ: the text background colour of
three R2000 records, which the R2000 file holds as ACI 9 and the export as
the true colour 0xC2C8C8C8 that the R2004 to R2018 saves hold in full
(#381). 495 decoded values have no DXF group (the per-line style fields
the export omits, the unnamed MC and B, the pre-R2010 arrow and label
lists, the text's trailing flag). tools/oracle/baseline.tsv gains the 602
new rows; the §20.4.48 row of docs/spec-coverage.md says what the oracle
measured, and the oracle's section map files the class under §20.4.48.

Refs #99, #102, #147, #381
@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 ✅ Completed 2026-10-27T16:05:43.544280Z 80c935f 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: c5c622ce5b

ℹ️ 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 examples/dxf_oracle/scorers.rs Resolved
… when it has no leader roots

Without a 302 LEADER{ block the context's groups after the roots lie
in the same range as those before them, so groups 272 and 273 were looked up in an
empty range and reported as DWG-only with their DXF counterparts not
decoded. No corpus record lacks a root: the oracle's output is unchanged.

Refs #99, #102, #147
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 27, 2026 16:10
@DrunkOnJava
DrunkOnJava merged commit 61255e9 into main Oct 27, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/dxf-oracle-mleader branch October 27, 2026 16:33
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…10-27 (#416)

* docs: bring README, ROADMAP and CHANGELOG up to the landings of 2026-10-27

README's code-page and DXF writer text named work in review that has landed
(#371, #380, #382, #384); jev_review.py prose ranked those sentences 0.72 to
0.96. ROADMAP's "where it stands" table was a 2026-10-21 snapshot whose
numbers, CI row and release row were all out of date; it now points to the
rendered numbers instead of repeating them. CHANGELOG gains #371, #380, #382,
#384, #385 and #404.

* docs(changelog): record the CI-only merge train (#408)

* docs: OBJECTS landed (#372): README, ROADMAP and CHANGELOG

* docs: LAYOUT, GROUP and MLINESTYLE (#373), the class map writer (#405) and the double-byte round trip (#414) landed

* docs: VISUALSTYLE landed (#413)

* docs(readme): name the skipped types still in review without per-type counts; MATERIAL landed (#325)

* docs(readme): point to the open decoder PRs instead of a list that each landing makes stale
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