Skip to content

feat(dxf): score LEADER in the value oracle (§20.4.47) - #402

Merged
DrunkOnJava merged 3 commits into
mainfrom
feat/dxf-oracle-leader
Oct 28, 2026
Merged

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

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

The value oracle scores LEADER (§20.4.47, decoded by #71) against AutoCAD's DXF export under AcDbLeader: 6 records, R2000 to R2018 (1 per release).

Scored: the annotation type (73), the hook line direction (74), the extrusion (210, the DXF default when omitted), the vertices (10) and, up to R2007, the text box height and width (40, 41). When the leader has a hook line (75 is 1) the export inserts the hook line's start before the last vertex and counts it in 76, as the decoder's probe measures; the oracle compares the count with the decoded vertices plus one and leaves the inserted vertex not-decoded. The path type and arrowhead flag (72, 71), which the export omits, the horizontal direction and block offset (211, 212) and the spec's two fields with no DXF group (the origin and the end point projection) are DWG-only; the dimension style and the annotation are handles.

Spec reference

Spec §20.4.47 LEADER. Before and after, on the 49 drawing pairs:

Records Equal Default Different DWG only Not decoded
before (main) 6 paired, listed under "Paired records no scorer covers: no scorer yet" - - - - -
after 6 78 18 0 60 42

No field comes out different. The 18 default values are the extrusion, which the export omits. From R2010 the record holds no box height or width while the export still writes groups 40 and 41, so those stay not-decoded there (the decoder's docs record the departure). The other not-decoded groups are the hook line flag (75), the inserted hook line vertex, the dimension style name (3), the annotation handle (340), the owner and the layer.

tools/oracle/baseline.tsv gains the 120 new rows; no existing row changes (the ratchet against main's baseline passes). The §20.4.47 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 spec's DXF column and the DXF Reference's AcDbLeader 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.

The LEADER decoder (#71) is now compared with AutoCAD's export field by
field, under AcDbLeader: the annotation type (73), the hook line direction
(74), the extrusion (210, the DXF default when omitted), the vertices (10)
and, up to R2007, the text box height and width (40, 41). When the leader
has a hook line (75 is 1) the export inserts the hook line's start before
the last vertex and counts it in 76, as the decoder's probe measures: the
oracle compares the count with the decoded vertices plus one and the
inserted vertex stays not-decoded. The path type and arrowhead flag
(72, 71), which the export omits, the horizontal direction and block
offset (211, 212) and the spec's two groupless fields (the origin and the
end point projection) are DWG-only; the dimension style and the annotation
are handles.

On the 49 drawing pairs: 6 records, R2000 to R2018 (1 per release), 78
values equal the export and 18 by its default; none differ. 60 decoded
values have no DXF group. From R2010 the record holds no box height or
width while the export still writes them: those two groups stay
not-decoded. tools/oracle/baseline.tsv gains the new rows, and the
§20.4.47 row of docs/spec-coverage.md says what the oracle measured. The
oracle's section map files LEADER under §20.4.47.

Refs #99, #102, #147
@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-28T15:30:21.649292Z cde3815 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
DrunkOnJava enabled auto-merge (squash) October 28, 2026 15:40
@DrunkOnJava
DrunkOnJava merged commit 1639c65 into main Oct 28, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/dxf-oracle-leader branch October 28, 2026 15:47
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