Skip to content

fix(elem-table): declare the ElemTable's second id where the two ids differ (RE-41) - #329

Merged
DrunkOnJava merged 1 commit into
mainfrom
feat/elemtable-secondary-ids
Sep 23, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
feat/elemtable-secondary-ids

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

A 40-byte Global/ElemTable record carries two ElementId-shaped u32s, at +16 (id_primary) and +36 (id_secondary), and rvt-rs declared only the first. Where the two differ, the second is the element's ElementId: the id of its partition record (RE-35) and the Tag Revit's own IFC export writes. elem_table::declared_ids now declares both, and every production path uses it. On Snowdon Towers Architectural the 37 element records that were left unattributed now export, all of them elements Revit's export holds.

Motivation

Found while measuring RE-40 (#327): the 33 elements of the primary design option on Snowdon are in Revit's export but were counted as element_record_without_element_id. Their chain records' ids were not declared, because the ElemTable holds them at +36, not +16.

Changes

  • src/elem_table.rs:
    • declared_ids(&[ElemRecord]) returns every id_primary, plus id_secondary on 40-byte records when it is non-zero, so nothing declared before is dropped;
    • RECORD_LEN_40;
    • declared_element_ids uses it;
    • the id_secondary doc and a unit test.
  • The 13 production call sites that built the set as map(|r| r.id_primary) now call it: partition_element_records (2), partition_schema_mvp (8), partition_level_records, partition_names, partition_design_options. rvt-elem-table uses it for its owner statistics.
  • examples/probe_re41_elem_table_secondary_ids.rs (new). probe_re40_design_options uses the new set.
  • reports/element-framing/RE-41-elem-table-secondary-ids.md, a support-matrix row (experimental), README, status, CHANGELOG, docs/export-diagnostics.md, the ElemTable layout doc, a reconnaissance addendum, and cross-references in RE-35 and RE-40.

Measurements

probe_re41_elem_table_secondary_ids:

file records ids differ chain ids not id_primary not id_secondary
Snowdon Architectural (2024, local) 47,233 84 85 1
Snowdon Structural (2024, local) 16,571 27 20 0
Core Interior, RE1 x4, teste_export_2025, Projeto1 – 0 same same

The 2016 to 2023 projects (28-byte layout) have no record whose ids differ. Each family file has exactly one, record 18, and a 0 there is not added.

Of the 84 architectural records whose ids differ, 39 have their id_secondary as a Tag in Revit's IFC4 export (17 proxies, 16 walls, 4 columns, 2 column types), and none has its id_primary as one.

Snowdon Architectural against Revit's IFC4 export:

before (main) after
exported elements 6,007 6,044
in Revit's export 5,907 5,944
Revit's elements of an exported entity that rvt-rs misses 38 1 (a stair run with no readable frame)
element_record_without_element_id 37 absent
confidence.unexported_element_records / score 37 / below 1 0 / 1.0

Snowdon Structural gains one floor (670566), which the VIM export also holds. Core Interior, RE1 Architecture and RE1 Electrical export byte-identically apart from the header and owner-history timestamps, so the committed witness observations do not change.

Testing

  • tools/check-local.sh
  • Every integration test with the family corpus and the magnetar + RE1 project corpus
  • cargo +1.85.0 check --profile ci --all-targets, cargo +nightly check --manifest-path fuzz/Cargo.toml
  • Snowdon Architectural and Structural exports scored against Revit's IFC4 export and the VIM

Audit-honesty checklist

  • Status experimental: the positive evidence is local. No licensed file has a differing record.
  • What id_primary holds where the two differ is stated as unknown. The chain ids that neither id covers on Core Interior and RE1 Electrical are unchanged and stated.
  • No emojis, no private paths.

Legal and contribution hygiene

  • Apache-2.0
  • Clean-room: byte observations scored against Revit's own IFC export and the VIM export. No SDK source or decompiled material. Snowdon and the VIM are measured locally and not committed.
  • No PII

Breaking changes

elem_table::declared_element_ids can return more ids than before, on files where the two ids differ. No signature changes.

Related issues

Follows RE-40 (#327). Refs #309, #295.


Note

Medium Risk
Widens the declared ElementId set used across all partition element export paths; behavior is unchanged on most files but can add elements on models where primary and secondary ids diverge.

Overview
RE-41 fixes element attribution when a 40-byte Global/ElemTable row’s two u32 ids at +16 and +36 disagree: rvt-rs used only id_primary, but on Snowdon (and similar) id_secondary is the partition ElementId / IFC Tag Revit exports.

The change adds elem_table::declared_ids, which keeps every id_primary and also adds non-zero id_secondary on 40-byte records. declared_element_ids, partition scanning, design-option probes, and rvt-elem-table all use that set instead of mapping id_primary alone.

On Snowdon Towers Architectural, 37 previously unattributed walls/columns/generic models now export (6,044 vs 6,007 elements; element_record_without_element_id gone). Structural gains one floor. CI-licensed corpora with no differing ids stay byte-identical aside from timestamps.

Docs add RE-41 report/probe, support-matrix row, and updated export-diagnostics and status counts.

Reviewed by Cursor Bugbot for commit 82d3ff4. Configure here.

@cursor

cursor Bot commented Sep 23, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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_3b357f6c-73c8-4505-8026-c07f18e83434)

@DrunkOnJava
DrunkOnJava merged commit 27f734b into main Sep 23, 2026
23 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/elemtable-secondary-ids branch September 23, 2026 06:46
DrunkOnJava added a commit that referenced this pull request Sep 23, 2026
… (RE-42) (#330)

## Summary

RE-38 names an element `Family:Type:ElementId` when its type's partition
record holds exactly one other named id of the type's category. When the
type's family nests other families of that category, the record names
those too, and RE-38 left the element unnamed (#324). The family is the
one candidate whose own partition record names every other candidate,
and `partition_names::resolve_family` now picks it. Every name this adds
is Revit's own.

## Motivation

Closes #324. RE1 Electrical's 12 lighting fixtures had no names. Revit
names them `265100-LIGHT-CAN:6":<id>` and so on.

## Changes

- `src/partition_names.rs`: `resolve_family` keeps RE-38's
single-candidate rule. With several candidates, it returns the one whose
own record names all the others, and only when exactly one does. Doc
states the sibling-type limit. There is a unit test for the rule, and
the RE-38 test now uses two families that do not name each other.
- `tests/element_names.rs`: checks RE1 Electrical (12). RE1 Mechanical's
pin moves from 36 to 42: 6 "300x150" fittings are now named, all equal
to Revit's.
- `examples/probe_re42_nested_families.rs` (new).
- `reports/element-framing/RE-42-nested-families.md`, the support-matrix
row, README, status, CHANGELOG, a reconnaissance addendum, and a
cross-reference in RE-38.

## Measurements

| file | names written | equal to Revit's (or the VIM's) | new |
|---|---:|---:|---:|
| RE1 Electrical | 12 | 12 | 12 |
| RE1 Mechanical | 42 | 42 | 6 |
| RE1 Architecture, Plumbing, Core Interior | unchanged | unchanged | 0
|
| Snowdon Architectural (local) | 3,902 | 3,831 (71 Revit omits) | 117 |
| Snowdon Structural (VIM, local) | 1,184 | 1,132 of 1,156 in the VIM |
50, all equal |

- The 24 structural differences are one type the VIM's later edition
renamed (RE-38 §4).
- Where a type with several candidates has an ElemTable owner among
them, the owner is the family the rule picks in every case (24 types
over five files). The owner is unset on most types, so it is not used.
- Over the elements Revit's export also holds, 4,397 names now equal
Revit's, with none that differ.

## Testing

- [x] `tools/check-local.sh`
- [x] Every integration test with the family corpus and the magnetar +
RE1 project corpus, including `element_names` on RE1 Electrical
- [x] `cargo +1.85.0 check --profile ci --all-targets`, `cargo +nightly
check --manifest-path fuzz/Cargo.toml`
- [x] Snowdon Architectural and Structural names scored against Revit's
IFC4 export and the VIM

## Audit-honesty checklist

- [x] The sibling-type limit is stated in the doc and the report; no
measured file has such a record.
- [x] System-family types are unchanged (#322).
- [x] No emojis, no private paths.

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] Clean-room: byte observations scored against Revit's own IFC
exports and the VIM export. No SDK source or decompiled material.
Snowdon and the VIM are measured locally and not committed.
- [x] No PII

## Breaking changes

`resolve_family` now returns a family for some types that had several
candidates and returned `None` before. IFC names change for those
elements, from `Class-ElementId` to Revit's `Family:Type:ElementId`.

## Related issues

Closes #324. Follows #329 (RE-41).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes IFC `Name`/`ObjectType` for elements that previously had no
resolved family (breaking for consumers of those strings), though
selection is fail-closed and corpus-gated against Revit exports.
> 
> **Overview**
> **RE-38** already produced Revit-matching `Family:Type:ElementId` IFC
names when a type’s partition record listed a single same-category
family id. Types whose family **nests** other families of that category
list multiple candidates, so **`partition_names::resolve_family`** used
to return **`None`** and those instances kept **`Class-ElementId`**
names (#324).
> 
> The resolver now keeps the single-candidate path unchanged. With
several candidates, it returns the unique id whose **own** partition
record names every other candidate (the nested families). Ambiguous
cases still return **`None`**.
> 
> **Impact:** newly named instances on corpus models—e.g. RE1
Electrical’s 12 lighting fixtures, six mechanical duct fittings, and
many Snowdon elements—now match Revit’s IFC names; the documented
cross-model count rises from 4,241 to **4,397** matching names.
Integration coverage adds **RE1 Electrical** and bumps the mechanical
name check to **42**.
> 
> Also adds **`probe_re42_nested_families`**, the RE-42 report, and
doc/support-matrix updates.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1192545. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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