Skip to content

feat(formats)!: classify the residual Formats/Latest field encodings, and show Revit 2027's flagged fields hold no instance bytes (#1196) (RE-323) - #1309

Merged
DrunkOnJava merged 8 commits into
mainfrom
re/1196-residual-field-encodings
Nov 4, 2026
Merged

DrunkOnJava merged 8 commits into
mainfrom
re/1196-residual-field-encodings

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Classifies 11 of the 14 names the residual list held (the encodings FieldType::decode left Unknown in every release), shows that Revit 2027's flagged runtime-state fields occupy no instance bytes, and leaves three fields unclassified with the reason measured. The coverage gate stays at 100% of the remainder and now also reads each schema with the exact grammar.

Motivation

Refs #1196 (it stays open for the three fields below). The residual list was 9 to 12 fields per release; Revit 2027 added 339 flagged fields whose instance bytes RE-264 had not measured.

Changes

  • src/formats.rs: FieldType::PointerArray (0e 13) and FieldType::PointerContainer (0e 53, 0e 54) appended to the non-exhaustive enum; Flagged takes byte 2 = 0x04 (VarExpr::m_refCt, 04 00 04 00); the scan decodes a field's type from the stream instead of from its class's 4,096-byte scan window, which clipped ZoningAppInfo::first to two bytes (0e 00).
  • src/walker.rs: the new variants read as Unknown did, so no walk changes.
  • docs/schemas/schema-table.schema.json: two FieldType branches.
  • tests/field_type_coverage.rs: RESIDUAL shrinks from 14 names to 3; a second list, keyed by the classes the exact grammar (schema_registry) says declare the fields, holds the grammar's Unknown fields to account; both lists fail on an entry that no longer decodes Unknown.
  • probes/examples/probe_re323_residual_field_encodings.rs, reports/element-framing/RE-323-residual-field-encodings.md, a changelog fragment and the docs that quoted "9 to 12".

Testing

Unit tests are banned in this repository: none added. Measured end to end on real files with the probe; it checks every instance of each residual field against its proposed layout (the native graph decoder consumes the whole record body, every non-null pointer token resolves to an object of the record).

  • tools/check-local.sh passes: no local build here (the repository's rule for this machine); fmt run locally, the rest is CI's.
  • Verified end to end on real Revit files: 58 Autodesk sample projects (2015 to 2027) and the 12-release family corpus plus a 2014 maker family; the commands and counts are in RE-323 sections 2 and 7; Measure runs 41754444445, 41754940721, 41754944550 and 41754936505 (probe 94541d1, the classification as it was), 41756271989 and 41756275764 (the two readings of modifier 4, not merged), 41757339031 (families on the head). GEdge's three arrays: 111,985 instances each on 13 releases, no layout failure, no unresolved pointer. VarExpr::m_refCt, VarSketchConstrObj::m_constrElems, VarSketchObj::m_params: 138,477, 58,876 and 93,092 instances on 2018 to 2027, same. 2027's flagged fields: 97,000 of 97,005 records of the five sample projects end exactly at their body's last byte with the 339 fields skipped as zero-width, 110 of them in classes the records hold; the other 5 fail on a size budget.
  • IFC exporter: not touched. Identity Measure 41757335670 (-f base=main -f nordic=true -f r2025=true -f samples=true -f families=true -f scorers=none, head 1a8427d; later commits add only the report and PR text): results in RE-323 section 8 and the PR conversation when it finishes.
  • Not a performance change.

Audit-honesty checklist

  • README / docs reflect the current state: the "9 to 12 residual fields" statements are now "2 or 3"; nothing claims more than the report measures.
  • A user-visible change has its entry as a fragment under changelog.d/changed/.
  • Limitations are stated in the report, the enum docs and the changelog: five fields are classified by their header alone (no instance in any file read), ClassDefinitionRef::m_ref has no instance, VarParam::m_pSubst's 31,705 instances are all null pointers, which two layouts read alike, and VarSketchDimObj::m_dimValue has none.
  • Commit messages describe what and why.
  • No emojis, no private paths.
  • Reverse-engineering finding: a reproducible probe under probes/examples/ and the dated report under reports/element-framing/.

Legal and contribution hygiene

  • Licensable under Apache-2.0.
  • Clean-room declaration: every finding rests on public byte observations of Autodesk's published sample files (the phi-ag/rvt family corpus and the sample projects Autodesk publishes) and the schema grammar already in the repository. No Autodesk SDK source, decompiled internals, NDA material or ODA code was used.
  • No fixtures added; no PII.

Breaking changes

FieldType gains two variants (the enum is #[non_exhaustive], so a downstream match already has a wildcard) and the schema-table JSON schema gains two anyOf branches, which the semver gate counts as breaking. A field that decoded Unknown (or, on one 2026 field, was clipped) now decodes as one of them; rvt-schema JSON output changes for those fields only. The title carries ! for that.

Screenshots or output samples

Not applicable (no IFC or UI output changes); the measured tables are in the report.

Related issues

Refs #1196

…its proposed layout and prints the clipped windows (#1196)
…lagged i32 of the schema, and read a field's type past the scan window (#1196) (RE-323)

FieldType gains PointerArray (0e 13, GEdge's three face/edge arrays) and PointerContainer (0e 53, 0e 54), appended to the non-exhaustive enum; Flagged takes byte 2 = 0x04 (VarExpr::m_refCt). The scan now decodes a field's type from the stream rather than from its class's 4,096-byte scan window, which clipped ZoningAppInfo::first to two bytes. The walker reads the new variants as it read them when they were Unknown.
…d fail on a residual entry that no longer decodes Unknown (#1196) (RE-323)

The scan files a class's fields after an inline class definition under that inline class (GEdge's under GInfo, VarSketchDimObj's under VarSketchObj, VarExpr's under VarFunction), so the residual names it gives are not the classes that declare the fields. tests/field_type_coverage.rs now also reads each schema with schema_registry and keeps RESIDUAL_GRAMMAR by the declaring classes; RESIDUAL shrinks to the three fields RE-323 could not classify.
… twelve; the probe counts the flagged fields the scan misses (#1196) (RE-323)
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 4, 2026 02:09
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 4, 2026 02:09
@DrunkOnJava
DrunkOnJava merged commit e5f065b into main Nov 4, 2026
28 checks passed
@DrunkOnJava
DrunkOnJava deleted the re/1196-residual-field-encodings branch November 4, 2026 02:26
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Automated Claude Code review (the maintainer's review agent; it read the code, the gate and the probe artifacts): no blocking items. The field-type coverage gate is not loosened: each of the 11 names it drops now decodes to a typed encoding, and a new Unknown field still fails it. The per-field counts in the report re-sum from the probe artifacts (GEdge 111,985 in 57 projects, m_refCt 138,477, m_constrElems 58,876, m_params 93,092, none misread). The five fields read from their header alone rest on header codes proven by instances on other fields. Measure 41757335670 found every IFC, diagnostics, rvt-info and schema output byte-identical; only rvt-schema's JSON moves, by design.

DrunkOnJava added a commit that referenced this pull request Nov 4, 2026
…#1196) (RE-325) (#1315)

## 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.

- [x] 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.
- [x] 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.
- [x] `tools/check-local.sh`'s gates run in CI (no local builds in this
checkout)

## Audit-honesty checklist

- [x] 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).
- [x] Changelog fragment under `changelog.d/fixed/`.
- [x] 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.
- [x] No emojis; no private paths.
- [x] Reverse-engineering finding: probe under `probes/examples/` and
report `RE-325`; `docs/format-reconnaissance.md` carries a dated
correction.

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] 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`).
- [x] 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).
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