Repository navigation
feat(sections): decode every AcDb:Header variable from one table (§9, #126) - #302
Conversation
…126) src/header_table.rs holds §9 as one table, a row per slot in stream order with its bit code and first and last release; src/header_vars.rs walks the rows of the file's release. R14 to R2018: 311 slots on R2018, each under its AutoCAD name ($INSBASE, $EXTMIN, $DIMTAD, ...) or named UNKNOWN_<code>_<n>. R2007 and later read the data, string and handle streams the way an object does. The size in bits counts from 32 bits before the data and ends at the first handle bit; the string stream is found backwards from there. All 52 pinned drawings pass both sentinels, the size, the CRC and every stream boundary. examples/probe_header_vars.rs compares every variable with AutoCAD's DXF export of the same drawing: 11,544 agree, 316 hold a stated relation (case-insensitive names, a later save, a per-save GUID, a clamped flag), 0 disagree. The spec's own R14 header dump decodes in full (examples/spec_examples.rs). The Corpus job runs the probe; the header_vars fuzz target wraps its input in a valid frame for every release so it reaches the slot decoder. §9 differs from the files in ways ARCHITECTURE.md §7n records: MENUNAME is read on every release, four BS and (from R2004) five B end the section, the padding is ones, R2000 and later store universal time, and a CMC from R2004 keeps its meaning in the top byte of its BL.
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. |
# Conflicts: # .github/workflows/ci.yml # docs/spec-coverage.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a2b4b8d03
ℹ️ 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".
… its index (§9, #126) An R2007+ header whose strings-present bit is clear has no string stream to end, so the strings-end boundary is checked only when one exists. The decoded entries are read through HeaderVars::entries(): the field is private so a caller cannot reorder or clear it under the name index and make get() answer for another variable or index out of bounds.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 028ba2695e
ℹ️ 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".
…(§9, #126) R14 to R2004 store text in the drawing's code page, which the crate does not apply; reading it as UTF-8 returned a corrupted string with no diagnostic. A text with a byte above 0x7F is now Value::RawText with its bytes; ASCII text is Value::Text as before. Nothing in the corpus has such text.
# Conflicts: # .github/workflows/ci.yml # ARCHITECTURE.md # docs/spec-coverage.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00a4cb40ba
ℹ️ 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: 922543a2f0
ℹ️ 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".
… short string stream (§9, #126) parse_lossy checked the beginning sentinel only in strict mode and the CRC excludes those 16 bytes, so a damaged first sentinel left a clean-looking result; it is now a diagnostic. From R2007, with the strings-present bit set, a text slot read after the string stream is exhausted is an error instead of an implicit empty string, so a shortened stream no longer yields empty variables that still close.
# Conflicts: # ARCHITECTURE.md # docs/spec-coverage.md
Summary
Decodes every variable of
AcDb:Header(§9) from one table, R14 to R2018, with the R2007+ string and handle streams, and holds the result to every pinned drawing's DXF export. Closes #126.This is one PR rather than a pre-R2007 family first: every release closes and agrees, and cutting it would leave a probe that fails on 36 of the 52 files. Say if you want it split.
Spec reference
ODA v5.4.1 §9, with §2.11 (CMC), §2.13 (handles) and the §19.1 object layout for the R2007+ streams.
ARCHITECTURE.md§7n records the frame, the stream plan and where §9 differs from the files. R13 (AC1012) has no file in the corpus, so its rows are the table's and unmeasured.src/header_table.rs: the table, a row per slot in stream order (bit code, first and last release, AutoCAD name orUNKNOWN_<code>_<n>).src/header_vars.rs: frame (sentinels, size, CRC), the three streams, typedValues,HeaderVars::{decode, parse_strict, parse_lossy, get, unknowns};DwgFile::header_vars_strict. The section is bounded by the newParseLimits::max_header_bytes; every length is checked before use and every failure is anError.examples/probe_header_vars.rs(dxf-readerfeature), wired into the Corpus job.fuzz/fuzz_targets/header_vars.rswraps its input in a valid frame (both sentinels, a fitting size, the CRC) for every release so it reaches the slot decoder; 47,191 runs over seeds of the 52 real sections found nothing.examples/spec_examples.rs: the spec's own R14 header dump now decodes in full (199 slots, every stream on its boundary), not just its first four BDs.docs/data/spec-coverage.tsviscloses, notcomplete: R13 has no file and no AC1014 export exists.Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo run --release --features dxf-reader --example probe_header_vars -- <dwg-corpus>over the 52 pinned drawings:Padding after the last slot is all ones on 52 of 52. The AC1014 twin is the AC1015 export of the same drawing (no AC1014 export exists). Without arguments the probe reads
../../samples(19 drawings, no twins there): 19 of 19 close.cargo run --release --example spec_examplespasses, with the new §9 decode.cargo test --release --all-featureswas held by the governor and did not complete;cargo test --lib header(25 tests) passed after the rebase.Findings (§9 against the files)
MENUNAME is read on every release (§9 says R13-R18); four unknown
BSend the section on every release from R14 and fiveBfollow them from R2004, in the handle stream from R2007; the padding is ones (the spec's 1998 R14 dump differs, so the probe counts and does not require it); R2000 and later hold universal time in what §9 calls TDCREATE/TDUPDATE (named$TDUCREATE/$TDUUPDATE); a CMC from R2004 keeps its meaning in the top byte of itsBL; the unknownBbefore INTERFERECOLOR and the last unknownBDare$REALWORLDSCALEand$SHADOWPLANELOCATION. The 316 relations are listed by rule in §7n (twin saved later, per-save VERSIONGUID, case-insensitive names, leading-underscore arrowhead blocks, XCLIPFRAME 2 written false before R2010, the default visual style DXF fills in on R2013+, a true colour written as an approximate index).Existing tests changed
In
src/header_vars.rs: removedparse_strict_accepts_sentinel_prefixandparse_reads_sentinel_and_size(they asserted that a 21- or 23-byte "section" with no CRC or end sentinel parses and that the size word counts bits; §9's size counts bytes and the section is at least 58 bytes); adaptedparse_strict_errors_on_short_input(wanted 20 became the 58-byte minimum); kept the three lossy-parse tests unchanged. No test added.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:
The only other inputs: the public corpus (byte inspection and AutoCAD's own DXF exports), and AutoCAD's published lineweight list for
lineweight_hundredths(named in its doc comment; index 29 is the only entry the corpus measures). No algorithm-description comments in other projects were read.Developer Certificate of Origin
I affirm the contribution is my own work and may be distributed under the project's Apache-2.0 license.