Skip to content

feat(dxf): score HATCH in the value oracle (§20.4.75) - #389

Merged
DrunkOnJava merged 5 commits into
mainfrom
feat/dxf-oracle-hatch
Oct 28, 2026
Merged

DrunkOnJava merged 5 commits into
mainfrom
feat/dxf-oracle-hatch

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

The value oracle scores HATCH (§20.4.75) against AutoCAD's DXF export: 48 records, R2000 to R2018 (8 per release).

The export writes the groups in the order the spec prints them, so the oracle scores them in that order, each within the next few groups of the record. A group out of place then shows as a missing one, and the order is checked along with the values: the elevation (the z of the dummy point 10), the extrusion, the name, the solid and associative flags, the path count; per path its flags, its vertices (72, 73, 93, 10/20) or line edges (93, 72, 10/20, 11/21) and its boundary handle count (97); the hatch style and type; the pattern block (angle, scale, double flag, and per line the angle, base point, offset and dash lengths); the pixel size of a derived path; the seed points; and the gradient block (450 to 470). Paths, edges and pattern lines are scored under one field name each, so a 232-line pattern adds no rows.

Spec reference

Spec §20.4.75 HATCH. Before and after, on the 49 drawing pairs:

Records Equal Default Different DWG only Not decoded
before (main) 48 paired, listed under "Paired records no scorer covers: no scorer yet" - - - - -
after 48 23360 0 0 20 454

Per release: 5 hatches with line edges and 3 with a polyline path (flags 7, which also carry the pixel size), and from R2004 two with a gradient. No field comes out different.

A gradient colour is a CMC word. The decoder keeps the method byte 0xC2 and the RGB (0xC20000FF for blue); the export's 421 is the RGB alone, so the oracle compares the word's 24-bit payload when the method is 0xC2, as it does for VISUALSTYLE. Group 63, the ACI AutoCAD derives from the RGB (5 and 2), is not stored: the BS beside the word is 0 on every record, so that BS is DWG-only (20 values) and the 63s stay not-decoded.

Only line edges and polylines occur in a file that has a DXF twin: the one spline edge of the corpus is in export_sample.dwg, which has none, and no file holds an arc or ellipse edge. Those edge types stay unscored (the code says so), and §20.4.75 stays partial.

The not-decoded groups are the dummy x and y of the elevation point (10 and 20), the boundary handles (330), the reserved 451, the layer, and the extended data.

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

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 AcDbHatch 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 HATCH decoder is now compared with AutoCAD's export field by field.
The export writes the groups in the order the spec prints them, so they
are scored in that order, each within the next few groups of the record,
which checks the order as well as the values: the elevation as the z of
the dummy point 10, the extrusion, name, solid and associative flags, the
path count, each path's flags with its vertices or line edges and its
boundary handle count (97), the hatch style and type, the pattern block
(angle, scale, double flag, each line's angle, base point, offset and dash
lengths), the pixel size of a derived path, the seed points and the
gradient block (450 to 470). Paths, edges and pattern lines are scored
under one field name each. A gradient colour is a CMC word: the DWG keeps
the method byte 0xC2 and the RGB, which is group 421; group 63, the ACI
AutoCAD derives from the RGB, is not stored (the BS beside it is 0) and
stays not-decoded.

On the 49 drawing pairs: 48 records, R2000 to R2018 (8 per release; 3 of
each hold a polyline path and 5 line edges, 10 hold a gradient), 23360
values equal the export, none differ, 20 decoded values have no DXF group
(the colour BS that is always 0). Only line edges and polylines occur in
a file with a DXF twin, so arc, ellipse and spline edges stay unscored,
and the section stays partial. tools/oracle/baseline.tsv gains the 278 new
rows, and the §20.4.75 row of docs/spec-coverage.md says what the oracle
measured. The oracle's section map files HATCH under §20.4.75.

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 🔄 Running since 2026-10-28T08:25:29.439422Z 93c41ca 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: de1773d4b0

ℹ️ 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
An arc, ellipse or spline edge was recorded as not scored but its DXF groups were left in place, so
every later edge, the boundary-handle count and the pattern fields were compared against the wrong
groups. The scorer now ends the record there, noting that the rest is not scored. The corpus holds
only line edges and polylines, so no measured count changes.
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.
# Conflicts:
#	README.md
#	STATUS.md
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 28, 2026 08:30
@DrunkOnJava
DrunkOnJava merged commit 81251b8 into main Oct 28, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/dxf-oracle-hatch branch October 28, 2026 08:40
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…, and record them (#437)

README named LIGHT, ACSH_CYLINDER_CLASS, ACSH_REVOLVE_CLASS and RAPIDRTRENDERENVIRONMENT as skipped; they decode since #425, #426 and #427, and main's baseline now skips 32 records. CHANGELOG records those and the HATCH and TOLERANCE scorers (#389, #392).
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