Repository navigation
feat(dxf): an ASCII DXF reader keyed by handle, for the value oracle - #223
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37496b9c26
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f909585de7
ℹ️ 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".
9568d0e to
087bf66
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 087bf6626c
ℹ️ 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".
Reads every group of every record in file order, typed by the DXF Reference's group-code value table, and indexes records by handle (group 5, or 105 on DIMSTYLE) with the owner taken from the first 330 outside the 102 brackets. Refuses malformed input instead of guessing: truncation, unknown codes, unparsable values, open brackets, missing or duplicate handles from AC1012 on, mixed line endings, binary DXF, and every size cap. Behind the default-off dxf-reader feature: a measuring instrument for all 42 nextgis/dwg_samples exports and damages each eleven ways to show every damaged copy is refused. Refs #100
The DXF Reference's extended-data table gives 1004 as a binary chunk and 1005 as a database handle; the 1000-1009 text range swallowed both, so a malformed 1004 or 1005 parsed silently. No corpus export carries either code; the census still reads all 42 files and refuses all 448 damaged copies.
A 999 comment is legal anywhere in a DXF file. The pre-scan that finds $ACADVER took the group right after `9 $ACADVER` as its value, so a comment there stood in for the version: UTF-8 decoding and the R13+ handle check followed the comment instead of the file. SECTION's name was read the same way, so a comment between `0 SECTION` and `2 <name>` refused a valid file. Both now skip 999 groups, as the HEADER parser already did. dxf_census --mutations now also puts a comment in those two places and inside a record, and each copy must read exactly as the original; and removes a handle behind a comment placed where the version is read, which must be refused. Before the fix, over the 42 nextgis exports, 35 such copies were accepted and 42 commented copies were refused; after, all 126 commented copies read as their originals and all 483 damaged copies are refused.
087bf66 to
cec1f4a
Compare
…us copies
An XRECORD's groups after its `100 AcDbXrecord` marker are the
application's: the DXF Reference's XRECORD page gives codes 1 to 369 (but
5 and 105) to the application "in any way", so a `102 {data` there is a
value. The reader treated it as a bracket and refused the file ("XRECORD
leaves a 102 bracket open"); bracket, handle and owner checks now stop at
the marker, and top_level() returns every data group.
dxf_census --mutations split a CRLF file on LF and joined its copies with
LF, so every commented copy of a valid CRLF file was refused for mixed
line endings. Copies now keep the file's own ending, and a fourth legal
copy puts an unclosed `102 {` in the first XRECORD's data.
On a CRLF copy of arc_2004.dxf the three commented copies were refused
and are now read as the original; arc_2004.dxf with `102 {data` in its
first XRECORD was refused and now reads. The 42 nextgis DXFs: 483 damaged
copies refused, 161 legal copies (35 of them the XRECORD one) read as the
original, 0 accepted; 9093 header variables, 7425 records, 6538 handles.
Summary
An ASCII DXF reader (
src/dxf_reader.rs, behind the new default-offdxf-readerfeature) that keeps every group of every record in file order, types each value by its group code, and indexes records by handle, so the DWG decode can be compared with AutoCAD's own DXF export record by record (#99, #100).#100 asks for a development tool rather than library API; the epic's brief asks for it in
src/, self-validating and capped like the rest of the crate. A default-off feature does both: library consumers never compile it, while--all-featuresin CI builds, lints and documents it, and the oracle examples declarerequired-features = ["dxf-reader"].Spec reference
Autodesk's public DXF Reference (the group-code/value grammar and its "Group Code Value Types" table), recalled; disclosed in
CLEANROOM.md. Two readings were measured on the corpus exports rather than taken from the document, and the module docs record both:DIMBLK(text; the R12 exports write it empty), which is why DIMSTYLE's handle is group 105;102bracket closes as}or as<name>}(the AC1015-AC1021ellipse_*exports write XRECORD data as{ATTRRECORD...ATTRRECORD}).What the reader refuses (module docs, written before the code): binary DXF, a BOM or UTF-16; every size cap; mixed CRLF/LF; a code with no value line; a non-integer or out-of-table group code; a value that does not parse as its code's type (non-finite real, integer out of width, boolean other than 0/1, bad hex handle or binary chunk); non-ASCII text before AC1021 (it would need
$DWGCODEPAGE) or non-UTF-8 after; a broken section/table/block structure, noEOFor data after it; a repeated or orphan header variable; an unbalanced102bracket; and from AC1012 on, a record in TABLES/BLOCKS/ENTITIES/OBJECTS with no handle, handle 0, or a duplicate handle.Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurescargo +1.85 check --all-features --all-targetsThe 42
.dxffiles ofnextgis/dwg_samplesatff05d5a89ce123da511ed93c5fe5e6df85e02ab8(each checked against its git blob hash), fetched into a cache outside the repo:Every file parses, every AC1015+ record outside CLASSES and ENDTAB carries a unique handle, and the 2000+ exports print reals at 16 significant digits (R12 at 17).
--mutationsputs a999comment in three legal places of each file (after9 $ACADVER, between0 SECTIONand2 <name>, inside a record): all 126 commented copies read exactly as their originals. It also damages each file twelve ways in memory; all 483 applicable damaged copies are refused and none is accepted (the R12 files have no102brackets and optional handles, so three of the twelve do not apply to them). Review fixes: 1004/1005 typed as binary/handle (f909585); 999 skipped where the version and section names are read (9568d0e), before which 35 handle-less copies with a comment where the version is read were accepted and 42 commented copies were refused:Pairing with the DWG records (#101) and the field scorers (#102) follow in their own PRs.
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:
CLEANROOM.md).dwg-rsis Apache-2.0 and must remain compatible.My contribution is based on:
CLEANROOM.md) and the bytes of AutoCAD's own exports innextgis/dwg_samples(read from a cache, not vendored).Developer Certificate of Origin
By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.
Closes #100