Repository navigation
feat(container): open and walk AC1012 (R13), pinned on 22 real drawings (#119) - #323
DrunkOnJava wants to merge 27 commits into
Conversation
… R13-R15 container (#119) R13 shares the flat section-locator container, the unframed object stream and the R13-R14 branches of the entity and object prologues with R14, so every test the crate wrote as 'is R14' for one of those branches becomes is_r13_r14().
…es, so its size field reaches 2034 (#213) The walk refused any chunk whose size field passed 2032. That rejected 7 of 22 real R13 drawings and the AutoCAD-saved R14 and R2000 drawings of ACadSharp, which hold chunks of 2033 and 2034 bytes. The streaming E2E now walks one of each against an independent framing parse and the legacy reader.
…§2.10) The helpers read the R2000+ flag-then-value forms on every release, which only agrees with the R13-R14 form when thickness is 0 and the extrusion is (0,0,1). Measured on Cabin.dwg: 18 LINE and 2 POLYLINE_2D records with a non-default thickness or extrusion now end exactly on their RL boundary. The synthetic R14 LINE of tests/integration_legacy_container.rs wrote the one-bit defaults the old reader assumed; it writes the BD and 3BD §2.8 and §2.10 print.
§20.4.44 prints 'R14 Only' for the RC after Numitems; R13 writes nothing there. 88 R13 DICTIONARY records missed their RL boundary (by 8 bits when the dictionary is empty).
…over the R13-R14 branches added since (#119) header_vars.rs matched Version exhaustively, so the R13 variant needs its own arm: the table already carries the R13 rows. MTEXT's and LWPOLYLINE's R13-R14 branches (#261, #264) were written as 'is R14'. Cabin.dwg's 195 header slots end on the stated size; the probe also reports the 21 Sovol headers, which hold 84 bits more than any table reads.
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. |
, #119) The 21 Sovol R13 drawings write the four 'R14+' unknown shorts of §9 (each -1; §9 says they 'do not seem to be required') after the R13 slots, and size the header one byte past the byte holding the last slot, so the R13 rows left 84 bits and the Corpus job's header probe failed on them. An AC1012 header whose R13 rows leave a whole byte or more is now read with the R14 rows and may end one byte before its data; Cabin.dwg and every other release read as before. All 22 R13 headers, 199 slots on the Sovol drawings, now decode to the stated size.
…er's R13, not AutoCAD's format (#119)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0c186b7b1
ℹ️ 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".
… header-variable failure (#119) The header-variable arm printed FAIL without setting the exit status, so a drawing that passed the framing checks but did not decode to its stated end reported success. Every failure line now goes through one emit that sets it, including a file that fails to open and a missing object map or header.
Conflicts: ARCHITECTURE.md (the R13 section is 7ac, after main's 7ab), docs/data/spec-coverage.tsv and docs/spec-coverage.md (my row notes appended to main's, §3 and §23 kept), src/entities/dispatch.rs (main's R13/R14 DIMSTYLE arm kept as main wrote it; the BT/BE decode_for routing kept), and tools/corpus/baseline.tsv regenerated: main's rows unchanged, 22 R13 rows added.
…riters (#119, #345) Autodesk's own R13 discs pad 0000 in 196 of 263 headers and 1111 in 6. What holds on every AutoCAD-written header: 195 slots, a section of exactly ceil(bits / 8), three or four locators and a real preview. The Sovol files are not AutoCAD's on the extra header byte, the blank preview and the R2007+ SUN object. The byte after 18 in section 26's tail varies on Autodesk's own files, so Cabin's 18 30 is not evidence against AutoCAD.
…cator layout still waits for Autodesk's discs (#345)
…sha256 and what was read (#119, #345) Griffin decided on 2026-10-26 that these drawings are measured and cited, never pinned, fetched by CI or committed. docs/data/r13-autodesk-discs.tsv has one row per distinct drawing; the ARCHITECTURE section cites the 3- and 4-locator layouts, the 195-slot ceil(bits / 8) header, the padding spread and the real previews from it.
…ies and probe_dxf_tables map R13 to no DXF writer, as R14 (#119) Main matches Version exhaustively in the three probes, so clippy --all-targets does not compile them once Version::R13 exists.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ 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".
| return Err(Error::NotDwg { got: *magic }); | ||
| } | ||
| Ok(match magic { | ||
| b"AC1012" => Self::R13, |
There was a problem hiding this comment.
Keep R13 on the primitive DXF export path
For an AC1012 drawing with a closed header and decoded layers, conversion to R2000-or-later DXF silently drops all geometry. Accepting R13 here exposes the existing dxf_entities::writes() predicate, which excludes only R14, so dxf_convert::convert() selects the handle-aware exporter instead of its primitive fallback. However, handle_stream_start() returns None for R13 records, and the entity_refs() error makes dxf_entities::build() skip every entity; the converter then returns a successful but empty export. Exclude R13 alongside R14 in the exporter-selection predicate until its handle references are supported.
Useful? React with 👍 / 👎.
* 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.
Summary
DwgFileopens and walks AC1012 (R13): 22 real R13 drawings are pinned in the corpus, every handle-map entry of all of them lands on a record that repeats its handle, and the R13-R14 fixes the new files surfaced are in (#119).Spec reference
ODA v5.4.1 §3, §9, §10.1, §14.2, §20.1, §20.4.1, §20.4.44, §23.1, §26 and §2.8/§2.10. The findings, with bit evidence, are ARCHITECTURE.md §7au and the notes of docs/data/spec-coverage.tsv. R13 claims boundaries only: no AutoCAD DXF of an R13 drawing exists, so no row changes state and nothing is marked
complete.What the PR contains, one commit each:
tools/corpus/pins.tsv: SketchUp'sCabin.dwg(Apache-2.0) and the 21 Sovol3d/SOVOL-ZERO drawings (no licence stated: fetched by pinned hash, never committed).fetch.pynow percent-encodes the repository path: the Sovol paths are Chinese part names with spaces, and the unquoted URL raiseshttp.client.InvalidURL, whichfetch.pydoes not catch. CLEANROOM.md records the provenance.Version::R13(AC1012) andVersion::is_r13_r14(); every "is R14" test the crate wrote for an R13-R14 branch now asks it.tools/streaming/verify_walk.pyalso walksCabin.dwgand two Sovol drawings (manifestswalk-sketchup-corpus.json,walk-sovol-corpus.json) and percent-encodes their URLs.read_bt_for/read_be_for: BT and BE on R13-R14 are a bareBDand3BD(§2.8, §2.10).examples/probe_r13_container.rsandexamples/probe_r13_entities.rs.header_vars.rsmatchedVersionexhaustively, so it gets an R13 arm (the table already carries the R13 rows); an AC1012 header whose R13 rows leave a whole byte is read with the R14 rows (see the header bullet below); the R13-R14 branches of MTEXT (fix(entities): read MTEXT's §20.4.46 version branches on R13 to R2004 (#226) #261) and LWPOLYLINE (fix(entities): route the R14 LWPOLYLINE and HATCH classes and read LWPOLYLINE's R13-R14 vertices (#229) #264), written as== Version::R14, askis_r13_r14().tools/corpus/baseline.tsv: 22 added rows, no existing row changed.lib.rsversion table, README, ROADMAP's containers row.examples/probe_dxf_header.rs(feat(dxf): write the decoded header into dwg-to-dxf's HEADER section (#126) #320) matchedVersionexhaustively, soclippy --all-targetsfailed on the merged tree onceVersion::R13existed; R13 maps to no DXF header writer, as R14.Evidence
Before: every one of the 22 files is
open-failed: Unsupported DWG version. After (coverage_report, with main at 4ec356a, which brings #258, #297 and #249, merged in):probe_reference_closure); every class reaches its declared count (probe_class_census).probe_r13_containerre-reads the framing independently and passes locator CRC, sentinels, image sentinel, §9 and §10.1 sections and every §23.1 chunk CRC on all 22. Two layouts:Cabin.dwghas 4 locators (CRC XOR 0x8101, first count-4 file measured) with image data at the end; the Sovol drawings have 5 (0x3CC4) with image data at 0x58. No three-locator (C2) drawing exists in the corpus.stream_walkandstream_walk --legacylist the same records on all 22 and on ACadSharp'ssample_AC1014.dwgandsample_AC1015.dwg. Before main's chunk fix (§7ac) 9 of those 24 (7 R13, the R14 and the R2000) failed withMapChunk; their chunks are 2033 or 2034 bytes (the size field counts its own two bytes, so §23.1's 2032 counts the entries).tools/streaming/verify_walk.pynow also walksCabin.dwgand two Sovol drawings (beside main's ACadSharp files) against its independent framing parse.0x28ofCabin.dwg(RL boundary 605): read as BD + 3BD it ends on bit 605 with thickness 1.0 and extrusion (-1, -3e-16, 0); read as BT + BE it reads a reserved11BD tag. 18 LINE and 2 POLYLINE_2D records close that errored; no R14 or R2000 baseline row moves (their records have the default thickness and extrusion, for which the two forms read the same bits).probe_header_varsruns on them and exits 0).Cabin.dwgcloses on the 195 R13 slots. The 21 Sovol headers read their R13 slots plausibly and then hold 84 bits: four BS00+FFFF(72 bits) and 12 bits of padding. The four BS are §9's "R14+" block, "unknown short (type 5/6 only) ... these do not seem to be required" (the Sovol writer writes -1 in each; AutoCAD's R14 files hold arbitrary values). The 12 bits are the 4 bits ending the byte of the last slot (1010in all 21) and one whole byte more (00in 19,52and7Fin the others): the Sovol section size isceil(bits/8)+1(403 to 404 bytes, 395 to 396). The padding bits do not tell writers apart (Autodesk's own R13 discs pad0000in 196 of 263 headers and1111in 6, R13: no AutoCAD-written AC1012 drawing in the public corpus #345); what holds on every AutoCAD-written R13 header is 195 slots in a section of exactlyceil(bits/8), so the Sovol files are non-AutoCAD on the extra byte, a blank preview bitmap (the same 180 x 97 image in all 21) and the R2007+SUNobject. An AC1012 header whose R13 rows leave a whole byte is therefore read with the R14 rows and may end one byte before its data does; that tolerance is for this writer's variant, confined to AC1012, not AutoCAD's format.Cabin.dwgand every other release read as before. Bit evidence in ARCHITECTURE.md §7au.== Version::R14ormatches!(version, Version::R14): ATTRIB 179 and ATTDEF 57 (TEXT family, fix(entities): read TEXT, ATTRIB and ATTDEF as §20.4.3-§20.4.5 print them on every release (#226, #62) #258), DIMSTYLE 161 (fix(tables): decode R14 DIMSTYLE with §20.4.68's R13/R14 block (#74) #297), LEADER 42 (fix(entities): read §20.4.47 LEADER's end point projection and tails on every release (#71) #249). The 21 skipped are oneSUNclass record per Sovol drawing. The follow-up that swaps those tests foris_r13_r14()(and skips LEADER'sEndptprojon R13, which §20.4.47 marks "R14+") is a separate PR with its own R13 and R14 corpus evidence; in a scratch tree with those swapsCabin.dwgwas 3,590 decoded, 0 skipped, 0 errored and the 21 Sovol drawings 24,103 decoded, 21 skipped (SUN), 0 errored. Every other release stays at 0 errors.Reproduce (the commands the Corpus job runs):
python3 -I tools/corpus/fetch.py --dest ../dwg-corpus cargo build --release --features dxf-reader --example coverage_report \ --example probe_class_census --example probe_reference_closure \ --example probe_r13_container --example probe_r13_entities python3 -I tools/corpus/measure.py run --corpus ../dwg-corpus --bin target/release/examples --out r.json python3 -I tools/corpus/measure.py check --results r.json target/release/examples/probe_r13_container ../dwg-corpus/sketchup/Cabin.dwg ../dwg-corpus/sovol/*.dwgTest plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features,cargo +1.85 check --all-featurescargo test --release --all-features --no-fail-fast: no unit test added. One existing test encoded the disproven behaviour and is adapted:tests/integration_legacy_container.rswrite_r13_r14_line_bodywrote the R14 LINE's thickness and extrusion as the two one-bit R2000+ defaults; it writes the bareBDand3BDthat §2.8 and §2.10 print.measure.py checkdiffers from the committed baseline only by the 22 added rows), thedxf_oracleratchet,probe_r2007_rs,probe_data_page_header --strictandprobe_header_vars(exit 0, all 22 R13 headers closed) with the R13 files in the directory,tools/streaming/verify_walk.pyagainst a release build (CI runs the debug one).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).My contribution is based on the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1) and on byte-level inspection of the 22 public drawings pinned in
tools/corpus/pins.tsv, read only through this crate and its probes (no code from SketchUp/sketchup-developer-tools or Sovol3d/SOVOL-ZERO was consulted). No reading of another DWG implementation's comments was needed; nothing needs adding toCLEANROOM.mdbeyond the corpus provenance entry in this PR.Developer Certificate of Origin
I affirm that the contribution complies with the Developer Certificate of Origin 1.1.