Skip to content

fix(formats): a char field is 1 byte and a short field 2, not 2 and 4 (#1196) (RE-325) - #1315

Merged
DrunkOnJava merged 7 commits into
mainfrom
re/1196-scalar-widths
Nov 4, 2026
Merged

DrunkOnJava merged 7 commits into
mainfrom
re/1196-scalar-widths

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

A Formats/Latest descriptor with base byte 2 (the C++ char) is 1 byte in an instance and base byte 3 (short) is 2; FieldType::decode gave them 2 and 4, and the walker read the first as a u16. The native graph decoder had them right. This measures the widths from instance bytes and corrects the classifier, the walker and the docs (RE-325).

Motivation

#1196. RE-323 (#1309) found the native decoder reading base 2 as 1 byte and base 3 as 2 and decoding 97,000 of 97,005 Revit 2027 records with them, but nobody had shown, field by field, that instances take those widths. Layer 4c FieldType changes need byte evidence from the corpus.

Changes

  • probes/examples/probe_re325_scalar_widths.rs: the census of every base-2 and base-3 grammar field and of the scan's reading of them, the slot types of the std::pair< A, B > classes, the instances in complete native graphs (value ranges, byte-blob signatures) and the same records decoded again with the schema's base bytes rewritten to other widths, every field at once and one at a time.
  • src/formats.rs: Primitive { kind: 0x02 } is 1 byte, { kind: 0x03 } 2 (scalar_size); docs. No other classification moves; tests/field_type_coverage.rs is untouched.
  • src/walker.rs: read_field_by_type / write_field_by_type read and write a 0x02 primitive as a u8 and a 0x03 primitive as an i16; a 0x02 vector or container (a byte blob) is read whole with its count instead of leaving its payload to be read as the next fields.
  • src/research/native_document.rs: Options::keep_body and Record::body (off by default) so a probe can decode a record's bytes under another reading of the schema.
  • reports/element-framing/RE-325-scalar-widths.md, changelog.d/fixed/1196-scalar-widths.md, and the corrected widths in docs/format.md, docs/extending-layer-5b.md, docs/container-wire-format-2026-04-21.md and a correction note in docs/format-reconnaissance.md.

Testing

Unit tests are banned: none added. The probe is the test, run through Measure on Autodesk's 58 sample projects (Revit 2015 to 2027) and the 13 family files; runs and counts are in the report.

  • Verified end to end on real Revit files: Measure 41762248491 (families), 41762555375, 41762559148, 41762563120 (samples), probe commit 6f099c91. The 58 projects (13 releases) hold 402,652 native records with an instance of a base-2 or base-3 field; 402,293 decode without the extensible-storage catalog (the other 359, in the 2024 projects, need it) and every one of those (683,250 instances of 20 fields) is read completely at 1 and 2 bytes. FieldType's widths (2, 4) read 65 of them (those whose only instances are empty byte buffers); base 3 at 1 or 4 bytes reads 393,581 and leaves exactly the 8,712 that hold a base-3 instance; each of the 20 fields rewritten alone to another width leaves none of its non-empty records whole. 13,407 PNGs end with their IEND chunk at the declared count, one byte per element.
  • Identity (Measure 41765290302, -f base=main -f nordic=true -f r2025=true -f samples=true -f holdout=true -f families=true, head 3084c431 against main at 5aa4da77): 124 items; every ifc.sha256, diagnostics.json, info.json, info.exit, schema.txt and scorer output is byte-identical, and the scorer diff is empty. Nothing moves in an export. Held-out models: counts only, nothing quoted.
  • tools/check-local.sh's gates run in CI (no local builds in this checkout)

Audit-honesty checklist

  • Docs reflect the state after this PR; the old claim that 0x03 is a deprecated 4-byte alias seen in 2016 to 2018 only is corrected in docs/format.md and docs/format-reconnaissance.md (kept, with a correction note).
  • Changelog fragment under changelog.d/fixed/.
  • Limitation recorded: 03 10 00 00 (short[3]) arrays are still Unknown in the scan (they sit in an empty-named composite the scan never files); not changed.
  • No emojis; no private paths.
  • Reverse-engineering finding: probe under probes/examples/ and report RE-325; docs/format-reconnaissance.md carries a dated correction.

Legal and contribution hygiene

  • Apache-2.0
  • Clean-room declaration: the evidence is public byte observations (the schema's own type names and instance bytes of Autodesk's redistributable sample files and the maker families), no Autodesk or ODA SDK source, disassembly or NDA material (CLEANROOM.md).
  • No fixtures added.

Breaking changes

None to the API. FieldType::Primitive's size for kinds 2 and 3 changes value (2 to 1, 4 to 2).

Related issues

Refs #1196 (RE-323, #1309).

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 4, 2026 03:40
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 4, 2026 03:40
@DrunkOnJava
DrunkOnJava merged commit 410dda0 into main Nov 4, 2026
28 checks passed
@DrunkOnJava
DrunkOnJava deleted the re/1196-scalar-widths branch November 4, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant