Skip to content

fix(partitions): read second-prologue ElementIds from the enclosing partition record (RE-35) - #317

Merged
DrunkOnJava merged 1 commit into
mainfrom
fix/partition-record-wrapper
Sep 23, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
fix/partition-record-wrapper

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every Partitions/* stream of a Revit 2024/2025 project opens with a chain of ElementId-keyed records, one per element. A second-prologue element frame (RE-30) sits inside its element's record, so its ElementId is now read from the record header instead of inferred from reference order (RE-34). This fixes a wrong id RE-34 produced outside its hold-outs and completes recall on the RE1 models.

Motivation

On Projeto1 (Revit 2025, 255ribeiro/intro_ifc, local only), RE-34 exported a door with Tag 49480. Revit's own export has that door as 325405 and lists 49480 as its IfcDoorType. Partitions are not one ascending ElementId run: elements saved later sit in their own runs, and RE-34's chain borrowed a far anchor's bound. Following the bytes around that door led to the record header:

u64 ElementId · u32 size · u16 prologue constant (release constant + 28) · u16 count · body ·
u64 (unread) · u32 flag 0 | 0x0100_0000 · u32 size again

Changes

  • src/partition_element_records.rs:
    • adds partition_record_chain, enclosing_record, record_prologue_constant, PartitionRecordSpan, and the header and trailer lengths;
    • assign_second_prologue_ids reads the enclosing record's id;
    • unattributed counts cover only frames inside the chain (the records after it are loaded families' own documents);
    • removes the RE-34 chain, context_element_ids, SECOND_PROLOGUE_CONTEXT_REFERENCES and SKETCH_OWNING_CATEGORIES;
    • renames id_from_reference_order to id_from_enclosing_record.
  • src/partition_schema_mvp.rs, src/ifc/export_content.rs: drops the element_id_from_reference_order warning and the ElementIdSource IFC property. No id is inferred any more.
  • tests/partition_record_chain.rs (new): every first-prologue frame in the project corpus starts a record of its own id, and the chains hold the declared ids.
  • tests/element_records_2025.rs: RE1 pins become set equalities with Revit's export, plus two measured extras.
  • tests/second_prologue_ids.rs and examples/probe_re34_holdout.rs are removed; examples/probe_re35_record_wrapper.rs is added.
  • reports/element-framing/RE-35-partition-record-wrapper.md (new); superseded note on RE-34; addendum on RE-30; dated addendum in docs/rvt-moat-break-reconnaissance.md.
  • README, docs/status.md, docs/support-matrix.json, docs/export-diagnostics.md, CHANGELOG [Unreleased].

Measurements

All 30,432 first-prologue frames across nine 2024/2025 files start a record of their own id. The chains hold 26,425 of 26,425 declared ids on Core Interior and all or all-but-one on every other file.

file exported before in Revit's export exported after in Revit's export
Snowdon Towers Architectural 4,132 4,036 4,795 4,678
RE1 Architecture 67 67 74 73
RE1 Mechanical 48 48 66 66
RE1 Plumbing 39 39 124 123
Projeto1 1 0 (wrong id) 2 2
teste_export_2025 0 0 8 8
Core Interior byte-identical

Where RE-34 had assigned an id, the record agrees on 13,943 frames and differs on 5. The record is right in all 5 (the Projeto1 door, and four Snowdon stairs/roof ids that were never exported). Nothing exported before is lost except the wrong id. Every exported id outside Revit's export is a real element Revit's exporter leaves out. On Snowdon, 17 of them are in a non-primary design option; the frame slot +0x2a holds the option id, which is recorded but not yet used.

Testing

  • tools/check-local.sh (fmt, clippy -D warnings, rustdoc -D warnings, workspace tests)
  • tools/check-local.sh --corpus with the family corpus and the magnetar + RE1 project corpus
  • cargo +1.85.0 check --profile ci --all-targets (MSRV)
  • cargo +nightly check --manifest-path fuzz/Cargo.toml
  • New unit tests: chain walk and stop conditions, enclosing-record id regardless of reference list (the Projeto1 shape), family records after the chain, non-instances
  • tests/fixtures/synthetic-project.ifc unchanged (synthetic fixtures have no second-prologue frames)

Audit-honesty checklist

  • README / docs reflect the state after this PR
  • RE-34's failure is recorded in its report as a measured negative, with the commit it can be rerun from
  • The two elements Revit's RE1 exports leave out (door 417199, fixture 442378) are pinned and documented as unexplained
  • No emojis, no private paths
  • Reproducible probe under examples/ and a dated addendum to docs/rvt-moat-break-reconnaissance.md

Legal and contribution hygiene

  • Apache-2.0
  • Clean-room declaration: the finding comes from byte observation of the inflated partition streams, scored against Revit's own IFC exports (Tags = ElementIds) and a VIM export's element ids. No Autodesk or ODA SDK source, disassembly, decompiled internals, leaked documentation or NDA material was used. The Snowdon, 255ribeiro and VIM oracles were measured locally and are not committed.
  • No PII

Breaking changes

  • PartitionElementRecord::id_from_reference_order is renamed id_from_enclosing_record.
  • assign_second_prologue_ids(buf, marker, declared) drops its context argument. context_element_ids, SECOND_PROLOGUE_CONTEXT_REFERENCES, SKETCH_OWNING_CATEGORIES, ID_FROM_REFERENCE_ORDER_* and ELEMENT_ID_SOURCE_PROPERTY / ELEMENT_ID_FROM_REFERENCE_ORDER are removed.
  • All of these landed after 0.1.x and are unreleased (0.2.0 is still a draft).

Related issues

Refs #295, #309. Supersedes RE-34.


Note

Medium Risk
Changes core element-id attribution for Revit 2024/2025 partition decoding and export counts; behavior is well-tested on corpus but affects many exported ElementIds and removes the prior inference path.

Overview
RE-35 replaces RE-34’s reference-order inference with direct reads of ElementIds from each partition stream’s leading record chain (u64 ElementId header, body, size-echo trailer). Second-prologue frames get the id of their enclosing record; frames after the chain (loaded family documents) are excluded from export and from element_record_without_element_id.

The RE-34 machinery (context_element_ids, sketch exclusions, longest-rising chain, hold-out probe/tests) is removed. PartitionElementRecord::id_from_reference_order becomes id_from_enclosing_record; IFC no longer emits ElementIdSource / element_id_from_reference_order warnings.

Impact: Snowdon architectural export grows (~4.1k → ~4.8k elements); RE1 models reach full recall vs Revit’s export on recovered categories; Projeto1’s door id bug (type vs instance) is fixed. New partition_record_chain API, tests/partition_record_chain.rs, and probe_re35_record_wrapper.rs; docs and support matrix updated throughout.

Reviewed by Cursor Bugbot for commit 58b61d6. Configure here.

…artition record (RE-35)

Every Partitions/* stream of a Revit 2024 or 2025 project opens with a
chain of records, one per element: u64 ElementId, u32 size, u16 prologue
constant (release constant + 28), u16 count, the body, and a 16-byte
trailer that repeats the size. A frame carrying its ElementId at +0x00
starts its record; a second-prologue frame (RE-30) sits inside its
element's record, so its id is read from the record header.

RE-34 inferred those ids from the reference list and an assumed ascending
frame order. On a Revit 2025 project outside its hold-outs it gave a door
its type's id (49480 instead of 325405): partitions are several ascending
runs, not one. It also had four latent wrong ids on Snowdon stairs and a
roof. The inference, its context threshold, SKETCH_OWNING_CATEGORIES, its
hold-out probe and test are removed.

Measured: all 30,432 first-prologue frames across nine 2024 and 2025
files start a record of their own id. The RE1 Architecture, Mechanical
and Plumbing models now match every recovered entity in Revit's own
export. Snowdon Towers Architectural exports 4,795 elements (4,678 in
Revit's export, the rest ones Revit's export omits, #309). Floors,
building pads and ceilings get their ids. Frames after the chain belong
to loaded families' documents and are no longer counted as unattributed.
Core Interior exports byte-identically.

The ElementIdSource IFC property and the element_id_from_reference_order
warning are dropped with the inference; PartitionElementRecord's flag is
now id_from_enclosing_record.
@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_4639231a-caac-4529-9f98-2b4be8af3ef4)

@DrunkOnJava
DrunkOnJava merged commit a376fd8 into main Sep 23, 2026
23 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/partition-record-wrapper branch September 23, 2026 04:58
DrunkOnJava added a commit that referenced this pull request Sep 23, 2026
…eneric models from element records (RE-36) (#318)

## Summary

Structural framing, structural columns, structural foundations and
generic models now decode from partition element records, with
ElementIds from RE-35's enclosing records. They export as `IfcBeam`
(`.BEAM.`), `IfcColumn` (`.COLUMN.`), `IfcFooting` and
`IfcBuildingElementProxy`.

## Motivation

A free Revit reader has to open structural models. On Autodesk's Snowdon
Towers structural sample rvt-rs exported only 60 walls and slabs; the
framing, columns and foundations were never mapped. Nearly all of their
frames use the second prologue, so they only became reachable with RE-35
(#317).

## Changes

- `src/partition_element_records.rs`: adds `OST_STRUCTURAL_FRAMING`,
`OST_STRUCTURAL_COLUMNS`, `OST_STRUCTURAL_FOUNDATION` and
`OST_GENERIC_MODEL` to `PRODUCT_RECORD_CATEGORIES` /
`RECOVERED_CATEGORIES`. The mappings already exist in `category_map`.
- `examples/probe_re36_vim_oracle.rs` (new) contains a small BFAST/VIM
reader. It scores every placed-instance element record of a model
against one document of a VIM export (`vim-format`, MIT): same category,
other category, or absent.
- `reports/element-framing/RE-36-structural-categories.md` (new).
- `docs/support-matrix.json`: new
`element-records-structural-categories` row, status **experimental**
because the evidence is local-only.
- README, `docs/status.md`, `docs/supported-profile.md`, ROADMAP,
`docs/export-diagnostics.md`, CHANGELOG `[Unreleased]`.

## Measurements (local; the Snowdon samples have no licence and are not
in CI)

`probe_re36_vim_oracle` over the Structural sample, against
`vimaec/vim-hackathon` `vims/Snowdon.r2027.vim` (commit `50f4373`):

| category | frames | same category in the VIM | absent | other category
|
|---|---:|---:|---:|---:|
| structural framing | 942 | 914 | 28 | 0 |
| structural columns | 74 | 74 | 0 | 0 |
| structural foundations | 90 | 90 | 0 | 0 |
| generic models | 91 | 91 | 0 | 0 |
| all categories | | 1,403 | | **0** |

The VIM is the 2027 edition of the sample: 347 of its structural
elements are not declared in the 2024 file. The 28 absent framing ids
are 2024 beam-system members, which come in runs of three consecutive
ids; 24 of them name a beam system in their reference list. Beam systems
regenerate their members with new ids when they are edited.

End to end, the Structural sample exports 1,281 elements instead of 84,
and 1,253 are in the VIM under the same category. On the architectural
sample, 260 of the 261 generic models are in Revit's own IFC4 export.
The other one carries non-primary design option 1500727 in frame slot
`+0x2a`. Core Interior, the RE1 models and the `255ribeiro` projects
export unchanged.

## Testing

- [x] `tools/check-local.sh` (fmt, clippy, rustdoc, workspace tests)
- [x] `cargo +1.85.0 check --profile ci --all-targets`
- [x] `product_categories_are_distinct_mapped_and_counted` covers the
new rows
- [x] IFC fixtures unchanged

## Audit-honesty checklist

- [x] Status is `experimental`. The evidence is a local VIM oracle, not
a Revit IFC export and not CI.
- [x] Limits are stated:
- braces would export as `IfcBeam`, since the structural type is not
decoded;
  - Revit's own `PredefinedType` for framing is unmeasured;
- rebar, connections and beam systems have correct ids but are not
exported;
  - bodies are bounding boxes.
- [x] Reproducible probe under `examples/`

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] Clean-room: byte observations only. The VIM reader follows the
public, MIT-licensed `vim-format` container layout. BuiltInCategory
names come from the public enum. No Autodesk or ODA SDK source,
decompiled internals or NDA material. The oracles are not committed.
- [x] No PII

## Breaking changes

None. `PRODUCT_RECORD_CATEGORIES` and `RECOVERED_CATEGORIES` grow from
13 to 17 and from 20 to 24 entries.

## Related issues

Refs #295. Builds on #317 (RE-35).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Expands real-project IFC export surface and category/id attribution on
structural models; evidence is local-only and geometry remains coarse
bounding boxes, but changes are additive with no breaking API.
> 
> **Overview**
> **RE-36** extends partition element-record recovery to four
structural/product categories—structural framing, structural columns,
structural foundations, and generic models—using the same RE-21 instance
rule and RE-35 enclosing-record ElementIds as walls and doors. They are
registered in `PRODUCT_RECORD_CATEGORIES` and `RECOVERED_CATEGORIES`
(13→17 and 20→24 entries) and export through existing `category_map`
mappings as **`IfcBeam`** (`.BEAM.`), **`IfcColumn`**, **`IfcFooting`**,
and **`IfcBuildingElementProxy`**, with bounding-box bodies.
> 
> Documentation and honesty gates are updated (CHANGELOG, README,
ROADMAP, status/support profile, export diagnostics, new
**`element-records-structural-categories`** matrix row marked
**experimental**). On Snowdon architectural,
**`element_record_without_element_id`** is revised to **37** (adding 17
unattributed generic models). A new
**`examples/probe_re36_vim_oracle.rs`** scores placed-instance records
against a VIM export oracle;
**`reports/element-framing/RE-36-structural-categories.md`** records
local measurements. Rebar, connections, and beam systems keep correct
ids but are not exported; braces would map to **`IfcBeam`** without
structural-type decoding.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2e5003d. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
DrunkOnJava added a commit that referenced this pull request Sep 23, 2026
…, site elements, elevators and ramps from element records (RE-37) (#320)

## Summary

Nine more categories export from partition element records, each as the
entity Revit's own IFC4 export writes for it:
- lighting fixtures as `IfcLightFixture`;
- air terminals as `IfcAirTerminal`;
- food-service equipment as `IfcElectricAppliance`;
- planting, parking, entourage and hardscape as
`IfcBuildingElementProxy`;
- elevators as `IfcTransportElement`;
- ramps as `IfcRamp`.

Every exported element is one Revit's export holds, and each entity is
complete.

## Motivation

After RE-35 (#317) second-prologue ids are read directly. A census of
the remaining categories against Revit's own exports found these nine at
zero false positives. RE1 Electrical exported nothing before this.

## Changes

- `src/partition_element_records.rs`: nine `OST_*` constants, added to
`PRODUCT_RECORD_CATEGORIES` / `RECOVERED_CATEGORIES`.
- `src/ifc/category_map.rs`: `DuctTerminal`, `FoodServiceEquipment`,
`Planting`, `Parking`, `Entourage`, `Hardscape` and
`VerticalCirculation` rows. `src/ifc/step_writer.rs`: IFC4 arity rows
for `IFCAIRTERMINAL` and `IFCTRANSPORTELEMENT` (9 each).
- `.github/workflows/ci.yml`: tier 2 fetches RE1 Electrical (MIT) by
pinned commit and hash.
- `tests/element_records_2025.rs`: air terminals equal Revit's
`IfcFlowTerminal`s on RE1 Mechanical. The 12 lighting fixtures are
Revit's, and are the only elements exported, on RE1 Electrical.
-
`reports/element-framing/RE-37-fixture-site-circulation-categories.md`;
new support-matrix row; README, status, supported profile, ROADMAP,
export diagnostics, CHANGELOG.

## Measurements

| category | entity | Snowdon (IFC4, local) | RE1 Mech | RE1 Elec |
outside Revit's export |
|---|---|---:|---:|---:|---:|
| lighting fixtures | `IfcLightFixture` | 447/447 | – | 12/12 | 0 |
| air terminals | `IfcAirTerminal` | – | 7/7 | – | 0 |
| food service | `IfcElectricAppliance` | 26/26 | – | – | 0 |
| planting, parking, entourage, hardscape | `IfcBuildingElementProxy` |
157 | – | – | 0 |
| elevators | `IfcTransportElement` | 2/2 | – | – | 0 |
| ramps | `IfcRamp` | 2/2 | – | – | 0 |

Core Interior, RE1 Architecture and Plumbing, the Snowdon Structural
sample and the `255ribeiro` projects export unchanged.

Measured and not added:
- electrical fixtures (15 in Revit's export, 15 not) and lighting
devices (12 in, 6 not);
- slab edges (59 in, 9 not). All 9 are in a non-primary design option,
#319.
- fire alarm devices, data devices, electrical equipment and mechanical
equipment. Only IFC2x3 references exist for them.
- stairs, runs, landings, stringers and roofs, which Revit exports as
aggregates.

## Testing

- [x] `tools/check-local.sh`
- [x] Every integration test with the family corpus and the magnetar +
RE1 (all four) project corpus
- [x] `cargo +1.85.0 check --profile ci --all-targets`

## Audit-honesty checklist

- [x] Each entity follows Revit's IFC4 export on Snowdon. The
air-terminal entity is the IFC4 subtype of Revit's IFC2x3 choice, and
this is stated as such.
- [x] Omitted categories and their reasons are in the report and the
support matrix.

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] Clean-room: byte observations scored against Revit's own exports;
BuiltInCategory names from the public enum; no SDK source or decompiled
material. Snowdon is measured locally and not committed.
- [x] No PII

## Breaking changes

None.

## Related issues

Refs #309, #319.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes expand real-model IFC export and category recovery on the
production `iter_elements` path, but behavior is gated by oracle-aligned
tests and fail-closed category rules rather than broad refactors.
> 
> **Overview**
> **RE-37** extends partition element-record export with nine more Revit
categories, each mapped to the IFC4 entity Revit's own export uses on
measured oracles (lighting fixtures, air terminals, food service, site
proxies, elevators, ramps).
> 
> **Decoder / export wiring:** `partition_element_records.rs` adds
`OST_*` constants and registers the categories in
`PRODUCT_RECORD_CATEGORIES` and `RECOVERED_CATEGORIES`.
`category_map.rs` gains IFC rows for duct terminals, food service,
planting, parking, entourage, hardscape, and vertical circulation;
`step_writer.rs` adds schema-arity entries for `IFCAIRTERMINAL` and
`IFCTRANSPORTELEMENT`.
> 
> **CI and tests:** Tier-2 CI now downloads pinned **RE1-Electrical**
assets. `tests/element_records_2025.rs` asserts air-terminal ElementIds
on RE1 Mechanical (vs Revit `IfcFlowTerminal`) and that RE1 Electrical
exports exactly 12 `IfcLightFixture` ids matching Revit's export.
> 
> **Docs:** Changelog, README/status/roadmap/support matrix, export
diagnostics, and a new RE-37 research report document scope, counts, and
categories deliberately left out (unmeasured IFC4 entities,
design-option slab edges, etc.).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
69f35c7. 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