Repository navigation
feat(objects): decode VISUALSTYLE on R14, R2000 and R2007 — one field list, four releases - #79
Merged
Merged
Conversation
… list, four releases #72 made the R14 / R2000 / R2007 object walk work and their 216 VISUALSTYLE records reached a decoder for the first time. Neither shipped list closed on any of them, and #73 opened on the obvious reading: a third generation of the layout. There is not one. Measured first, the corpus: every one of the nineteen files holds exactly 24 VISUALSTYLE records, R14 included, so the 216 split 72 / 72 / 72 rather than 108 / 108 / 0. R14 and R2000 write the same 30 flag-less fields in the same order as R2004. The whole difference is §2.11 — before R2004 a colour is the bare BS index, without the BL true-colour word and RC colour byte. Read the five colour slots that way and the list lands all 144 records of the six R14 / R2000 files exactly on their boundary, delta 0. The two encodings agree through the change: R2004's "none" 0xC8000000 is index 257, 0xC3000007 is index 7, and ColorChange's grey 0xC2808080 (face + edge) and Shaded's 0xC2787878 silhouette are ACI index 8 — in exactly those three slots of exactly those two records. R2007 keeps the R2004 colour form and adds exactly one 2-bit slot before the record's final B. With the R2004 list its records land two bits short on all 72, and the leftover bits are 10 then is_internal_use_only — 101 on the fourteen hidden styles, 100 on the ten listed ones, on every record of all three files. Dim pins the position: it is the one record whose display_brightness is the full 34-bit BL rather than the 2-bit zero form, and placing the slot before the brightness closes 23 of 24 and fails on exactly Dim. The head and after-the-final-B placements fail on all 24. Declined honestly: the new slot's token type and its side of display_shadow_type are not determined — both are two bits reading 0 on all 72 records — so it is surfaced as display_unknown_short rather than named after a guess. It is not R2010's format_version, which decodes 2. examples/probe_visualstyle_layout.rs is new: census, joint-boundary check and one-token uniqueness search over every VISUALSTYLE record of every file named. Its --search mode reports 33 closing neighbours on R2007 and 64 on R14 / R2000, all encoding aliases rather than rival layouts — pre-R2004 a colour is a BS, and BS / BL / BD coincide on the small-value forms these records use. Width alone does not pick the layout; the cross-release value agreement does. Measured on the 19-file corpus (examples/coverage_report.rs), merged onto origin/main at 6cc9b13: R14 426 / 450 / 0 / 48.6 % -> 498 / 378 / 0 / 56.8 % R2000 534 / 99 / 0 / 84.4 % -> 606 / 27 / 0 / 95.7 % R2007 462 / 96 / 0 / 82.8 % -> 534 / 24 / 0 / 95.7 % TOTAL 3695 / 741 / 9 / 83.1 % -> 3911 / 525 / 9 / 88.0 % VISUALSTYLE leaves the unhandled histogram entirely; XRECORD (345) is now the largest unmatched class, and the error count is unchanged. Closes #73 Claude-Session: https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C
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_e8529c75-dfaf-4372-b6ea-fb720d89244f) |
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
#73 opened on the reading that R14 / R2000 / R2007 write a third generation of the VISUALSTYLE layout, because neither shipped field list closed on any of their 216 records. Derived per band, the answer is narrower and better: there is no third generation. All four pre-R2010 releases write the same 30 flag-less fields in the same order. The 216 misses have two causes, and neither is field order.
All 456 VISUALSTYLE records of the 19-file corpus now decode.
The record distribution, measured first
The issue allowed for R14 predating VISUALSTYLE. It does not.
examples/probe_visualstyle_layout.rswith no--specis the census, and every one of the nineteen corpus files holds exactly 24 records:So the 216 split 72 / 72 / 72, not 108 / 108 / 0.
Band 1 — R14 and R2000: the R2004 list, with §2.11's older colour form
R14 and R2000 write the same 30 fields in the same order as R2004. The whole difference is §2.11: before R2004 a colour is the bare
BSindex, without theBLtrue-colour word andRCcolour byte R2004 added. Five colour slots × 40 bits is most of the 154-to-170-bit gap between an R2000 record and its R2004 counterpart.Read the colours that way and the list lands 144 of 144 records of the six R14 / R2000 files exactly on their boundary, delta 0. (On R14 the boundary is the
RLobject-data-size that release writes inside the common object data rather than in the object prologue.)The two bands are bit-identical in shape — an R14 file and the R2000 file built from the same drawing give the same 24 budgets: 388, 476, 412, 500, 396, 444, 428, 484, 508, 436, 420, 436, 420, 452, 452, 460, 540, 484, 412, 524, 428, 436, 452, 460 bits.
The two colour encodings agree through the change, on all 144 records:
CMCColorChange0xC2FFFFFF7ColorChangeface + edge colour0xC28080808(ACI dark grey)Shadedsilhouette colour0xC278787880xC8000000("none")257Shades of Gray+Sketchy0xC30000077And the non-colour corroboration the issue asked for, all agreeing with R2004 record for record:
internal_style_type— the dense enumeration0Flat,1FlatWithEdges,2Gouraud,3GouraudWithEdges,42dWireframe,7Basic,9Conceptual…27Shaded;face_opacity—-0.6on twenty-three styles,+0.5onX-Ray, sign included;edge_crease_angle—40onHidden/Sketchy/Shades of Gray,179onConceptual,1elsewhere;display_brightness— the sameBL:-50Dim,50Brighten,0on the other twenty-two;is_internal_use_only, the record's final bit —falseon exactly the ten styles the Visual Styles Manager lists andtrueon the fourteen it hides.Band 2 — R2007: the same list plus one 2-bit slot
R2007 keeps the R2004 colour form and its records land 2 bits short on all 72. The leftover bits are
10followed byis_internal_use_only—101on the fourteen hidden styles and100on the ten listed ones, on every record of all three files. One more 2-bit read before that finalBcloses 72 of 72, delta 0.The slot's position is measured, and
Dimis what measures it: it is the one record whosedisplay_brightnessis not the 2-bit zero form but the full 34-bitBLholding-50, so it discriminates placements the other 23 cannot.arc_2007.dwgdisplay_shadow_type, before the finalBdisplay_brightnessDiminternal_style_typeis_internal_use_onlyHonest declines, with budgets
0on all 72 records, soBS/BL/BDall fit. Surfaced asAcadVisualStyle::display_unknown_shortrather than given a plausible-sounding name — the same treatment the R2004 13-bit constant run already gets. It is not R2010'sBS format_version, which decodes2.display_shadow_typeis not determined either. Both slots are two bits reading0on all 72 records, so the two are interchangeable in the field list. A future R2007 file with a non-default shadow type would settle it.probe_visualstyle_layout --searchmeasures every one-token neighbour (insert / delete / substitute overB BS BL BD RC CMC) against every record at once. It reports 33 closing neighbours on R2007 and 64 on the R14 / R2000 band. Every one is an encoding alias rather than a rival layout: pre-R2004 a colour is aBS, andBS/BL/BDshare bit-prefix grammar so they coincide on the small-value forms these records use. The cross-release value agreement above is what selects the reading, and that is the honest framing — the search narrows the field, the values pick the answer.Coverage — measured before and after, on the merged tree
cargo run --release --example coverage_report, run aftergit -c merge.ff=false merge origin/main(main at6cc9b13):VISUALSTYLE leaves the unhandled histogram entirely. XRECORD (345) is now the largest unmatched class. The error count is unchanged at nine, and the class-census ratchets in
tests/class_census.rsandtests/canonical_corpus.rsare untouched — the walk already reached these records; only the decode changed.Tests
objects::acad_visual_style, one per band boundary: an R14 record closing on theRLinside its own common object data, an R2000 record closing on bare-index colours, an R2007 record closing on its string stream, plus three negative directions (an R2000 body rejected under the R2004 colour form, an R2007 body without the extra slot rejected, an inline body carrying the extra slot rejected under the R2004 list).tests/samples.rsgains a corpus-gated pin over all 456 records: 24 per file, the ten/fourteen internal-use split, the dense0…27enumeration,X-Ray's opacity, the crease angles, the brightness triple andColorChange's grey in both encodings. The content assertions are scoped to the eighteen saved-downarc_/circle_/line_files, becausesample_AC1032.dwgis a different drawing whose author edited some of those values (itsConceptualcarries a 40-degree crease angle).examples/probe_visualstyle_layout.rsis new — census, joint-boundary check and uniqueness search — and exits non-zero when a--specrun leaves any record off its boundary, so it can gate.Follow-ups
acad_materialstill reads only strings and a budget.Gate
cargo fmt --all,cargo clippy --all-targets --all-features -- -D warnings,cargo test --release(774 lib + all integration suites, run with the corpus present so every corpus-gated test and ratchet actually executed),cargo +1.85.0 test --no-run,cargo deny check all,RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features— all clean.Source-provenance declaration
This contribution incorporates no executable code from any source whose license is incompatible with Apache-2.0. No Autodesk SDK source, no ODA SDK / Teigha source, no LibreDWG or other GPL-licensed DWG implementation source was consulted. The colour-form rule is the ODA Open Design Specification for .dwg files v5.4.1 §2.11; VISUALSTYLE itself has no §20.4 prescription, and every field list here was derived by measuring the bytes of the local sample corpus against the boundary each record carries. No third-party project's comments or source were read while preparing it.
Closes #73
https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C
Note
Medium Risk
Changes bit-level object decoding and colour handling for a high-volume object type across three release bands; mitigated by strict boundary checks and extensive corpus tests.
Overview
Closes #73 by decoding all 216 previously unhandled VISUALSTYLE records on R14, R2000, and R2007 using the same 30-field flag-less layout as R2004—not a separate “third generation.”
R14 / R2000: Colour slots are read as bare
BSindices (§2.11 pre-R2004) instead of fullCMCtriples, which closes all 144 records at boundary delta 0.R2007: Keeps R2004 colours and adds one extra 2-bit field before the final
is_internal_use_onlybit, exposed asdisplay_unknown_short(always0in the corpus; token type not pinned).decode_objectno longer returnsUnsupportedfor older releases; pre-R2010 paths all usedecode_legacywith version-awareread_color. Docs, coverage tables, and roadmap items are updated (88.0% aggregate decode rate; VISUALSTYLE off the unhandled list).New
examples/probe_visualstyle_layout.rs(census, joint boundary check,--searchuniqueness). Six unit tests plus a corpus-gatedtests/samples.rspin over 456 records.Reviewed by Cursor Bugbot for commit ad5c737. Configure here.