Skip to content

fix(formats)!: ElementIdRef is the class reference alone, without the spilled sub (#1101) - #1154

Merged
DrunkOnJava merged 3 commits into
mainfrom
fix/1101-element-id-ref
Oct 30, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
fix/1101-element-id-ref

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

FieldType::ElementIdRef { referenced_tag, sub } becomes ElementIdRef { referenced_tag }. sub was never part of the field: it read the two bytes after a six-byte class reference, which belong to whatever follows. referenced_tag now has bit 15 cleared, and every reference to the root ElementId class reads as ElementId. Closes #1101. Griffin chose on 2026-10-30 to fix it before 1.0.

Motivation

The schema grammar the crate already reads with (schema_classes, STE1200's, #154) gives a by-value reference as the type word 0e 00 00 00 and a u16 class reference, where bit 15 means the class is defined inline after a zero u16. Measured on the page-stripped schemas of the 2016, 2020, 2024 and 2026 sample families, the bytes FieldType::decode read as sub are:

Schema next field's name length inline-definition pad class's GUID-list count not modelled by my quick scanner
2016 1,564 213 563 30
2020 1,707 226 611 32
2024 1,866 238 638 39
2026 1,979 253 661 44

The last column is root-class references at a class's end followed by an inline structure. The grammar reader parses those too; my local scanner does not model them. In none of the four schemas is sub part of the reference. The same spill decided whether a reference to tag 0x14 read as ElementId or as ElementIdRef { 0x14, .. }. walker::find_self_id_field tells those apart in its third rule.

Changes

  • src/formats.rs:
  • docs/schemas/schema-table.schema.json: ElementIdRef requires only referenced_tag.
  • changelog.d/changed/element-id-ref.md.

Testing

Unit tests are banned and none are added.

  • field_type_coverage (12-release family corpus) must keep every field outside RESIDUAL classified.
  • json_schema_contracts must validate rvt-schema --json against the edited schema.
  • Measure with base=main on every model shows whether any export moves through the walker's self-id choice. The result is added below before this PR is armed.

Breaking changes

FieldType::ElementIdRef { referenced_tag, sub } → ElementIdRef { referenced_tag }, and rvt-schema --json drops sub. Code that names sub stops compiling: drop it. Code that matched ElementIdRef { referenced_tag: 0x14, .. } sees ElementId instead.

… spilled sub (#1101)

The schema grammar (schema_classes) reads a by-value reference as the type
word 0e 00 00 00 and a u16 class reference, bit 15 meaning the class is
defined inline after a zero u16. FieldType::decode read two more bytes as
ElementIdRef's sub, but those belong to what follows: measured on the 2016,
2020, 2024 and 2026 sample families' page-stripped schemas, the next
field's name length on 1,564 to 1,979 references, the zero pad before an
inline definition on 213 to 253, and a class's GUID-list count on about
600. The same spill decided whether a reference to the root ElementId
class read as ElementId or ElementIdRef { 0x14, .. }, which the walker's
self-id search tells apart.

ElementIdRef keeps referenced_tag only, with bit 15 cleared; a reference
to tag 0x14 is always ElementId; encode writes the six bytes and its doc no
longer claims a writer uses it. rvt-schema's JSON schema drops sub. Griffin
chose to fix this before 1.0 (2026-10-30).
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Self-review with verification.

Measure 41102077364 compared base=main against this head on every reference model, the office, the R2025 models, Autodesk's 2015 to 2027 samples and the family corpus: 380 files on each side.

  • Every ifc.sha256 is identical: no export moves through the walker's self-id choice.
  • 48 diagnostics.json differ, all in the walker's low-confidence schema-scan candidates, which the default export already suppressed. decoded.class_counts.HostObjAttr, diagnostic_proxy_candidates and the matching warning fall on 39 files (1,138 to 91 on the 2027 MEP sample). The sample names in skipped change with them, and one 2024 sample counts 12 GArray where it counted 20.
  • Fewer spurious candidates is what removing the spill from the type should do. The changelog fragment now says so.

Code. decode reads exactly the six bytes the grammar defines, clears bit 15, and maps tag 0x14 to ElementId whatever follows. encode emits six bytes, and its doc drops the claim that a writer uses it. The JSON schema requires only referenced_tag. Nothing in the workspace named sub.

CI passed, including field_type_coverage (no new Unknown outside RESIDUAL on the 12 releases), json_schema_contracts and semver checks (the break is announced with !). Nothing else to fix.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 30, 2026 18:15
@DrunkOnJava
DrunkOnJava merged commit 559a524 into main Oct 30, 2026
28 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/1101-element-id-ref branch October 30, 2026 18:28
Repository owner deleted a comment from chatgpt-codex-connector Bot Oct 31, 2026
Repository owner deleted a comment from chatgpt-codex-connector Bot Oct 31, 2026
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.

formats: an ElementIdRef's sub is the next field's name length on about 93% of references

1 participant