Repository navigation
feat(objects): decode VISUALSTYLE on R2004 — the flag-less generation (72 records, 92.0% → 95.0%) - #64
Merged
Conversation
R2004 stores the same 24 shipped styles on a second field list: 30 fields, no (value, flag) pairs, one fewer property and a different order. It closes with delta 0 on all 24 records of each of arc_2004.dwg, circle_2004.dwg and line_2004.dwg — the whole 72-record Unhandled block. Both ends of the record are anchored from its own redundancy: the front from probe_token_scan's full-form BDs and method-carrying CMCs, the back from the unique offset at which BS, BL, BS, B lands exactly on the RL object-data-size boundary. Two structural findings fall out: is_internal_use_only is the record's final bit rather than part of its head, and display_brightness is a BL where R2010 spends a BD, which is why Dim's record runs 32 bits longer than its neighbours' and Brighten's 8. Twelve BS slots, all five CMCs and both remaining BDs decode the same value as the same style on arc_2010.dwg, on all 24 records. face_opacity and face_specular are signed on R2004; magnitudes match R2010 everywhere and the sign tracks whether the property applies. The 13 bits between edge_silhouette_width and edge_intersection_linetype are constant on all 72 records, so only their width is evidence: read as RC BS B BS, with the leading byte surfaced as edge_unknown_byte rather than given an invented name. R2007 stays declined — the container parse is Deferred for AC1021 and the split-stream trailer is located from an MC field only R2010+ writes, so no R2007 object reaches a decoder at all. Corpus: 2187/191/0 (92.0%) -> 2259/119/0 (95.0%); R2004 85.4% -> 97.5%. Refs #48
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_c0a24daf-d7b8-4232-9156-ec96d19610fc) |
This was referenced Aug 30, 2026
…4-r2007 # Conflicts: # README.md # STATUS.md
This was referenced Aug 30, 2026
fix(entities): hold every entity type to its exact data-stream boundary (2262/116/0 → 2273/96/9)
#69
Merged
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.
Closes the R2004 half of #48:
VISUALSTYLEnow dispatches onAC1018,taking all 72 of its corpus records — the largest remaining
Unhandledblock. The R2007 half stays open, and the reason is upstreamrather than this object (see below).
Measured coverage
cargo run --release --example coverage_report -- <samples>, re-run onthe merged tree (
origin/mainis7418d25; nothing moved under itduring this work, so the merge was a no-op).
Per-file:
arc_2004.dwg,circle_2004.dwgandline_2004.dwgeach go170 / 29 / 0 → 194 / 5 / 0. Zero errors corpus-wide is preserved, and
VISUALSTYLEnow reaches 240 of the 240 records the class censusdeclares across the walkable files.
The R2004 layout
30 fields, no
(value, flag)pairs, one fewer property than R2010, anda different order. Delta 0 on all 24 records of all three
*_2004.dwgfiles.
Three slots of the R2010 head are gone or moved: there is no
format_versionat all,face_modifiersits afterface_mono_color,and
is_internal_use_onlyis the record's last bit.Bit evidence
Both ends anchored from the record's own redundancy. At the front,
examples/probe_token_scan.rsreports the self-identifying tokens —full-form
BDs that decode to short decimals andCMCs whosetrue-colour word carries a real method octet — which pin
face_opacity(bit 435 on
arc_2004.dwghandle 42),face_specular(501) andface_mono_color(567). Neither pattern survives a one-bit shift.At the back, a reverse scan for the offset at which
BS, BL, BS, Blands exactly on the
RLobject-data-size boundary returns exactlyone position on every one of the 24 records, and its four values
reproduce R2010's
edge_style_apply(13on Flat/FlatWithEdges/Gouraud/GouraudWithEdges/Realistic/X-Ray,
5on the two Shaded styles,1elsewhere),display_shadow_type(0) andis_internal_use_only.That last bit splits the 24 styles into precisely the ten AutoCAD's
Visual Styles Manager lists and the fourteen it hides — the same
partition R2010 produces from a bit 500-odd positions earlier.
Two structural findings.
is_internal_use_onlymoved from the headto the final bit; and
display_brightnessis aBLwhere R2010spends a
BD, decoding-50(Dim),50(Brighten) and0(the other22) against R2010's
-50.0/50.0/0.0. TheBLis also the wholeexplanation for the corpus's bit budgets: the tails after the two edge
CMCs measure 124 bits on 22 records, 156 onDim(fullBL, +32) and132 on
Brighten(byteBL, +8), and nothing else in the record variesbetween those three styles.
Value corroboration against a second file. Twelve
BSslots, allfive
CMCs and both remainingBDs decode the same value as the samestyle on
arc_2010.dwg, on all 24 records — including everything thatvaries style by style:
internal_style_type0Flat …27Shaded;edge_modifier0/8/10/11/12,edge_silhouette_width3/5/6,edge_width1,edge_overhang6,edge_jitter2;edge_obscured_linetype2on Hidden and Shaded-with-edges,7onLinepattern,
1elsewhere — andedge_intersection_linetype7onLinepattern,
1elsewhere, the pair that pins the two ends of thetrailing run;
edge_crease_angle40on Hidden / Shades of Gray / Sketchy,179on Conceptual,
1elsewhere;face_mono_color0xC2FFFFFFeverywhere but ColorChange's0xC2808080;edge_silhouette_color0xC3000007everywhere butShaded's
0xC2787878.Two slots differ, informatively.
face_opacityandface_specularare signed on R2004. Magnitudes match R2010 on all 24; the sign
tracks whether the property applies —
face_specularis positive onexactly the seven styles that shade faces (Flat, FlatWithEdges, Gouraud,
GouraudWithEdges, Realistic, Shaded, Shaded with edges) and negative on
the other seventeen, and
face_opacityis positive on exactlyX-Ray,the one translucent style. Values are surfaced as measured, sign
included. One further value differs for content reasons:
Realisticdecodes
face_lighting_quality2on R2004 and3on R2010, withevery other field of that record agreeing — the style being clamped when
saved down, not a mis-read field.
What is not determined — the 13-bit run
Thirteen bits sit between
edge_silhouette_widthandedge_intersection_linetype, and they hold the constant0b0_0000_0001_0010on every one of the 72 corpus records. A runthat never varies cannot have its internal boundaries measured, only its
width; an exhaustive enumeration returns many splits that fit. The module
reads it as
RC BS B BS— the only fit whose first token is a whole byte— names the last three for the three properties R2010 places in exactly
this position (
edge_halo_gap,edge_hide_precision,edge_isoline_count, all of which decode0/false/0there onthe same 24 styles), and surfaces the leading byte as
AcadVisualStyle::edge_unknown_byterather than giving it aplausible-sounding name. Documented as a reading, not as evidence, in
the module docs, ARCHITECTURE.md §7d.1a and CLEANROOM.md. A future R2004
file with a non-default halo gap or isoline count would settle it.
Why R2007 is still declined
Not for want of a field list. Two upstream gaps stand between an
AC1021file and any decoder:SectionMapStatus::Deferredfor R2007(Publish from a signed tag through trusted publishing #110, second Sec_Mask obfuscation layer);
string_stream::data_section_endlocates the split-stream trailerfrom the leading
MChandle-stream size that only R2010 and newerwrite, so it declines R2007 outright.
probe_object_layoutonarc_2007.dwgpanics with "this version hasno object-stream walk", and
probe_class_censusreports "noAcDb:Classes section". No R2007 object of any type reaches this module,
so the corpus cannot say whether R2007 writes the flag-less list or the
paired one.
decode_objectreturnsError::Unsupportedfor that bandrather than shipping a reading no byte has ever confirmed, and the
dispatcher maps that to
Unhandled. #48 stays open for R2007 — thisPR says
Refs #48, notCloses.Tests
Four new
BitWriterfixtures alongside the existing R2010/R2013 ones:r2004_inline_visual_style_closes_on_its_object_data_size— theflag-less body on the inline layout, checking
format_version == 0(no such slot on R2004), the signed
face_opacity, theBLbrightness,
edge_unknown_byteand an emptyproperty_flags;r2004_body_rejected_by_the_r2010_field_list— the two lists differby 28
BSflags, so the boundary check has to reject the crossover;rejects_r2007/rejects_pre_r2004— both decline withError::Unsupported, so a dispatched record lands in the Unhandledbucket rather than being reported as broken.
Gate:
cargo fmt --all,cargo clippy --all-targets --all-features -D warnings,cargo test --release(16 suites, all green),cargo +1.85.0 test --no-run,cargo deny check all,RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features— allclean.
Clean-room declaration
I certify that:
CLEANROOM.md. Inparticular, I did not consult Autodesk SDK source, ODA SDK (Drawings
SDK / Teigha) source, LibreDWG source, decompilations of Autodesk or
ODA binaries, or any copyleft-licensed DWG implementation code.
derived entirely from the corpus bytes and the boundary the format
itself carries, and every name on it is carried over from the R2010
list already disclosed in
CLEANROOM.md(2026-08-30, VISUALSTYLEproperty names), justified slot by slot against the value the same
style decodes on
arc_2010.dwg. The one slot with no R2010counterpart is labelled
edge_unknown_byte. ODA spec v5.4.1 §20.4carries no
VISUALSTYLEentry, and no citation is claimed for it.CLEANROOM.mdrecords this in the VISUALSTYLE section.commercial or NDA'd context.
Refs #48
Note
Medium Risk
Non-spec binary layout decoding affects 72 real records; wrong field boundaries would mis-read style data, though boundary self-checks and cross-file corroboration reduce that risk.
Overview
Adds R2004 (
AC1018) decoding forACAD_VISUALSTYLE, clearing the largest remaining unhandled block (72 corpus records) by routingdecode_objectto a new 30-field, flag-less wire layout distinct from the R2010+(value, flag)list.The R2004 path reads inline
TV, usesBLfordisplay_brightness(widened tof64), leavesformat_versionat 0, movesis_internal_use_onlyto the record tail, and exposes a constant 13-bit gap asedge_unknown_byteplus documented halo/isoline slots rather than inventing names. R2010+ behavior is unchanged behinddecode_paired; pre-R2004 and R2007 still returnError::Unsupported(upstream object-stream gaps, not guessed).Coverage docs (
README,STATUS,CHANGELOG,ARCHITECTURE,CLEANROOM) now report 2,259 decoded / 119 skipped / 0 errored (95.0% aggregate), with R2004 at 97.5%. New unit tests assert the R2004 body closes onRLboundary and is rejected if parsed with the R2010 field list.Reviewed by Cursor Bugbot for commit 723a6bb. Configure here.