Repository navigation
feat(tables): R2007+ LTYPE / BLOCK_HEADER string-stream decoders, LWPOLYLINE DD vertices, R2013/R2018 boundary pins - #13
Merged
Conversation
…OLYLINE DD vertices, R2013/R2018 boundary pins Uncommitted April 2026 work recovered from the reconnaissance checkout (~/Developer/re/dwg-recon-2026-04-19/tools/dwg-rs) and re-gated on the clean clone: build, fmt, clippy -D warnings, and every test suite green (649 lib tests). Content, as documented in the CHANGELOG entries it adds: - LTYPE and BLOCK_HEADER modern paths read R2007+ table-record names from the split string stream (ODA v5.4.1 §19.1 / §19.5.3), with fallback to the legacy inline decoder when the modern parse is implausible - LWPOLYLINE vertices as first point RD/RD then DD/DD against the previous point; LINE end coordinates as DD with the start as default - BitCursor::read_dd and bit-writer counterparts - real-DWG regressions in tests/r2013_entity_values.rs (block-record and linetype names on sample_AC1032.dwg, LINE geometry on line_2013.dwg, LWPOLYLINE bodies), two new trace probes under examples/ - README / STATUS / ROADMAP / docs re-measured: aggregate real-file coverage 7.3% -> 20.1% on the 19-file local sample set (R2018 sample 13.8% -> 44.2%), error table per entity type refreshed
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_2f089c95-aaf2-4f71-a1ed-88879bc5ea98) |
The April decoder-table work added 123 undocumented pub fns, tripping the docs-rs workflow's 80% soft gate. Each now carries a one-line doc naming the ODA bit code, flag mask, or spec code it implements; no behavior changes.
10 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
…94, refs #17) (#19) * test(ci): commit a self-generated canonical DWG corpus and make coverage-smoke non-vacuous tests/fixtures/canonical/ held no .dwg file, so the CI job "Coverage smoke test (canonical corpus)" skipped with a warning on every run and provided zero regression protection (task #94). The corpus README said this was blocked on write-path Stages 2-5. It is not: file_writer::assemble_dwg_bytes lands a complete R2004-family byte buffer, handle_map::write_handle_map emits AcDb:Handles, and the ElementEncoder impls cover LINE / CIRCLE / ARC / POINT. Wiring those together with a common-entity-preamble writer (the exact inverse of common_entity::read_common_entity_data) produces files this crate's reader decodes end-to-end. - examples/build_fixtures.rs generates the corpus: four Apache-2.0, self-generated files (~1.2 KB each), one per version assemble_dwg_bytes accepts (R2004, R2010, R2013, R2018), each with AcDb:Header + AcDb:Handles + AcDb:AcDbObjects and five entities (2D LINE, 3D LINE, CIRCLE, ARC, POINT). Generation is byte-deterministic. - Measured with `cargo run --release --example coverage_report`: 20 decoded / 0 unhandled / 0 errored, aggregate decoded_ratio 100.0%. - ci.yml now fails when the corpus is empty instead of skipping, checks the committed bytes still match the generator, and asserts decoded_ratio >= 95.0 — the measured 100.0 minus one entity out of twenty. The margin is small on purpose: the ratio is a deterministic function of the committed bytes, not a timing measurement. - tests/canonical_corpus.rs is the tight companion gate under `cargo test`: it pins per-file entity counts AND decoded field values, so a bit-alignment regression that still "decodes" into garbage coordinates fails even though the ratio would stay at 100%. No byte of any Autodesk-, ODA-, or third-party-produced DWG is redistributed; provenance and the honest-scope note are in tests/fixtures/canonical/README.md. * ci(perf): gate criterion regressions on ratio + absolute delta + a confirming re-run Refs #17. Profiling first. An attribution probe (replace both compute_checksum call sites in build_section with black_box(0u32), re-run the bench) shows stage1_build_section/uniform_16k is 92% section_writer:: compute_checksum: 21.25 us -> 1.73 us. lz77_encode::compress is literal-only and performs no match search at all, so #17's premise — "the longest-match path of the encoder ... the most branch-predictor / alignment sensitive one" — does not hold: the four bench cells differ only in size, not in compressibility, and the moved cell is a serial rotate-and-add chain, not a matcher. That loop is `sum = rot1(sum) + b`, a strict loop-carried dependency of two 1-cycle ops. 2 cycles/byte is the floor and vectorisation is impossible (rot1 is 2x mod 2^32-1, the add is mod 2^32; they do not distribute). Measured cost is ~2.2 cycles/byte, already within ~11% of that floor. Then the layout hypothesis, tested. Six measurements of uniform_16k on an M2 Max, taking the minimum per-iteration time across criterion's 100 samples rather than the mean: rolled checksum, unperturbed ................ 20802 ns / 21893 ns rolled checksum, + unrelated fn in bitwriter 20960 ns 8-way unrolled + #[inline(never)], unperturbed 21830 ns 8-way unrolled + #[inline(never)], + that fn 20867 ns Everything lands in a 20.80-21.89 us band with no consistent ordering by build. The same source measured twice moves 5.2%. The unrolled + #[inline(never)] variant was therefore dropped: it stabilises nothing and it is not faster. What was actually unstable is the estimator. On a loaded machine criterion's mean reported 21.25 us -> 32.99 us (+55%) for the same binary where the minimum of the same samples showed +4.9%. A 21 us bench on a shared GitHub vCPU cannot support a 20%-ratio verdict on its own — which matches #13's run, where uniform_16k "regressed" 24% while three sibling cells improved 10-17%. So the fix is CI-side. A bench now fails only when all three hold: 1. ratio = pr_mean / main_mean >= 1.20 (threshold unchanged) 2. delta = pr_mean - main_mean >= 5000 ns 3. the same bench trips (1) and (2) again on an immediate re-run The table prints on every run regardless of the verdict, and the re-run only executes on the failing path. 5 us is chosen so the cells it exempts (alt_1k ~1.7 us, uniform_16k ~21 us) exercise the same build_sections code path as mixed_64k (~100 us) and mixed_256k (~334 us), which stay gated — no code path loses coverage. Also: - .github/scripts/criterion-gate.sh reads criterion's own estimates.json with jq instead of scraping critcmp's formatted text, which drops a ~1-minute `cargo install` from every run and gives the gate the exact nanosecond delta it needs. - benches/write_path.rs switches to iter_batched so the per-iteration 16-256 KiB payload clone is setup rather than measurement; it was charging allocator variance to the work under test. - compute_checksum grows a doc comment recording the attribution numbers, and a test pinning its output at every length and seed against the spec 4.6.1 reference definition, so the next person to try unrolling it has to stay byte-identical. * chore(git): ignore the target-msrv/ CARGO_TARGET_DIR used for MSRV checks
Closed
4 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Recovers ~1,400 lines of April 2026 decoder work that was left uncommitted in the reconnaissance checkout, re-gated on a clean clone: modern (R2007+)
LTYPEandBLOCK_HEADERtable paths that read names from the split string stream,LWPOLYLINEDD vertex decoding,LINEDD end coordinates,BitCursor::read_dd, real-DWG regression tests, and the re-measured coverage docs.Motivation
Symbol-table names (block records, linetypes) and correct polyline vertices are exactly what Revit-exported DWGs are made of, and this is the step toward dwg-rs being usable as a documented-format oracle for rvt-rs geometry. Measured aggregate real-file coverage moves from 7.3% to 20.1% on the 19-file local sample set; the R2018 sample from 13.8% to 44.2%.
Changes
See the CHANGELOG entries this PR adds (dated 2026-04-29, #103):
src/tables/{ltype,block_record}.rs,src/entities/{dispatch,line,lwpolyline}.rs,src/bitcursor.rs,src/bitwriter.rs,src/common_entity.rs,src/element_encoder.rs, tests (r2013_entity_values,integration_entity_regression,proptest_roundtrip), examples (two new trace probes), README / STATUS / ROADMAP / docs numbers.Testing
cargo build --all-targets,cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings: cleancargo test --all-targets: every suite green (649 lib tests + integration suites)examples/coverage_report.rsre-run today against the same sample set reproduces the README table exactly: 458 decoded / 1,660 skipped / 163 errored / 20.1%;sample_AC1032.dwg329 / 337 / 79 / 44.2%.gitwere archived byte-for-byte first (~/Developer/archive/dwg-rs-uncommitted-2026-08-30/); the recon checkout is untouched.Note
Medium Risk
Large changes to bit-aligned entity and table decoders on production DWG payloads; regressions would misdecode geometry or names, though real-DWG tests and coverage metrics mitigate that.
Overview
This PR lands a batch of #103 real-file decoder fixes that realign R2013/R2018 payloads and recover more symbol-table strings on modern DWGs. Measured corpus decode success rises from ~7.3% to ~20.1% aggregate (AC1032 ~13.8% → ~44.2%), with README/ROADMAP/STATUS and announcement copy updated to match.
Bit primitives and geometry: Adds
read_dd/write_ddand switchesLINEend points from BD deltas to DD defaults (each start coordinate).LWPOLYLINEvertices use first-pointRD/RD, thenDD/DDchained from the previous vertex.common_entitypreamble is corrected for traced R2013/R2018 data (drops obsolete modern layer/linetype bits, R2013+ DS-data bit, RCshadow_flags, R2004+ CMC suffix skips without eating handle-stream bits).R2007+ tables:
BLOCK_HEADERand simpleLTYPErecords get split string-stream decode paths inblock_record/ltype, wired fromdispatchwith legacy inline fallback. Dump example printsBlockRecordandLTYPEnames.Verification:
tests/r2013_entity_valuesis active (no#[ignore]) with assertions online_2013.dwg, AC1032 LINE/LWPOLYLINE populations, and expected block/ltype names. New forensic examplestrace_entity_boundaryandtrace_table_entrysupport boundary debugging.Reviewed by Cursor Bugbot for commit d0e3a03. Configure here.