Skip to content

feat(elements): infer second-prologue ElementIds from reference order (RE-34) - #313

Merged
DrunkOnJava merged 1 commit into
mainfrom
feat/second-prologue-element-ids
Sep 23, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
feat/second-prologue-element-ids

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Records in the second element-record prologue (RE-30) now get their ElementId from the reference list and the frame order. The id is taken only when the ordering forces it. Hidden-id hold-outs on five files make no wrong pick, and Autodesk's Snowdon Towers architectural sample goes from 80 exported elements to 4,245.

Motivation

On Snowdon (and on parts of the RE1 MEP models) most records carry no ElementId at +0x00, so the fail-closed decode dropped them. RE-30 found the id is one slot of the record's reference list (§7) and that records sit in ascending ElementId order (§8). The one-sided chain it tried made 32 wrong picks, so nothing shipped (#295). Full report: reports/element-framing/RE-34-second-prologue-element-ids.md.

The rule

  • For each partition: first-prologue records are fixed at their +0x00 id. A second-prologue placed instance (no container, placement 0xffffef7f, RE-33) may take any declared id in its reference list after the leading slot.
  • The longest strictly rising chain is found twice, with ties resolved toward smaller and toward larger ids. A record gets an id only when both agree.
  • Ids named by ≥ 56 records across the file (Levels, types) are never candidates.
  • Floors, building pads and ceilings never get an id, because their list names their sketch at id − 1 (Snowdon floor 1423899 next to sketch 1423898).

Measurements

Hold-outs (every +0x00 id hidden, then scored):

file correct wrong
2024_Core_Interior 3,458 0
Snowdon Towers Architectural (first-prologue records) 445 0
RE1 Architecture / Mechanical / Plumbing 41 / 7 / 36 0

Zero wrong holds for context thresholds 48 to 64 (56 is the middle of that band). Without the filter, the Core hold-out made 6 wrong picks, each a Level or type id named by 66 to 260 records; no true own id is named by more than 34.

End to end against Revit's exports, by Tag:

file exported before after not in Revit's export
Snowdon Architectural (local) 80 4,245 115
Snowdon Structural (local) 26 60 —
RE1 Mechanical 33 48 0
RE1 Plumbing 9 39 0
RE1 Architecture / Core Interior unchanged unchanged 0

The 115 on Snowdon were checked one by one. They are 45 specialty-equipment items, 47 panels and 15 fixtures whose reference lists hold no exported element of that type, 7 bleacher-seating walls, and the #309 slab. All are real elements Revit's exporter leaves out, the same limitation the first-prologue path already has (#309), and none is a wrong id for an exported element. Each carries an element_id_from_reference_order provenance warning.

Readiness on Snowdon rises from 36% to 91%, and the unattributed count drops from 4,886 to 684. Core Interior's IFC body is byte-identical and its export time unchanged (2.75 s).

Changes

  • src/partition_element_records.rs:
    • framed_elements, context_element_ids and assign_second_prologue_ids (the double chain) with longest_rising_chain;
    • compute_second_prologue_ids, decode_frame_as and find_category_records_assigned;
    • SECOND_PROLOGUE_CONTEXT_REFERENCES and SKETCH_OWNING_CATEGORIES;
    • the PartitionElementRecord::id_from_reference_order field;
    • the sweeps and the unattributed count use the assignment.
  • src/reader.rs: RevitFile::second_prologue_ids memo.
  • src/partition_schema_mvp.rs: m_id_from_reference_order field and provenance warning.
  • tests/second_prologue_ids.rs (Core hold-out, zero wrong), examples/probe_re34_holdout.rs, and tests/element_records_2025.rs (the RE1 MEP recall pins).
  • The report, a RE-30 §9 addendum, README, docs/status.md, docs/export-diagnostics.md, docs/support-matrix.json (new element-records-second-prologue-ids, partial; RE-33 row corrected), and CHANGELOG. RE-33's "zero false positives on four files" now reads correctly as holding for records carrying their id at +0x00.

Testing

  • tools/check-local.sh --corpus --viewer and npm run test:browser
  • cargo +1.85.0 check --profile ci --all-targets and cargo +nightly check --manifest-path fuzz/Cargo.toml
  • Browser viewer (ad hoc Playwright run, not committed): Snowdon Architectural (94.7 MB) loads in 18 s within wasm32 memory, showing "Geometry · 91%", 10 storeys, 4,185 elements with geometry and "Incomplete model · 684 model element records could not be exported", with no page error. Native peak RSS for its export is 1.77 GB, against 0.52 GB for Core Interior.
  • Unit tests for the chain, the tie fail-closed case, non-instance frames, and assigned records decoding and dropping out of the unattributed count
  • IfcOpenShell 0.8.5 validate on the Snowdon Architectural (84,077 instances), RE1 Mechanical and RE1 Plumbing exports of this branch (rebased on fix(ifc): write IfcBoolean as .T. / .F. #312): no validation issues. tools/ci/ifc_schema_arity.py passes on them too.

Audit-honesty checklist

  • The 115 Snowdon elements Revit omits are stated everywhere the recall is, and the RE-33 claim is narrowed accordingly
  • The threshold is a measured band, not a proof; the report says what lies outside it
  • No emojis, private paths or PII. Snowdon was measured locally and is not committed.

Legal and contribution hygiene

  • Apache-2.0; public byte observations and prior RE reports only (CLEANROOM.md)

Breaking changes

PartitionElementRecord gains id_from_reference_order (serde default false). element_record_without_element_id counts fall on files with second-prologue records, because assigned records are exported instead.

Related issues

Refs #295 (resolved for all but sketch-owning categories), #309, #94, #95.

… (RE-34)

A second-prologue element record (RE-30) carries no ElementId at +0x00,
but its own id is one slot of its reference list, and records sit in
each partition in ascending ElementId order. assign_second_prologue_ids
finds the longest strictly rising chain through a partition twice, with
ties resolved toward smaller and toward larger ids, and gives a placed
instance an id only when both agree, so the id is forced by the order.
Ids named by 56 or more records across the file (Levels, types) are
never candidates, and floors, building pads and ceilings never get an
id, because their lists name their sketch one id earlier.

Hidden-id hold-outs make no wrong pick: 3,458 correct on Core Interior,
445 on Snowdon, 41, 7 and 36 on the RE1 models; zero wrong holds for
context thresholds 48 to 64. Snowdon Towers Architectural now exports
4,245 elements instead of 80 (readiness 36% -> 91%); 4,077 of its tagged
elements are in Revit's export and the other 115 are real elements
Revit's export omits (#309). The RE1 MEP models gain their ducts, pipes
and fittings, all in Revit's export. Core Interior, which has no such
records, exports byte-identically.

The result is memoised as RevitFile::second_prologue_ids and used by
the element-record sweeps and the unattributed count. Assigned elements
carry an element_id_from_reference_order provenance warning and an
m_id_from_reference_order field. tests/second_prologue_ids.rs holds the
Core hold-out at zero wrong; examples/probe_re34_holdout.rs runs it on
any file.
@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_b75fd5b4-4344-4190-94b3-4b3564a1eea2)

@DrunkOnJava
DrunkOnJava merged commit a692306 into main Sep 23, 2026
23 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/second-prologue-element-ids branch September 23, 2026 02:49
DrunkOnJava added a commit that referenced this pull request Sep 23, 2026
…t (RE-34) (#314)

## Summary

An element whose `Tag` RE-34 inferred from its record's reference list
and the frame order now says so in the IFC: `ElementIdSource =
'reference_order'` in its `RvtElementRecordGeometry` property set. The
viewer's support-profile panel now describes what RE-34 leaves out.

## Motivation

#313 records the inference on the decoded element (field and provenance
warning), but the IFC, which is what users take away, did not carry it.
On Snowdon Towers Architectural that covers 4,142 exported elements. A
consumer, and the viewer's element info panel, can now tell an inferred
id from one read off the record. Records that carry their id write
nothing new.

## Changes

- `src/ifc/export_content.rs`: `ELEMENT_ID_SOURCE_PROPERTY` /
`ELEMENT_ID_FROM_REFERENCE_ORDER`, written when the decoded element has
`m_id_from_reference_order`, plus a unit test covering one inferred and
one read id.
- `viewer/index.html` ("Not ready"): records whose ElementId neither the
record nor the record order gives, and elements Revit's export filters
out (#309), replace the old "records with no ElementId".
- CHANGELOG.

## Testing

- [x] `tools/check-local.sh`
- [x] Snowdon Architectural export: 4,142 `ElementIdSource` properties;
`ifcopenshell.validate` reports no issue
- [x] 2024_Core_Interior export byte-identical to main apart from the
header timestamp

## Breaking changes

None.

## Related issues

Refs #295, #309.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Additive IFC metadata and viewer copy only; no change to id assignment
logic or exports where ids are read from records.
> 
> **Overview**
> **RE-34 inferred ElementIds are now labeled in exported IFC.** When an
element’s `Tag` was assigned from reference-list / frame-order inference
rather than read from the record, the exporter adds `ElementIdSource =
'reference_order'` on `RvtElementRecordGeometry`. Records with a native
id omit the property (Core Interior stays unchanged aside from header
timestamps).
> 
> New constants and export logic live in `export_content.rs`, with a
unit test covering one inferred and one read id. The viewer **Supported
profile** “Not ready” copy is updated to describe ids that neither the
record nor order resolve (e.g. second-layout floors) and elements
Revit’s export omits but rvt-rs still exports. **CHANGELOG** documents
the addition.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7528906. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
DrunkOnJava added a commit that referenced this pull request Sep 23, 2026
… does (#309) (#316)

## Summary

Placed element-record instances whose bounding box has no volume (2D
symbol families) are left out of the export, as Revit's own IFC export
leaves them out. The sidecar reports them as
`element_record_without_volume`. This cuts the Snowdon elements outside
Revit's export from 115 to 55.

## Motivation

#309 tracks elements rvt-rs exports that Revit's export omits. After
RE-34 (#313) that was 115 on Snowdon Towers. They follow their **type**:
eight type ids that no exported element names cover 111 of them. Three
of those types sit next to the strings "Floor Drain-2D", "ADA Clear
Space" and "Wheel Chair Circle", which are 2D symbol families with no 3D
body.

The byte signature is exact:

| category | omitted, bbox flat on an axis | exported by Revit, bbox
flat |
|---|---|---|
| Specialty equipment | 45 / 45 | 0 / 211 |
| Plumbing fixtures | 15 / 15 | 0 / 130 |
| all other categories | – | 0 |
| Core Interior, RE1 Architecture / Mechanical / Plumbing, Snowdon
Structural | – | 0 (no flat instance at all) |

## Changes

- `src/partition_element_records.rs`:
  - `VOLUME_EPSILON_FEET` and `PartitionElementRecord::has_volume`;
- `scan_volumeless_instances`, which counts by class once per ElementId;
  - flat second-prologue frames no longer count as unattributed.
- `src/partition_schema_mvp.rs`: `select_instance_records` skips
instances without volume. Sketch lines take their own path and are
unaffected.
- `src/ifc/mod.rs`: the `element_record_without_volume` skipped item. It
is not counted toward `unexported_element_records`, because these are
omitted by design, not missing.
- Docs: README, docs/status.md, docs/export-diagnostics.md, the schema's
reason description, docs/support-matrix.json (Snowdon now 4,185
exported, 55 outside Revit's export), a RE-34 report §8 addendum, and
CHANGELOG.

## Testing

- [x] `tools/check-local.sh --corpus`
- [x] Unit test: a flat and a solid instance, decoded and counted
- [x] Snowdon Architectural: 4,185 exported; 4,077 of 4,132 tagged in
Revit's export; `element_record_without_volume` = 60 (45 + 15);
`unexported_element_records` unchanged at 684
- [x] Core Interior: IFC byte-identical apart from the header timestamp

## Breaking changes

None. The skipped item is additive.

## Related issues

Refs #309 (the 47 curtain panels, 7 walls and 1 slab remain; the panel
types include the system "Empty" panel).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Export filtering and additive diagnostics only; Core Interior IFC
stays byte-identical aside from header timestamp per PR testing.
> 
> **Overview**
> Placed partition element-record instances whose bounding box is flat
on any axis (2D symbol families such as floor drains and ADA clearance
graphics) are **no longer exported**, aligning rvt-rs with Revit’s IFC
behavior (#309).
> 
> **Export path:** `PartitionElementRecord::has_volume()` (with
`VOLUME_EPSILON_FEET`) gates instance selection in
`select_instance_records` and unattributed-frame counting; flat
second-prologue frames are not treated as missing ElementIds.
> 
> **Diagnostics:** IFC export diagnostics add a `skipped` bucket
`element_record_without_volume` (via `scan_volumeless_instances`),
documented in the export-diagnostics schema and user docs. These
omissions are intentional and do **not** feed
`unexported_element_records`.
> 
> **Measured impact:** On Snowdon Towers Architectural, export drops
from 4,245 to **4,185** elements; elements outside Revit’s export fall
from **115 to 55** (60 volumeless instances). Docs, support matrix, and
CHANGELOG are updated accordingly.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4ad86fa. 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