Repository navigation
fix(elem-table): recover the last declared record on the 40-byte project variant, and gate the test that missed it - #209
Merged
Conversation
…ect variant `elem_table::parse_records` walked 26,424 of the 26,425 records declared by `Global/ElemTable` on the magnetar `2024_Core_Interior.rvt`. `detect_layout` took the first `0xFF` run as record 0's first byte, but on that variant the run is a sentinel-valued field *inside* the record: each record opens with a zero `u32` and only then carries `FF`x8. The four-byte shift ran the walk out of bytes just short of the last record. Byte evidence: the page-stripped decompressed stream is 1,057,030 bytes (the gzip member's CRC32 and ISIZE both verify; the un-stripped inflate yields 1,059,812 and fails the CRC), which is `0x1E` + 26,425 x 40 exactly, and the `u32` ahead of every marker is zero on all 26,425 records. `record_origin` now recovers the origin as `len - record_count * stride` when it lands a whole number of `u32` fields, and less than one stride, ahead of the marker; `ElemTableLayout::marker_offset` keeps field extraction anchored to the marker. Ids on the previously-parsed records are byte-identical. The 28-byte 2023 variant is unchanged: its end-anchored origin would fall five bytes ahead of the marker, which the alignment guard rejects, so it still walks 2,614 of 2,615 with a 23-byte tail - now pinned exactly instead of asserted as `<=`. Gate gap closed first: `elem_table_corpus` reads `RVT_PROJECT_CORPUS_DIR` but was named by no CI job, so it skipped on every run. It is now named by the `test` matrix job (family half) and by `corpus-tier2` (project half), along with the six other corpus-reading targets that were equally ungated. A configured-but-incomplete corpus is now a failure, not a skip, and one always-on test runs off a committed 270-byte MIT excerpt. No OctetProof observation changed: `rvt-rs.json` stays b6d9b67c10c3350b69b58cbd2c6caeca405f63ce182e7291feba3e3ff10f3e00 on both recorded edges, and the Core Interior verdict replays PASS. Closes #206
Bugbot couldn't run - usage limit reachedBugbot 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_32cd02ca-d61b-4f8e-b061-e798ed05f499) |
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
…lement records (#210) Recovers architectural column instances from `2024_Core_Interior.rvt` and closes the last measured gap on the full-project export that had no decoder path at all. ## How columns present in the bytes Revit 2024 project partitions frame each *element* record with a fixed prologue. Reading it on `2024_Core_Interior.rvt` (sha256 `c805df44…`, eight `Partitions/*` streams, ~190 MiB inflated): ```text +0x00 u64 ElementId of this record (declared in Global/ElemTable) +0x08 u32 record flags (0x00e1 / 0x0111 / 0x0131 / 0x0141 / …) +0x0c u32 0x0000059f on every observed record of this shape +0x10 u16 0 +0x12 i64 BuiltInCategory id, negative (OST_Columns = -2000100) +0x1a 54B 0xff sentinel padding + three unattributed words +0x50 8B bbox marker 46 01 ff ff ff ff ab 05 +0x58 48B bounding box: min x/y/z, max x/y/z, feet, f64 LE ``` 24880 records of this shape exist on that file. The marker sits at exactly `+0x50` on 23470 of them (94.3 %), which is why the offset is treated as fixed rather than searched, and **every** leading `u64` is an ElementId declared in `Global/ElemTable` — the decoder requires that join, so a stray byte match cannot become an element. `OST_Columns` alone is not an instance claim: 393 distinct ElementIds carry it. Two further steps, both structural rather than fitted: 1. **Family-local bboxes are type definitions, not placements.** A symbol's envelope is stored in family coordinates and is therefore centred on the plan origin (`min_x == -max_x`, `min_y == -max_y`). 17 of the 393 are like that — the `Column_Sqaure : 24" x 24"` symbol (id 5755) plus per-level variants. Dropped. 2. **Co-located pairs are a superseded generation and its replacement.** The remaining 375 collapse to 256 distinct project-coordinate footprint origins: 137 footprints hold one record, 119 hold exactly two. In every pair the two records differ only in top extent (e.g. `76.0 → 91.0` vs `76.0 → 90.33`, an 8-inch difference consistent with a column being attached to a slab after placement). Revit allocates ElementIds monotonically, so the higher id in each group is the live element. That yields 256 ids. They are not merely the right *count*: the emitted `IfcColumn.Tag` set is byte-for-byte the set of ElementIds in Revit's own export (`{int(c.Tag) for c in cols} == reference ids` → `True` under IfcOpenShell 0.8.5), and the placements agree — column 20375 lands at (24.0, 110.0, 76.0) ft, the centre of the 2 ft box whose min corner is the (23.0, 109.0, 76.0) the Revit exporter writes. ## What ships - `src/partition_element_records.rs` — the record decoder, version-gated to Revit 2024, fail-closed on the ElemTable join, the `+0x10` zero word, the BuiltInCategory band, the bbox marker, non-finite doubles and inverted boxes. - `partition_schema_mvp::columns_from_partition_category_records` — the three-step instance selection above, merged into production `iter_elements` as `class == "Column"`. `columns_from_records` is split out so the rule is unit-tested without a corpus file. - IFC export emits `IfcColumn` with a project placement and a bounding-box `IfcExtrudedAreaSolid`. This is an **envelope, not a recovered family profile**, and the `RvtColumnGeometry` property set says so (`ProfileResolved: false`, `LevelBindResolved: false`, `BodySource: partition_element_record_bbox`). Base/top Level ElementIds stay unbound (#86). ## Measured, before → after `./target/ci/rvt-ifc <rvt> -o /tmp/x.ifc --diagnostics /tmp/d.json`, `2024_Core_Interior.rvt`, every value re-measured on this branch (nothing estimated): | metric | before | after | |---|---:|---:| | `by_ifc_type.IFCCOLUMN` | 0 | **256** | | `by_ifc_type.IFCSLAB` | 64 | 64 | | `by_ifc_type.IFCSPACE` | 18 | 18 | | `by_ifc_type.IFCWALL` / `IFCDOOR` / `IFCWINDOW` / `IFCROOF` / `IFCBEAM` / `IFCFLOWTERMINAL` | 0 | 0 | | `storey_count` | 12 | 12 | | `material_count` | 102 | 102 | | `step.IFCUNITASSIGNMENT` | 1 | 1 | | `step.IFCPROPERTYSET` | 64 | **320** | | `building_elements` | 82 | 338 | | `building_elements_with_geometry` | 0 | **256** | `rvt-elements --counts` goes from `{ArcWallRectOpening 3777, Floor 64, Level 12, Material 102, Room 18}` (3973) to the same plus `Column 256` (4229). Export wall-clock on this machine: 13.1 s → 15.8 s. ## Manifests - `2024-core-interior-slim.json`: `columns` moves `known_gap` → **`known`**, `decoder_expected` 0 → 256, tolerance 0. `property_sets.decoder_expected` 64 → 320. `rooms_spaces.unsupported_feature` moves to the new `partial_element_geometry` code (see below). - `2024-core-interior.json` (the 20 KB element fixture): `columns` moves `known` → **`decoder_baseline`**, `decoder_expected` 0 → 256. That reference has no `IFCCOLUMN`, so scoring the count there would be wrong; it is scored against the full export in the sibling manifest. `property_sets.decoder_expected` 64 → 320. ## Verdicts Both regenerated and both `PASS`. **The observation hashes changed** (`research/witness/*/observations/rvt-rs.json`), so the umbrella mirror will need the new bytes after merge. ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 7 fields, excluded: 5, diffs: 0 magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 5 fields, excluded: 8, diffs: 0 ``` The slim claimed surface widens from four fields to five: `entity_counts.IFCCOLUMN` joins `IFCROOF`, `IFCBEAM`, `IFCFLOWTERMINAL` and `IFCUNITASSIGNMENT`. It is the first field in that surface with a non-zero expectation — the other four are agreements about absence. ## Diagnostics fix (second commit) `unsupported_features` carried `real_file_element_geometry` only while *no* exported element had a body, so the first category to gain geometry silently cleared the gap for every other one. It now reports `real_file_element_geometry` when nothing has a body and the new `partial_element_geometry` when some do and some do not. Documented in `docs/export-diagnostics.md`. ## Generalisation — deliberately not taken here The same header carries every other building category. Measured with the shipped decoder on the same file (`scan_category_records` + the same family-local drop and footprint de-duplication), against the ElementId set Revit's export tags: | category | records | ids carrying the category | recall of exported ids | after the instance filter | TP | FP | FN | |---|---:|---:|---:|---:|---:|---:|---:| | `OST_Columns` | 480 | 392 | **256 / 256** | 256 | 256 | 0 | 0 | | `OST_Walls` | 1488 | 1210 | 360 / 360 | 648 | 360 | 288 | 0 | | `OST_Doors` | 335 | 200 | 132 / 132 | 139 | 132 | 7 | 0 | | `OST_Windows` | 9 | 9 | 6 / 6 | 8 | 6 | 2 | 0 | | `OST_Floors` | 146 | 124 | 79 / 80 | 67 | 43 | 24 | 37 | | `OST_Rooms` | 399 | 277 | n/a | 169 | — | — | — | Category membership alone reaches every exported wall, door and window ElementId and all but one slab, which is a real result — but only columns survive the instance filter exactly, so **no other category's status moved** in this PR and the documented RE-19 / RE-20 negatives are untouched. (`IfcSpace` carries no ElementId tag in this export, so rooms cannot be scored by id at all.) Follow-up issues carry these numbers. ## Gate `cargo fmt --all -- --check`, `cargo clippy --all-targets -- -D warnings`, `cargo +1.85.0 check --all-targets` (MSRV, no let-chains), `tools/check-local.sh`, and the full suite (1127 tests) all green. With `RVT_PROJECT_CORPUS_DIR` set, the tier-two targets from #209's new CI step are green too: `elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration`, plus `project_count_fixtures`, `witness_verdict`, `witness_registry`, `support_matrix`, `json_schema_contracts`. Branched from `main` and merged `origin/main` (bcc4e53, #209) mid-flight; the ElemTable record-origin fix does not move any number here. Closes #204 ## Follow-ups filed - #211 — walls / doors / windows: category recall is 100 % (360/360, 132/132, 6/6) but the instance filter over-counts (648 / 139 / 8). RE-19 stands; this is a different mechanism, not a re-opening. - #212 — slabs: 79 of 80 ids carry the category, but footprint de-duplication is the wrong identity rule for plates (43 TP / 37 FN). Also the obvious source for `floor_slab_extrusion_thickness`. - #213 — bind columns to storeys via the record bbox base elevation; the 10 distinct base z values are themselves better elevation evidence than the current name strings. - #215 — recover the real column profile from the family-local symbol record instead of the instance envelope. - #216 — research: what the 137 non-exported `OST_Columns` elements actually are (17 family-local symbols, 119 exact co-locations of an exported column). Answering it would replace the highest-id heuristic with a direct test, and probably fixes #211 too. - #214 — pre-existing and unrelated to this change: the IFC4 writer omits the trailing `PredefinedType` attribute on every building element (`IFCSLAB` / `IFCSPACE` on `main` have the same shape), so the instances are non-conformant even though IfcOpenShell tolerates them.
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
…rom Revit 2024 partition element records (#211) (#221) Closes #211. Explains and closes #216. `2024_Core_Interior.rvt` (sha256 `c805df44…`) against Revit's own full-project export `IFC Exports/2024_Core_Interior_slim.ifc` (sha256 `bfdf36ff…`), whose per-entity `Tag` carries the source ElementId. ## The rule #210 established that the Revit 2024 partition element-record header reaches **100 %** of the exported ElementIds in every architectural category. What was missing was precision. Two fields inside the 54 bytes #210 recorded as "0xff sentinel padding + three unattributed words" supply it: ```text +0x32 u64 container ElementId, 0xffff_ffff_ffff_ffff = none +0x42 u32 placement kind: 0xffffef7f placed instance 0xffff8000 family/type symbol envelope ``` > A record is a standalone placed instance — what Revit's exporter emits as a > building element — **iff** `u64 @ +0x32 == 0xFFFF_FFFF_FFFF_FFFF` **and** > `u32 @ +0x42 == 0xFFFF_EF7F`. `PartitionElementRecord::is_exported_instance`. Both halves are required; neither is sufficient alone. **This is not a re-opening of RE-19.** The carrier is the element record's own `BuiltInCategory` field, not the `ArcWallRectOpening` index and not a schema-field decode. Both RE-19 negatives stand and are still reported: `schema_field_wall_instances` still fires (its check now requires a wall whose body did *not* come from an element record, so an element-record wall cannot clear it by accident), and door/window **host binding** is still unsupported. ## Set-difference evidence Prologue bytes `+0x1a..+0x50`, exported vs not exported: | side | distinct patterns | shape | |---|---:|---| | exported | 1 per category | `ff`×40 then `7fefffff` `<w46>` `<w4a>` `ffffffff` | | container members | 9 owner values | `ff`×24 then **`<owner u64>`** then `ff`×8 then `7fefffff` … | | type symbols | 2 per category | `ff`×40 then **`0080ffff`** `<w46>` `<w4a>` `ffffffff` | Rules measured independently and together (ElementId sets, not counts): | category | A: `+0x32` unset | B: `+0x42` placed | **A ∧ B** | exported | |---|---:|---:|---:|---:| | `OST_Walls` (-2000011) | 361 (1 FP) | 1209 (849 FP) | **360 exact** | 360 | | `OST_Doors` (-2000023) | 147 (15 FP) | 185 (53 FP) | **132 exact** | 132 | | `OST_Windows` (-2000014) | 8 (2 FP) | 7 (1 FP) | **6 exact** | 6 | | `OST_Columns` (-2000100) | 273 (17 FP) | 375 (119 FP) | **256 exact** | 256 | Every non-sentinel `+0x32` value is a container ElementId: all nine are declared in `Global/ElemTable`, all are lower than every member id that names them, each owns a contiguous ElementId block spanning several categories at once, and none has an element record of its own (brute scan of all 23470 decodable records finds none). | owner | columns | walls | doors | windows | member range | |---:|---:|---:|---:|---:|---| | 16229 | 23 | 66 | 14 | 1 | 16347 – 16995 | | 21984 | 24 | 8 | – | – | 22008 – 22077 | | 23117 | 24 | 57 | 11 | – | 23134 – 23733 | | 26863 | 24 | 63 | 14 | – | 26880 – 28001 | | 26908 | – | 27 | – | – | 26993 – 27045 | | 33696 | 24 | 70 | 14 | – | 33748 – 34467 | | 81029 | – | 277 | – | – | 81041 – 87363 | | 87754 | – | 4 | – | – | 87758 – 87764 | | 108205 | – | 277 | – | – | 108216 – 114538 | Full write-up, histograms and reproduction commands: [`reports/element-framing/RE-21-partition-element-record-instance-rule.md`](reports/element-framing/RE-21-partition-element-record-instance-rule.md). ## Measured before → after `cargo build --profile ci --bin rvt-ifc && ./target/ci/rvt-ifc <rvt> -o /tmp/x.ifc --diagnostics /tmp/d.json` | decoder metric | before | after | export expects | manifest status | |---|---:|---:|---:|---| | `by_ifc_type.IFCWALL` | 0 | **360** | 360 | `known_gap` → **`known`**, tol 0 | | `by_ifc_type.IFCDOOR` | 0 | **132** | 132 | `known_gap` → **`known`**, tol 0 | | `by_ifc_type.IFCWINDOW` | 0 | **6** | 6 | `known_gap` → **`known`**, tol 0 | | `by_ifc_type.IFCCOLUMN` | 256 | 256 | 256 | `known` (rule replaced) | | `by_ifc_type.IFCSLAB` | 64 | 64 | 80 | `known_gap` (#212) | | `by_ifc_type.IFCSPACE` | 18 | 18 | 116 | `known_gap` | | `exported.material_count` | 102 | 102 | 10 | `known_gap` | | `step.IFCPROPERTYSET` | 320 | **818** | 0 | `known_gap` | | `step.IFCUNITASSIGNMENT` | 1 | 1 | 1 | `known` | | `exported.storey_count` | 11 | 11 | 15 | `decoder_baseline` | | `building_elements_with_geometry` | 256 | **754** | — | — | | `exported.storey_bound_elements` | 256 | **743** of 836 | — | — | | `step.IFCRELCONTAINEDINSPATIALSTRUCTURE` | 11 | 11 | — | — | ("before" = `main` at f4b88df, i.e. after #217.) Id-set check on the emitted IFC (not just counts): ``` IFCWALL: rvt-rs=360 export=360 exact=True missing=0 extra=0 IFCDOOR: rvt-rs=132 export=132 exact=True missing=0 extra=0 IFCWINDOW: rvt-rs=6 export=6 exact=True missing=0 extra=0 IFCCOLUMN: rvt-rs=256 export=256 exact=True missing=0 extra=0 ``` ## #216 falls out The 136 `OST_Columns` ids Revit omits split with no remainder: - **17 type symbols** (`+0x42 == 0xffff8000`) — ids 5755, 19250, 22374, 24299, 28008, 53894, 75407–75417, exactly the 17 #216 lists as family-local; - **119 container members** (`+0x32` set) — the blocks 16347–16369, 22045–22068, 23134–23157, 26880–26903, 33748–33771 that #216 identified as "exact co-locations of an exported column", each owned by the id allocated just before its block. So the #204 heuristic is **retired**: `partition_schema_mvp` no longer drops origin-centred family-local bounding boxes and no longer collapses co-located footprint groups to their highest `ElementId`. It applies the direct test, reproduces the same 256/256 columns, and additionally the wall / door / window id sets — which the heuristic could not (648 / 139 / 8). `is_family_local` is kept as a documented, strictly weaker diagnostic: the `+0x42` symbol set is a superset of it on every category, catching 15 door, 2 window and 1 wall symbols whose envelope is centred on only one axis (e.g. id 17331 spans `x −1.749…1.749` but `y −0.332…3.251`). ## What did not move `OST_Floors` stays `known_gap` (#212), measured not hand-waved: 124 distinct ids carry the category, 79 of the 80 exported slabs have a record at all, and the rule selects 99 (TP 79 / FP 20 / FN 1). `+0x42` is `0xffffef7f` on all 146 floor records — there are no slab type symbols on this file — so the rule degenerates to `+0x32` alone there. That needs a slab-appropriate identity key, not a looser tolerance. No tolerance was widened anywhere in this PR. ## Storey elevations — the #213 evidence base did not widen silently #217 derives storey elevations from element-record base `z`. Adding three categories to the record set would have widened that evidence base by accident, so the restriction is now measured, against the fifteen `IfcBuildingStorey.Elevation` values in the export: | category | distinct base elevations | equal to a storey | not a storey | |---|---:|---:|---| | `OST_Columns` | 11 | 11 | — | | `OST_Doors` | 11 | 11 | — | | `OST_Walls` | 13 | 12 (adds **−40 ft**) | 56.4167 | | `OST_Windows` | 6 | **0** | 80.73, 95.73, 110.73, 125.73, 140.73, 155.73 | A window sits at its sill height above the level that hosts it, so its record base is never a storey elevation; a wall may start mid-storey. Only `IFCCOLUMN` therefore *supplies* elevations (new `ifc::STOREY_ELEVATION_SOURCE_TYPES`), which keeps #213's measured "no false positives" claim exactly as recorded and `storey_count` at 11. Every record-bodied element still *binds* by exact match, so `IfcRelContainedInSpatialStructure` stays 11 while storey-bound elements go **256 → 743 of 836**: all 256 columns, all 132 doors, 355 of 360 walls. The 5 walls at −40 / 56.4167 ft and all 6 windows stay unbound rather than being placed by proximity. **Of the four export elevations #213 could not reach (−40, −20, 15, 185.5 ft), these categories surface exactly one: −40 ft, from wall records — and taking it costs one elevation that is not a storey.** That trade is left open rather than taken. The other three carry no record of any of the four categories. ## IFC4 attribute arity (#214) `tools/ci/ifc_schema_arity.py` on a fresh Core Interior export including the new walls/doors/windows: ``` IFC schema conformance passed schema: IFC4 instances checked: 15035 across 36 entity type(s) PredefinedType populated: IfcColumn=256, IfcSlab=64, IfcWall=360 ``` ## Verdicts ``` magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 8 fields, excluded: 5, diffs: 0 ``` surface `IFCWALL`, `IFCDOOR`, `IFCWINDOW`, `IFCCOLUMN`, `IFCROOF`, `IFCBEAM`, `IFCFLOWTERMINAL`, `IFCUNITASSIGNMENT` (was 5 fields / 8 excluded); `verdict_hash_sha256` `afa87bb0a4e35ea8e5fa9a1adb21b29f8a0ba532571c88fd00c14dabcd4c7145`. ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 4 fields, excluded: 8, diffs: 0 ``` `verdict_hash_sha256` `ae4679f6044a4c3caa0b2f3a6030648bc633b1d878957a759120f011f71ded5e`. Both `rvt-rs.json` observations were regenerated **after** merging `origin/main` at f4b88df (#217), so their `observation_hash_sha256` reflects both changes: `d88897c6d9b8223350a831f4caf48d76d469a4d4f47815da56da6d34e9364fb7`. ## Diagnostics vocabulary made precise Two composite `unsupported_features` were half-true after this change, so they were split into what is actually still missing: - `typed_door_window_discrimination_and_host_binding` now fires only when no typed door or window is exported at all. When they are exported but carry no host, the narrower **`door_window_host_wall_binding`** fires instead. - New **`revit_element_parameters_to_ifc_property_sets`** fires while every exported `IfcPropertySet` is rvt-rs provenance about a recovered body rather than a Revit element parameter (#35). The two manifest rows that previously borrowed the door/window feature name now use accurate ones. - `schema_field_wall_instances` keeps firing (see above). ## Docs `docs/status.md`, `docs/support-matrix.json` (`column-instance-recovery` → `element-record-instance-recovery`, still `verified`, scope restated for four categories; `typed-door-window` and `schema-field-wall` stay `unsupported` with their honesty invariants intact), `docs/verification-protocol.md` edges table + honesty note, `docs/supported-profile.md`, `README.md` (three surgical lines), `CHANGELOG.md`, and the new RE-21 report. ## Gates run `cargo fmt --all`, `cargo clippy --profile ci --all-targets -- -D warnings`, `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps`, `cargo +1.85.0 check --all-targets` (MSRV 1.85, no let-chains), `tools/check-local.sh`, and the full `cargo test --profile ci` suite with `RVT_PROJECT_CORPUS_DIR` / `RVT_CORPUS_TIER1_DIR` — all green, including every tier-2 target from #209 (`elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration`) plus `witness_verdict`, `witness_registry`, `project_count_fixtures`, `support_matrix`. `tests/iter_elements_typed.rs::core_interior_2024_rect_openings_not_fake_doors` now pins the exact counts **and** asserts every recovered Wall/Door/Window carries provenance `partition_schema_mvp::element_category_record`, so the RE-19 negative is enforced by mechanism, not by a zero. ## Merge with #217 `origin/main` at f4b88df was merged into this branch before the final measurement, so every number above is post-#217. The STEP emitter and `category_map` `predefined_type` values are untouched; the hunks in `src/ifc/mod.rs` are `unsupported_export_features`, the new `STOREY_ELEVATION_SOURCE_TYPES` restriction described above, one re-export line, and one `expect` message. ## Follow-ups - #212 slab instance identity — the rule does not hold there; the record bbox is also the obvious source for the unresolved extrusion thickness. - Door/window host-wall binding (`door_window_host_wall_binding`) — the record body past `+0xa8` was dumped but not yet mined for a host reference. - `docs/octetproof-spec.md` §6's worked verdict example is a two-lineage snapshot and was already stale before this PR (the committed verdict has three lineages); refreshing a published 1.0.0 artifact is a separate call. - `+0x46` / `+0x4a` remain unattributed; their values correlate with class, which may be a schema class-id join worth a look. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core decode/IFC export and cross-witness gates for a corpus-proven Revit 2024 edge; scope is narrow but wrong instance filtering would skew real-project exports and CI verdicts. > > **Overview** > **Revit 2024 partition element records** now drive typed **Wall, Door, Window, and Column** recovery using a direct byte rule instead of the retired #204 column heuristic (family-local bbox drop + highest-`ElementId` per footprint). Records decode **container reference** at `+0x32` and **placement kind** at `+0x42`; `PartitionElementRecord::is_exported_instance` keeps only standalone placed instances. On Core Interior that matches Revit’s export **ElementId sets** at tolerance 0 (360/132/6/256), with bbox envelope geometry and shared `RvtElementRecordGeometry` property sets in IFC. > > **Production and verification** wire walls/doors/windows through `partition_schema_mvp::instances_from_partition_category_records`, unify element-record geometry in `export_content`, and narrow **storey elevation sourcing** to columns only (`STOREY_ELEVATION_SOURCE_TYPES`) while other record-bodied elements still **bind** storeys by exact base elevation (743/836 bound). OctetProof manifests move walls/doors/windows to **`known`** on the slim edge (8-field claimed surface); diagnostics split host binding vs discrimination and add `revit_element_parameters_to_ifc_property_sets`. RE-19/schema-field walls and door/window **host** binding stay explicitly unsupported; slabs (`OST_Floors`) remain #212 `known_gap`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cb75c37. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
… Revit 2024 partition element records (#212) (#225) Closes #212. Refs #31 #218 #219. RE-21 recorded `OST_Floors` as the one category where the partition element-record instance rule fails: 99 selected against 80 exported, `TP 79 / FP 20 / FN 1`. Both numbers reproduce exactly. **Neither is a decoder error.** Full evidence, rejected candidates and reproduction commands: [`reports/element-framing/RE-22-slab-instance-rule.md`](reports/element-framing/RE-22-slab-instance-rule.md). ## 1. The set difference **The 20 "false positives" are exported.** They are, id for id and in order, the export's 20 `IFCSHADINGDEVICE` `Tag` values: ``` 20953, 64160, 64227, 64292, 64358, 64423, 64488, 64553, 64618, 64683, 70366, 71171, 71231, 71291, 71351, 71411, 71471, 71531, 71591, 71651 ``` ``` #3468=IFCSHADINGDEVICE(…,'Floor:Arch Topping Slab - 2":20953',$, 'Floor:Arch Topping Slab - 2"',…,'20953',.NOTDEFINED.); ``` So the instance rule selects 99 ids on `OST_Floors` and **all 99 are exported** — 79 as `IfcSlab`, 20 as `IfcShadingDevice`. Precision was already 100 %; #212 measured a type-assignment gap wearing a precision gap's clothes. **The 1 "false negative" is a building pad.** `#3526=IFCSLAB(…,'Pad:Site Pad:21975',…,'21975',.FLOOR.)`. A brute scan of all 23 470 decodable element records finds ElementId 21975 exactly once, with `category = -2001263` — Autodesk's published `BuiltInCategory.OST_BuildingPad`. Same prologue shape, same instance rule, and Revit's exporter maps a building pad to `IfcSlab` `.FLOOR.`. #212 guessed this outcome; the bytes confirm it. | stage | count | |---|---:| | distinct ids carrying `OST_Floors` | 124 | | instance rule selects on `OST_Floors` | 99 | | of those, exported by Revit | **99** (79 `IfcSlab` + 20 `IfcShadingDevice`) | | instance rule selects on `OST_BuildingPad` | 1 | | exported `IFCSLAB` recovered | **80 / 80** | | exported `IFCSHADINGDEVICE` recovered | **20 / 20** | ## 2. The rule The `IfcSlab` / `IfcShadingDevice` split is decided **per instance**, not per type — the reference export carries `IFCSLABTYPE` *and* `IFCSHADINGDEVICETYPE` rows with the same `Tag` (`4166`, `71848`), so the same Revit `FloorType` lands on both sides. That is Revit's `IFC Export As` instance parameter, and its value is in the file as a UTF-16LE string: ``` -0x11e u64 owning ElementId (confirmation slot) -0x0dc u64 owning ElementId -0x004 u32 value length in UTF-16 code units (0x10) +0x000 32B "IfcShadingDevice", UTF-16LE +0x020 u64 parameter-definition ElementId (17368, then 17493) ``` Over a 3 KB window around every one of the 62 hits, the owning ElementId appears **only** at those two offsets, always as a `u64`, always identical in both slots. Requiring the slots to agree and the id to be declared in `Global/ElemTable` accepts 31 entries naming 21 ids; the second string of each pair is rejected (sentinel owner slots), and so is the parameter *definition* block. The 21st id (`16925`) is a container member the RE-21 rule already excludes — its superseded twin, same `182.3333 x 121.6111 ft` box as `20953`. > **The rule.** A partition element record is an exported slab iff it is a > standalone placed instance (RE-21) in `OST_Floors` or `OST_BuildingPad` > **and** no accepted `IFC Export As` override names it. An override naming > `IfcShadingDevice` redirects the entity type rather than suppressing the > element. The scan is general (any `Ifc…` value string); only `IfcShadingDevice` is honoured as a target (`ifc::category_map::EXPORT_OVERRIDE_TARGETS`), because it is the only value a reference export has demonstrated. An unrecognised value leaves the element on its class mapping. ### What was rejected Two byte fields separate the two sides *within* `OST_Floors` on this file and neither survives contact with the rest of the corpus — both are shipped as **not** the rule: | candidate | inside `OST_Floors` | why rejected | |---|---|---| | prologue flags `+0x08` | `0x0119` on all 30 shading records, none of the 91 slab records | 32 **exported** `IFCWALL` records also carry `0x0119`. The word is a count (`0xe9 + 8k`, tracking `+0x88`); the separation is a consequence of all 20 shading plates sharing one footprint. | | record byte `+0x88` | `8` on all 30 shading records | 153 exported `IFCWALL` and 107 exported `IFCCOLUMN` records carry `8`. | | bbox shape | all 20 shading plates are exactly `182.3333 x 121.6111 ft` | shape identity, not a byte test — the same objection #212 raised against #204's footprint key. | ## 3. Measured before / after on `2024_Core_Interior.rvt` | metric | before | after | reference export | |---|---:|---:|---:| | `IFCSLAB` | 64 (plan-loop annotations, no ids) | **80** (exact id set) | 80 | | `IFCSHADINGDEVICE` | 0 | **20** (exact id set) | 20 | | `IFCWALL` / `IFCDOOR` / `IFCWINDOW` / `IFCCOLUMN` | 360 / 132 / 6 / 256 | 360 / 132 / 6 / 256 | same | | building elements | 836 | 872 | — | | with a recovered body | 754 | 854 | — | | `storey_bound_elements` | 743 | 794 | — | | `IFCBUILDINGSTOREY` | 11 | 11 | 15 | | `IFCPROPERTYSET` | 818 | 854 | 0 | Exactness verified on the emitted IFC with IfcOpenShell 0.8.5 (`Tag` sets, `include_subtypes=False`), the reference side independently with IFClite 7.1.1: ``` IfcSlab export= 80 rvt-rs= 80 missing=0 extra=0 EXACT=YES IfcShadingDevice export= 20 rvt-rs= 20 missing=0 extra=0 EXACT=YES IfcWall export= 360 rvt-rs= 360 missing=0 extra=0 EXACT=YES IfcDoor export= 132 rvt-rs= 132 missing=0 extra=0 EXACT=YES IfcWindow export= 6 rvt-rs= 6 missing=0 extra=0 EXACT=YES IfcColumn export= 256 rvt-rs= 256 missing=0 extra=0 EXACT=YES ``` `tools/ci/ifc_schema_arity.py` on the fresh export: 16 674 instances across 37 entity types, `IfcShadingDevice` at its declared IFC4 arity of 9 with `PredefinedType` written as `$` rather than an invented `.NOTDEFINED.`. ## 4. Thickness (#31) The record's bbox `z` extent **is** the slab's extrusion depth, measured against the export's `IfcExtrudedAreaSolid.Depth`: ``` thickness: exact match 79/80; matches the sum of stacked solids 1; other 0 layered: 22756 thickness 1.5 vs export solids [0.333333333, 1.166666667] (sum 1.5) ``` `Floor:Basement Slab` 22756 is exported as two stacked solids that sum to exactly the recorded 1.5 ft — agreement in substance on all 80. Record-backed slabs now carry `ThicknessResolved`, `ThicknessFeet` and `ThicknessSource`, and `floor_slab_extrusion_thickness` is raised per slab so the plan-loop path (2023) still declares it. The slab *profile* stays the bbox rectangle — `ProfileResolved: false`, #31's polygon-profile half is open. Also changed: where one ElementId is framed more than once (22 of 100 slabs), the record with the **greatest `z` extent** is kept. First-by-`(stream, offset)` agrees with the export on 67 of 80; greatest-extent on 79 of 80. The change is uniform and perturbs nothing — 268 walls, 132 doors and 88 columns also carry multiple records and every one agrees on the box. ## 5. Storey containment (#219) The 64 plan-loop `IFCSLAB` annotations carried no ElementId, no bbox and no storey. They stand down where records decode — **exactly one `IFCSLAB` per exported id**, no double emission. Plates bind by their **top** face (Revit hangs a floor below its level): | join over the 100 record-backed plates | bound | agrees with the export | wrong | |---|---:|---:|---:| | base `z` equals a recovered storey elevation | 0 | 0 | 0 | | **top `z` equals a recovered storey elevation** | **51** | **51** | **0** | Exact match, no tolerance, no proximity fallback. `storey_bound_elements` 743 → 794. #219's 82 unbound becomes 78: 49 plates (was 64), 18 spaces, 5 walls, 6 windows. ## 6. Storey elevations (#218): measured, and the answer is no | slab record face | distinct values | equal to a storey elevation | not a storey elevation | |---|---:|---:|---:| | base `z` | 40 | **0** | 40 | | top `z` | 26 | 13 | 13 | Slab tops would add **−40 ft and 185.5 ft**, two of the four storeys #213 misses, at the price of **13** values that are not storeys (each 0.1667 ft below a real one — the structural-slab / topping interface). Two for thirteen is not a trade this project takes: `ifc::STOREY_ELEVATION_SOURCE_TYPES` stays `["IFCCOLUMN"]` and the count stays 11. #218 keeps both halves open with the numbers it asked for. ## 7. Verdicts Both OctetProof verdicts `PASS`, replayed byte-for-byte: ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 4 fields, excluded: 9, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 10 fields, excluded: 4, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match ``` The full-project claimed surface goes **8 → 10 fields** (`entity_counts.IFCSLAB` and `entity_counts.IFCSHADINGDEVICE` join), excluded 5 → 4. `floors` moves `known_gap` → `known` at tolerance 0; a new `shading_devices` row scores the 20 the manifest previously left unscored. ## 8. Gates run `cargo fmt --all`, `cargo clippy --all-targets -- -D warnings`, `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps`, `cargo +1.85.0 check --all-targets` (MSRV), `tools/check-local.sh --ifcopenshell` (all requested gates passed), the full `cargo test --profile ci` suite with `RVT_PROJECT_CORPUS_DIR` / `RVT_CORPUS_TIER1_DIR` set (55 test groups, 0 failures), and the seven tier-2 corpus targets from #209 (`elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration`) — all green. New coverage: `tests/iter_elements_typed.rs::core_interior_2024_slab_instances_and_export_overrides` pins the 100-instance set, the single `BuildingPad`, the exact 20-id override set and the plan-loop stand-down; nine unit tests in `src/partition_ifc_export_overrides.rs` cover the framing's fail-closed paths; plus selection, override-mapping, thickness and top-face-bind unit tests. ## 9. Docs `docs/status.md`, `docs/support-matrix.json` (scope wording in the RE-21 row's style — the `verified` row now names six categories and states the override carrier, the record-selection rule and the plate bind explicitly), `docs/verification-protocol.md`, `docs/supported-profile.md`, `docs/compatibility.md`, `docs/user-guide.md`, `README.md`, `ROADMAP.md`, `TODO.md`, `CHANGELOG.md`, and the viewer's typed-class row. `docs/octetproof-spec.md` takes a **1.0.2 patch** (non-semantic, §16.1): its §6.2/§6.3 worked examples quote files this PR changes by design, so they are now labelled dated snapshots rather than a live mirror of `research/witness/`. No schema, diff-function or provenance change. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes partition MVP merge, IFC entity typing, storey binding, and gated witness artifacts on a narrow 2024 path; behaviour is fail-closed and corpus-tested but affects production export output counts and geometry metadata. > > **Overview** > **Revit 2024 slab export parity** on the Core Interior corpus: **80/80 `IFCSLAB`** and **20/20 `IFCSHADINGDEVICE`** with exact ElementId sets vs Revit’s exporter, replacing 64 id-less plan-loop slab annotations when element records decode. > > Recovery extends the RE-21 partition element-record instance rule to **`OST_Floors` and `OST_BuildingPad`**, adds **`partition_ifc_export_overrides`** to read per-instance **“IFC Export As”** strings (honouring only proven **`IfcShadingDevice`** redirects), and picks **one record per id by greatest bounding-box `z` extent** for thickness. IFC export maps **`BuildingPad` → `IFCSLAB`**, applies overrides in **`export_content`**, emits **measured slab thickness** from record bbox height, and binds **slabs/shading devices to storeys by top face** (`record_top_elevation`). Plan-loop floors are **cleared when `slabs` is non-empty** to avoid double-counting. > > **OctetProof / CI fixtures** widen the slim verdict surface to **`IFCSLAB` + `IFCSHADINGDEVICE`**, refresh witness observations, and document OctetProof **1.0.2** snapshot wording. Docs, support matrix, viewer status classes, and a research **`probe_slab_instance_rule`** example are updated accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1271c20. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
… and emit the IFC4 opening chain (#222) (#226) ## The rule Past the 88-byte prologue and the 48-byte bounding box, at `+0x88`, every Revit 2024 partition element record carries a **counted reference list**: a `u32` length then that many `u64` slots. **The host wall is the slot immediately before the record's own ElementId.** Door ElementId 25947, `Partitions/46`: ```text +0x88 06 00 00 00 n = 6 +0x8c 03 00 00 00 00 00 00 00 3 +0x94 32 4f 00 00 00 00 00 00 20274 +0x9c cc 5c 00 00 00 00 00 00 23756 door type symbol (RE-21 §5) +0xa4 ed 5e 00 00 00 00 00 00 24301 door type symbol (RE-21 §5) +0xac 90 63 00 00 00 00 00 00 25488 ← host wall +0xb4 5b 65 00 00 00 00 00 00 25947 ← the record's own id ``` Window ElementId 20898 has the same framing with `n = 18`, its host at `+0x10c` and its own id at `+0x114`. The value is accepted only when it is one of the **360 ElementIds the RE-21 instance rule selects as exported walls**, so a wrong read fails closed instead of inventing a host. Both halves are required: the slot is where the byte says the host is, the wall-set membership is what makes the join self-checking. ## Evidence 138 door/window instances are framed by **273 records**. Scoring every record, not just the one the per-id selection keeps: | rule | correct | wrong | no value | |---|---:|---:|---:| | **slot before the record's own id** | **273** | **0** | 0 | | `u64 @ +0xac` (list index 4) | 186 | 87 | 0 | | `u64 @ +0xa4` (list index 3) | 81 | 192 | 0 | | last two slots are `(host, self)` | 192 | 81 | 0 | All three rejected candidates assume a shape the list does not have. The length varies — 6 on every door record, 18 on every window record, up to 101 elsewhere — and 81 door records continue past their own id with a trailing type-symbol slot (only `132750`, `132824`, `132825`, `132875` ever appear there, all `+0x42 == 0xffff8000` symbols RE-21 already excludes). The predecessor read applied to every category (instances only) shows what the rule is *not*: | category | records | predecessor is an exported wall | something else | |---|---:|---:|---:| | `OST_Doors` | 267 | **267** | 0 | | `OST_Windows` | 6 | **6** | 0 | | `OST_Walls` | 638 | 528 | 110 | | `OST_Columns` | 344 | 0 | 344 | | `OST_Floors` | 121 | 0 | 121 | 528 wall records also have a wall predecessor, so "the predecessor is a wall" is not a category discriminator — it is a fail-closed check on a value only the two categories RE-21 already identifies by `BuiltInCategory` are asked for. ## Pair-set agreement `rvt-ifc` emits the chain Revit itself emits — `IfcOpeningElement` (bodied with the door/window's own record bounding box, `Tag` repeating the filling element's, as the reference does on all 138) + `IfcRelVoidsElement` (wall → opening) + `IfcRelFillsElement` (opening → door/window). The `(host Tag, filling Tag)` pairs read back out with IfcOpenShell 0.8.5: | | rvt-rs | Revit export | |---|---:|---:| | `IFCRELFILLSELEMENT` pairs | 138 | 138 | | distinct pairs | 138 | 138 | | in the export, missing from rvt-rs | **0** | — | | in rvt-rs, absent from the export | **0** | — | **Exact set equality, no tolerance.** 132 doors + 6 windows across 92 distinct host walls (65 hold one opening, 8 hold two, 19 hold three). The export's other 63 `IfcOpeningElement` — 42 slab penetrations, 20 shading-device penetrations, 1 unfilled wall opening — are not recovered: rvt-rs emits no opening that is not filled by a recovered element. Entity counts are unchanged: `IFCWALL` 360, `IFCDOOR` 132, `IFCWINDOW` 6, `IFCCOLUMN` 256, `IFCSLAB` 80, `IFCSHADINGDEVICE` 20. `tools/ci/ifc_schema_arity.py` passes on the fresh export — **18 192 instances across 40 entity types**, `IfcOpeningElement` at its declared arity of 9 ending in `PredefinedType`, `IfcRelVoidsElement` and `IfcRelFillsElement` at 6. ## Two writer bugs the binding exposed Neither was reachable before, because no real-file door had ever carried a host. 1. **The host lookup sat in a dead branch.** `ifc::export_content` consulted `recover_door_host` / `recover_window_host` only in the `else` arm of the element-record geometry check, so every door with a record bounding box — which is every door recovered since #211 — skipped it. 2. **Void/fill resolution depended on emission order.** `ifc::step_writer` resolved `host_element_index` against `entity_index_to_el_id` *inside* the element loop, so a host emitted after its own opening silently dropped the whole chain. Both relationships are now emitted after the loop. ## OctetProof: a second field class Entity counts are a weak agreement — two witnesses can report the same 138 fill relationships while disagreeing about every wall those openings belong to. `relations` (spec **1.1.0**, §7.2 / §9.4 / §20.1) is the sorted multiset of `[host Tag, filling Tag]` pairs, compared as an **exact set with no tolerance concept**; a diff names the pairs each side holds alone (`only_in_a` / `only_in_b`, `tolerance_applied: false`). An identity a witness cannot read is the empty string, never an omitted pair. All three witnesses emit it with their own parser and no shared code: | witness | reader | |---|---| | `rvt-rs` (source) | splits its own emitted STEP; `IfcElement.Tag` is attribute 7 | | `ifcopenshell` (bridge) | `by_type(include_subtypes=False)` + attribute access | | `ifc-lite` (bridge) | `EntityScanner` + `parse_entity` + `decode_ifc_string` | The three `relations` payloads are **byte-identical** on the full-project artifact. `entity_counts` semantics are untouched; `relations` is its own top-level payload key with its own verdict field class. ### Verdicts ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 4 fields, excluded: 10, diffs: 0 magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 11 fields, excluded: 4, diffs: 0 ``` The slim claimed surface goes **10 → 11 fields**: ``` entity_counts.IFCWALL, entity_counts.IFCSLAB, entity_counts.IFCROOF, entity_counts.IFCDOOR, entity_counts.IFCWINDOW, entity_counts.IFCCOLUMN, entity_counts.IFCBEAM, entity_counts.IFCFLOWTERMINAL, entity_counts.IFCUNITASSIGNMENT, entity_counts.IFCSHADINGDEVICE, relations.IFCRELFILLSELEMENT ``` On `magnetar-2024-core-interior` the same relation is `decoder_baseline` and excluded first-class with `tracking_issue: 222` — its paired export is a 20 KB element fixture carrying **no** `IfcRelFillsElement` at all, so the two sides of that edge are not comparable on this field. Recorded rather than rounded off. ## Spec and schema changes - `docs/octetproof-spec.md` → **1.1.0**. §7.2 gains a *relation pair sets* row plus the normative paragraph; §9.4 gains the `relations` vocabulary term; §6.1 gains the manifest `relations` block reading; §6.2 gains the payload key; §16.3 notes all three emitters carry it; **§20** is the additive-release changelog, structured as subsections (§20.1 is this field class) so a further additive field class appends rather than renumbers. - `docs/schemas/witness-observation.schema.json`: `schema_version` becomes `enum ["1.0.0", "1.1.0"]` (1.0.0 observations stay valid, §16.2), `semantic_surface_covered` gains `relations`, and `observation.relations` is specified as an object of 2-element string-pair arrays. - `docs/schemas/witness-verdict.schema.json`: `semantic_surface` documents the `relations.<TYPE>` form and `diffs[]` gains `only_in_a` / `only_in_b`. - Both committed artifacts' observations and verdicts validate against the published schemas. ## Gates - `tests/iter_elements_typed.rs::core_interior_2024_door_window_host_wall_binding` — re-reads the reference export, follows its own void/fill chain, and requires exact pair-set equality. No embedded expectations to drift. - `relations.IFCRELFILLSELEMENT` inside the slim OctetProof surface. - `tests/project_count_fixtures.rs` — manifest `relations` shape plus source and decoder pair counts. - `cargo test --profile ci --test witness_verdict --test witness_registry --test project_count_fixtures --test support_matrix` green with `RVT_PROJECT_CORPUS_DIR` set; the seven #209 tier-2 targets green; `cargo +1.85.0 check --all-targets` clean (workspace MSRV); `cargo clippy --all-targets -- -D warnings` clean for the workspace and for the out-of-workspace ifc-lite witness; `tools/check-local.sh --ifcopenshell` passes. ## Support matrix New **verified** row `element-record-door-window-host-binding`, scoped to two `BuiltInCategory` ids, one release band and one recorded edge, on the gated exact match. `typed-door-window` stays **unsupported** and is narrowed to what RE-19 actually leaves open — the `ArcWallRectOpening` index still carries no Door/Window discriminator and no host claim — exactly as RE-21 handled the instance half. Evidence: `reports/element-framing/RE-23-door-window-host-binding.md` Closes #222 https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes real-file IFC topology (openings/voids) and bumps the verification protocol; risk is mitigated by exact pair-set gates and three-way witness replay, but regressions would affect export semantics and CI verdicts. > > **Overview** > Recovered Revit 2024 doors and windows now bind to host walls by reading the partition element record’s counted reference list at `+0x88` (host = slot before the record’s own ElementId), accepted only when that id is in the recovered wall instance set. IFC export emits Revit’s **IfcOpeningElement** / **IfcRelVoidsElement** / **IfcRelFillsElement** chain for all 138 openings, with opening `Tag` matching the fill element. > > Two export bugs are fixed: host recovery no longer sits behind the element-record geometry branch, and void/fill relationships are written after the element loop so host index resolution is complete. > > **OctetProof 1.1.0** adds cross-witness **`relations`** — exact multiset equality on `[host Tag, filling Tag]` pairs for `IFCRELFILLSELEMENT` — with schema/manifest/verdict updates, all three witnesses emitting it, and the slim artifact claimed surface growing to 11 fields. Docs, support matrix, RE-23 report, corpus gates, and committed witness JSON are refreshed; `door_window_host_wall_binding` is removed from unsupported features. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cb49924. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
…partition Level records (#218) (RE-24) (#230) ## The Levels are elements #213 derived storey elevations from the bounding-box distribution of the recovered column records: 11 of the export's 15, with no names, because a rank join of 12 name candidates onto 11 elevations mislabels — it puts `Level 6` at 91 ft where Revit puts `Level 7`. The four it missed (−40, −20, 15, 185.5 ft) carry no column record, so no distribution over column bases can ever contain them. The Levels are in the file as elements. A Revit `Level` has a `BuiltInCategory` (`OST_Levels`, −2000240), so it is framed like one. ### The record: an element prologue with no bounding box Scanning the eight partition streams for the 8-byte LE encoding of −2000240 finds **190** hits; `partition_element_records::decode_at` accepts **zero**. The prologue is not the problem — on `Partitions/46 +228578`: ```text +0x00 87 3c 01 00 00 00 00 00 ElementId 81031, declared in Global/ElemTable +0x08 8f 00 00 00 flags +0x0c 9f 05 00 00 0x0000059f, as on every element record +0x10 00 00 0 +0x12 90 7a e1 ff ff ff ff ff BuiltInCategory −2000240 = OST_Levels +0x1a ff × 24 sentinel padding +0x32 85 3c 01 00 00 00 00 00 container ElementId 81029 +0x3a ff × 8 sentinel +0x42 7f ef ff ff placement kind, PLACED +0x46 0a 00 00 00 unattributed +0x4a 76 09 unattributed +0x4c 00 00 00 00 0 (0xffffffff on a bbox-bearing record) +0x50 ff ff ff ff ab 05 record marker +0x56 03 00 record kind ``` The divergence is at `+0x4c`. A bbox-bearing record carries `ff ff ff ff` there, `46 01` at `+0x50`, `ff ff ff ff ab 05` at `+0x52` and 48 bbox bytes at `+0x58`. A Level record carries `00 00 00 00` at `+0x4c` and the same six marker bytes two bytes earlier, then a `u16`, then the next record — 151 bytes apart. A datum plane is not a solid, so it has no bounding box, so the reader that requires one at `+0x50` rejects it. `src/partition_level_records.rs` is that reader with the bbox requirement replaced by the six-byte marker; nothing else about the prologue changes. 75 records carry `OST_Levels`. Which of them is a *Level element* is the #211 instance test, unchanged: | selection | n | |---|---:| | `OST_Levels` records total | 75 | | container member (`+0x32` set) | 59 | | type / symbol envelope (`+0x42` = `0xffff8000`) | 1 (ElementId 1673) | | **standalone placed instance** | **15** | ### The name / elevation block Framed the way RE-22 framed the per-instance `IFC Export As` override — an owning `ElementId` at a fixed negative offset from the value: ```text V-0x47 u64 owning ElementId V-0x3f 56B 0xff sentinel run V-0x07 3B 0x00 V-0x04 u32 name length, UTF-16 code units V 2n the name, UTF-16LE … variable-length parameter run M 8B 05 00 00 00 48 02 00 00 M+55 f64 elevation, feet M+208 f64 the same elevation again ``` Two things were found the hard way: - **The gap between the name and the marker is not fixed** — 347 bytes for fourteen levels, **363** for `Basement 2`, whose block carries one extra entry. A fixed `name_end + 402` offset read `0.0` there, a plausible elevation that would have shipped a wrong storey. The marker is searched forward within 2048 bytes and the copy at `+153` must agree bit-for-bit. - **The owner slot is the discriminator, not the name.** `Level 3 - Wall Layouts 1` appears nine times in `Partitions/46`; at `+21322916` it is paired with **46.0 ft** and at `+21323710` `Level 4 - Wall Layouts 2` with **61.0**. Every wrong pair is owned by an `OST_Levels` record that is a container member (31636, 31637, 33628, 33629, 21990, …) — exactly what the #211 test already excludes. Filtering to the 15 standalone Level ids leaves 15 blocks in the whole file. The scan itself walks maximal `0xff` runs, requires the owner to be declared in `Global/ElemTable` and requires the two elevation copies to agree. A run of exactly 56 is required, which the owner's own encoding guarantees can only start where the framing says (an `ElementId` is a `u32`, so its high four bytes are zero). ## 15 / 15, names and elevations | ElementId | recovered name | recovered elevation (ft) | export `Name` | export `Elevation` | | |---:|---|---:|---|---:|:-:| | 20273 | `Basement 2` | −40 | `Basement 2` | −40. | ✓ | | 20272 | `Basement 1` | −20 | `Basement 1` | −20. | ✓ | | 20268 | `Level 1` | 0 | `Level 1` | 0. | ✓ | | 20275 | `Mez 1-2` | 15 | `Mez 1-2` | 15. | ✓ | | 20274 | `Level 3 - Wall Layouts 1` | 31 | `Level 3 - Wall Layouts 1` | 31. | ✓ | | 20276 | `Level 4 - Wall Layouts 2` | 46 | `Level 4 - Wall Layouts 2` | 46. | ✓ | | 20277 | `Level 4 - Wall Layouts 3` | 61 | `Level 4 - Wall Layouts 3` | 61. | ✓ | | 20308 | `Level 6` | 76 | `Level 6` | 76. | ✓ | | 20307 | `Level 7` | 91 | `Level 7` | 91. | ✓ | | 20306 | `Level 8` | 106 | `Level 8` | 106. | ✓ | | 20305 | `Level 9` | 121 | `Level 9` | 121. | ✓ | | 20304 | `Level 10` | 136 | `Level 10` | 136. | ✓ | | 20303 | `Level 11` | 151 | `Level 11` | 151. | ✓ | | 20302 | `Level 12` | 166 | `Level 12` | 166. | ✓ | | 65128 | `Level 13` | 185.5 | `Level 13` | 185.5 | ✓ | No wrong pair, no missing storey, no extra storey — on **both** reference exports, which carry the same 15 `IfcBuildingStorey`. Note the ElementId order and the elevation order do not agree (65128 is the top level, 20302…20308 run *downwards*), so a rank join on ids would have been as wrong as the rank join on names #213 rejected. The pairing survives because the file states it. Recovery is all-or-nothing per file: a Level with no accepted block emits nothing, and the whole set is discarded unless every Level record owns exactly one block and no two levels share an elevation. `element_record_storeys` survives as the fallback. ## Binding, before and after Containment logic is untouched — exact elevation match, plates by their record top face, fail-closed on a miss and on an ambiguity. Only the storey set is wider. | | 11 storeys (#213) | 15 storeys (RE-24) | |---|---:|---:| | `IFCCOLUMN` | 256 / 256 | 256 / 256 | | `IFCDOOR` | 132 / 132 | 132 / 132 | | `IFCWALL` | 355 / 360 | **359 / 360** | | `IFCSLAB` | 41 / 80 | **44 / 80** | | `IFCSHADINGDEVICE` | 10 / 20 | 10 / 20 | | `IFCWINDOW` | 0 / 6 | 0 / 6 | | `IFCSPACE` | 0 / 18 | 0 / 18 | | **total bound** | **794 / 872** | **801 / 872** | Two #219 expectations did **not** hold, and the numbers say so rather than the prose: - **The 6 windows still bind to nothing.** Never an elevation-set problem: a window record's base is its *sill height* (80.73, 95.73, … ft), which RE-21 already measured at 0 of 6. Binding a window needs its host level, not more elevations. - **46 of the 49 unbound plates stay unbound** (36 `IFCSLAB` + all 10 unbound `IFCSHADINGDEVICE`); three bind. RE-22 measured why: they sit 0.1667 ft below their level, at the structural-slab / architectural-topping interface. That is #219's real content — a thickness question. ## Cross-witness surface `levels` moves from `decoder_baseline` to `known` at tolerance 0 on both manifests (`diagnostics.exported.storey_count` = 15, both references carry 15 `IfcBuildingStorey`). A count is a weak claim, so the pair set is gated too, as OctetProof 1.1.0's second additive field class (`storeys`, spec §20.2 — a separate top-level payload key and a separate verdict field class from #222's `relations`). One complication is real: **the two sides declare different length units.** Revit's export of this imperial project declares `FOOT` as an `IfcConversionBasedUnit` over `METRE` and writes `-40.`; rvt-rs declares `METRE` and writes `-12.192000`. Both are faithful; the raw numbers differ by 3.28. So each witness resolves its *own* file's `LENGTHUNIT` before emitting and renders feet at 1e-6 as a fixed six-decimal string (a string, not a number, so §7.3's canonical form stays integer/string only): | witness | reads | unit resolution | |---|---|---| | `rvt-rs` | its own emitted STEP | walks `IfcProject` → `IfcUnitAssignment` itself | | IfcOpenShell 0.8.5 | Revit's `.ifc` | `ifcopenshell.util.unit.calculate_unit_scale` | | IFClite 7.1.1 | Revit's `.ifc` | `ifc_lite_core::extract_length_unit_scale` | All three payloads are byte-identical on both artifacts. ### Verdicts ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 6 fields, excluded: 10, diffs: 0 magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 13 fields, excluded: 3, diffs: 0 ``` Claimed surface, slim (11 → 13): `entity_counts.IFCBUILDINGSTOREY`, `…IFCWALL`, `…IFCSLAB`, `…IFCROOF`, `…IFCDOOR`, `…IFCWINDOW`, `…IFCCOLUMN`, `…IFCBEAM`, `…IFCFLOWTERMINAL`, `…IFCUNITASSIGNMENT`, `…IFCSHADINGDEVICE`, `relations.IFCRELFILLSELEMENT`, **`storeys.IFCBUILDINGSTOREY`**. Element fixture (4 → 6): `entity_counts.IFCBUILDINGSTOREY`, `…IFCROOF`, `…IFCBEAM`, `…IFCFLOWTERMINAL`, `…IFCUNITASSIGNMENT`, **`storeys.IFCBUILDINGSTOREY`**. Unusually for this corpus the thin 20 KB fixture supports the field as strongly as the 19879-entity export: Revit writes the complete fifteen-storey hierarchy into an export carrying one building element. Storey payload, identical across all three witnesses: ```json "storeys": { "IFCBUILDINGSTOREY": [ ["Basement 1", "-20.000000"], ["Basement 2", "-40.000000"], ["Level 1", "0.000000"], ["Level 10", "136.000000"], ["Level 11", "151.000000"], ["Level 12", "166.000000"], ["Level 13", "185.500000"], ["Level 3 - Wall Layouts 1", "31.000000"], ["Level 4 - Wall Layouts 2", "46.000000"], ["Level 4 - Wall Layouts 3", "61.000000"], ["Level 6", "76.000000"], ["Level 7", "91.000000"], ["Level 8", "106.000000"], ["Level 9", "121.000000"], ["Mez 1-2", "15.000000"] ] } ``` ## Spec / schema changes (1.1.0 additive, §20.2) - **§7.2** — new field class *storey sets*: exact equality of the sorted set of (name, elevation rounded to 1e-6 ft), no tolerance concept. Documents the unit normalization, why the elevation is a string, and why Unicode normalization is deliberately **not** applied to the name (three runtimes, three Unicode tables — a normalizer that disagrees between them would launder a real difference into agreement; the strict direction is correct for a gate). - **§9.4** — `storeys` joins the coverage vocabulary next to `relations`. - **§6.1** — manifests gain a `storeys` block parallel to `counts` and `relations`. - **§6.2** — the observation payload gains an optional `storeys` object under its own top-level key. - **§20.2** — the release note for the field class. - `docs/schemas/witness-observation.schema.json` — `storeys` in the surface enum and in the payload; `docs/schemas/witness-verdict.schema.json` — `only_in_a` / `only_in_b` re-described as covering both set-valued field classes. Merged `origin/main` (#226) first and kept both fields in every emitter: `relations` and `storeys` are separate top-level payload keys and separate verdict field classes. ## Gates - `cargo fmt --all`, `cargo clippy --all-targets -- -D warnings`, `cargo clippy` on the out-of-workspace `witness-ifc-lite` — all clean. - `cargo +1.85.0 check --all-targets` — clean (MSRV). - `cargo test --profile ci --test witness_verdict --test witness_registry --test project_count_fixtures --test support_matrix` with `RVT_PROJECT_CORPUS_DIR` — 2 / 3 / 4 / 2 passed. - Tier-two decoder gates (#209): `elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration` — all green. - `tools/ci/ifc_schema_arity.py` on a fresh export — passed, 18209 instances across 40 entity types; `IfcBuildingStorey` at its declared arity of **10** with `Elevation` as `IfcLengthMeasure` (REAL). - `tools/check-local.sh --ifcopenshell` — passed. - All six observations and both verdicts regenerated; both verdicts `PASS`. Closes #218 Refs #219 https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core IFC spatial hierarchy and cross-witness CI gates on golden artifacts; logic is fail-closed and heavily tested, but binary layout decoding is Revit 2024–specific and affects many emitted entities. > > **Overview** > **Revit 2024 IFC export now uses real Level names and elevations** from partition `OST_Levels` records instead of the eleven column-bbox-derived storeys with placeholder labels (#213). New `partition_level_records` decodes Level prologues (no bbox), joins name/elevation parameter blocks by ElementId, and **fails closed** unless all 15 standalone levels recover uniquely; `apply_partition_level_storeys` replaces the storey list in the IFC path, with column-derived storeys kept as fallback. > > **OctetProof 1.1.0 gains `storeys`**: witnesses compare exact sorted `[name, elevation-in-feet]` sets with per-file `LENGTHUNIT` normalization (FOOT vs METRE). `rvt-ifc --observation`, IfcOpenShell, IFClite, `witness-verdict.py`, schemas, manifests, and golden observations/verdicts are updated; **`levels` / `IFCBUILDINGSTOREY` move to `known` at 15** on both magnetar artifacts (verdicts stay `PASS`). Wider storey set improves elevation containment binding (**801 / 872** elements vs 794). > > Docs (`CHANGELOG`, `status.md`, support matrix, RE-24 report) and CI fixture validation for manifest `storeys` blocks accompany the decoder change. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cf608bb. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
…s from OST_SketchLines records (#31) (RE-25) (#231) RE-22 (#225) recovered all 80 exported `IFCSLAB` by ElementId and closed the thickness half of #31, leaving one sentence open: *"The profile is still the bbox rectangle, not the recovered floor boundary polygon: `ProfileResolved` stays false."* This closes it, exactly, for all 80. Report: `reports/element-framing/RE-25-slab-plan-profiles.md`. ## Where the profile is not The plan-loop scanner is a measured dead end. Inventoried over all eight inflated `Partitions/*` streams with the shipped constants (4–8 points, span ≥ 5 ft, closure ≤ 0.05 ft): **2317** closed plan-polyline candidates — 2310 of 4 points, 4 of 5, 3 of 6 — and **zero** with the plan bounds of any of the 100 record-backed plates. The perimeter profile needs 26 vertices. Searching all 187 MiB of inflated partitions for the export's polygon as a packed run of `(x, y)` doubles — in the project frame, in the export's own profile frame, at strides of 2/3/4/5/6/8 doubles — finds no ordered vertex run at all. Revit does not store this boundary as a polyline. ## The join rule, and its evidence **Each boundary line of a Revit sketch is its own partition element record.** `BuiltInCategory` `OST_SketchLines` = **-2000045** (Autodesk's published constant; the bytes are `53 7b e1 ff ff ff ff ff` in the same signed `i64` slot at `+0x12` that RE-21 documented). These decode through the *unmodified* RE-21 header — declared ElementId at `+0x00`, `0x059f` at `+0x0c`, the fixed bbox marker at `+0x50`, the box at `+0x58` — and the box **is** the segment: the boundary line at `x = 136.5, y = 115 … 123` is recorded as `136.5, 115 – 136.5, 123`, degenerate in `x`. RE-23 read the *first* counted list at `+0x88`. A **second** list is framed identically right after it, and its last slot names the sketched element: ```text +0x88 u32 n1 = 5 +0x8c 5×u64 20309, 20310, 20312, 20313, 20315 (sibling sketch lines) +0xb4 u32 n2 = 2 +0xb8 2×u64 20308, 20311 ← 20311 is the slab ``` Measured over all 3688 `OST_SketchLines` records on `2024_Core_Interior.rvt` (`Partitions/46` 3070, `/51` 570, `/55` 48; 3070 distinct ids; **0** frames of one id disagreeing on box or owner): | owners named by the second list's last slot | count | |---|---:| | exported `IFCSLAB` ElementIds | **80 / 80** | | exported `IFCSHADINGDEVICE` ElementIds | **20 / 20** | | other elements (walls, the superseded container twin 16925, …) | 26 | | **distinct owners** | **126** | **The join is by ElementId only — no geometry, no proximity, no containment.** A sketch line belongs to the element the byte names, or to nothing. Geometric containment was used once, as a check, and is not the rule: the recovered profile's plan bounds are asserted equal to the record's own plan box in the corpus gate. ## Reconstruction: closure, not fitting A box is not a segment when the segment is diagonal, and 37 of the 1454 plate segments carry a box *looser* than the line (the top boundary of every rectangular plate is recorded `20,113 – 167,115` for a line the export puts at `y = 114`). Both are resolved by the loop, never by the reference export: 1. Every segment degenerate on exactly one axis contributes its endpoints. 2. Every remaining segment is placed only when exactly **one** pair of still-open vertices fits its box — corner pairs (the box's own diagonals) first, and only when no corner pair is open, a pair that spans the box lengthwise and is degenerate across it. 3. An ambiguous segment, a vertex that does not finish at degree 2, an unused edge, a zero-extent box or a loop under three vertices rejects the **whole element**. There is no partial or best-effort profile. Collinear vertices are then merged — Revit splits the ring's north-east run at `x = 167`, so the raw chain has 27 outer segments where the export has 26 edges. ## Profile agreement Recovered profile vs the reference export's `IfcExtrudedAreaSolid` swept areas (`IFC Exports/2024_Core_Interior_slim.ifc`, sha256 `bfdf36ff…`, read with IfcOpenShell 0.8.5), both reduced to the project plan frame, compared as cyclic vertex sequences with orientation normalised, tolerance 1e-3 ft per vertex: | slabs | recovered | export swept area | outer verts | voids | segments | exact | near | miss | |---:|---|---|---:|---:|---:|---:|---:|---:| | 42 | outer ring + 1 void | `IfcArbitraryProfileDefWithVoids` | 26 | 1 (4 verts) | 31 | **42** | 0 | 0 | | 38 | single loop | `IfcArbitraryClosedProfileDef` | 4 | 0 | 4 | **38** | 0 | 0 | | **80** | | | | | | **80** | **0** | **0** | 122 loops compared (80 outer + 42 inner). **Worst vertex deviation 1.563e-12 ft** — the recovered vertices are the same doubles as the export's, differing only in the floating dust of Revit's own transform (`177.00000000000011` for a nominal 177 ft, which the record box and the export's profile carry identically). Re-measured on the emitted IFC after the metre round-trip: 0 mismatches, worst deviation **2.842e-14 ft**. No frame alignment was needed — the 2024 project frame and the export frame coincide. Before this, all 80 were rectangles: accidentally exact on the 38 whose profile *is* the box, and filling a courtyard on the 42 perimeter rings. **The 20 exported `IFCSHADINGDEVICE` are declined, with the reason.** The same join names all 20; each carries 57 sketch lines — 1 with a zero-extent box, 35 axis-parallel, 21 diagonal. The first zero-extent box rejects them outright, and the export writes each as a 29-vertex rotated ring (`0 … 182.3333` by `8.6936 … 130.3064`) with no axis-parallel anchor to force a first choice. They keep the record box rectangle and `ProfileResolved: false`. Five further owners are declined the same way (16925 — the container-member twin of 20953 already excluded by RE-21 — plus 31636, 31637, 34362, 55840). Twenty-one non-plate owners do close and are recovered but not emitted; nothing here maps them to an IFC entity. ## Verdict outputs — unchanged ```text magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 6 fields, excluded: 10, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 13 fields, excluded: 3, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match ``` Both committed `verdict.json` files are **byte-identical**. The two committed `rvt-rs` observations were regenerated because the observation payload counts *every* emitted entity type; the four bridge-witness observations are byte-identical. Building-element counts and the diagnostics sidecar are unchanged, and the sidecar is byte-identical to `main` (a0044f4): | entity | before | after | |---|---:|---:| | `IFCRECTANGLEPROFILEDEF` | 992 | 912 | | `IFCARBITRARYCLOSEDPROFILEDEF` | 0 | 38 | | `IFCARBITRARYPROFILEDEFWITHVOIDS` | 0 | 42 | | `IFCPOLYLINE` | 0 | 122 | | `IFCCARTESIANPOINT` | 1847 | 3381 | | `IFCPROPERTYSINGLEVALUE` | 5371 | 5611 | | total instances | 18209 | 20105 | | `IFCSLAB` / `IFCSHADINGDEVICE` / `IFCWALL` / `IFCDOOR` / `IFCWINDOW` / `IFCCOLUMN` | 80 / 20 / 360 / 132 / 6 / 256 | unchanged | | `IFCBUILDINGSTOREY` | 15 | 15 | | `storey_bound_elements` | 801 | 801 | ## Gates run `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets --all-features -- -D warnings`, `RUSTDOCFLAGS=-D warnings cargo doc --no-deps --lib`, `cargo +1.85.0 check --all-targets` (MSRV, no let-chains), `cargo test --workspace --all-targets --all-features` with `RVT_PROJECT_CORPUS_DIR` + `RVT_CORPUS_TIER1_DIR` (152 test binaries ok), the four named targets (`witness_verdict`, `witness_registry`, `project_count_fixtures`, `support_matrix`), the seven #209 tier-2 targets, `tools/ci/ifc_schema_arity.py` on a fresh export (20 105 instances across 43 entity types; `IfcArbitraryClosedProfileDef` at its declared arity of 3, `IfcArbitraryProfileDefWithVoids` at 4, `IfcPolyline` at 1), and `tools/check-local.sh --ifcopenshell`. New gates: `tests/iter_elements_typed.rs::core_interior_2024_slab_plan_profiles` (the 100 record-backed plates partition exactly — 80 resolve a profile, and the 20 that do not are exactly the export's `IFCSHADINGDEVICE` `Tag` set; 42 × (26 outer, 1 void), 38 × (4 outer, 0 voids); each profile's plan bounds equal the record's own plan box) and 15 unit gates in `src/element_record_plan_profiles.rs`. ## Support-matrix status New row `element-record-slab-plan-profile` at **`partial`**, not `verified`: the agreement is measured and regression-gated, but profile geometry is not a field of either OctetProof claimed surface — no witness compares it — so it has not met the two-independent-witnesses bar in `docs/verification-protocol.md`. ## Follow-ups - **The 20 shading devices.** Sketch present and joined; only the closure declines. Resolving 21 mutually constraining diagonal boxes needs either a second carrier for the segment endpoints or a global search with a uniqueness proof. - **`IfcExtrudedAreaSolid.Position` is the element's own `IfcAxis2Placement3D`**, which is also the `IfcLocalPlacement`'s relative placement, so a consumer composing both applies the element translation twice. This predates RE-25 and affects every emitted element on every release; the profile is expressed in the same element-local frame the rectangle profile always used, so nothing regressed. Needs its own issue. - **Walls, doors, windows, columns** still carry the record box. Wall sketches are not `OST_SketchLines`; the 26 non-plate owners here are a hint of what else is sketched, not a claim. - **#227** is untouched. Note that the perimeter ring's void is *profile* geometry, not an opening element, so the 42 slab penetrations #227 asks for are a different set. Refs #31 #227 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches partition decoding, geometry reconstruction, and IFC STEP emission for all record-backed slabs; scope is gated to Revit 2024 and fail-closed closure, but wrong profile logic would change exported solid geometry without shifting entity counts. > > **Overview** > **Slab IFC geometry now uses recovered sketch boundaries instead of bounding-box rectangles** for Revit 2024 partition-backed floors where sketch lines close unambiguously (#31 / RE-25). > > The change reads **`OST_SketchLines`** element records, joins each segment to its owner slab via the **last slot of the second reference list** at `+0x88` (`owner_reference`), and **chains segment bounding boxes into closed loops** (fail-closed on ambiguity). Those polygons flow through **`partition_schema_mvp::slabs_from_partition_category_records`** (single multi-category partition scan) into decoded fields, then **`ifc::export_content`** emits **`IfcArbitraryClosedProfileDef`** or **`IfcArbitraryProfileDefWithVoids`** with **`ProfileResolved: true`** and related diagnostics. **`scan_category_records_multi`** avoids re-inflating partitions when floors, pads, and sketch lines are needed together. > > On the Core Interior corpus this matches **80/80** reference slab profiles (including courtyard voids); **20 shading devices** still use the record box because closure rejects their diagonal sketch envelopes. Docs, support matrix, changelog, corpus tests (`core_interior_2024_slab_plan_profiles`), a research probe, and witness **entity-count** observations reflect the richer IFC profile chain while **building-element counts and OctetProof verdicts stay unchanged**. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 07e0a8a. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 30, 2026
…on PredefinedType (#236) Two conformance fixes to the IFC4 writer, both measured against Revit's own export of the same project. Corpus: `.rvt` sha256 `c805df445d613b408e37337765572021265e3f5dfdc7d1fa53b22ba1600b8014`, slim IFC sha256 `bfdf36ffb0bb768f3409d818403990e64d4c262c6780603be87f8077387ad86d`. ## #232 — every element was placed twice The writer emitted the element's own `IfcAxis2Placement3D` in **both** the `IfcLocalPlacement`'s `RelativePlacement` and the swept solid's `Position`. IFC4 has a conforming consumer compose `ObjectPlacement × Position`, so the element translation was applied twice. Viewers that ignore `Position` drew the file correctly, which is exactly why it shipped on every release: two tools could disagree about the same bytes with neither of them misreading. ### The Position decision, and the export's evidence Read with IfcOpenShell 0.8.5 on `2024_Core_Interior_slim.ifc`, Revit's own exporter is consistent about one thing — **the element translation appears exactly once** — and splits it two different ways depending on the frame the profile is authored in: | Revit entity | `ObjectPlacement.RelativePlacement.Location` | `IfcExtrudedAreaSolid.Position.Location` | |---|---|---| | `IfcWall` #2240 (`SweptSolid` body) | `(48.0, 57.667, 0.0)` | `(0.0, 0.0, 0.0)` — identity | | `IfcSlab` #1590 | `(0.0, 0.0, 0.0)` — identity | `(90.444, 71.185, -0.167)` | | `IfcSlab` #1619 | `(0.0, 0.0, 0.0)` — identity | `(93.5, 69.5, 0.0)` | | `IfcSpace` #186 | `(0.0, 0.0, 0.0)` — identity | `(51.694, 69.556, 0.0)` | Never both. Revit's walls put the location in the placement and leave `Position` at identity because the wall profile is authored in the element-local frame; its slabs and spaces do the mirror image because those profiles are authored in storey coordinates. rvt-rs authors **every** profile in the element-local frame — the rectangle always did, and the plan profile recovered in #231 uses the same frame — and it already carries the location on the element's own `IfcLocalPlacement`. So the correct half of Revit's own convention is the `IfcWall` row: **`Position` becomes the project-level identity placement**, and the placement carries the translation once. That is what this PR does. No entity is added or removed — the per-element axis is still emitted, the solid just stops pointing at it. The representation-map path is deliberately left alone, with a comment saying why: a mapped item resolves as `MappingTarget × MappingOrigin⁻¹ × geometry`, so a `Position` equal to the `MappingOrigin` cancels against the inverse instead of compounding, and `origin_feet` is `[0,0,0]` on every map rvt-rs builds today anyway. ### World-coordinate verification IfcOpenShell geometry iterator, `use-world-coords`, matched by `Tag` against the Revit export, deltas in feet. **BEFORE** | Class | shared Tags | max centroid delta | max min-vertex delta | Tags within 1e-3 ft | |---|---:|---:|---:|---:| | IfcColumn | 256 | 166.0000 ft | 166.0000 ft | 0/256 | | IfcSlab | 80 | 185.3333 ft | 185.3333 ft | 0/80 | | IfcWall | 360 | 170.2500 ft | 166.2500 ft | 0/360 | | IfcDoor | 132 | 166.0748 ft | 166.0000 ft | 0/132 | | IfcWindow | 6 | 157.1805 ft | 155.7300 ft | 0/6 | | Class | Tag | rvt-rs world centroid (ft) | Revit world centroid (ft) | delta (ft) | |---|---|---|---|---| | IfcColumn | 20375 | (48.0000, 220.0000, 159.1667) | (23.8750, 110.0000, 81.5833) | (24.1250, 110.0000, 77.5833) | | IfcColumn | 20376 | (98.0000, 220.0000, 159.1667) | (49.1250, 110.0000, 81.5833) | (48.8750, 110.0000, 77.5833) | | IfcSlab | 20311 | (181.3000, 139.0000, 151.7500) | (88.3000, 69.5000, 75.9167) | (93.0000, 69.5000, 75.8333) | | IfcSlab | 20345 | (187.0000, 139.0000, 151.7500) | (93.5000, 69.5000, 75.9167) | (93.5000, 69.5000, 75.8333) | | IfcWall | 20796 | (122.7500, 162.0000, 159.5000) | (60.1042, 81.0000, 81.7500) | (62.6458, 81.0000, 77.7500) | | IfcWall | 20797 | (96.0000, 138.7500, 159.5000) | (48.0000, 69.1667, 83.5000) | (48.0000, 69.5833, 76.0000) | | IfcDoor | 20810 | (194.0874, 118.9189, 156.1247) | (97.0437, 58.0499, 80.0499) | (97.0437, 60.8689, 76.0748) | | IfcWindow | 20898 | (65.4902, 172.2757, 165.9056) | (30.8441, 86.1378, 83.7251) | (34.6460, 86.1378, 82.1805) | The doubling reads straight off the table: the rvt-rs value is 2× Revit's wherever the element's own frame is the whole story — slab 20345 at `(187.0, 139.0)` against `(93.5, 69.5)`, column 20375 at `220.0` against `110.0`. **AFTER** | Class | shared Tags | max centroid delta | max min-vertex delta | Tags within 1e-3 ft | |---|---:|---:|---:|---:| | IfcColumn | 256 | 1.5833 ft | 0.3333 ft | 107/256 | | IfcSlab | 80 | 0.2083 ft | **0.0000 ft** | 79/80 | | IfcWall | 360 | 2.5336 ft | 0.7500 ft | 78/360 | | IfcDoor | 132 | 1.5095 ft | 3.0022 ft | 0/132 | | IfcWindow | 6 | 1.9010 ft | 0.8012 ft | 0/6 | | Class | Tag | rvt-rs world centroid (ft) | Revit world centroid (ft) | delta (ft) | |---|---|---|---|---| | IfcColumn | 20375 | (24.0000, 110.0000, 83.1667) | (23.8750, 110.0000, 81.5833) | (0.1250, -0.0000, 1.5833) | | IfcColumn | 20376 | (49.0000, 110.0000, 83.1667) | (49.1250, 110.0000, 81.5833) | (-0.1250, 0.0000, 1.5833) | | IfcSlab | 20311 | (88.3000, 69.5000, 75.9167) | (88.3000, 69.5000, 75.9167) | (-0.0000, 0.0000, 0.0000) | | IfcSlab | 20345 | (93.5000, 69.5000, 75.9167) | (93.5000, 69.5000, 75.9167) | (-0.0000, 0.0000, 0.0000) | | IfcWall | 20796 | (60.1875, 81.0000, 81.8123) | (60.1042, 81.0000, 81.7500) | (0.0833, 0.0000, 0.0623) | | IfcWall | 20797 | (48.0000, 69.3750, 83.5000) | (48.0000, 69.1667, 83.5000) | (0.0000, 0.2083, 0.0000) | | IfcDoor | 20810 | (97.0437, 59.4594, 80.1247) | (97.0437, 58.0499, 80.0499) | (-0.0000, 1.4095, 0.0748) | | IfcWindow | 20898 | (32.7451, 86.1378, 85.1756) | (30.8441, 86.1378, 83.7251) | (1.9010, -0.0000, 1.4505) | **All 80 slabs now agree with Revit's export on every world-space vertex to 0.0000 ft.** That is the class where rvt-rs recovers a real plan profile (#231), so it is the class where a placement fix can be checked at full precision, and it is exact. The residuals that remain elsewhere are **geometry recovery fidelity, not placement composition**, and each is an existing tracked gap: columns sit 0.125 ft off in plan and 1.58 ft off in Z (insertion point and base elevation), walls up to 2.53 ft on location-curve-derived bodies, and doors and windows carry the record's bounding-box envelope rather than a panel (#86, #82). None of them scales with the element's distance from the origin any more, which is the signature the doubling had. ### The gate `tools/ci/ifc_schema_arity.py` closes the class two ways, both fail-closed: 1. **Structural invariant, every file, every product** — a swept solid's `Position` may not be the very `IfcAxis2Placement3D` instance its product's `IfcLocalPlacement` already uses as `RelativePlacement`. Run against the pre-fix export it produces 992 findings, first one: `#216 IfcColumn reuses #207 as both its ObjectPlacement's RelativePlacement and its IfcExtrudedAreaSolid.Position`. 2. **Pinned composition** — for five elements the gate computes `ObjectPlacement × Position × first-profile-point` explicitly (`ifcopenshell.util.placement`, no geometry kernel) and compares against a pinned coordinate at 1e-6. Two are in `synthetic-project.ifc`, one in `synthetic-structural.ifc` and two are the recorded artifact's column `20375` and slab `20345`, so the probe fires in the fixture-only CI step *and* on the real export. A file that does not hold the Tag skips the probe rather than failing. ## #220 — PredefinedType follows the authoring witness The issue's suggested rule is adopted: where a recorded edge shows the witness's choice, take it. Agreement with the export is what the OctetProof verdicts score, and a value the witness demonstrably wrote is a recorded observation, not an invention. ### Per-type agreement, measured with IfcOpenShell | Entity | Revit's export writes | rvt-rs before | rvt-rs after | rvt-rs count | agreement | |---|---|---|---|---:|---| | IfcWall | `.NOTDEFINED.` ×360 | `.STANDARD.` | `.NOTDEFINED.` | 360 | 360/360 exact | | IfcSpace | `.SPACE.` ×116 | `.INTERNAL.` | `.SPACE.` | 18 | 18/18 exact (recall gap tracked separately) | | IfcDoor | `.DOOR.` ×132 | `$` | `.DOOR.` | 132 | 132/132 exact | | IfcWindow | `.WINDOW.` ×6 | `$` | `.WINDOW.` | 6 | 6/6 exact | | IfcColumn | `.COLUMN.` ×256 | `.COLUMN.` | `.COLUMN.` | 256 | 256/256 exact (unchanged) | | IfcSlab | `.FLOOR.` ×78, `.ROOF.` ×2 | `.FLOOR.` | `.FLOOR.` | 80 | inside the witness's value set (unchanged) | | IfcShadingDevice | `.NOTDEFINED.` ×20 | `$` | `$` | 20 | **not changed — see #235** | `Area`, `Space` and `GenericModel` keep `$`: no recorded edge shows what the witness does with those Revit classes, and inventing a value is the thing this table exists to avoid. `IfcSlab` keeps `.FLOOR.` for all 80 because splitting floors from roofs is a per-element decode, not a mapping default; the gate accepts `{FLOOR, ROOF}` for that type. `IfcShadingDevice` is the one row the witness rule reaches that this PR does not change — `category_map.rs` carries an explicit prior decision for it ("`$`, not an invented `.NOTDEFINED.`"), and flipping a written-down decision deserves its own verdict rather than riding along here. Filed as **#235**. ### No new observation surface class `PredefinedType` is an attribute value; the observation payload counts entity **type names** plus relations and storeys. Both changes are therefore invisible to the observation hash, which was confirmed rather than assumed — see below. So instead of widening the surface, the agreement check went into the arity gate as `--witness-agreement`, run on the recorded artifact in CI: ``` PredefinedType agrees with the witness: IfcColumn.COLUMN=256, IfcDoor.DOOR=132, IfcSlab.FLOOR=80, IfcSpace.SPACE=18, IfcWall.NOTDEFINED=360, IfcWindow.WINDOW=6 ``` `IfcDoor` and `IfcWindow` also joined `PREDEFINED_TYPE_REQUIRED`, since every `category_map` row for them now supplies a value. ## Observations did not move Regenerated all three witnesses on both recorded edges and diffed against the committed files: | Edge | rvt-rs | ifcopenshell | ifc-lite | verdict | |---|---|---|---|---| | `magnetar-2024-core-interior` | byte-identical | byte-identical | byte-identical | PASS, 6 fields, 0 diffs, replay match ×3 | | `magnetar-2024-core-interior-slim` | byte-identical | byte-identical | byte-identical | PASS, 13 fields, 0 diffs, replay match ×3 | **Nothing under `research/witness/` was regenerated, because nothing moved.** Entity counts, relations and storeys are unchanged. ## Fixtures Both committed fixture IFCs are regenerated with their test pins, since the writer change alters them: - `synthetic-project.ifc` — 7 `IFCEXTRUDEDAREASOLID` rows repoint from the element axis to `#14` (the project identity placement), 4 `IFCWALL` move to `.NOTDEFINED.`, the door and two windows gain `.DOOR.` / `.WINDOW.`. - `synthetic-structural.ifc` — 4 `IFCEXTRUDEDAREASOLID` rows repoint to `#14`. Its `predefined_type` values are hardcoded in the test model, not looked up, so they are untouched. `synthetic-project.ifc` also picks up a change it should have carried since #222: it was last dumped at `f4b88df` (#217), before `08f7858` gave `IfcOpeningElement` the `Tag` of the element that fills it, so its one opening still wrote `$` there. Fixtures only regenerate behind `DUMP_IFC=1`, which is how it drifted a commit behind the writer with no test noticing. Two Rust tests moved with the mappings: `lookup_known_class` now expects `.NOTDEFINED.`, and `door_and_window_have_no_predefined_type_by_default` — which asserted the old decision — is rewritten as `door_and_window_follow_the_witness_predefined_type`, with a comment recording why the old reading (type variance belongs on `IfcDoorType`) is defensible and still wrong here: Revit populates both. A new `witness_following_predefined_types` covers all five changed rows. ## Verification run | Gate | Result | |---|---| | `cargo fmt --all` | clean | | `cargo clippy --all-targets -- -D warnings` | clean | | `cargo +1.85.0 check --all-targets` | clean | | `cargo test --profile ci` × 6 named targets, corpus set | 16 passed, 0 failed | | Tier-two decoder gates (#209), 7 targets, corpus set | 40 passed, 0 failed | | `cargo test --profile ci --workspace --all-targets`, corpus set | 152 result blocks, 0 failed | | `tools/ci/ifc_schema_arity.py --witness-agreement` on a fresh export | pass — 20105 instances, 992 solids, 2 pinned probes matched | | Same gate on the pre-fix export | fails, 992 composition findings | | `tools/ci/validate-real-ifc.py` (Einhoven) | pass | | `tools/check-local.sh --ifcopenshell` | all requested gates passed | | OctetProof verdicts, both edges, `--compare-committed` | PASS, replay match on all six observations | ## Follow-ups - **#235** (filed) — `IFCSHADINGDEVICE` emits `$` where Revit writes `.NOTDEFINED.` on all 20; the #220 rule reaches it but a documented prior decision guards it. - Column Z is 1.58 ft off and plan position 0.125 ft off against the export; wall bodies up to 2.53 ft. Both are geometry recovery, now measurable for the first time because the placement no longer swamps them. - Revit splits 80 slabs into 78 `.FLOOR.` + 2 `.ROOF.`; rvt-rs writes `.FLOOR.` for all 80. Closes #232 Closes #220 https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core IFC geometry placement and attribute emission for all extruded products; mitigated by new fail-closed CI gates and unchanged OctetProof observation hashes per the PR description. > > **Overview** > Fixes two IFC4 writer conformance issues measured against Revit's export of the 2024 Core Interior project. > > **Placement (#232).** Swept solids no longer reuse the element's `IfcAxis2Placement3D` as both `IfcLocalPlacement.RelativePlacement` and `IfcExtrudedAreaSolid.Position`. Translation lives only on the local placement; solid `Position` is the project identity frame so `ObjectPlacement × Position` is not applied twice. The same rule applies to extrusions, openings, and the generic `emit_solid_shape` path (mapped-item geometry is documented as a separate composition case). > > **PredefinedType (#220).** `category_map` now emits witness-aligned values where a recorded edge exists: walls `.NOTDEFINED.`, rooms `.SPACE.`, doors `.DOOR.`, windows `.WINDOW.` (replacing `.STANDARD.`, `.INTERNAL.`, and `$`). Tests and docs/compatibility tables are updated accordingly. > > **CI and gates.** `tools/ci/ifc_schema_arity.py` adds placement-composition checks on every file (no shared placement instance; pinned Tag probes) and optional `--witness-agreement` for the real-project export in CI. Synthetic IFC fixtures are regenerated (solid positions, enum values, opening `Tag` catch-up from #222). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1e78616. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
…ect variant, and gate the test that missed it (#209) Closes #206. `elem_table_corpus::project_2024_file_parses_all_declared_records` failed with 26424 parsed vs 26425 declared on magnetar's `2024_Core_Interior.rvt`, and had been failing invisibly because no CI job ever ran that test with a corpus. Gate first, then root cause. ## 1. The gate gap Corpus jobs name specific `--test` targets; the matrix jobs run every target but without `RVT_PROJECT_CORPUS_DIR`. So every corpus-reading target that no job names takes its skip path on **every** CI run. Full audit of `tests/*.rs` that read `RVT_PROJECT_CORPUS_DIR` or `RVT_SAMPLES_DIR`: | Target | Corpus var(s) | Named by a job before this PR? | |---|---|---| | `corpus_tier2_health` | project | yes — `corpus-tier2`, `corpus-nightly` | | `project_corpus_smoke` | project | yes — `corpus-tier2`, `corpus-nightly` | | `project_count_fixtures` | project, tier1 | yes — `corpus-tier2`, `writer-patch-corpus`, `corpus-nightly` | | `cfb_roundtrip_delta` | project, samples | yes — `writer-patch-corpus` | | `samples` | samples | yes — matrix `test`, `corpus-nightly` | | `field_type_coverage` | samples (+`RVT_REQUIRE_CORPUS`) | yes — matrix `test`, `corpus-nightly` | | `ifc_roundtrip` | samples | yes — matrix `test`, `corpus-nightly` | | **`elem_table_corpus`** | project + samples | **no — never run with either corpus** | | **`arc_wall_corpus`** | project | **no** | | **`partition_scanner`** | project | **no** | | **`iter_elements_typed`** | project (+tier1) | **no** | | **`re15_geometry_invariants`** | project | **no** | | **`re19_door_window_wall_negative`** | project | **no** | | **`walker_to_ifc_integration`** | project + samples | **no** | (`geometry_recovery` / `typed_decoders` read `RVT_CORPUS_TIER1_DIR`, which defaults to the in-repo `corpus/tier1` tree, so they are non-vacuous already. `tests/python` gets `RVT_SAMPLES_DIR` from the wheel job.) All seven ungated targets are now named: - `corpus-tier2` gains a **"Tier-two decoder gates"** step running all seven with `RVT_PROJECT_CORPUS_DIR` + `RVT_CORPUS_TIER1_DIR`. The step comment says a new corpus-reading target has to be added to that list to count as gated. - The matrix `test` job gains an **"ElemTable record framing (family corpus)"** step running `elem_table_corpus` with `RVT_SAMPLES_DIR` and `RVT_REQUIRE_CORPUS=1`, so the family half is non-vacuous too. Each job gates the half it has a corpus for; the other half skips and says so. All seven pass locally against the corpus (this PR fixes the only failure). **Loud skip.** `tests/elem_table_corpus.rs` now panics when `RVT_PROJECT_CORPUS_DIR` is set but the named file is absent (the rule `tests/project_count_fixtures.rs` already uses), and treats a missing family release as a failure under `RVT_REQUIRE_CORPUS=1` (the rule `tests/field_type_coverage.rs` already uses). It also carries one always-on test over committed bytes, so the target is never wholly vacuous. ## 2. Root cause — a four-byte record-origin shift, not a missing record ### The decompressed length is authoritative `Global/ElemTable` is a checksum-paged stream, so the production path strips page trailers before inflating. On this file: | | bytes | |---|---| | stored CFB stream | 125,892 (one full 65,249 B page + 60,643 remainder) | | page-stripped | 125,539 | | **inflated (production path)** | **1,057,030** | | inflated without stripping | 1,059,812 — **gzip CRC32 fails** | The stripped stream's gzip footer verifies: `CRC32` matches and `ISIZE` is 1,057,030. The 1,059,812 figure recorded in the 2026-04-21 layout note (and the reason the test's `assert_eq!` once passed) came from a CRC-invalid inflate of un-stripped bytes. ### 1,057,030 = 0x1E + 26,425 x 40, exactly | Candidate origin | Records that fit | Bytes left over | |---|---|---| | `0x22` — the first `FF` run (what `detect_layout` used) | 26,424 | 36 — neither a record nor padding | | `0x1E` — `0x22` minus one `u32` | **26,425** | **0** | ### The four bytes ahead of the marker are a record field The `u32` at `0x1E + 40k` is **zero for all 26,425 values of k** — including the 26,425th slot that only exists under the corrected origin. `rvt-elem-table --raw` on record 0 now prints the framing directly: ``` 00000000 ffffffff ffffffff 00000000 01000000 000000000000000000000000 01000000 +0 +4 marker (8B) +12 +16 id +20 payload +36 id2 ``` The `FF`x8 run is two `u32` owner slots with `0xFFFFFFFF` meaning "none" — record 1283 carries `02 05 00 00` (= 1282) there instead, so it is a field, not a frame delimiter. The final record (`k = 26424`) reads ``` 00000000 00020855 00000000 00000000 00000000 ffffffff 00000901 00020859 00000000 00000000 ``` — a zero-id terminator, but a structurally well-formed 40-byte record that ends flush with the stream. ### Decision: the decoder was wrong The header count and the CRC-verified stream length agree exactly under one origin and disagree under the other, and the disputed four bytes are provably a zero field of the record rather than slack. The assertion stays `assert_eq!(records.len(), header.record_count)` — no `>=`, no tolerance. `detect_layout` finds the marker and the stride as before; new `elem_table::record_origin` then recovers record 0's origin as `len - record_count * stride` when that lands a whole number of `u32` fields (and less than one stride) ahead of the marker. New public field `ElemTableLayout::marker_offset` records the difference so field extraction stays anchored to the marker. **Every id on records 0..26,423 is byte-identical before and after.** What changes: `ElemRecord::offset` / `raw` shift by -4, and record 26,424 is recovered. `declared_element_ids` consequently gains `0` for this file; the one consumer that could care (`partition_schema_mvp`'s ElemTable confirmation of `ArcWallRectOpening` related ids) produces byte-identical IFC on this corpus, so no opening has a zero related id. ### The 2023 variant is deliberately left alone End-anchoring `Revit_IFC5_Einhoven.rvt` would put the origin at `73,245 - 2615 x 28 = 25 = 0x19` — **five** bytes ahead of the marker. A record field cannot begin at a non-`u32` boundary inside the record, so the `% 4` guard rejects it and the 28-byte variant keeps the marker as its origin. That file still walks 2,614 of 2,615 and leaves a 23-byte tail. That is an open question, not a loosened assertion, and the test now pins **2614 exactly** (it previously asserted only `>= 2000` and `<= record_count`), so the day it changes it changes visibly. ## 3. Regression coverage - `tests/fixtures/elem-table/2024-core-interior-elemtable-head-tail.bin` — 270 bytes, MIT, with a `.license.json` sidecar recording the source hash and the exact derivation: the real 0x1E-byte header with `record_count` rewritten 26425 -> 6, then records 0-2 and 26422-26424 verbatim. It preserves the property under test (`0x1E + 6 * 40 = 270`, flush) and parses 5 records on the old decoder, 6 on the new one. Runs with no corpus. - Three new unit tests in `src/elem_table.rs` cover the aligned recovery, the non-`u32`-aligned rejection, and a stream shorter than the declared span. - The 2024 corpus test additionally asserts `last.offset + last.raw.len() == header.decompressed_bytes`. ## 4. OctetProof Nothing to regenerate. `rvt-ifc --observation` re-run against both recorded edges (`magnetar-2024-core-interior` and `...-slim`) produces files byte-identical to the committed ones; `observation_hash_sha256` stays `b6d9b67c10c3350b69b58cbd2c6caeca405f63ce182e7291feba3e3ff10f3e00` on both. `tools/ci/witness-verdict.py` with the fresh observation: ``` magnetar-2024-core-interior: PASS - witnesses ifc-lite, ifcopenshell, rvt-rs surface: 8 fields, excluded: 4, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match ``` ## Docs `docs/elem-table-record-layout-2026-04-21.md` gains a "Where the record array starts" section with the evidence above and the record-count semantics (`record_count` counts fixed-stride records including terminators with `id_primary == 0`; distinct ElementIds are `element_count` = 1,411). `docs/status.md` needed no change - no status sentence became false. No change to `docs/support-matrix.json`. ## Gates run `cargo fmt --all`, `cargo clippy --all-targets -- -D warnings`, `RUSTDOCFLAGS="-D warnings" cargo doc`, `cargo +1.85.0 check --all-targets` (MSRV), `tools/check-local.sh` (all requested gates passed), and the full `cargo test --profile ci` suite with `RVT_PROJECT_CORPUS_DIR` / `RVT_CORPUS_TIER1_DIR` set - all green. ## Note for the parallel lane This branch touches no file in `src/ifc/`, `src/walker*`, `tests/fixtures/project-counts/2024-core-interior-slim.json`, or `research/witness/magnetar-2024-core-interior-slim/`. It does add `walker_to_ifc_integration` to the `corpus-tier2` step list (workflow only, no test-file change). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes authoritative ElemTable enumeration and adds a breaking `ElemTableLayout` field, but behavior is heavily regression-tested and downstream IFC observations are unchanged per the PR. > > **Overview** > Fixes **#206**: on Revit 2024 project `Global/ElemTable`, the decoder treated the first `0xFF` run as record 0’s start, but each 40-byte row begins with a zero `u32` and the marker sits at **+4**. That four-byte shift walked **26,424** of **26,425** declared records on `2024_Core_Interior.rvt`. > > **Decoder** — `record_origin` anchors the array with `len − record_count × stride` when that lands u32-aligned before the marker; **`ElemTableLayout::marker_offset`** (breaking pre-`0.2.0`) keeps ID extraction past the marker. Parsed IDs on existing rows stay the same; offsets/`raw` shift by −4 and the final record is recovered. The 28-byte 2023 variant is unchanged (alignment guard rejects a bogus earlier origin). > > **CI** — `elem_table_corpus` and six other corpus-reading integration targets were never named by a job with `RVT_PROJECT_CORPUS_DIR` / family corpus, so they skipped every run. They are now run from the matrix `test` job (family + `RVT_REQUIRE_CORPUS`) and `corpus-tier2` (project batch). Corpus tests **fail** when env is set but files are missing; a committed 270-byte MIT fixture gives an always-on regression without external corpus. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 981ba72bf2c2805bb875c47018e0fd025e958290. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
…lement records (#210) Recovers architectural column instances from `2024_Core_Interior.rvt` and closes the last measured gap on the full-project export that had no decoder path at all. ## How columns present in the bytes Revit 2024 project partitions frame each *element* record with a fixed prologue. Reading it on `2024_Core_Interior.rvt` (sha256 `c805df44…`, eight `Partitions/*` streams, ~190 MiB inflated): ```text +0x00 u64 ElementId of this record (declared in Global/ElemTable) +0x08 u32 record flags (0x00e1 / 0x0111 / 0x0131 / 0x0141 / …) +0x0c u32 0x0000059f on every observed record of this shape +0x10 u16 0 +0x12 i64 BuiltInCategory id, negative (OST_Columns = -2000100) +0x1a 54B 0xff sentinel padding + three unattributed words +0x50 8B bbox marker 46 01 ff ff ff ff ab 05 +0x58 48B bounding box: min x/y/z, max x/y/z, feet, f64 LE ``` 24880 records of this shape exist on that file. The marker sits at exactly `+0x50` on 23470 of them (94.3 %), which is why the offset is treated as fixed rather than searched, and **every** leading `u64` is an ElementId declared in `Global/ElemTable` — the decoder requires that join, so a stray byte match cannot become an element. `OST_Columns` alone is not an instance claim: 393 distinct ElementIds carry it. Two further steps, both structural rather than fitted: 1. **Family-local bboxes are type definitions, not placements.** A symbol's envelope is stored in family coordinates and is therefore centred on the plan origin (`min_x == -max_x`, `min_y == -max_y`). 17 of the 393 are like that — the `Column_Sqaure : 24" x 24"` symbol (id 5755) plus per-level variants. Dropped. 2. **Co-located pairs are a superseded generation and its replacement.** The remaining 375 collapse to 256 distinct project-coordinate footprint origins: 137 footprints hold one record, 119 hold exactly two. In every pair the two records differ only in top extent (e.g. `76.0 → 91.0` vs `76.0 → 90.33`, an 8-inch difference consistent with a column being attached to a slab after placement). Revit allocates ElementIds monotonically, so the higher id in each group is the live element. That yields 256 ids. They are not merely the right *count*: the emitted `IfcColumn.Tag` set is byte-for-byte the set of ElementIds in Revit's own export (`{int(c.Tag) for c in cols} == reference ids` → `True` under IfcOpenShell 0.8.5), and the placements agree — column 20375 lands at (24.0, 110.0, 76.0) ft, the centre of the 2 ft box whose min corner is the (23.0, 109.0, 76.0) the Revit exporter writes. ## What ships - `src/partition_element_records.rs` — the record decoder, version-gated to Revit 2024, fail-closed on the ElemTable join, the `+0x10` zero word, the BuiltInCategory band, the bbox marker, non-finite doubles and inverted boxes. - `partition_schema_mvp::columns_from_partition_category_records` — the three-step instance selection above, merged into production `iter_elements` as `class == "Column"`. `columns_from_records` is split out so the rule is unit-tested without a corpus file. - IFC export emits `IfcColumn` with a project placement and a bounding-box `IfcExtrudedAreaSolid`. This is an **envelope, not a recovered family profile**, and the `RvtColumnGeometry` property set says so (`ProfileResolved: false`, `LevelBindResolved: false`, `BodySource: partition_element_record_bbox`). Base/top Level ElementIds stay unbound (#86). ## Measured, before → after `./target/ci/rvt-ifc <rvt> -o /tmp/x.ifc --diagnostics /tmp/d.json`, `2024_Core_Interior.rvt`, every value re-measured on this branch (nothing estimated): | metric | before | after | |---|---:|---:| | `by_ifc_type.IFCCOLUMN` | 0 | **256** | | `by_ifc_type.IFCSLAB` | 64 | 64 | | `by_ifc_type.IFCSPACE` | 18 | 18 | | `by_ifc_type.IFCWALL` / `IFCDOOR` / `IFCWINDOW` / `IFCROOF` / `IFCBEAM` / `IFCFLOWTERMINAL` | 0 | 0 | | `storey_count` | 12 | 12 | | `material_count` | 102 | 102 | | `step.IFCUNITASSIGNMENT` | 1 | 1 | | `step.IFCPROPERTYSET` | 64 | **320** | | `building_elements` | 82 | 338 | | `building_elements_with_geometry` | 0 | **256** | `rvt-elements --counts` goes from `{ArcWallRectOpening 3777, Floor 64, Level 12, Material 102, Room 18}` (3973) to the same plus `Column 256` (4229). Export wall-clock on this machine: 13.1 s → 15.8 s. ## Manifests - `2024-core-interior-slim.json`: `columns` moves `known_gap` → **`known`**, `decoder_expected` 0 → 256, tolerance 0. `property_sets.decoder_expected` 64 → 320. `rooms_spaces.unsupported_feature` moves to the new `partial_element_geometry` code (see below). - `2024-core-interior.json` (the 20 KB element fixture): `columns` moves `known` → **`decoder_baseline`**, `decoder_expected` 0 → 256. That reference has no `IFCCOLUMN`, so scoring the count there would be wrong; it is scored against the full export in the sibling manifest. `property_sets.decoder_expected` 64 → 320. ## Verdicts Both regenerated and both `PASS`. **The observation hashes changed** (`research/witness/*/observations/rvt-rs.json`), so the umbrella mirror will need the new bytes after merge. ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 7 fields, excluded: 5, diffs: 0 magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 5 fields, excluded: 8, diffs: 0 ``` The slim claimed surface widens from four fields to five: `entity_counts.IFCCOLUMN` joins `IFCROOF`, `IFCBEAM`, `IFCFLOWTERMINAL` and `IFCUNITASSIGNMENT`. It is the first field in that surface with a non-zero expectation — the other four are agreements about absence. ## Diagnostics fix (second commit) `unsupported_features` carried `real_file_element_geometry` only while *no* exported element had a body, so the first category to gain geometry silently cleared the gap for every other one. It now reports `real_file_element_geometry` when nothing has a body and the new `partial_element_geometry` when some do and some do not. Documented in `docs/export-diagnostics.md`. ## Generalisation — deliberately not taken here The same header carries every other building category. Measured with the shipped decoder on the same file (`scan_category_records` + the same family-local drop and footprint de-duplication), against the ElementId set Revit's export tags: | category | records | ids carrying the category | recall of exported ids | after the instance filter | TP | FP | FN | |---|---:|---:|---:|---:|---:|---:|---:| | `OST_Columns` | 480 | 392 | **256 / 256** | 256 | 256 | 0 | 0 | | `OST_Walls` | 1488 | 1210 | 360 / 360 | 648 | 360 | 288 | 0 | | `OST_Doors` | 335 | 200 | 132 / 132 | 139 | 132 | 7 | 0 | | `OST_Windows` | 9 | 9 | 6 / 6 | 8 | 6 | 2 | 0 | | `OST_Floors` | 146 | 124 | 79 / 80 | 67 | 43 | 24 | 37 | | `OST_Rooms` | 399 | 277 | n/a | 169 | — | — | — | Category membership alone reaches every exported wall, door and window ElementId and all but one slab, which is a real result — but only columns survive the instance filter exactly, so **no other category's status moved** in this PR and the documented RE-19 / RE-20 negatives are untouched. (`IfcSpace` carries no ElementId tag in this export, so rooms cannot be scored by id at all.) Follow-up issues carry these numbers. ## Gate `cargo fmt --all -- --check`, `cargo clippy --all-targets -- -D warnings`, `cargo +1.85.0 check --all-targets` (MSRV, no let-chains), `tools/check-local.sh`, and the full suite (1127 tests) all green. With `RVT_PROJECT_CORPUS_DIR` set, the tier-two targets from #209's new CI step are green too: `elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration`, plus `project_count_fixtures`, `witness_verdict`, `witness_registry`, `support_matrix`, `json_schema_contracts`. Branched from `main` and merged `origin/main` (e8ac9a1, #209) mid-flight; the ElemTable record-origin fix does not move any number here. Closes #204 ## Follow-ups filed - #211 — walls / doors / windows: category recall is 100 % (360/360, 132/132, 6/6) but the instance filter over-counts (648 / 139 / 8). RE-19 stands; this is a different mechanism, not a re-opening. - #212 — slabs: 79 of 80 ids carry the category, but footprint de-duplication is the wrong identity rule for plates (43 TP / 37 FN). Also the obvious source for `floor_slab_extrusion_thickness`. - #213 — bind columns to storeys via the record bbox base elevation; the 10 distinct base z values are themselves better elevation evidence than the current name strings. - #215 — recover the real column profile from the family-local symbol record instead of the instance envelope. - #216 — research: what the 137 non-exported `OST_Columns` elements actually are (17 family-local symbols, 119 exact co-locations of an exported column). Answering it would replace the highest-id heuristic with a direct test, and probably fixes #211 too. - #214 — pre-existing and unrelated to this change: the IFC4 writer omits the trailing `PredefinedType` attribute on every building element (`IFCSLAB` / `IFCSPACE` on `main` have the same shape), so the instances are non-conformant even though IfcOpenShell tolerates them.
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
…rom Revit 2024 partition element records (#211) (#221) Closes #211. Explains and closes #216. `2024_Core_Interior.rvt` (sha256 `c805df44…`) against Revit's own full-project export `IFC Exports/2024_Core_Interior_slim.ifc` (sha256 `bfdf36ff…`), whose per-entity `Tag` carries the source ElementId. ## The rule #210 established that the Revit 2024 partition element-record header reaches **100 %** of the exported ElementIds in every architectural category. What was missing was precision. Two fields inside the 54 bytes #210 recorded as "0xff sentinel padding + three unattributed words" supply it: ```text +0x32 u64 container ElementId, 0xffff_ffff_ffff_ffff = none +0x42 u32 placement kind: 0xffffef7f placed instance 0xffff8000 family/type symbol envelope ``` > A record is a standalone placed instance — what Revit's exporter emits as a > building element — **iff** `u64 @ +0x32 == 0xFFFF_FFFF_FFFF_FFFF` **and** > `u32 @ +0x42 == 0xFFFF_EF7F`. `PartitionElementRecord::is_exported_instance`. Both halves are required; neither is sufficient alone. **This is not a re-opening of RE-19.** The carrier is the element record's own `BuiltInCategory` field, not the `ArcWallRectOpening` index and not a schema-field decode. Both RE-19 negatives stand and are still reported: `schema_field_wall_instances` still fires (its check now requires a wall whose body did *not* come from an element record, so an element-record wall cannot clear it by accident), and door/window **host binding** is still unsupported. ## Set-difference evidence Prologue bytes `+0x1a..+0x50`, exported vs not exported: | side | distinct patterns | shape | |---|---:|---| | exported | 1 per category | `ff`×40 then `7fefffff` `<w46>` `<w4a>` `ffffffff` | | container members | 9 owner values | `ff`×24 then **`<owner u64>`** then `ff`×8 then `7fefffff` … | | type symbols | 2 per category | `ff`×40 then **`0080ffff`** `<w46>` `<w4a>` `ffffffff` | Rules measured independently and together (ElementId sets, not counts): | category | A: `+0x32` unset | B: `+0x42` placed | **A ∧ B** | exported | |---|---:|---:|---:|---:| | `OST_Walls` (-2000011) | 361 (1 FP) | 1209 (849 FP) | **360 exact** | 360 | | `OST_Doors` (-2000023) | 147 (15 FP) | 185 (53 FP) | **132 exact** | 132 | | `OST_Windows` (-2000014) | 8 (2 FP) | 7 (1 FP) | **6 exact** | 6 | | `OST_Columns` (-2000100) | 273 (17 FP) | 375 (119 FP) | **256 exact** | 256 | Every non-sentinel `+0x32` value is a container ElementId: all nine are declared in `Global/ElemTable`, all are lower than every member id that names them, each owns a contiguous ElementId block spanning several categories at once, and none has an element record of its own (brute scan of all 23470 decodable records finds none). | owner | columns | walls | doors | windows | member range | |---:|---:|---:|---:|---:|---| | 16229 | 23 | 66 | 14 | 1 | 16347 – 16995 | | 21984 | 24 | 8 | – | – | 22008 – 22077 | | 23117 | 24 | 57 | 11 | – | 23134 – 23733 | | 26863 | 24 | 63 | 14 | – | 26880 – 28001 | | 26908 | – | 27 | – | – | 26993 – 27045 | | 33696 | 24 | 70 | 14 | – | 33748 – 34467 | | 81029 | – | 277 | – | – | 81041 – 87363 | | 87754 | – | 4 | – | – | 87758 – 87764 | | 108205 | – | 277 | – | – | 108216 – 114538 | Full write-up, histograms and reproduction commands: [`reports/element-framing/RE-21-partition-element-record-instance-rule.md`](reports/element-framing/RE-21-partition-element-record-instance-rule.md). ## Measured before → after `cargo build --profile ci --bin rvt-ifc && ./target/ci/rvt-ifc <rvt> -o /tmp/x.ifc --diagnostics /tmp/d.json` | decoder metric | before | after | export expects | manifest status | |---|---:|---:|---:|---| | `by_ifc_type.IFCWALL` | 0 | **360** | 360 | `known_gap` → **`known`**, tol 0 | | `by_ifc_type.IFCDOOR` | 0 | **132** | 132 | `known_gap` → **`known`**, tol 0 | | `by_ifc_type.IFCWINDOW` | 0 | **6** | 6 | `known_gap` → **`known`**, tol 0 | | `by_ifc_type.IFCCOLUMN` | 256 | 256 | 256 | `known` (rule replaced) | | `by_ifc_type.IFCSLAB` | 64 | 64 | 80 | `known_gap` (#212) | | `by_ifc_type.IFCSPACE` | 18 | 18 | 116 | `known_gap` | | `exported.material_count` | 102 | 102 | 10 | `known_gap` | | `step.IFCPROPERTYSET` | 320 | **818** | 0 | `known_gap` | | `step.IFCUNITASSIGNMENT` | 1 | 1 | 1 | `known` | | `exported.storey_count` | 11 | 11 | 15 | `decoder_baseline` | | `building_elements_with_geometry` | 256 | **754** | — | — | | `exported.storey_bound_elements` | 256 | **743** of 836 | — | — | | `step.IFCRELCONTAINEDINSPATIALSTRUCTURE` | 11 | 11 | — | — | ("before" = `main` at 55491d7, i.e. after #217.) Id-set check on the emitted IFC (not just counts): ``` IFCWALL: rvt-rs=360 export=360 exact=True missing=0 extra=0 IFCDOOR: rvt-rs=132 export=132 exact=True missing=0 extra=0 IFCWINDOW: rvt-rs=6 export=6 exact=True missing=0 extra=0 IFCCOLUMN: rvt-rs=256 export=256 exact=True missing=0 extra=0 ``` ## #216 falls out The 136 `OST_Columns` ids Revit omits split with no remainder: - **17 type symbols** (`+0x42 == 0xffff8000`) — ids 5755, 19250, 22374, 24299, 28008, 53894, 75407–75417, exactly the 17 #216 lists as family-local; - **119 container members** (`+0x32` set) — the blocks 16347–16369, 22045–22068, 23134–23157, 26880–26903, 33748–33771 that #216 identified as "exact co-locations of an exported column", each owned by the id allocated just before its block. So the #204 heuristic is **retired**: `partition_schema_mvp` no longer drops origin-centred family-local bounding boxes and no longer collapses co-located footprint groups to their highest `ElementId`. It applies the direct test, reproduces the same 256/256 columns, and additionally the wall / door / window id sets — which the heuristic could not (648 / 139 / 8). `is_family_local` is kept as a documented, strictly weaker diagnostic: the `+0x42` symbol set is a superset of it on every category, catching 15 door, 2 window and 1 wall symbols whose envelope is centred on only one axis (e.g. id 17331 spans `x −1.749…1.749` but `y −0.332…3.251`). ## What did not move `OST_Floors` stays `known_gap` (#212), measured not hand-waved: 124 distinct ids carry the category, 79 of the 80 exported slabs have a record at all, and the rule selects 99 (TP 79 / FP 20 / FN 1). `+0x42` is `0xffffef7f` on all 146 floor records — there are no slab type symbols on this file — so the rule degenerates to `+0x32` alone there. That needs a slab-appropriate identity key, not a looser tolerance. No tolerance was widened anywhere in this PR. ## Storey elevations — the #213 evidence base did not widen silently #217 derives storey elevations from element-record base `z`. Adding three categories to the record set would have widened that evidence base by accident, so the restriction is now measured, against the fifteen `IfcBuildingStorey.Elevation` values in the export: | category | distinct base elevations | equal to a storey | not a storey | |---|---:|---:|---| | `OST_Columns` | 11 | 11 | — | | `OST_Doors` | 11 | 11 | — | | `OST_Walls` | 13 | 12 (adds **−40 ft**) | 56.4167 | | `OST_Windows` | 6 | **0** | 80.73, 95.73, 110.73, 125.73, 140.73, 155.73 | A window sits at its sill height above the level that hosts it, so its record base is never a storey elevation; a wall may start mid-storey. Only `IFCCOLUMN` therefore *supplies* elevations (new `ifc::STOREY_ELEVATION_SOURCE_TYPES`), which keeps #213's measured "no false positives" claim exactly as recorded and `storey_count` at 11. Every record-bodied element still *binds* by exact match, so `IfcRelContainedInSpatialStructure` stays 11 while storey-bound elements go **256 → 743 of 836**: all 256 columns, all 132 doors, 355 of 360 walls. The 5 walls at −40 / 56.4167 ft and all 6 windows stay unbound rather than being placed by proximity. **Of the four export elevations #213 could not reach (−40, −20, 15, 185.5 ft), these categories surface exactly one: −40 ft, from wall records — and taking it costs one elevation that is not a storey.** That trade is left open rather than taken. The other three carry no record of any of the four categories. ## IFC4 attribute arity (#214) `tools/ci/ifc_schema_arity.py` on a fresh Core Interior export including the new walls/doors/windows: ``` IFC schema conformance passed schema: IFC4 instances checked: 15035 across 36 entity type(s) PredefinedType populated: IfcColumn=256, IfcSlab=64, IfcWall=360 ``` ## Verdicts ``` magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 8 fields, excluded: 5, diffs: 0 ``` surface `IFCWALL`, `IFCDOOR`, `IFCWINDOW`, `IFCCOLUMN`, `IFCROOF`, `IFCBEAM`, `IFCFLOWTERMINAL`, `IFCUNITASSIGNMENT` (was 5 fields / 8 excluded); `verdict_hash_sha256` `afa87bb0a4e35ea8e5fa9a1adb21b29f8a0ba532571c88fd00c14dabcd4c7145`. ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 4 fields, excluded: 8, diffs: 0 ``` `verdict_hash_sha256` `ae4679f6044a4c3caa0b2f3a6030648bc633b1d878957a759120f011f71ded5e`. Both `rvt-rs.json` observations were regenerated **after** merging `origin/main` at 55491d7 (#217), so their `observation_hash_sha256` reflects both changes: `d88897c6d9b8223350a831f4caf48d76d469a4d4f47815da56da6d34e9364fb7`. ## Diagnostics vocabulary made precise Two composite `unsupported_features` were half-true after this change, so they were split into what is actually still missing: - `typed_door_window_discrimination_and_host_binding` now fires only when no typed door or window is exported at all. When they are exported but carry no host, the narrower **`door_window_host_wall_binding`** fires instead. - New **`revit_element_parameters_to_ifc_property_sets`** fires while every exported `IfcPropertySet` is rvt-rs provenance about a recovered body rather than a Revit element parameter (#35). The two manifest rows that previously borrowed the door/window feature name now use accurate ones. - `schema_field_wall_instances` keeps firing (see above). ## Docs `docs/status.md`, `docs/support-matrix.json` (`column-instance-recovery` → `element-record-instance-recovery`, still `verified`, scope restated for four categories; `typed-door-window` and `schema-field-wall` stay `unsupported` with their honesty invariants intact), `docs/verification-protocol.md` edges table + honesty note, `docs/supported-profile.md`, `README.md` (three surgical lines), `CHANGELOG.md`, and the new RE-21 report. ## Gates run `cargo fmt --all`, `cargo clippy --profile ci --all-targets -- -D warnings`, `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps`, `cargo +1.85.0 check --all-targets` (MSRV 1.85, no let-chains), `tools/check-local.sh`, and the full `cargo test --profile ci` suite with `RVT_PROJECT_CORPUS_DIR` / `RVT_CORPUS_TIER1_DIR` — all green, including every tier-2 target from #209 (`elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration`) plus `witness_verdict`, `witness_registry`, `project_count_fixtures`, `support_matrix`. `tests/iter_elements_typed.rs::core_interior_2024_rect_openings_not_fake_doors` now pins the exact counts **and** asserts every recovered Wall/Door/Window carries provenance `partition_schema_mvp::element_category_record`, so the RE-19 negative is enforced by mechanism, not by a zero. ## Merge with #217 `origin/main` at 55491d7 was merged into this branch before the final measurement, so every number above is post-#217. The STEP emitter and `category_map` `predefined_type` values are untouched; the hunks in `src/ifc/mod.rs` are `unsupported_export_features`, the new `STOREY_ELEVATION_SOURCE_TYPES` restriction described above, one re-export line, and one `expect` message. ## Follow-ups - #212 slab instance identity — the rule does not hold there; the record bbox is also the obvious source for the unresolved extrusion thickness. - Door/window host-wall binding (`door_window_host_wall_binding`) — the record body past `+0xa8` was dumped but not yet mined for a host reference. - `docs/octetproof-spec.md` §6's worked verdict example is a two-lineage snapshot and was already stale before this PR (the committed verdict has three lineages); refreshing a published 1.0.0 artifact is a separate call. - `+0x46` / `+0x4a` remain unattributed; their values correlate with class, which may be a schema class-id join worth a look. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core decode/IFC export and cross-witness gates for a corpus-proven Revit 2024 edge; scope is narrow but wrong instance filtering would skew real-project exports and CI verdicts. > > **Overview** > **Revit 2024 partition element records** now drive typed **Wall, Door, Window, and Column** recovery using a direct byte rule instead of the retired #204 column heuristic (family-local bbox drop + highest-`ElementId` per footprint). Records decode **container reference** at `+0x32` and **placement kind** at `+0x42`; `PartitionElementRecord::is_exported_instance` keeps only standalone placed instances. On Core Interior that matches Revit’s export **ElementId sets** at tolerance 0 (360/132/6/256), with bbox envelope geometry and shared `RvtElementRecordGeometry` property sets in IFC. > > **Production and verification** wire walls/doors/windows through `partition_schema_mvp::instances_from_partition_category_records`, unify element-record geometry in `export_content`, and narrow **storey elevation sourcing** to columns only (`STOREY_ELEVATION_SOURCE_TYPES`) while other record-bodied elements still **bind** storeys by exact base elevation (743/836 bound). OctetProof manifests move walls/doors/windows to **`known`** on the slim edge (8-field claimed surface); diagnostics split host binding vs discrimination and add `revit_element_parameters_to_ifc_property_sets`. RE-19/schema-field walls and door/window **host** binding stay explicitly unsupported; slabs (`OST_Floors`) remain #212 `known_gap`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2c9d2971d7e42cc2473d0da579485467340216c4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
… Revit 2024 partition element records (#212) (#225) Closes #212. Refs #31 #218 #219. RE-21 recorded `OST_Floors` as the one category where the partition element-record instance rule fails: 99 selected against 80 exported, `TP 79 / FP 20 / FN 1`. Both numbers reproduce exactly. **Neither is a decoder error.** Full evidence, rejected candidates and reproduction commands: [`reports/element-framing/RE-22-slab-instance-rule.md`](reports/element-framing/RE-22-slab-instance-rule.md). ## 1. The set difference **The 20 "false positives" are exported.** They are, id for id and in order, the export's 20 `IFCSHADINGDEVICE` `Tag` values: ``` 20953, 64160, 64227, 64292, 64358, 64423, 64488, 64553, 64618, 64683, 70366, 71171, 71231, 71291, 71351, 71411, 71471, 71531, 71591, 71651 ``` ``` #3468=IFCSHADINGDEVICE(…,'Floor:Arch Topping Slab - 2":20953',$, 'Floor:Arch Topping Slab - 2"',…,'20953',.NOTDEFINED.); ``` So the instance rule selects 99 ids on `OST_Floors` and **all 99 are exported** — 79 as `IfcSlab`, 20 as `IfcShadingDevice`. Precision was already 100 %; #212 measured a type-assignment gap wearing a precision gap's clothes. **The 1 "false negative" is a building pad.** `#3526=IFCSLAB(…,'Pad:Site Pad:21975',…,'21975',.FLOOR.)`. A brute scan of all 23 470 decodable element records finds ElementId 21975 exactly once, with `category = -2001263` — Autodesk's published `BuiltInCategory.OST_BuildingPad`. Same prologue shape, same instance rule, and Revit's exporter maps a building pad to `IfcSlab` `.FLOOR.`. #212 guessed this outcome; the bytes confirm it. | stage | count | |---|---:| | distinct ids carrying `OST_Floors` | 124 | | instance rule selects on `OST_Floors` | 99 | | of those, exported by Revit | **99** (79 `IfcSlab` + 20 `IfcShadingDevice`) | | instance rule selects on `OST_BuildingPad` | 1 | | exported `IFCSLAB` recovered | **80 / 80** | | exported `IFCSHADINGDEVICE` recovered | **20 / 20** | ## 2. The rule The `IfcSlab` / `IfcShadingDevice` split is decided **per instance**, not per type — the reference export carries `IFCSLABTYPE` *and* `IFCSHADINGDEVICETYPE` rows with the same `Tag` (`4166`, `71848`), so the same Revit `FloorType` lands on both sides. That is Revit's `IFC Export As` instance parameter, and its value is in the file as a UTF-16LE string: ``` -0x11e u64 owning ElementId (confirmation slot) -0x0dc u64 owning ElementId -0x004 u32 value length in UTF-16 code units (0x10) +0x000 32B "IfcShadingDevice", UTF-16LE +0x020 u64 parameter-definition ElementId (17368, then 17493) ``` Over a 3 KB window around every one of the 62 hits, the owning ElementId appears **only** at those two offsets, always as a `u64`, always identical in both slots. Requiring the slots to agree and the id to be declared in `Global/ElemTable` accepts 31 entries naming 21 ids; the second string of each pair is rejected (sentinel owner slots), and so is the parameter *definition* block. The 21st id (`16925`) is a container member the RE-21 rule already excludes — its superseded twin, same `182.3333 x 121.6111 ft` box as `20953`. > **The rule.** A partition element record is an exported slab iff it is a > standalone placed instance (RE-21) in `OST_Floors` or `OST_BuildingPad` > **and** no accepted `IFC Export As` override names it. An override naming > `IfcShadingDevice` redirects the entity type rather than suppressing the > element. The scan is general (any `Ifc…` value string); only `IfcShadingDevice` is honoured as a target (`ifc::category_map::EXPORT_OVERRIDE_TARGETS`), because it is the only value a reference export has demonstrated. An unrecognised value leaves the element on its class mapping. ### What was rejected Two byte fields separate the two sides *within* `OST_Floors` on this file and neither survives contact with the rest of the corpus — both are shipped as **not** the rule: | candidate | inside `OST_Floors` | why rejected | |---|---|---| | prologue flags `+0x08` | `0x0119` on all 30 shading records, none of the 91 slab records | 32 **exported** `IFCWALL` records also carry `0x0119`. The word is a count (`0xe9 + 8k`, tracking `+0x88`); the separation is a consequence of all 20 shading plates sharing one footprint. | | record byte `+0x88` | `8` on all 30 shading records | 153 exported `IFCWALL` and 107 exported `IFCCOLUMN` records carry `8`. | | bbox shape | all 20 shading plates are exactly `182.3333 x 121.6111 ft` | shape identity, not a byte test — the same objection #212 raised against #204's footprint key. | ## 3. Measured before / after on `2024_Core_Interior.rvt` | metric | before | after | reference export | |---|---:|---:|---:| | `IFCSLAB` | 64 (plan-loop annotations, no ids) | **80** (exact id set) | 80 | | `IFCSHADINGDEVICE` | 0 | **20** (exact id set) | 20 | | `IFCWALL` / `IFCDOOR` / `IFCWINDOW` / `IFCCOLUMN` | 360 / 132 / 6 / 256 | 360 / 132 / 6 / 256 | same | | building elements | 836 | 872 | — | | with a recovered body | 754 | 854 | — | | `storey_bound_elements` | 743 | 794 | — | | `IFCBUILDINGSTOREY` | 11 | 11 | 15 | | `IFCPROPERTYSET` | 818 | 854 | 0 | Exactness verified on the emitted IFC with IfcOpenShell 0.8.5 (`Tag` sets, `include_subtypes=False`), the reference side independently with IFClite 7.1.1: ``` IfcSlab export= 80 rvt-rs= 80 missing=0 extra=0 EXACT=YES IfcShadingDevice export= 20 rvt-rs= 20 missing=0 extra=0 EXACT=YES IfcWall export= 360 rvt-rs= 360 missing=0 extra=0 EXACT=YES IfcDoor export= 132 rvt-rs= 132 missing=0 extra=0 EXACT=YES IfcWindow export= 6 rvt-rs= 6 missing=0 extra=0 EXACT=YES IfcColumn export= 256 rvt-rs= 256 missing=0 extra=0 EXACT=YES ``` `tools/ci/ifc_schema_arity.py` on the fresh export: 16 674 instances across 37 entity types, `IfcShadingDevice` at its declared IFC4 arity of 9 with `PredefinedType` written as `$` rather than an invented `.NOTDEFINED.`. ## 4. Thickness (#31) The record's bbox `z` extent **is** the slab's extrusion depth, measured against the export's `IfcExtrudedAreaSolid.Depth`: ``` thickness: exact match 79/80; matches the sum of stacked solids 1; other 0 layered: 22756 thickness 1.5 vs export solids [0.333333333, 1.166666667] (sum 1.5) ``` `Floor:Basement Slab` 22756 is exported as two stacked solids that sum to exactly the recorded 1.5 ft — agreement in substance on all 80. Record-backed slabs now carry `ThicknessResolved`, `ThicknessFeet` and `ThicknessSource`, and `floor_slab_extrusion_thickness` is raised per slab so the plan-loop path (2023) still declares it. The slab *profile* stays the bbox rectangle — `ProfileResolved: false`, #31's polygon-profile half is open. Also changed: where one ElementId is framed more than once (22 of 100 slabs), the record with the **greatest `z` extent** is kept. First-by-`(stream, offset)` agrees with the export on 67 of 80; greatest-extent on 79 of 80. The change is uniform and perturbs nothing — 268 walls, 132 doors and 88 columns also carry multiple records and every one agrees on the box. ## 5. Storey containment (#219) The 64 plan-loop `IFCSLAB` annotations carried no ElementId, no bbox and no storey. They stand down where records decode — **exactly one `IFCSLAB` per exported id**, no double emission. Plates bind by their **top** face (Revit hangs a floor below its level): | join over the 100 record-backed plates | bound | agrees with the export | wrong | |---|---:|---:|---:| | base `z` equals a recovered storey elevation | 0 | 0 | 0 | | **top `z` equals a recovered storey elevation** | **51** | **51** | **0** | Exact match, no tolerance, no proximity fallback. `storey_bound_elements` 743 → 794. #219's 82 unbound becomes 78: 49 plates (was 64), 18 spaces, 5 walls, 6 windows. ## 6. Storey elevations (#218): measured, and the answer is no | slab record face | distinct values | equal to a storey elevation | not a storey elevation | |---|---:|---:|---:| | base `z` | 40 | **0** | 40 | | top `z` | 26 | 13 | 13 | Slab tops would add **−40 ft and 185.5 ft**, two of the four storeys #213 misses, at the price of **13** values that are not storeys (each 0.1667 ft below a real one — the structural-slab / topping interface). Two for thirteen is not a trade this project takes: `ifc::STOREY_ELEVATION_SOURCE_TYPES` stays `["IFCCOLUMN"]` and the count stays 11. #218 keeps both halves open with the numbers it asked for. ## 7. Verdicts Both OctetProof verdicts `PASS`, replayed byte-for-byte: ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 4 fields, excluded: 9, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 10 fields, excluded: 4, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match ``` The full-project claimed surface goes **8 → 10 fields** (`entity_counts.IFCSLAB` and `entity_counts.IFCSHADINGDEVICE` join), excluded 5 → 4. `floors` moves `known_gap` → `known` at tolerance 0; a new `shading_devices` row scores the 20 the manifest previously left unscored. ## 8. Gates run `cargo fmt --all`, `cargo clippy --all-targets -- -D warnings`, `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps`, `cargo +1.85.0 check --all-targets` (MSRV), `tools/check-local.sh --ifcopenshell` (all requested gates passed), the full `cargo test --profile ci` suite with `RVT_PROJECT_CORPUS_DIR` / `RVT_CORPUS_TIER1_DIR` set (55 test groups, 0 failures), and the seven tier-2 corpus targets from #209 (`elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration`) — all green. New coverage: `tests/iter_elements_typed.rs::core_interior_2024_slab_instances_and_export_overrides` pins the 100-instance set, the single `BuildingPad`, the exact 20-id override set and the plan-loop stand-down; nine unit tests in `src/partition_ifc_export_overrides.rs` cover the framing's fail-closed paths; plus selection, override-mapping, thickness and top-face-bind unit tests. ## 9. Docs `docs/status.md`, `docs/support-matrix.json` (scope wording in the RE-21 row's style — the `verified` row now names six categories and states the override carrier, the record-selection rule and the plate bind explicitly), `docs/verification-protocol.md`, `docs/supported-profile.md`, `docs/compatibility.md`, `docs/user-guide.md`, `README.md`, `ROADMAP.md`, `TODO.md`, `CHANGELOG.md`, and the viewer's typed-class row. `docs/octetproof-spec.md` takes a **1.0.2 patch** (non-semantic, §16.1): its §6.2/§6.3 worked examples quote files this PR changes by design, so they are now labelled dated snapshots rather than a live mirror of `research/witness/`. No schema, diff-function or provenance change. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes partition MVP merge, IFC entity typing, storey binding, and gated witness artifacts on a narrow 2024 path; behaviour is fail-closed and corpus-tested but affects production export output counts and geometry metadata. > > **Overview** > **Revit 2024 slab export parity** on the Core Interior corpus: **80/80 `IFCSLAB`** and **20/20 `IFCSHADINGDEVICE`** with exact ElementId sets vs Revit’s exporter, replacing 64 id-less plan-loop slab annotations when element records decode. > > Recovery extends the RE-21 partition element-record instance rule to **`OST_Floors` and `OST_BuildingPad`**, adds **`partition_ifc_export_overrides`** to read per-instance **“IFC Export As”** strings (honouring only proven **`IfcShadingDevice`** redirects), and picks **one record per id by greatest bounding-box `z` extent** for thickness. IFC export maps **`BuildingPad` → `IFCSLAB`**, applies overrides in **`export_content`**, emits **measured slab thickness** from record bbox height, and binds **slabs/shading devices to storeys by top face** (`record_top_elevation`). Plan-loop floors are **cleared when `slabs` is non-empty** to avoid double-counting. > > **OctetProof / CI fixtures** widen the slim verdict surface to **`IFCSLAB` + `IFCSHADINGDEVICE`**, refresh witness observations, and document OctetProof **1.0.2** snapshot wording. Docs, support matrix, viewer status classes, and a research **`probe_slab_instance_rule`** example are updated accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 5069cdde4f31b810325c5523c8d93cff819ee434. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
… and emit the IFC4 opening chain (#222) (#226) ## The rule Past the 88-byte prologue and the 48-byte bounding box, at `+0x88`, every Revit 2024 partition element record carries a **counted reference list**: a `u32` length then that many `u64` slots. **The host wall is the slot immediately before the record's own ElementId.** Door ElementId 25947, `Partitions/46`: ```text +0x88 06 00 00 00 n = 6 +0x8c 03 00 00 00 00 00 00 00 3 +0x94 32 4f 00 00 00 00 00 00 20274 +0x9c cc 5c 00 00 00 00 00 00 23756 door type symbol (RE-21 §5) +0xa4 ed 5e 00 00 00 00 00 00 24301 door type symbol (RE-21 §5) +0xac 90 63 00 00 00 00 00 00 25488 ← host wall +0xb4 5b 65 00 00 00 00 00 00 25947 ← the record's own id ``` Window ElementId 20898 has the same framing with `n = 18`, its host at `+0x10c` and its own id at `+0x114`. The value is accepted only when it is one of the **360 ElementIds the RE-21 instance rule selects as exported walls**, so a wrong read fails closed instead of inventing a host. Both halves are required: the slot is where the byte says the host is, the wall-set membership is what makes the join self-checking. ## Evidence 138 door/window instances are framed by **273 records**. Scoring every record, not just the one the per-id selection keeps: | rule | correct | wrong | no value | |---|---:|---:|---:| | **slot before the record's own id** | **273** | **0** | 0 | | `u64 @ +0xac` (list index 4) | 186 | 87 | 0 | | `u64 @ +0xa4` (list index 3) | 81 | 192 | 0 | | last two slots are `(host, self)` | 192 | 81 | 0 | All three rejected candidates assume a shape the list does not have. The length varies — 6 on every door record, 18 on every window record, up to 101 elsewhere — and 81 door records continue past their own id with a trailing type-symbol slot (only `132750`, `132824`, `132825`, `132875` ever appear there, all `+0x42 == 0xffff8000` symbols RE-21 already excludes). The predecessor read applied to every category (instances only) shows what the rule is *not*: | category | records | predecessor is an exported wall | something else | |---|---:|---:|---:| | `OST_Doors` | 267 | **267** | 0 | | `OST_Windows` | 6 | **6** | 0 | | `OST_Walls` | 638 | 528 | 110 | | `OST_Columns` | 344 | 0 | 344 | | `OST_Floors` | 121 | 0 | 121 | 528 wall records also have a wall predecessor, so "the predecessor is a wall" is not a category discriminator — it is a fail-closed check on a value only the two categories RE-21 already identifies by `BuiltInCategory` are asked for. ## Pair-set agreement `rvt-ifc` emits the chain Revit itself emits — `IfcOpeningElement` (bodied with the door/window's own record bounding box, `Tag` repeating the filling element's, as the reference does on all 138) + `IfcRelVoidsElement` (wall → opening) + `IfcRelFillsElement` (opening → door/window). The `(host Tag, filling Tag)` pairs read back out with IfcOpenShell 0.8.5: | | rvt-rs | Revit export | |---|---:|---:| | `IFCRELFILLSELEMENT` pairs | 138 | 138 | | distinct pairs | 138 | 138 | | in the export, missing from rvt-rs | **0** | — | | in rvt-rs, absent from the export | **0** | — | **Exact set equality, no tolerance.** 132 doors + 6 windows across 92 distinct host walls (65 hold one opening, 8 hold two, 19 hold three). The export's other 63 `IfcOpeningElement` — 42 slab penetrations, 20 shading-device penetrations, 1 unfilled wall opening — are not recovered: rvt-rs emits no opening that is not filled by a recovered element. Entity counts are unchanged: `IFCWALL` 360, `IFCDOOR` 132, `IFCWINDOW` 6, `IFCCOLUMN` 256, `IFCSLAB` 80, `IFCSHADINGDEVICE` 20. `tools/ci/ifc_schema_arity.py` passes on the fresh export — **18 192 instances across 40 entity types**, `IfcOpeningElement` at its declared arity of 9 ending in `PredefinedType`, `IfcRelVoidsElement` and `IfcRelFillsElement` at 6. ## Two writer bugs the binding exposed Neither was reachable before, because no real-file door had ever carried a host. 1. **The host lookup sat in a dead branch.** `ifc::export_content` consulted `recover_door_host` / `recover_window_host` only in the `else` arm of the element-record geometry check, so every door with a record bounding box — which is every door recovered since #211 — skipped it. 2. **Void/fill resolution depended on emission order.** `ifc::step_writer` resolved `host_element_index` against `entity_index_to_el_id` *inside* the element loop, so a host emitted after its own opening silently dropped the whole chain. Both relationships are now emitted after the loop. ## OctetProof: a second field class Entity counts are a weak agreement — two witnesses can report the same 138 fill relationships while disagreeing about every wall those openings belong to. `relations` (spec **1.1.0**, §7.2 / §9.4 / §20.1) is the sorted multiset of `[host Tag, filling Tag]` pairs, compared as an **exact set with no tolerance concept**; a diff names the pairs each side holds alone (`only_in_a` / `only_in_b`, `tolerance_applied: false`). An identity a witness cannot read is the empty string, never an omitted pair. All three witnesses emit it with their own parser and no shared code: | witness | reader | |---|---| | `rvt-rs` (source) | splits its own emitted STEP; `IfcElement.Tag` is attribute 7 | | `ifcopenshell` (bridge) | `by_type(include_subtypes=False)` + attribute access | | `ifc-lite` (bridge) | `EntityScanner` + `parse_entity` + `decode_ifc_string` | The three `relations` payloads are **byte-identical** on the full-project artifact. `entity_counts` semantics are untouched; `relations` is its own top-level payload key with its own verdict field class. ### Verdicts ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 4 fields, excluded: 10, diffs: 0 magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 11 fields, excluded: 4, diffs: 0 ``` The slim claimed surface goes **10 → 11 fields**: ``` entity_counts.IFCWALL, entity_counts.IFCSLAB, entity_counts.IFCROOF, entity_counts.IFCDOOR, entity_counts.IFCWINDOW, entity_counts.IFCCOLUMN, entity_counts.IFCBEAM, entity_counts.IFCFLOWTERMINAL, entity_counts.IFCUNITASSIGNMENT, entity_counts.IFCSHADINGDEVICE, relations.IFCRELFILLSELEMENT ``` On `magnetar-2024-core-interior` the same relation is `decoder_baseline` and excluded first-class with `tracking_issue: 222` — its paired export is a 20 KB element fixture carrying **no** `IfcRelFillsElement` at all, so the two sides of that edge are not comparable on this field. Recorded rather than rounded off. ## Spec and schema changes - `docs/octetproof-spec.md` → **1.1.0**. §7.2 gains a *relation pair sets* row plus the normative paragraph; §9.4 gains the `relations` vocabulary term; §6.1 gains the manifest `relations` block reading; §6.2 gains the payload key; §16.3 notes all three emitters carry it; **§20** is the additive-release changelog, structured as subsections (§20.1 is this field class) so a further additive field class appends rather than renumbers. - `docs/schemas/witness-observation.schema.json`: `schema_version` becomes `enum ["1.0.0", "1.1.0"]` (1.0.0 observations stay valid, §16.2), `semantic_surface_covered` gains `relations`, and `observation.relations` is specified as an object of 2-element string-pair arrays. - `docs/schemas/witness-verdict.schema.json`: `semantic_surface` documents the `relations.<TYPE>` form and `diffs[]` gains `only_in_a` / `only_in_b`. - Both committed artifacts' observations and verdicts validate against the published schemas. ## Gates - `tests/iter_elements_typed.rs::core_interior_2024_door_window_host_wall_binding` — re-reads the reference export, follows its own void/fill chain, and requires exact pair-set equality. No embedded expectations to drift. - `relations.IFCRELFILLSELEMENT` inside the slim OctetProof surface. - `tests/project_count_fixtures.rs` — manifest `relations` shape plus source and decoder pair counts. - `cargo test --profile ci --test witness_verdict --test witness_registry --test project_count_fixtures --test support_matrix` green with `RVT_PROJECT_CORPUS_DIR` set; the seven #209 tier-2 targets green; `cargo +1.85.0 check --all-targets` clean (workspace MSRV); `cargo clippy --all-targets -- -D warnings` clean for the workspace and for the out-of-workspace ifc-lite witness; `tools/check-local.sh --ifcopenshell` passes. ## Support matrix New **verified** row `element-record-door-window-host-binding`, scoped to two `BuiltInCategory` ids, one release band and one recorded edge, on the gated exact match. `typed-door-window` stays **unsupported** and is narrowed to what RE-19 actually leaves open — the `ArcWallRectOpening` index still carries no Door/Window discriminator and no host claim — exactly as RE-21 handled the instance half. Evidence: `reports/element-framing/RE-23-door-window-host-binding.md` Closes #222 https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes real-file IFC topology (openings/voids) and bumps the verification protocol; risk is mitigated by exact pair-set gates and three-way witness replay, but regressions would affect export semantics and CI verdicts. > > **Overview** > Recovered Revit 2024 doors and windows now bind to host walls by reading the partition element record’s counted reference list at `+0x88` (host = slot before the record’s own ElementId), accepted only when that id is in the recovered wall instance set. IFC export emits Revit’s **IfcOpeningElement** / **IfcRelVoidsElement** / **IfcRelFillsElement** chain for all 138 openings, with opening `Tag` matching the fill element. > > Two export bugs are fixed: host recovery no longer sits behind the element-record geometry branch, and void/fill relationships are written after the element loop so host index resolution is complete. > > **OctetProof 1.1.0** adds cross-witness **`relations`** — exact multiset equality on `[host Tag, filling Tag]` pairs for `IFCRELFILLSELEMENT` — with schema/manifest/verdict updates, all three witnesses emitting it, and the slim artifact claimed surface growing to 11 fields. Docs, support matrix, RE-23 report, corpus gates, and committed witness JSON are refreshed; `door_window_host_wall_binding` is removed from unsupported features. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1dc396944c1900bbdb00bd203148b0bb01d4fb6f. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
…partition Level records (#218) (RE-24) (#230) ## The Levels are elements #213 derived storey elevations from the bounding-box distribution of the recovered column records: 11 of the export's 15, with no names, because a rank join of 12 name candidates onto 11 elevations mislabels — it puts `Level 6` at 91 ft where Revit puts `Level 7`. The four it missed (−40, −20, 15, 185.5 ft) carry no column record, so no distribution over column bases can ever contain them. The Levels are in the file as elements. A Revit `Level` has a `BuiltInCategory` (`OST_Levels`, −2000240), so it is framed like one. ### The record: an element prologue with no bounding box Scanning the eight partition streams for the 8-byte LE encoding of −2000240 finds **190** hits; `partition_element_records::decode_at` accepts **zero**. The prologue is not the problem — on `Partitions/46 +228578`: ```text +0x00 87 3c 01 00 00 00 00 00 ElementId 81031, declared in Global/ElemTable +0x08 8f 00 00 00 flags +0x0c 9f 05 00 00 0x0000059f, as on every element record +0x10 00 00 0 +0x12 90 7a e1 ff ff ff ff ff BuiltInCategory −2000240 = OST_Levels +0x1a ff × 24 sentinel padding +0x32 85 3c 01 00 00 00 00 00 container ElementId 81029 +0x3a ff × 8 sentinel +0x42 7f ef ff ff placement kind, PLACED +0x46 0a 00 00 00 unattributed +0x4a 76 09 unattributed +0x4c 00 00 00 00 0 (0xffffffff on a bbox-bearing record) +0x50 ff ff ff ff ab 05 record marker +0x56 03 00 record kind ``` The divergence is at `+0x4c`. A bbox-bearing record carries `ff ff ff ff` there, `46 01` at `+0x50`, `ff ff ff ff ab 05` at `+0x52` and 48 bbox bytes at `+0x58`. A Level record carries `00 00 00 00` at `+0x4c` and the same six marker bytes two bytes earlier, then a `u16`, then the next record — 151 bytes apart. A datum plane is not a solid, so it has no bounding box, so the reader that requires one at `+0x50` rejects it. `src/partition_level_records.rs` is that reader with the bbox requirement replaced by the six-byte marker; nothing else about the prologue changes. 75 records carry `OST_Levels`. Which of them is a *Level element* is the #211 instance test, unchanged: | selection | n | |---|---:| | `OST_Levels` records total | 75 | | container member (`+0x32` set) | 59 | | type / symbol envelope (`+0x42` = `0xffff8000`) | 1 (ElementId 1673) | | **standalone placed instance** | **15** | ### The name / elevation block Framed the way RE-22 framed the per-instance `IFC Export As` override — an owning `ElementId` at a fixed negative offset from the value: ```text V-0x47 u64 owning ElementId V-0x3f 56B 0xff sentinel run V-0x07 3B 0x00 V-0x04 u32 name length, UTF-16 code units V 2n the name, UTF-16LE … variable-length parameter run M 8B 05 00 00 00 48 02 00 00 M+55 f64 elevation, feet M+208 f64 the same elevation again ``` Two things were found the hard way: - **The gap between the name and the marker is not fixed** — 347 bytes for fourteen levels, **363** for `Basement 2`, whose block carries one extra entry. A fixed `name_end + 402` offset read `0.0` there, a plausible elevation that would have shipped a wrong storey. The marker is searched forward within 2048 bytes and the copy at `+153` must agree bit-for-bit. - **The owner slot is the discriminator, not the name.** `Level 3 - Wall Layouts 1` appears nine times in `Partitions/46`; at `+21322916` it is paired with **46.0 ft** and at `+21323710` `Level 4 - Wall Layouts 2` with **61.0**. Every wrong pair is owned by an `OST_Levels` record that is a container member (31636, 31637, 33628, 33629, 21990, …) — exactly what the #211 test already excludes. Filtering to the 15 standalone Level ids leaves 15 blocks in the whole file. The scan itself walks maximal `0xff` runs, requires the owner to be declared in `Global/ElemTable` and requires the two elevation copies to agree. A run of exactly 56 is required, which the owner's own encoding guarantees can only start where the framing says (an `ElementId` is a `u32`, so its high four bytes are zero). ## 15 / 15, names and elevations | ElementId | recovered name | recovered elevation (ft) | export `Name` | export `Elevation` | | |---:|---|---:|---|---:|:-:| | 20273 | `Basement 2` | −40 | `Basement 2` | −40. | ✓ | | 20272 | `Basement 1` | −20 | `Basement 1` | −20. | ✓ | | 20268 | `Level 1` | 0 | `Level 1` | 0. | ✓ | | 20275 | `Mez 1-2` | 15 | `Mez 1-2` | 15. | ✓ | | 20274 | `Level 3 - Wall Layouts 1` | 31 | `Level 3 - Wall Layouts 1` | 31. | ✓ | | 20276 | `Level 4 - Wall Layouts 2` | 46 | `Level 4 - Wall Layouts 2` | 46. | ✓ | | 20277 | `Level 4 - Wall Layouts 3` | 61 | `Level 4 - Wall Layouts 3` | 61. | ✓ | | 20308 | `Level 6` | 76 | `Level 6` | 76. | ✓ | | 20307 | `Level 7` | 91 | `Level 7` | 91. | ✓ | | 20306 | `Level 8` | 106 | `Level 8` | 106. | ✓ | | 20305 | `Level 9` | 121 | `Level 9` | 121. | ✓ | | 20304 | `Level 10` | 136 | `Level 10` | 136. | ✓ | | 20303 | `Level 11` | 151 | `Level 11` | 151. | ✓ | | 20302 | `Level 12` | 166 | `Level 12` | 166. | ✓ | | 65128 | `Level 13` | 185.5 | `Level 13` | 185.5 | ✓ | No wrong pair, no missing storey, no extra storey — on **both** reference exports, which carry the same 15 `IfcBuildingStorey`. Note the ElementId order and the elevation order do not agree (65128 is the top level, 20302…20308 run *downwards*), so a rank join on ids would have been as wrong as the rank join on names #213 rejected. The pairing survives because the file states it. Recovery is all-or-nothing per file: a Level with no accepted block emits nothing, and the whole set is discarded unless every Level record owns exactly one block and no two levels share an elevation. `element_record_storeys` survives as the fallback. ## Binding, before and after Containment logic is untouched — exact elevation match, plates by their record top face, fail-closed on a miss and on an ambiguity. Only the storey set is wider. | | 11 storeys (#213) | 15 storeys (RE-24) | |---|---:|---:| | `IFCCOLUMN` | 256 / 256 | 256 / 256 | | `IFCDOOR` | 132 / 132 | 132 / 132 | | `IFCWALL` | 355 / 360 | **359 / 360** | | `IFCSLAB` | 41 / 80 | **44 / 80** | | `IFCSHADINGDEVICE` | 10 / 20 | 10 / 20 | | `IFCWINDOW` | 0 / 6 | 0 / 6 | | `IFCSPACE` | 0 / 18 | 0 / 18 | | **total bound** | **794 / 872** | **801 / 872** | Two #219 expectations did **not** hold, and the numbers say so rather than the prose: - **The 6 windows still bind to nothing.** Never an elevation-set problem: a window record's base is its *sill height* (80.73, 95.73, … ft), which RE-21 already measured at 0 of 6. Binding a window needs its host level, not more elevations. - **46 of the 49 unbound plates stay unbound** (36 `IFCSLAB` + all 10 unbound `IFCSHADINGDEVICE`); three bind. RE-22 measured why: they sit 0.1667 ft below their level, at the structural-slab / architectural-topping interface. That is #219's real content — a thickness question. ## Cross-witness surface `levels` moves from `decoder_baseline` to `known` at tolerance 0 on both manifests (`diagnostics.exported.storey_count` = 15, both references carry 15 `IfcBuildingStorey`). A count is a weak claim, so the pair set is gated too, as OctetProof 1.1.0's second additive field class (`storeys`, spec §20.2 — a separate top-level payload key and a separate verdict field class from #222's `relations`). One complication is real: **the two sides declare different length units.** Revit's export of this imperial project declares `FOOT` as an `IfcConversionBasedUnit` over `METRE` and writes `-40.`; rvt-rs declares `METRE` and writes `-12.192000`. Both are faithful; the raw numbers differ by 3.28. So each witness resolves its *own* file's `LENGTHUNIT` before emitting and renders feet at 1e-6 as a fixed six-decimal string (a string, not a number, so §7.3's canonical form stays integer/string only): | witness | reads | unit resolution | |---|---|---| | `rvt-rs` | its own emitted STEP | walks `IfcProject` → `IfcUnitAssignment` itself | | IfcOpenShell 0.8.5 | Revit's `.ifc` | `ifcopenshell.util.unit.calculate_unit_scale` | | IFClite 7.1.1 | Revit's `.ifc` | `ifc_lite_core::extract_length_unit_scale` | All three payloads are byte-identical on both artifacts. ### Verdicts ``` magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 6 fields, excluded: 10, diffs: 0 magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 13 fields, excluded: 3, diffs: 0 ``` Claimed surface, slim (11 → 13): `entity_counts.IFCBUILDINGSTOREY`, `…IFCWALL`, `…IFCSLAB`, `…IFCROOF`, `…IFCDOOR`, `…IFCWINDOW`, `…IFCCOLUMN`, `…IFCBEAM`, `…IFCFLOWTERMINAL`, `…IFCUNITASSIGNMENT`, `…IFCSHADINGDEVICE`, `relations.IFCRELFILLSELEMENT`, **`storeys.IFCBUILDINGSTOREY`**. Element fixture (4 → 6): `entity_counts.IFCBUILDINGSTOREY`, `…IFCROOF`, `…IFCBEAM`, `…IFCFLOWTERMINAL`, `…IFCUNITASSIGNMENT`, **`storeys.IFCBUILDINGSTOREY`**. Unusually for this corpus the thin 20 KB fixture supports the field as strongly as the 19879-entity export: Revit writes the complete fifteen-storey hierarchy into an export carrying one building element. Storey payload, identical across all three witnesses: ```json "storeys": { "IFCBUILDINGSTOREY": [ ["Basement 1", "-20.000000"], ["Basement 2", "-40.000000"], ["Level 1", "0.000000"], ["Level 10", "136.000000"], ["Level 11", "151.000000"], ["Level 12", "166.000000"], ["Level 13", "185.500000"], ["Level 3 - Wall Layouts 1", "31.000000"], ["Level 4 - Wall Layouts 2", "46.000000"], ["Level 4 - Wall Layouts 3", "61.000000"], ["Level 6", "76.000000"], ["Level 7", "91.000000"], ["Level 8", "106.000000"], ["Level 9", "121.000000"], ["Mez 1-2", "15.000000"] ] } ``` ## Spec / schema changes (1.1.0 additive, §20.2) - **§7.2** — new field class *storey sets*: exact equality of the sorted set of (name, elevation rounded to 1e-6 ft), no tolerance concept. Documents the unit normalization, why the elevation is a string, and why Unicode normalization is deliberately **not** applied to the name (three runtimes, three Unicode tables — a normalizer that disagrees between them would launder a real difference into agreement; the strict direction is correct for a gate). - **§9.4** — `storeys` joins the coverage vocabulary next to `relations`. - **§6.1** — manifests gain a `storeys` block parallel to `counts` and `relations`. - **§6.2** — the observation payload gains an optional `storeys` object under its own top-level key. - **§20.2** — the release note for the field class. - `docs/schemas/witness-observation.schema.json` — `storeys` in the surface enum and in the payload; `docs/schemas/witness-verdict.schema.json` — `only_in_a` / `only_in_b` re-described as covering both set-valued field classes. Merged `origin/main` (#226) first and kept both fields in every emitter: `relations` and `storeys` are separate top-level payload keys and separate verdict field classes. ## Gates - `cargo fmt --all`, `cargo clippy --all-targets -- -D warnings`, `cargo clippy` on the out-of-workspace `witness-ifc-lite` — all clean. - `cargo +1.85.0 check --all-targets` — clean (MSRV). - `cargo test --profile ci --test witness_verdict --test witness_registry --test project_count_fixtures --test support_matrix` with `RVT_PROJECT_CORPUS_DIR` — 2 / 3 / 4 / 2 passed. - Tier-two decoder gates (#209): `elem_table_corpus`, `arc_wall_corpus`, `partition_scanner`, `iter_elements_typed`, `re15_geometry_invariants`, `re19_door_window_wall_negative`, `walker_to_ifc_integration` — all green. - `tools/ci/ifc_schema_arity.py` on a fresh export — passed, 18209 instances across 40 entity types; `IfcBuildingStorey` at its declared arity of **10** with `Elevation` as `IfcLengthMeasure` (REAL). - `tools/check-local.sh --ifcopenshell` — passed. - All six observations and both verdicts regenerated; both verdicts `PASS`. Closes #218 Refs #219 https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core IFC spatial hierarchy and cross-witness CI gates on golden artifacts; logic is fail-closed and heavily tested, but binary layout decoding is Revit 2024–specific and affects many emitted entities. > > **Overview** > **Revit 2024 IFC export now uses real Level names and elevations** from partition `OST_Levels` records instead of the eleven column-bbox-derived storeys with placeholder labels (#213). New `partition_level_records` decodes Level prologues (no bbox), joins name/elevation parameter blocks by ElementId, and **fails closed** unless all 15 standalone levels recover uniquely; `apply_partition_level_storeys` replaces the storey list in the IFC path, with column-derived storeys kept as fallback. > > **OctetProof 1.1.0 gains `storeys`**: witnesses compare exact sorted `[name, elevation-in-feet]` sets with per-file `LENGTHUNIT` normalization (FOOT vs METRE). `rvt-ifc --observation`, IfcOpenShell, IFClite, `witness-verdict.py`, schemas, manifests, and golden observations/verdicts are updated; **`levels` / `IFCBUILDINGSTOREY` move to `known` at 15** on both magnetar artifacts (verdicts stay `PASS`). Wider storey set improves elevation containment binding (**801 / 872** elements vs 794). > > Docs (`CHANGELOG`, `status.md`, support matrix, RE-24 report) and CI fixture validation for manifest `storeys` blocks accompany the decoder change. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 99b2a7dddce9d630a6ddaf30c20f13a06d987471. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
…s from OST_SketchLines records (#31) (RE-25) (#231) RE-22 (#225) recovered all 80 exported `IFCSLAB` by ElementId and closed the thickness half of #31, leaving one sentence open: *"The profile is still the bbox rectangle, not the recovered floor boundary polygon: `ProfileResolved` stays false."* This closes it, exactly, for all 80. Report: `reports/element-framing/RE-25-slab-plan-profiles.md`. ## Where the profile is not The plan-loop scanner is a measured dead end. Inventoried over all eight inflated `Partitions/*` streams with the shipped constants (4–8 points, span ≥ 5 ft, closure ≤ 0.05 ft): **2317** closed plan-polyline candidates — 2310 of 4 points, 4 of 5, 3 of 6 — and **zero** with the plan bounds of any of the 100 record-backed plates. The perimeter profile needs 26 vertices. Searching all 187 MiB of inflated partitions for the export's polygon as a packed run of `(x, y)` doubles — in the project frame, in the export's own profile frame, at strides of 2/3/4/5/6/8 doubles — finds no ordered vertex run at all. Revit does not store this boundary as a polyline. ## The join rule, and its evidence **Each boundary line of a Revit sketch is its own partition element record.** `BuiltInCategory` `OST_SketchLines` = **-2000045** (Autodesk's published constant; the bytes are `53 7b e1 ff ff ff ff ff` in the same signed `i64` slot at `+0x12` that RE-21 documented). These decode through the *unmodified* RE-21 header — declared ElementId at `+0x00`, `0x059f` at `+0x0c`, the fixed bbox marker at `+0x50`, the box at `+0x58` — and the box **is** the segment: the boundary line at `x = 136.5, y = 115 … 123` is recorded as `136.5, 115 – 136.5, 123`, degenerate in `x`. RE-23 read the *first* counted list at `+0x88`. A **second** list is framed identically right after it, and its last slot names the sketched element: ```text +0x88 u32 n1 = 5 +0x8c 5×u64 20309, 20310, 20312, 20313, 20315 (sibling sketch lines) +0xb4 u32 n2 = 2 +0xb8 2×u64 20308, 20311 ← 20311 is the slab ``` Measured over all 3688 `OST_SketchLines` records on `2024_Core_Interior.rvt` (`Partitions/46` 3070, `/51` 570, `/55` 48; 3070 distinct ids; **0** frames of one id disagreeing on box or owner): | owners named by the second list's last slot | count | |---|---:| | exported `IFCSLAB` ElementIds | **80 / 80** | | exported `IFCSHADINGDEVICE` ElementIds | **20 / 20** | | other elements (walls, the superseded container twin 16925, …) | 26 | | **distinct owners** | **126** | **The join is by ElementId only — no geometry, no proximity, no containment.** A sketch line belongs to the element the byte names, or to nothing. Geometric containment was used once, as a check, and is not the rule: the recovered profile's plan bounds are asserted equal to the record's own plan box in the corpus gate. ## Reconstruction: closure, not fitting A box is not a segment when the segment is diagonal, and 37 of the 1454 plate segments carry a box *looser* than the line (the top boundary of every rectangular plate is recorded `20,113 – 167,115` for a line the export puts at `y = 114`). Both are resolved by the loop, never by the reference export: 1. Every segment degenerate on exactly one axis contributes its endpoints. 2. Every remaining segment is placed only when exactly **one** pair of still-open vertices fits its box — corner pairs (the box's own diagonals) first, and only when no corner pair is open, a pair that spans the box lengthwise and is degenerate across it. 3. An ambiguous segment, a vertex that does not finish at degree 2, an unused edge, a zero-extent box or a loop under three vertices rejects the **whole element**. There is no partial or best-effort profile. Collinear vertices are then merged — Revit splits the ring's north-east run at `x = 167`, so the raw chain has 27 outer segments where the export has 26 edges. ## Profile agreement Recovered profile vs the reference export's `IfcExtrudedAreaSolid` swept areas (`IFC Exports/2024_Core_Interior_slim.ifc`, sha256 `bfdf36ff…`, read with IfcOpenShell 0.8.5), both reduced to the project plan frame, compared as cyclic vertex sequences with orientation normalised, tolerance 1e-3 ft per vertex: | slabs | recovered | export swept area | outer verts | voids | segments | exact | near | miss | |---:|---|---|---:|---:|---:|---:|---:|---:| | 42 | outer ring + 1 void | `IfcArbitraryProfileDefWithVoids` | 26 | 1 (4 verts) | 31 | **42** | 0 | 0 | | 38 | single loop | `IfcArbitraryClosedProfileDef` | 4 | 0 | 4 | **38** | 0 | 0 | | **80** | | | | | | **80** | **0** | **0** | 122 loops compared (80 outer + 42 inner). **Worst vertex deviation 1.563e-12 ft** — the recovered vertices are the same doubles as the export's, differing only in the floating dust of Revit's own transform (`177.00000000000011` for a nominal 177 ft, which the record box and the export's profile carry identically). Re-measured on the emitted IFC after the metre round-trip: 0 mismatches, worst deviation **2.842e-14 ft**. No frame alignment was needed — the 2024 project frame and the export frame coincide. Before this, all 80 were rectangles: accidentally exact on the 38 whose profile *is* the box, and filling a courtyard on the 42 perimeter rings. **The 20 exported `IFCSHADINGDEVICE` are declined, with the reason.** The same join names all 20; each carries 57 sketch lines — 1 with a zero-extent box, 35 axis-parallel, 21 diagonal. The first zero-extent box rejects them outright, and the export writes each as a 29-vertex rotated ring (`0 … 182.3333` by `8.6936 … 130.3064`) with no axis-parallel anchor to force a first choice. They keep the record box rectangle and `ProfileResolved: false`. Five further owners are declined the same way (16925 — the container-member twin of 20953 already excluded by RE-21 — plus 31636, 31637, 34362, 55840). Twenty-one non-plate owners do close and are recovered but not emitted; nothing here maps them to an IFC entity. ## Verdict outputs — unchanged ```text magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 6 fields, excluded: 10, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs surface: 13 fields, excluded: 3, diffs: 0 replay ifc-lite: match / ifcopenshell: match / rvt-rs: match ``` Both committed `verdict.json` files are **byte-identical**. The two committed `rvt-rs` observations were regenerated because the observation payload counts *every* emitted entity type; the four bridge-witness observations are byte-identical. Building-element counts and the diagnostics sidecar are unchanged, and the sidecar is byte-identical to `main` (9ce43f7): | entity | before | after | |---|---:|---:| | `IFCRECTANGLEPROFILEDEF` | 992 | 912 | | `IFCARBITRARYCLOSEDPROFILEDEF` | 0 | 38 | | `IFCARBITRARYPROFILEDEFWITHVOIDS` | 0 | 42 | | `IFCPOLYLINE` | 0 | 122 | | `IFCCARTESIANPOINT` | 1847 | 3381 | | `IFCPROPERTYSINGLEVALUE` | 5371 | 5611 | | total instances | 18209 | 20105 | | `IFCSLAB` / `IFCSHADINGDEVICE` / `IFCWALL` / `IFCDOOR` / `IFCWINDOW` / `IFCCOLUMN` | 80 / 20 / 360 / 132 / 6 / 256 | unchanged | | `IFCBUILDINGSTOREY` | 15 | 15 | | `storey_bound_elements` | 801 | 801 | ## Gates run `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets --all-features -- -D warnings`, `RUSTDOCFLAGS=-D warnings cargo doc --no-deps --lib`, `cargo +1.85.0 check --all-targets` (MSRV, no let-chains), `cargo test --workspace --all-targets --all-features` with `RVT_PROJECT_CORPUS_DIR` + `RVT_CORPUS_TIER1_DIR` (152 test binaries ok), the four named targets (`witness_verdict`, `witness_registry`, `project_count_fixtures`, `support_matrix`), the seven #209 tier-2 targets, `tools/ci/ifc_schema_arity.py` on a fresh export (20 105 instances across 43 entity types; `IfcArbitraryClosedProfileDef` at its declared arity of 3, `IfcArbitraryProfileDefWithVoids` at 4, `IfcPolyline` at 1), and `tools/check-local.sh --ifcopenshell`. New gates: `tests/iter_elements_typed.rs::core_interior_2024_slab_plan_profiles` (the 100 record-backed plates partition exactly — 80 resolve a profile, and the 20 that do not are exactly the export's `IFCSHADINGDEVICE` `Tag` set; 42 × (26 outer, 1 void), 38 × (4 outer, 0 voids); each profile's plan bounds equal the record's own plan box) and 15 unit gates in `src/element_record_plan_profiles.rs`. ## Support-matrix status New row `element-record-slab-plan-profile` at **`partial`**, not `verified`: the agreement is measured and regression-gated, but profile geometry is not a field of either OctetProof claimed surface — no witness compares it — so it has not met the two-independent-witnesses bar in `docs/verification-protocol.md`. ## Follow-ups - **The 20 shading devices.** Sketch present and joined; only the closure declines. Resolving 21 mutually constraining diagonal boxes needs either a second carrier for the segment endpoints or a global search with a uniqueness proof. - **`IfcExtrudedAreaSolid.Position` is the element's own `IfcAxis2Placement3D`**, which is also the `IfcLocalPlacement`'s relative placement, so a consumer composing both applies the element translation twice. This predates RE-25 and affects every emitted element on every release; the profile is expressed in the same element-local frame the rectangle profile always used, so nothing regressed. Needs its own issue. - **Walls, doors, windows, columns** still carry the record box. Wall sketches are not `OST_SketchLines`; the 26 non-plate owners here are a hint of what else is sketched, not a claim. - **#227** is untouched. Note that the perimeter ring's void is *profile* geometry, not an opening element, so the 42 slab penetrations #227 asks for are a different set. Refs #31 #227 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches partition decoding, geometry reconstruction, and IFC STEP emission for all record-backed slabs; scope is gated to Revit 2024 and fail-closed closure, but wrong profile logic would change exported solid geometry without shifting entity counts. > > **Overview** > **Slab IFC geometry now uses recovered sketch boundaries instead of bounding-box rectangles** for Revit 2024 partition-backed floors where sketch lines close unambiguously (#31 / RE-25). > > The change reads **`OST_SketchLines`** element records, joins each segment to its owner slab via the **last slot of the second reference list** at `+0x88` (`owner_reference`), and **chains segment bounding boxes into closed loops** (fail-closed on ambiguity). Those polygons flow through **`partition_schema_mvp::slabs_from_partition_category_records`** (single multi-category partition scan) into decoded fields, then **`ifc::export_content`** emits **`IfcArbitraryClosedProfileDef`** or **`IfcArbitraryProfileDefWithVoids`** with **`ProfileResolved: true`** and related diagnostics. **`scan_category_records_multi`** avoids re-inflating partitions when floors, pads, and sketch lines are needed together. > > On the Core Interior corpus this matches **80/80** reference slab profiles (including courtyard voids); **20 shading devices** still use the record box because closure rejects their diagonal sketch envelopes. Docs, support matrix, changelog, corpus tests (`core_interior_2024_slab_plan_profiles`), a research probe, and witness **entity-count** observations reflect the richer IFC profile chain while **building-element counts and OctetProof verdicts stay unchanged**. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d08c80c6aa7d4629b9538cda5a242ad8cfbb78b7. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
DrunkOnJava
added a commit
that referenced
this pull request
Aug 31, 2026
…on PredefinedType (#236) Two conformance fixes to the IFC4 writer, both measured against Revit's own export of the same project. Corpus: `.rvt` sha256 `c805df445d613b408e37337765572021265e3f5dfdc7d1fa53b22ba1600b8014`, slim IFC sha256 `bfdf36ffb0bb768f3409d818403990e64d4c262c6780603be87f8077387ad86d`. ## #232 — every element was placed twice The writer emitted the element's own `IfcAxis2Placement3D` in **both** the `IfcLocalPlacement`'s `RelativePlacement` and the swept solid's `Position`. IFC4 has a conforming consumer compose `ObjectPlacement × Position`, so the element translation was applied twice. Viewers that ignore `Position` drew the file correctly, which is exactly why it shipped on every release: two tools could disagree about the same bytes with neither of them misreading. ### The Position decision, and the export's evidence Read with IfcOpenShell 0.8.5 on `2024_Core_Interior_slim.ifc`, Revit's own exporter is consistent about one thing — **the element translation appears exactly once** — and splits it two different ways depending on the frame the profile is authored in: | Revit entity | `ObjectPlacement.RelativePlacement.Location` | `IfcExtrudedAreaSolid.Position.Location` | |---|---|---| | `IfcWall` #2240 (`SweptSolid` body) | `(48.0, 57.667, 0.0)` | `(0.0, 0.0, 0.0)` — identity | | `IfcSlab` #1590 | `(0.0, 0.0, 0.0)` — identity | `(90.444, 71.185, -0.167)` | | `IfcSlab` #1619 | `(0.0, 0.0, 0.0)` — identity | `(93.5, 69.5, 0.0)` | | `IfcSpace` #186 | `(0.0, 0.0, 0.0)` — identity | `(51.694, 69.556, 0.0)` | Never both. Revit's walls put the location in the placement and leave `Position` at identity because the wall profile is authored in the element-local frame; its slabs and spaces do the mirror image because those profiles are authored in storey coordinates. rvt-rs authors **every** profile in the element-local frame — the rectangle always did, and the plan profile recovered in #231 uses the same frame — and it already carries the location on the element's own `IfcLocalPlacement`. So the correct half of Revit's own convention is the `IfcWall` row: **`Position` becomes the project-level identity placement**, and the placement carries the translation once. That is what this PR does. No entity is added or removed — the per-element axis is still emitted, the solid just stops pointing at it. The representation-map path is deliberately left alone, with a comment saying why: a mapped item resolves as `MappingTarget × MappingOrigin⁻¹ × geometry`, so a `Position` equal to the `MappingOrigin` cancels against the inverse instead of compounding, and `origin_feet` is `[0,0,0]` on every map rvt-rs builds today anyway. ### World-coordinate verification IfcOpenShell geometry iterator, `use-world-coords`, matched by `Tag` against the Revit export, deltas in feet. **BEFORE** | Class | shared Tags | max centroid delta | max min-vertex delta | Tags within 1e-3 ft | |---|---:|---:|---:|---:| | IfcColumn | 256 | 166.0000 ft | 166.0000 ft | 0/256 | | IfcSlab | 80 | 185.3333 ft | 185.3333 ft | 0/80 | | IfcWall | 360 | 170.2500 ft | 166.2500 ft | 0/360 | | IfcDoor | 132 | 166.0748 ft | 166.0000 ft | 0/132 | | IfcWindow | 6 | 157.1805 ft | 155.7300 ft | 0/6 | | Class | Tag | rvt-rs world centroid (ft) | Revit world centroid (ft) | delta (ft) | |---|---|---|---|---| | IfcColumn | 20375 | (48.0000, 220.0000, 159.1667) | (23.8750, 110.0000, 81.5833) | (24.1250, 110.0000, 77.5833) | | IfcColumn | 20376 | (98.0000, 220.0000, 159.1667) | (49.1250, 110.0000, 81.5833) | (48.8750, 110.0000, 77.5833) | | IfcSlab | 20311 | (181.3000, 139.0000, 151.7500) | (88.3000, 69.5000, 75.9167) | (93.0000, 69.5000, 75.8333) | | IfcSlab | 20345 | (187.0000, 139.0000, 151.7500) | (93.5000, 69.5000, 75.9167) | (93.5000, 69.5000, 75.8333) | | IfcWall | 20796 | (122.7500, 162.0000, 159.5000) | (60.1042, 81.0000, 81.7500) | (62.6458, 81.0000, 77.7500) | | IfcWall | 20797 | (96.0000, 138.7500, 159.5000) | (48.0000, 69.1667, 83.5000) | (48.0000, 69.5833, 76.0000) | | IfcDoor | 20810 | (194.0874, 118.9189, 156.1247) | (97.0437, 58.0499, 80.0499) | (97.0437, 60.8689, 76.0748) | | IfcWindow | 20898 | (65.4902, 172.2757, 165.9056) | (30.8441, 86.1378, 83.7251) | (34.6460, 86.1378, 82.1805) | The doubling reads straight off the table: the rvt-rs value is 2× Revit's wherever the element's own frame is the whole story — slab 20345 at `(187.0, 139.0)` against `(93.5, 69.5)`, column 20375 at `220.0` against `110.0`. **AFTER** | Class | shared Tags | max centroid delta | max min-vertex delta | Tags within 1e-3 ft | |---|---:|---:|---:|---:| | IfcColumn | 256 | 1.5833 ft | 0.3333 ft | 107/256 | | IfcSlab | 80 | 0.2083 ft | **0.0000 ft** | 79/80 | | IfcWall | 360 | 2.5336 ft | 0.7500 ft | 78/360 | | IfcDoor | 132 | 1.5095 ft | 3.0022 ft | 0/132 | | IfcWindow | 6 | 1.9010 ft | 0.8012 ft | 0/6 | | Class | Tag | rvt-rs world centroid (ft) | Revit world centroid (ft) | delta (ft) | |---|---|---|---|---| | IfcColumn | 20375 | (24.0000, 110.0000, 83.1667) | (23.8750, 110.0000, 81.5833) | (0.1250, -0.0000, 1.5833) | | IfcColumn | 20376 | (49.0000, 110.0000, 83.1667) | (49.1250, 110.0000, 81.5833) | (-0.1250, 0.0000, 1.5833) | | IfcSlab | 20311 | (88.3000, 69.5000, 75.9167) | (88.3000, 69.5000, 75.9167) | (-0.0000, 0.0000, 0.0000) | | IfcSlab | 20345 | (93.5000, 69.5000, 75.9167) | (93.5000, 69.5000, 75.9167) | (-0.0000, 0.0000, 0.0000) | | IfcWall | 20796 | (60.1875, 81.0000, 81.8123) | (60.1042, 81.0000, 81.7500) | (0.0833, 0.0000, 0.0623) | | IfcWall | 20797 | (48.0000, 69.3750, 83.5000) | (48.0000, 69.1667, 83.5000) | (0.0000, 0.2083, 0.0000) | | IfcDoor | 20810 | (97.0437, 59.4594, 80.1247) | (97.0437, 58.0499, 80.0499) | (-0.0000, 1.4095, 0.0748) | | IfcWindow | 20898 | (32.7451, 86.1378, 85.1756) | (30.8441, 86.1378, 83.7251) | (1.9010, -0.0000, 1.4505) | **All 80 slabs now agree with Revit's export on every world-space vertex to 0.0000 ft.** That is the class where rvt-rs recovers a real plan profile (#231), so it is the class where a placement fix can be checked at full precision, and it is exact. The residuals that remain elsewhere are **geometry recovery fidelity, not placement composition**, and each is an existing tracked gap: columns sit 0.125 ft off in plan and 1.58 ft off in Z (insertion point and base elevation), walls up to 2.53 ft on location-curve-derived bodies, and doors and windows carry the record's bounding-box envelope rather than a panel (#86, #82). None of them scales with the element's distance from the origin any more, which is the signature the doubling had. ### The gate `tools/ci/ifc_schema_arity.py` closes the class two ways, both fail-closed: 1. **Structural invariant, every file, every product** — a swept solid's `Position` may not be the very `IfcAxis2Placement3D` instance its product's `IfcLocalPlacement` already uses as `RelativePlacement`. Run against the pre-fix export it produces 992 findings, first one: `#216 IfcColumn reuses #207 as both its ObjectPlacement's RelativePlacement and its IfcExtrudedAreaSolid.Position`. 2. **Pinned composition** — for five elements the gate computes `ObjectPlacement × Position × first-profile-point` explicitly (`ifcopenshell.util.placement`, no geometry kernel) and compares against a pinned coordinate at 1e-6. Two are in `synthetic-project.ifc`, one in `synthetic-structural.ifc` and two are the recorded artifact's column `20375` and slab `20345`, so the probe fires in the fixture-only CI step *and* on the real export. A file that does not hold the Tag skips the probe rather than failing. ## #220 — PredefinedType follows the authoring witness The issue's suggested rule is adopted: where a recorded edge shows the witness's choice, take it. Agreement with the export is what the OctetProof verdicts score, and a value the witness demonstrably wrote is a recorded observation, not an invention. ### Per-type agreement, measured with IfcOpenShell | Entity | Revit's export writes | rvt-rs before | rvt-rs after | rvt-rs count | agreement | |---|---|---|---|---:|---| | IfcWall | `.NOTDEFINED.` ×360 | `.STANDARD.` | `.NOTDEFINED.` | 360 | 360/360 exact | | IfcSpace | `.SPACE.` ×116 | `.INTERNAL.` | `.SPACE.` | 18 | 18/18 exact (recall gap tracked separately) | | IfcDoor | `.DOOR.` ×132 | `$` | `.DOOR.` | 132 | 132/132 exact | | IfcWindow | `.WINDOW.` ×6 | `$` | `.WINDOW.` | 6 | 6/6 exact | | IfcColumn | `.COLUMN.` ×256 | `.COLUMN.` | `.COLUMN.` | 256 | 256/256 exact (unchanged) | | IfcSlab | `.FLOOR.` ×78, `.ROOF.` ×2 | `.FLOOR.` | `.FLOOR.` | 80 | inside the witness's value set (unchanged) | | IfcShadingDevice | `.NOTDEFINED.` ×20 | `$` | `$` | 20 | **not changed — see #235** | `Area`, `Space` and `GenericModel` keep `$`: no recorded edge shows what the witness does with those Revit classes, and inventing a value is the thing this table exists to avoid. `IfcSlab` keeps `.FLOOR.` for all 80 because splitting floors from roofs is a per-element decode, not a mapping default; the gate accepts `{FLOOR, ROOF}` for that type. `IfcShadingDevice` is the one row the witness rule reaches that this PR does not change — `category_map.rs` carries an explicit prior decision for it ("`$`, not an invented `.NOTDEFINED.`"), and flipping a written-down decision deserves its own verdict rather than riding along here. Filed as **#235**. ### No new observation surface class `PredefinedType` is an attribute value; the observation payload counts entity **type names** plus relations and storeys. Both changes are therefore invisible to the observation hash, which was confirmed rather than assumed — see below. So instead of widening the surface, the agreement check went into the arity gate as `--witness-agreement`, run on the recorded artifact in CI: ``` PredefinedType agrees with the witness: IfcColumn.COLUMN=256, IfcDoor.DOOR=132, IfcSlab.FLOOR=80, IfcSpace.SPACE=18, IfcWall.NOTDEFINED=360, IfcWindow.WINDOW=6 ``` `IfcDoor` and `IfcWindow` also joined `PREDEFINED_TYPE_REQUIRED`, since every `category_map` row for them now supplies a value. ## Observations did not move Regenerated all three witnesses on both recorded edges and diffed against the committed files: | Edge | rvt-rs | ifcopenshell | ifc-lite | verdict | |---|---|---|---|---| | `magnetar-2024-core-interior` | byte-identical | byte-identical | byte-identical | PASS, 6 fields, 0 diffs, replay match ×3 | | `magnetar-2024-core-interior-slim` | byte-identical | byte-identical | byte-identical | PASS, 13 fields, 0 diffs, replay match ×3 | **Nothing under `research/witness/` was regenerated, because nothing moved.** Entity counts, relations and storeys are unchanged. ## Fixtures Both committed fixture IFCs are regenerated with their test pins, since the writer change alters them: - `synthetic-project.ifc` — 7 `IFCEXTRUDEDAREASOLID` rows repoint from the element axis to `#14` (the project identity placement), 4 `IFCWALL` move to `.NOTDEFINED.`, the door and two windows gain `.DOOR.` / `.WINDOW.`. - `synthetic-structural.ifc` — 4 `IFCEXTRUDEDAREASOLID` rows repoint to `#14`. Its `predefined_type` values are hardcoded in the test model, not looked up, so they are untouched. `synthetic-project.ifc` also picks up a change it should have carried since #222: it was last dumped at `55491d7` (#217), before `7f00dce` gave `IfcOpeningElement` the `Tag` of the element that fills it, so its one opening still wrote `$` there. Fixtures only regenerate behind `DUMP_IFC=1`, which is how it drifted a commit behind the writer with no test noticing. Two Rust tests moved with the mappings: `lookup_known_class` now expects `.NOTDEFINED.`, and `door_and_window_have_no_predefined_type_by_default` — which asserted the old decision — is rewritten as `door_and_window_follow_the_witness_predefined_type`, with a comment recording why the old reading (type variance belongs on `IfcDoorType`) is defensible and still wrong here: Revit populates both. A new `witness_following_predefined_types` covers all five changed rows. ## Verification run | Gate | Result | |---|---| | `cargo fmt --all` | clean | | `cargo clippy --all-targets -- -D warnings` | clean | | `cargo +1.85.0 check --all-targets` | clean | | `cargo test --profile ci` × 6 named targets, corpus set | 16 passed, 0 failed | | Tier-two decoder gates (#209), 7 targets, corpus set | 40 passed, 0 failed | | `cargo test --profile ci --workspace --all-targets`, corpus set | 152 result blocks, 0 failed | | `tools/ci/ifc_schema_arity.py --witness-agreement` on a fresh export | pass — 20105 instances, 992 solids, 2 pinned probes matched | | Same gate on the pre-fix export | fails, 992 composition findings | | `tools/ci/validate-real-ifc.py` (Einhoven) | pass | | `tools/check-local.sh --ifcopenshell` | all requested gates passed | | OctetProof verdicts, both edges, `--compare-committed` | PASS, replay match on all six observations | ## Follow-ups - **#235** (filed) — `IFCSHADINGDEVICE` emits `$` where Revit writes `.NOTDEFINED.` on all 20; the #220 rule reaches it but a documented prior decision guards it. - Column Z is 1.58 ft off and plan position 0.125 ft off against the export; wall bodies up to 2.53 ft. Both are geometry recovery, now measurable for the first time because the placement no longer swamps them. - Revit splits 80 slabs into 78 `.FLOOR.` + 2 `.ROOF.`; rvt-rs writes `.FLOOR.` for all 80. Closes #232 Closes #220 https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core IFC geometry placement and attribute emission for all extruded products; mitigated by new fail-closed CI gates and unchanged OctetProof observation hashes per the PR description. > > **Overview** > Fixes two IFC4 writer conformance issues measured against Revit's export of the 2024 Core Interior project. > > **Placement (#232).** Swept solids no longer reuse the element's `IfcAxis2Placement3D` as both `IfcLocalPlacement.RelativePlacement` and `IfcExtrudedAreaSolid.Position`. Translation lives only on the local placement; solid `Position` is the project identity frame so `ObjectPlacement × Position` is not applied twice. The same rule applies to extrusions, openings, and the generic `emit_solid_shape` path (mapped-item geometry is documented as a separate composition case). > > **PredefinedType (#220).** `category_map` now emits witness-aligned values where a recorded edge exists: walls `.NOTDEFINED.`, rooms `.SPACE.`, doors `.DOOR.`, windows `.WINDOW.` (replacing `.STANDARD.`, `.INTERNAL.`, and `$`). Tests and docs/compatibility tables are updated accordingly. > > **CI and gates.** `tools/ci/ifc_schema_arity.py` adds placement-composition checks on every file (no shared placement instance; pinned Tag probes) and optional `--witness-agreement` for the real-project export in CI. Synthetic IFC fixtures are regenerated (solid positions, enum values, opening `Tag` catch-up from #222). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dff9f2eccb02b3ffe3008181ebbca89253db4970. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #206.
elem_table_corpus::project_2024_file_parses_all_declared_recordsfailed with26424 parsed vs 26425 declared on magnetar's
2024_Core_Interior.rvt, and hadbeen failing invisibly because no CI job ever ran that test with a corpus.
Gate first, then root cause.
1. The gate gap
Corpus jobs name specific
--testtargets; the matrix jobs run every targetbut without
RVT_PROJECT_CORPUS_DIR. So every corpus-reading target that nojob names takes its skip path on every CI run. Full audit of
tests/*.rsthat readRVT_PROJECT_CORPUS_DIRorRVT_SAMPLES_DIR:corpus_tier2_healthcorpus-tier2,corpus-nightlyproject_corpus_smokecorpus-tier2,corpus-nightlyproject_count_fixturescorpus-tier2,writer-patch-corpus,corpus-nightlycfb_roundtrip_deltawriter-patch-corpussamplestest,corpus-nightlyfield_type_coverageRVT_REQUIRE_CORPUS)test,corpus-nightlyifc_roundtriptest,corpus-nightlyelem_table_corpusarc_wall_corpuspartition_scanneriter_elements_typedre15_geometry_invariantsre19_door_window_wall_negativewalker_to_ifc_integration(
geometry_recovery/typed_decodersreadRVT_CORPUS_TIER1_DIR, whichdefaults to the in-repo
corpus/tier1tree, so they are non-vacuous already.tests/pythongetsRVT_SAMPLES_DIRfrom the wheel job.)All seven ungated targets are now named:
corpus-tier2gains a "Tier-two decoder gates" step running all sevenwith
RVT_PROJECT_CORPUS_DIR+RVT_CORPUS_TIER1_DIR. The step commentsays a new corpus-reading target has to be added to that list to count as
gated.
testjob gains an "ElemTable record framing (familycorpus)" step running
elem_table_corpuswithRVT_SAMPLES_DIRandRVT_REQUIRE_CORPUS=1, so the family half is non-vacuous too. Each jobgates the half it has a corpus for; the other half skips and says so.
All seven pass locally against the corpus (this PR fixes the only failure).
Loud skip.
tests/elem_table_corpus.rsnow panics whenRVT_PROJECT_CORPUS_DIRis set but the named file is absent (the ruletests/project_count_fixtures.rsalready uses), and treats a missing familyrelease as a failure under
RVT_REQUIRE_CORPUS=1(the ruletests/field_type_coverage.rsalready uses). It also carries one always-ontest over committed bytes, so the target is never wholly vacuous.
2. Root cause — a four-byte record-origin shift, not a missing record
The decompressed length is authoritative
Global/ElemTableis a checksum-paged stream, so the production path stripspage trailers before inflating. On this file:
The stripped stream's gzip footer verifies:
CRC32matches andISIZEis1,057,030. The 1,059,812 figure recorded in the 2026-04-21 layout note (and
the reason the test's
assert_eq!once passed) came from a CRC-invalidinflate of un-stripped bytes.
1,057,030 = 0x1E + 26,425 x 40, exactly
0x22— the firstFFrun (whatdetect_layoutused)0x1E—0x22minus oneu32The four bytes ahead of the marker are a record field
The
u32at0x1E + 40kis zero for all 26,425 values of k — includingthe 26,425th slot that only exists under the corrected origin.
rvt-elem-table --rawon record 0 now prints the framing directly:The
FFx8 run is twou32owner slots with0xFFFFFFFFmeaning "none" —record 1283 carries
02 05 00 00(= 1282) there instead, so it is a field,not a frame delimiter. The final record (
k = 26424) reads— a zero-id terminator, but a structurally well-formed 40-byte record that
ends flush with the stream.
Decision: the decoder was wrong
The header count and the CRC-verified stream length agree exactly under one
origin and disagree under the other, and the disputed four bytes are provably
a zero field of the record rather than slack. The assertion stays
assert_eq!(records.len(), header.record_count)— no>=, no tolerance.detect_layoutfinds the marker and the stride as before; newelem_table::record_originthen recovers record 0's origin aslen - record_count * stridewhen that lands a whole number ofu32fields(and less than one stride) ahead of the marker. New public field
ElemTableLayout::marker_offsetrecords the difference so field extractionstays anchored to the marker.
Every id on records 0..26,423 is byte-identical before and after. What
changes:
ElemRecord::offset/rawshift by -4, and record 26,424 isrecovered.
declared_element_idsconsequently gains0for this file; theone consumer that could care (
partition_schema_mvp's ElemTable confirmationof
ArcWallRectOpeningrelated ids) produces byte-identical IFC on thiscorpus, so no opening has a zero related id.
The 2023 variant is deliberately left alone
End-anchoring
Revit_IFC5_Einhoven.rvtwould put the origin at73,245 - 2615 x 28 = 25 = 0x19— five bytes ahead of the marker. Arecord field cannot begin at a non-
u32boundary inside the record, so the% 4guard rejects it and the 28-byte variant keeps the marker as itsorigin. That file still walks 2,614 of 2,615 and leaves a 23-byte tail. That
is an open question, not a loosened assertion, and the test now pins 2614
exactly (it previously asserted only
>= 2000and<= record_count), sothe day it changes it changes visibly.
3. Regression coverage
tests/fixtures/elem-table/2024-core-interior-elemtable-head-tail.bin—270 bytes, MIT, with a
.license.jsonsidecar recording the source hash andthe exact derivation: the real 0x1E-byte header with
record_countrewritten 26425 -> 6, then records 0-2 and 26422-26424 verbatim. It
preserves the property under test (
0x1E + 6 * 40 = 270, flush) and parses5 records on the old decoder, 6 on the new one. Runs with no corpus.
src/elem_table.rscover the aligned recovery, thenon-
u32-aligned rejection, and a stream shorter than the declared span.last.offset + last.raw.len() == header.decompressed_bytes.4. OctetProof
Nothing to regenerate.
rvt-ifc --observationre-run against both recordededges (
magnetar-2024-core-interiorand...-slim) produces filesbyte-identical to the committed ones;
observation_hash_sha256staysb6d9b67c10c3350b69b58cbd2c6caeca405f63ce182e7291feba3e3ff10f3e00on both.tools/ci/witness-verdict.pywith the fresh observation:Docs
docs/elem-table-record-layout-2026-04-21.mdgains a "Where the record arraystarts" section with the evidence above and the record-count semantics
(
record_countcounts fixed-stride records including terminators withid_primary == 0; distinct ElementIds areelement_count= 1,411).docs/status.mdneeded no change - no status sentence became false. No changeto
docs/support-matrix.json.Gates run
cargo fmt --all,cargo clippy --all-targets -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc,cargo +1.85.0 check --all-targets(MSRV),
tools/check-local.sh(all requested gates passed), and the fullcargo test --profile cisuite withRVT_PROJECT_CORPUS_DIR/RVT_CORPUS_TIER1_DIRset - all green.Note for the parallel lane
This branch touches no file in
src/ifc/,src/walker*,tests/fixtures/project-counts/2024-core-interior-slim.json, orresearch/witness/magnetar-2024-core-interior-slim/. It does addwalker_to_ifc_integrationto thecorpus-tier2step list (workflow only, notest-file change).
Note
Medium Risk
Changes authoritative ElemTable enumeration and adds a breaking
ElemTableLayoutfield, but behavior is heavily regression-tested and downstream IFC observations are unchanged per the PR.Overview
Fixes #206: on Revit 2024 project
Global/ElemTable, the decoder treated the first0xFFrun as record 0’s start, but each 40-byte row begins with a zerou32and the marker sits at +4. That four-byte shift walked 26,424 of 26,425 declared records on2024_Core_Interior.rvt.Decoder —
record_originanchors the array withlen − record_count × stridewhen that lands u32-aligned before the marker;ElemTableLayout::marker_offset(breaking pre-0.2.0) keeps ID extraction past the marker. Parsed IDs on existing rows stay the same; offsets/rawshift by −4 and the final record is recovered. The 28-byte 2023 variant is unchanged (alignment guard rejects a bogus earlier origin).CI —
elem_table_corpusand six other corpus-reading integration targets were never named by a job withRVT_PROJECT_CORPUS_DIR/ family corpus, so they skipped every run. They are now run from the matrixtestjob (family +RVT_REQUIRE_CORPUS) andcorpus-tier2(project batch). Corpus tests fail when env is set but files are missing; a committed 270-byte MIT fixture gives an always-on regression without external corpus.Reviewed by Cursor Bugbot for commit a736bc4. Configure here.