Skip to content

feat(dxf): the value oracle — pair every DWG record by handle and score its fields - #248

Merged
DrunkOnJava merged 1 commit into
mainfrom
feat/dxf-oracle-scorers
Oct 26, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
feat/dxf-oracle-scorers

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

The DXF value oracle: examples/dxf_oracle pairs every DWG record of the corpus with the record of the same handle in AutoCAD's own DXF export of the same drawing (#101), and compares every decoded field with the DXF group that carries it (#102). A record that closes on its data-stream boundary proves the widths add up; this is the check that says the values are right.

One commit on main: #223 (the reader) and #235, #236 and #238, the three decoder fixes the oracle found, have landed.

What it does

  • Pairing (Pair every DWG record with the DXF object of the same handle #101): every .dwg under the corpus directory with its twin (<name>.dxf, the ACadSharp <name>_ascii.dxf, or nextgis's R14 saves with their R12 export). Reports, per file and by release and type, what pairs, what pairs with a different type, and what one side lacks. Every one-sided record is explained in the example's docs: each save's own round-trip/variable objects (fresh handles above every shared one, marked save-time), VP_ENT_HDR_CTRL (no DXF record), solid history the R2000/R2004 exports omit, and R12's missing sections.
  • Scorers (Field scorers for every type the public corpus holds #102): the decoded fields of 44 spec sections (ENDBLK and SEQEND pair with nothing to compare; TABLESTYLE pairs undecoded) (entities §20.4.3-§20.4.85 that the corpus holds and decodes, every symbol table and control, DICTIONARY, DICTIONARYVAR, SCALE, LAYOUT, MLINESTYLE, XRECORD, PLACEHOLDER). Field → group is the spec's DXF column, or the DXF Reference's for what the spec leaves out. Statuses: equal, default (export omitted a default-valued group), different, dwg-only, not-decoded; a one-sided field is listed, never counted equal. Reals agree within half a unit of AutoCAD's printing (16 significant digits and 16 decimal places, finer where a file prints finer, never coarser) plus 4 ulps; everything else is exact. Text a pre-AC1021 export holds in an undeclared code page is not compared (dwg-only, its group left not-decoded). The export's own conventions (degrees, ^J, the unwritten bit 64, anonymous-block numbering, embedded 101 objects, true colour) are measured and documented in scorers.rs.
  • Output: a matrix per type (field × release), every disagreement, the DXF groups no decoder surfaces, records no scorer covers, a summary by spec section; --tsv, --baseline (the Oracle results in CI, ratcheted #103 ratchet: fails when a row's agreeing count falls or a baseline row is absent, saying which, so a renamed field needs the regenerated TSV committed with it), --summary (Markdown for a job summary).
  • tools/oracle/spec_notes.py writes each measured section's note into docs/data/spec-coverage.tsv from the oracle's report (then tools/ci/spec_coverage.py --write), naming the issue a section's disagreements or remaining gap are filed under. It replaces only the note's oracle sentence and keeps the The spec's own example ... sentence test(fixtures): run the specification's own worked examples through the crate (#107) #280's spec_examples -- --update writes last, so the two can run in either order: on this branch --update reports no expect cell changed and leaves the regenerated TSV byte-identical, with all 76 such sentences.
  • Reader: pre-AC1021 non-ASCII text is kept as bytes (DxfValue::CodePageText) instead of refused: ACadSharp's R12 sample declares no $DWGCODEPAGE, so decoding it would be a guess. real_decimals() measures the decimal places a file prints.
  • Docs: each section the oracle measures says what it measured in docs/spec-coverage.md (data and page regenerated by tools/ci/spec_coverage.py --write). LAYER §20.4.54 moves partial → closes: its pre-R2007 field list is checked against the RL boundary and every value equals the export on every release (the subject of R2004 symbol-table field lists are unvalidated past the object header: LTYPE description and LAYER colour/lineweight decode silently wrong #34). No row moves to complete: the corpus has no R13 drawing and no R14 export with handles on tables and objects. release-1.0-criteria.md R3/R4/R8 "measured now" updated; CLEANROOM entry for the scorers' sources.

Test plan

cargo run --release --features dxf-reader --example dxf_oracle -- <corpus-dir> --tsv oracle.tsv --summary oracle.md
cargo run --release --features dxf-reader --example dxf_census -- <corpus-dir>/acadsharp      # exit 0, 8 files

Pairing over 49 drawing pairs (R14 to R2018):

file                       release   dwg   dxf paired differs dwg-only dxf-only unkeyed
TOTAL                              14209 12261   9566       2     4641     2693    1290

Disagreements: 19 values, each filed: VIEW_CONTROL/APPID_CONTROL num_entries vs TABLE 70 on the ACadSharp saves (#241), one LTYPE dash shape flag bit 8 (#242), the BLOCK name of a dynamic block's anonymous representation on R2000-R2007 (#243), geoloc.dwg's view height and centre (#244). Before #235, #236 and #238 there were 420 (308 entry-header bits, 84 VPORT, 9 LAYOUT plot flags, and 19 more the scorers' own rules resolved).

The ratchet: run against its own TSV it passes; with one baseline count raised by one it fails:

== Ratchet against base-raised.tsv
DROP R2013 LINE start.x 10: 100 agreeing in the baseline, 99 now        (exit 1)

Summary by spec section:

Section Type Records Equal Default Different DWG only Not decoded Unscored
§20.4.3 TEXT 116 580 1160 0 0 472 58
§20.4.4 ATTRIB 16 145 171 0 19 55 8
§20.4.5 ATTDEF 20 208 212 0 24 64 10
§20.4.6 BLOCK 264 261 0 3 0 2274 0
§20.4.7 ENDBLK 278 0 0 0 0 705 0
§20.4.8 SEQEND 24 0 0 0 0 48 0
§20.4.9 INSERT 72 408 384 0 72 359 0
§20.4.12 VERTEX_3D 30 120 0 0 0 60 0
§20.4.14 VERTEX_PFACE 30 120 0 0 0 60 0
§20.4.15 VERTEX_PFACE_FACE 12 42 6 0 0 72 0
§20.4.17 POLYLINE_3D 6 18 6 0 5 36 0
§20.4.18 ARC 24 144 96 0 0 81 0
§20.4.20 CIRCLE 84 336 336 0 0 229 0
§20.4.21 LINE 594 3564 2376 0 594 2891 0
§20.4.31 POINT 252 756 1260 0 0 939 0
§20.4.32 3DFACE 6 72 6 0 6 12 0
§20.4.33 POLYLINE_PFACE 6 12 0 0 5 42 0
§20.4.35 SOLID 84 1008 336 0 0 336 0
§20.4.39 ELLIPSE 11 132 0 0 0 22 0
§20.4.42 RAY 6 36 0 0 0 12 0
§20.4.43 XLINE 6 36 0 0 0 12 0
§20.4.44 DICTIONARY 1093 7541 682 0 12 6755 0
§20.4.45 ACDBDICTIONARYWDFLT 42 126 42 0 0 168 0
§20.4.46 MTEXT 175 1980 525 0 785 1382 35
§20.4.51 BLOCK_CONTROL 42 42 0 0 0 84 0
§20.4.52 BLOCK_HEADER 264 2816 258 0 575 1633 0
§20.4.53 LAYER_CONTROL 42 42 0 0 0 94 0
§20.4.54 LAYER 150 1197 138 0 315 1035 0
§20.4.55 STYLE_CONTROL 42 42 0 0 0 84 0
§20.4.56 STYLE 108 1188 0 0 216 438 0
§20.4.57 LTYPE_CONTROL 42 42 0 0 0 84 0
§20.4.58 LTYPE 156 1292 0 4 312 202 0
§20.4.59 VIEW_CONTROL 42 36 0 6 0 84 0
§20.4.61 UCS_CONTROL 42 42 0 0 0 84 0
§20.4.63 VPORT_CONTROL 42 42 0 0 0 99 0
§20.4.64 VPORT 42 1300 0 2 84 1034 0
§20.4.65 APPID_CONTROL 42 38 0 4 0 84 0
§20.4.66 APPID 341 682 341 0 682 341 0
§20.4.67 DIMSTYLE_CONTROL 42 84 0 0 0 135 0
§20.4.68 DIMSTYLE 102 667 1067 0 204 1085 6
§20.4.73 MLINESTYLE 42 462 0 0 84 168 0
§20.4.74 DICTIONARYVAR 258 516 0 0 0 516 0
§20.4.84 LAYOUT 82 4592 0 0 82 443 50
§20.4.85 LWPOLYLINE 143 1875 757 0 143 340 0
§20.4.92 SCALE 826 4130 0 0 0 1652 0
§20.4.101 TABLESTYLE 0 0 0 0 0 0 42
§20.4.104 XRECORD 1237 1237 0 0 1237 54466 0
- 3DSOLID 0 0 0 0 0 0 12
- ACAD_EVALUATION_GRAPH 0 0 0 0 0 0 14
- ACAD_TABLE 0 0 0 0 0 0 12
- ACDBASSOCPERSSUBENTMANAGER 0 0 0 0 0 0 6
- ACDBDETAILVIEWSTYLE 0 0 0 0 0 0 48
- ACDBPERSSUBENTMANAGER 0 0 0 0 0 0 6
- ACDBPLACEHOLDER 0 0 0 0 0 0 8
- ACDBSECTIONVIEWSTYLE 0 0 0 0 0 0 48
- ACDB_BLOCKREPRESENTATION_DATA 0 0 0 0 0 0 12
- ACDB_DYNAMICBLOCKPURGEPREVENTER_VERSION 0 0 0 0 0 0 6
- ACDB_PLACEHOLDER 34 34 0 0 0 68 0
- ACDB_TEXTOBJECTCONTEXTDATA_CLASS 0 0 0 0 0 0 6
- ACSH_BOX_CLASS 0 0 0 0 0 0 4
- ACSH_EXTRUSION_CLASS 0 0 0 0 0 0 4
- ACSH_HISTORY_CLASS 0 0 0 0 0 0 8
- BLOCKGRIPLOCATIONCOMPONENT 0 0 0 0 0 0 36
- BLOCKLINEARGRIP 0 0 0 0 0 0 12
- BLOCKLINEARPARAMETER 0 0 0 0 0 0 6
- BLOCKSCALEACTION 0 0 0 0 0 0 6
- BLOCKVISIBILITYGRIP 0 0 0 0 0 0 6
- BLOCKVISIBILITYPARAMETER 0 0 0 0 0 0 6
- DBCOLOR 0 0 0 0 0 0 6
- DIMASSOC 0 0 0 0 0 0 18
- DIMENSION_ALIGNED 0 0 0 0 0 0 12
- DIMENSION_ANG_2LN 0 0 0 0 0 0 6
- DIMENSION_ANG_3PT 0 0 0 0 0 0 6
- DIMENSION_DIAMETER 0 0 0 0 0 0 6
- DIMENSION_LINEAR 0 0 0 0 0 0 18
- DIMENSION_ORDINATE 0 0 0 0 0 0 12
- DIMENSION_RADIUS 0 0 0 0 0 0 6
- GEODATA 0 0 0 0 0 0 1
- GROUP 0 0 0 0 0 0 12
- HATCH 0 0 0 0 0 0 48
- IMAGE 0 0 0 0 0 0 6
- IMAGEDEF 0 0 0 0 0 0 6
- IMAGEDEF_REACTOR 0 0 0 0 0 0 6
- LEADER 0 0 0 0 0 0 6
- MATERIAL 0 0 0 0 0 0 174
- MESH 0 0 0 0 0 0 12
- MLEADERSTYLE 0 0 0 0 0 0 49
- MLINE 0 0 0 0 0 0 18
- MULTILEADER 0 0 0 0 0 0 90
- PDFDEFINITION 0 0 0 0 0 0 6
- PDFUNDERLAY 0 0 0 0 0 0 6
- RASTERVARIABLES 0 0 0 0 0 0 6
- REGION 0 0 0 0 0 0 6
- SHAPE 0 0 0 0 0 0 6
- SORTENTSTABLE 0 0 0 0 0 0 18
- SPATIAL_FILTER 0 0 0 0 0 0 6
- SPLINE 0 0 0 0 0 0 12
- SUN 0 0 0 0 0 0 1
- TABLECONTENT 0 0 0 0 0 0 6
- TABLEGEOMETRY 0 0 0 0 0 0 6
- TOLERANCE 0 0 0 0 0 0 18
- VIEW 0 0 0 0 0 0 6
- VIEWPORT 0 0 0 0 0 0 36
- VISUALSTYLE 0 0 0 0 0 0 1008
- WIPEOUT 0 0 0 0 0 0 6
- WIPEOUTVARIABLES 0 0 0 0 0 0 6

Not decoded counts DXF groups no decoded field maps to (owner and other handles, layer, colour, linetype on entities, extended data): the work left for complete. Unscored records are paired but not decoded, or decoded without a scorer yet (VISUALSTYLE, MLEADERSTYLE, the view styles, DIMENSION, HATCH, SPLINE, MLINE, GROUP and others; #102 stays open for them).

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.

Based on ODA spec v5.4.1 (the DXF column of each §20.4.x table), Autodesk's public DXF Reference (recalled), and AutoCAD's DXF exports in nextgis/dwg_samples and ACadSharp's samples/ read as data; recorded in CLEANROOM.md. No permissively-licensed project's 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.

Refs #99, #101, #102. Closes #34 (see its last comment for the measurement).

@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-26T12:43:24.666693Z 307659b 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 26, 2026 11:41
@DrunkOnJava
DrunkOnJava disabled auto-merge October 26, 2026 11:41

@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: 62389159ea

ℹ️ 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
Comment thread examples/dxf_oracle/main.rs Resolved
Comment thread examples/dxf_oracle/scorers.rs Resolved
Comment thread examples/dxf_oracle/main.rs Resolved
@DrunkOnJava
DrunkOnJava force-pushed the feat/dxf-oracle-scorers branch from 6238915 to 6bdfdc9 Compare October 26, 2026 11:48

@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: 6bdfdc90f6

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

@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: adcb53563c

ℹ️ 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
Comment thread examples/dxf_oracle/scorers.rs Resolved
@DrunkOnJava
DrunkOnJava force-pushed the feat/dxf-oracle-scorers branch from adcb535 to 390884b Compare October 26, 2026 12:02

@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: 390884b1d7

ℹ️ 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
Comment thread examples/dxf_oracle/main.rs Resolved
@DrunkOnJava
DrunkOnJava force-pushed the feat/dxf-oracle-scorers branch from 390884b to 74f333b Compare October 26, 2026 12:13

@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: 74f333bd6c

ℹ️ 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
@DrunkOnJava
DrunkOnJava force-pushed the feat/dxf-oracle-scorers branch 2 times, most recently from 1c10e27 to 59013d1 Compare October 26, 2026 12:21
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 12:24
@DrunkOnJava
DrunkOnJava force-pushed the feat/dxf-oracle-scorers branch from 59013d1 to 071dfc5 Compare October 26, 2026 12:31

@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: 071dfc5b39

ℹ️ 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/report.rs Resolved
…re its fields

examples/dxf_oracle pairs each corpus DWG with AutoCAD's own DXF export
of the drawing (nextgis/dwg_samples and the ACadSharp samples; R14 saves
with their R12 export), record by handle (#101), and compares every
decoded field with the DXF group that carries it (#102): the spec's DXF
column for the types v5.4.1 prescribes, the DXF Reference otherwise.
Statuses are equal, default (the export omitted a default-valued group),
different, dwg-only and not-decoded; reals agree within half a unit of
the 16 significant digits and 16 decimal places AutoCAD prints (finer
where a file prints finer, never coarser), plus 4 ulps. Text a pre-AC1021
export holds in an undeclared code page is not compared: the field (or
dictionary key) is dwg-only and the group stays not-decoded. An
XRECORD's application data, after `100 AcDbXrecord`, is counted group by
group, its `100`s and `102`s as data rather than markers or brackets, as
the reader reads it. A path option given without its path, an unknown
option or a second directory is a usage error, and a baseline that is
not the oracle's TSV (wrong header, a short row, a count that is not a
number, no rows) fails the run, so a requested ratchet cannot be skipped
silently. It prints the pairing and
one-sided records by release and type, a field matrix per type, every
disagreement, the DXF groups no decoder surfaces and a summary by spec
section, and writes a TSV that --baseline ratchets (#103); the baseline
is read before any output is written, so --tsv may name the same file.

Measured over 49 drawing pairs, R14 to R2018: 46 spec sections paired
(44 with decoded fields to compare), 19 values disagree, all filed
(#241-#244); the rest agree. The reader
keeps pre-AC1021 non-ASCII text as bytes instead of refusing it, and
measures the decimal places a file prints reals with.

docs/spec-coverage.md says what the oracle measured on each section,
written by tools/oracle/spec_notes.py, which replaces only a note's
oracle sentence and keeps the "The spec's own example ..." sentence
spec_examples --update writes last (#107), so the two can run in either
order;
LAYER moves to closes (its pre-R2007 values, the subject of #34, equal
the export on every release).

Refs #99, #101, #102
@DrunkOnJava
DrunkOnJava force-pushed the feat/dxf-oracle-scorers branch from 071dfc5 to 307659b Compare October 26, 2026 12:37
@DrunkOnJava
DrunkOnJava merged commit f44d92d into main Oct 26, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/dxf-oracle-scorers branch October 26, 2026 12:50
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.

R2004 symbol-table field lists are unvalidated past the object header: LTYPE description and LAYER colour/lineweight decode silently wrong

1 participant