Skip to content

Lane Seven: IFC export modes with honest geometry content - #130

Merged
DrunkOnJava merged 12 commits into
mainfrom
ifc/export-modes
Aug 29, 2026
Merged

DrunkOnJava merged 12 commits into
mainfrom
ifc/export-modes

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Aug 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements Lane Seven (IFC quality) on top of Lane Six geometry recovery: scaffold / typed-no-geometry / geometry / strict now shape emission as well as post-export validation gates, HostObjAttr proxies stay out of production export, and diagnostics sidecars remain schema-shaped.

Depends on Lane Six (geometry/wall-floor, PR #129) which includes typed decoders (#127). Aligns with Lane Nine (#128) forward-compatible mode names that fail closed for stronger modes.

Motivation

Quality modes previously acted mainly as validation gates on a single default export. Lane 7 makes mode content real where data allows: typed-only inventory without geometry claims, geometry attachment via Lane Six recovery when present, and strict fail-closed behavior without misleading proxies.

Refs M5-01 / M5-02 / M5-04 (TODO.md). Downstream: Lane 8 viewer confidence UI.

Changes

  • src/ifc/export_content.rs — content policy per quality mode; HostObjAttr/HostObject/Element/Symbol filter; Level → storey via elevation recovery; Wall curve / Floor boundary / Door·Window host attachment; geometry strip helper
  • RvtDocExporter::export_with_diagnostics_mode_and_limits — mode-aware emission
  • rvt-ifc --mode + Python write_ifc(mode=...) pass mode into export content
  • Default/scaffold never emits HostObjAttr-* proxies (diagnostic exporter unchanged)
  • Diagnostics sidecar unchanged schema (docs/schemas/export-diagnostics.schema.json); docs note content policy
  • tests/ifc_export_modes.rs — always-on tier1 coverage for all four modes + CLI

Mode semantics

Mode Emission Gate
scaffold Framework + production elements; geometry when recovered; no HostObjAttr proxies Always accepts valid envelope
typed-no-geometry Mapped/typed only; geometry fields stripped Requires typed elements
geometry Mapped/typed; Lane Six curves/loops/hosts/elevations when present Requires typed + geometry
strict Same as geometry Typed + geometry + metadata/units/storeys + no warnings/unsupported

On synthetic / tier1 fixtures only scaffold succeeds — honest scaffold-only, no invented geometry.

Testing

  • cargo test --release --lib ifc::export_content — 6 passed
  • cargo test --release --lib ifc:: — 325 passed
  • cargo test --release --test ifc_export_modes — 8 passed
  • cargo test --release --test ifc_synthetic_* --test rvt_ifc_diagnostics_cli --test walker_to_ifc_integration — passed (corpus tests skip without samples)
  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo clippy -p rvt-py --all-targets -- -D warnings
  • Smoke: gen-fixture + rvt-ifc --mode scaffold|typed-no-geometry|geometry|strict — HostObjAttr absent; stronger modes fail closed with diagnostics

Audit-honesty checklist

  • Tier1/synthetic remain scaffold-only; no invented wall/floor geometry
  • HostObjAttr proxies absent from default/scaffold; diagnostic path retained
  • Mode docs do not claim geometry/strict success on scaffold fixtures
  • No Autodesk samples committed
  • Commit messages describe what/why

Legal and contribution hygiene

  • Apache-2.0 licensable
  • No Autodesk proprietary / decompiled content
  • Fixtures remain synthetic (gen-fixture / corpus/tier1)

Breaking changes

None for callers of RvtDocExporter::export (still scaffold content). New export_with_*_mode_* APIs are additive. CLI/Python --mode / mode= now also shapes content (typed-no-geometry strips geometry).

Related issues

Refs #37 (M5-01), #38-class HostObjAttr (M5-02), #40 (M5-04). Depends on #129 (Lane Six). Aligns with #128 (Lane Nine mode names).


Note

Medium Risk
IFC export behavior changes for non-scaffold modes and production element filtering; broader surface area (partition scanner version gates, committed binaries) but synthetic corpus and fail-closed validation limit blast radius.

Overview
Adds a two-tier test corpus (in-repo Apache-2.0 synthetic corpus/tier1/ plus optional CI-cloned magnetar tier 2), CI jobs corpus-tier1 / corpus-tier2, SHA256 license checks, and known-count manifests—while allowing committed .rvt files under corpus/ via .gitignore exceptions.

Introduces partition scanning (partition_scanner), a typed ArcWall partition decoder, ElemTable linkage helpers, and a partition_scanner_json example for JSON diagnostics.

Adds Lane Six geometry recovery (geometry/recovery) with fail-closed wall curves, floor boundaries, opening hosts, and level elevations; extends typed Wall / Level projection for gen-fixture fields (m_height, location endpoints) and centralizes MVP typed decode via decode_typed / decoder_for_class.

Implements Lane Seven IFC content policy in export_content: --mode / Python mode= now drives emission (not just validation)—typed-no-geometry strips geometry, geometry/strict attach recovery when present, production export drops HostObjAttr proxies, and Levels become storeys from recovered elevations. RvtDocExporter::export_with_diagnostics_mode_and_limits wires CLI/Python through to export.

New integration tests cover tier1 corpus health, geometry honesty on synthetics, and all four IFC export modes (including CLI strict fail-closed on tier1).

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

cursoragent and others added 11 commits August 29, 2026 08:53
Curate Apache-2.0 synthetic fixtures under corpus/tier1/ with license
and known-count sidecars for levels/walls/floors/doors/windows, extend
project_count_fixtures for fixture_metric inventories, and wire
corpus-tier1 (always-on) plus corpus-tier2 (external magnetar) CI jobs.

Co-authored-by: DrunkOnJava <[email protected]>
…e link

Add a version-gated (Revit 2023/2024) filtered-tag scanner that emits
neutral PartitionRecordCandidate records, expresses the existing ArcWall
path, and joins recovered ElementIds to Global/ElemTable offsets
(M3-03 / M3-04). Includes JSON probe example and tier1/corpus tests.

Co-authored-by: DrunkOnJava <[email protected]>
Satisfy clippy::collapsible_if under -D warnings.

Co-authored-by: DrunkOnJava <[email protected]>
Harden Level/Wall/Floor/Door/Window/Room/Material wrong-schema rejection
and empty-input behavior; add ArcWall typed partition decoder with
class/tag rejection; expose decoder_for_class/decode_typed; add tier1
corpus tests that exercise fixture payloads without inventing geometry.

Co-authored-by: DrunkOnJava <[email protected]>
Add fail-closed recovery APIs for wall location curves (schema
endpoints + ArcWall partition), floor boundary loops, door/window
host relationships, and level elevations. Extend Wall typed view
with location curve fields. Tier1 tests assert honest empty/partial
recovery on scaffold fixtures.

Co-authored-by: DrunkOnJava <[email protected]>
Primitives live in src/geometry/mod.rs; recovery in recovery.rs.

Co-authored-by: DrunkOnJava <[email protected]>
Also fix match exhaustiveness and type annotation for clippy/rustc.

Co-authored-by: DrunkOnJava <[email protected]>
Make scaffold / typed-no-geometry / geometry / strict control IFC
emission (not only post-export gates): drop HostObjAttr proxies from
production export, strip geometry in typed-no-geometry, attach Lane
Six recovery when present, and keep diagnostics sidecars schema-shaped.

Co-authored-by: DrunkOnJava <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 6 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for all 6 issues found in the latest run.

  • ✅ Fixed: Walls emit invented thickness
    • Walker wall geometry now omits extrusion when thickness is unresolved, matching the floor annotation-only policy.
  • ✅ Fixed: Walls ignore level elevation
    • Wall placement Z now adds the recovered base level elevation plus base offset and curve Z instead of using offset alone.
  • ✅ Fixed: Level storeys drop ArcWall storeys
    • ArcWall-derived storeys are merged into walker Level storeys so partition wall elevations remain matchable.
  • ✅ Fixed: Elements skip recovered storey assignment
    • Walker walls, floors, doors, and windows now map base_level_id/level_id to storey_index while Levels are processed.
  • ✅ Fixed: Floor loops misread XY as XYZ
    • Ambiguous flat float vectors prefer interleaved XY unless every third float looks like a near-zero Z slot.
  • ✅ Fixed: Opening host links never emit
    • Opening hosts resolve after ArcWalls are indexed and set opening extrusions when decoded width and height are available.

Create PR

Or push these changes by commenting:

@cursor push c8ea46a243
Preview (c8ea46a243)
diff --git a/src/geometry/recovery.rs b/src/geometry/recovery.rs
--- a/src/geometry/recovery.rs
+++ b/src/geometry/recovery.rs
@@ -443,25 +443,53 @@
     if floats.len() < 6 {
         return None;
     }
-    if floats.len() % 3 == 0 {
-        let mut pts = Vec::with_capacity(floats.len() / 3);
-        for chunk in floats.chunks_exact(3) {
+
+    let xy_points = |values: &[f64]| -> Option<Vec<(f64, f64)>> {
+        if values.len() % 2 != 0 {
+            return None;
+        }
+        let mut pts = Vec::with_capacity(values.len() / 2);
+        for chunk in values.chunks_exact(2) {
             pts.push((chunk[0], chunk[1]));
         }
-        if pts.len() >= 3 {
-            return Some(pts);
+        if pts.len() >= 3 { Some(pts) } else { None }
+    };
+
+    let xyz_points = |values: &[f64]| -> Option<Vec<(f64, f64)>> {
+        if values.len() % 3 != 0 {
+            return None;
         }
-    }
-    if floats.len() % 2 == 0 {
-        let mut pts = Vec::with_capacity(floats.len() / 2);
-        for chunk in floats.chunks_exact(2) {
+        let mut pts = Vec::with_capacity(values.len() / 3);
+        for chunk in values.chunks_exact(3) {
             pts.push((chunk[0], chunk[1]));
         }
-        if pts.len() >= 3 {
+        if pts.len() >= 3 { Some(pts) } else { None }
+    };
+
+    // Lengths divisible by both 2 and 3 (6, 12, 18, …) are ambiguous.
+    // Plan floor loops are usually interleaved XY; flat XYZ sketches keep
+    // Z near zero on every third float.
+    if floats.len() % 6 == 0 {
+        let z_slots_all_near_zero = floats
+            .iter()
+            .enumerate()
+            .filter(|(idx, _)| idx % 3 == 2)
+            .all(|(_, z)| z.abs() < 1e-9);
+        if z_slots_all_near_zero {
+            if let Some(pts) = xyz_points(&floats) {
+                return Some(pts);
+            }
+        }
+        if let Some(pts) = xy_points(&floats) {
             return Some(pts);
         }
+        return xyz_points(&floats);
     }
-    None
+
+    if let Some(pts) = xy_points(&floats) {
+        return Some(pts);
+    }
+    xyz_points(&floats)
 }
 
 fn unique_plan_vertices(pts: &[(f64, f64)]) -> Vec<(f64, f64)> {
@@ -900,6 +928,22 @@
     }
 
     #[test]
+    fn flat_float_hexagon_prefers_interleaved_xy() {
+        // Six plan vertices (12 floats) must not be reinterpreted as
+        // four XYZ triples.
+        let items: Vec<InstanceField> = (0..12)
+            .map(|i| InstanceField::Float {
+                value: i as f64,
+                size: 8,
+            })
+            .collect();
+        let pts = points_from_flat_floats(&items).expect("hexagon xy loop");
+        assert_eq!(pts.len(), 6);
+        assert_eq!(pts[0], (0.0, 1.0));
+        assert_eq!(pts[5], (10.0, 11.0));
+    }
+
+    #[test]
     fn window_host_missing_fails_closed() {
         let window = Window::default();
         assert_eq!(

diff --git a/src/ifc/export_content.rs b/src/ifc/export_content.rs
--- a/src/ifc/export_content.rs
+++ b/src/ifc/export_content.rs
@@ -17,17 +17,21 @@
 
 use super::category_map;
 use super::entities::{self, Extrusion, Property, PropertySet, PropertyValue};
-use super::from_decoded::{wall_segment_angle_radians, wall_segment_length_feet};
+use super::from_decoded::{
+    door_opening_extrusion, wall_segment_angle_radians, wall_segment_length_feet,
+    window_opening_extrusion,
+};
 use super::{ExportQualityMode, Storey, UNRESOLVED_ARCWALL_THICKNESS_FEET};
 use crate::elements::floor::Floor;
 use crate::elements::level::Level;
+use crate::elements::level::normalise_field_name;
 use crate::elements::openings::{Door, Window};
 use crate::elements::wall::Wall;
 use crate::geometry::{
     recover_door_host, recover_floor_boundary, recover_level_elevation,
     recover_wall_location_curve_from_wall, recover_window_host,
 };
-use crate::walker::DecodedElement;
+use crate::walker::{DecodedElement, InstanceField};
 use std::collections::HashMap;
 
 /// What a quality mode allows the document exporter to emit.
@@ -89,17 +93,96 @@
     }
 }
 
+/// Opening host link deferred until all building elements (including
+/// partition ArcWalls) are present in `entities`.
+#[derive(Debug, Clone, PartialEq)]
+pub struct PendingOpeningHost {
+    pub entity_index: usize,
+    pub host_id: u32,
+    pub ifc_type: String,
+    pub width_feet: Option<f64>,
+    pub height_feet: Option<f64>,
+}
+
+/// Merge ArcWall-derived storeys into walker Level storeys without
+/// dropping elevations that only appear on partition walls.
+pub fn merge_building_storeys(existing: &mut Vec<Storey>, extra: &[Storey]) {
+    for storey in extra {
+        if !existing
+            .iter()
+            .any(|s| (s.elevation_feet - storey.elevation_feet).abs() < 1e-3)
+        {
+            existing.push(storey.clone());
+        }
+    }
+    existing.sort_by(|a, b| {
+        a.elevation_feet
+            .partial_cmp(&b.elevation_feet)
+            .unwrap_or(std::cmp::Ordering::Equal)
+    });
+}
+
+/// Wire hosted openings once every candidate host wall is indexed.
+pub fn resolve_opening_hosts(
+    entities: &mut [entities::IfcEntity],
+    pending: &[PendingOpeningHost],
+    id_to_entity: &HashMap<u32, usize>,
+) {
+    for item in pending {
+        let Some(&host_index) = id_to_entity.get(&item.host_id) else {
+            continue;
+        };
+        let host_depth = entities.get(host_index).and_then(|entity| match entity {
+            entities::IfcEntity::BuildingElement {
+                extrusion: Some(ex),
+                ..
+            } => Some(ex.depth_feet),
+            _ => None,
+        });
+        let (Some(width), Some(height)) = (item.width_feet, item.height_feet) else {
+            continue;
+        };
+        if !width.is_finite() || !height.is_finite() || width <= 0.0 || height <= 0.0 {
+            continue;
+        }
+        let thickness = host_depth.unwrap_or(UNRESOLVED_ARCWALL_THICKNESS_FEET);
+        let Some(entities::IfcEntity::BuildingElement {
+            host_element_index,
+            extrusion,
+            ..
+        }) = entities.get_mut(item.entity_index)
+        else {
+            continue;
+        };
+        *host_element_index = Some(host_index);
+        if extrusion.is_none() {
+            match item.ifc_type.as_str() {
+                "IFCDOOR" => {
+                    *extrusion = Some(door_opening_extrusion(width, height, thickness, 0.0));
+                }
+                "IFCWINDOW" => {
+                    *extrusion = Some(window_opening_extrusion(width, height, thickness, 0.0));
+                }
+                _ => {}
+            }
+        }
+    }
+}
+
 /// Accumulate production walker hits into IFC entities + storeys.
 ///
-/// Returns a map of Revit element id → index in `entities` for host linking.
+/// Returns a map of Revit element id → index in `entities` for host
+/// linking, plus opening hosts that still need resolution after
+/// partition ArcWalls are appended.
 pub fn append_typed_production_elements(
     decoded_iter: impl Iterator<Item = DecodedElement>,
     entities: &mut Vec<entities::IfcEntity>,
     building_storeys: &mut Vec<Storey>,
     policy: ExportContentPolicy,
-) -> HashMap<u32, usize> {
+) -> (HashMap<u32, usize>, Vec<PendingOpeningHost>) {
     let mut id_to_entity: HashMap<u32, usize> = HashMap::new();
-    let mut pending_hosts: Vec<(usize, u32)> = Vec::new();
+    let mut level_id_to_storey: HashMap<u32, usize> = HashMap::new();
+    let mut pending_hosts: Vec<PendingOpeningHost> = Vec::new();
 
     for decoded in decoded_iter {
         if is_misleading_proxy_class(&decoded.class) {
@@ -108,7 +191,11 @@
 
         if decoded.class == "Level" {
             if let Some(storey) = storey_from_level(&decoded) {
+                let storey_index = building_storeys.len();
                 building_storeys.push(storey);
+                if let Some(id) = decoded.id {
+                    level_id_to_storey.insert(id, storey_index);
+                }
             }
             continue;
         }
@@ -131,17 +218,26 @@
         let mut rotation_radians = None;
         let mut extrusion = None;
         let mut property_set = None;
-        let mut pending_host_id = None;
+        let mut pending_host = None;
+        let mut opening_width_feet = None;
+        let mut opening_height_feet = None;
+        let mut storey_index = None;
 
         if policy.include_geometry {
             match decoded.class.as_str() {
                 "Wall" => {
-                    if let Some(geom) = wall_geometry_from_decoded(&decoded) {
+                    if let Some(geom) =
+                        wall_geometry_from_decoded(&decoded, building_storeys, &level_id_to_storey)
+                    {
                         location_feet = Some(geom.location_feet);
                         rotation_radians = Some(geom.rotation_radians);
-                        extrusion = Some(geom.extrusion);
+                        extrusion = geom.extrusion;
                         property_set = geom.property_set;
                     }
+                    storey_index = storey_index_for_level_id(
+                        Wall::from_decoded(&decoded).base_level_id,
+                        &level_id_to_storey,
+                    );
                 }
                 "Floor" => {
                     if let Some(geom) = floor_boundary_annotation_from_decoded(&decoded) {
@@ -149,18 +245,49 @@
                         // provenance only — do not claim an extruded body.
                         property_set = Some(geom);
                     }
+                    storey_index = storey_index_for_level_id(
+                        Floor::from_decoded(&decoded).level_id,
+                        &level_id_to_storey,
+                    );
                 }
                 "Door" => {
                     let door = Door::from_decoded(&decoded);
                     if let Some(host) = recover_door_host(&door).ok() {
-                        pending_host_id = Some(host.host_element_id);
+                        pending_host = Some(host.host_element_id);
                     }
+                    (opening_width_feet, opening_height_feet) =
+                        opening_dimensions_from_decoded(&decoded);
+                    if let Some(loc) = door.location {
+                        let level_elev = level_elevation_for_level_id(
+                            door.level_id,
+                            &level_id_to_storey,
+                            building_storeys,
+                        )
+                        .unwrap_or(0.0);
+                        location_feet = Some([loc.x, loc.y, level_elev + loc.z]);
+                    }
+                    rotation_radians = door.rotation_radians;
+                    storey_index = storey_index_for_level_id(door.level_id, &level_id_to_storey);
                 }
                 "Window" => {
                     let window = Window::from_decoded(&decoded);
                     if let Some(host) = recover_window_host(&window).ok() {
-                        pending_host_id = Some(host.host_element_id);
+                        pending_host = Some(host.host_element_id);
                     }
+                    (opening_width_feet, opening_height_feet) =
+                        opening_dimensions_from_decoded(&decoded);
+                    if let Some(loc) = window.location {
+                        let level_elev = level_elevation_for_level_id(
+                            window.level_id,
+                            &level_id_to_storey,
+                            building_storeys,
+                        )
+                        .unwrap_or(0.0);
+                        let sill = window.sill_height_feet.unwrap_or(0.0);
+                        location_feet = Some([loc.x, loc.y, level_elev + sill + loc.z]);
+                    }
+                    rotation_radians = window.rotation_radians;
+                    storey_index = storey_index_for_level_id(window.level_id, &level_id_to_storey);
                 }
                 _ => {}
             }
@@ -170,15 +297,21 @@
         if let Some(id) = decoded.id {
             id_to_entity.insert(id, entity_index);
         }
-        if let Some(host_id) = pending_host_id {
-            pending_hosts.push((entity_index, host_id));
+        if let Some(host_id) = pending_host {
+            pending_hosts.push(PendingOpeningHost {
+                entity_index,
+                host_id,
+                ifc_type: ifc_type.clone(),
+                width_feet: opening_width_feet,
+                height_feet: opening_height_feet,
+            });
         }
 
         entities.push(entities::IfcEntity::BuildingElement {
             ifc_type,
             name,
             type_guid,
-            storey_index: None,
+            storey_index,
             material_index: None,
             property_set,
             location_feet,
@@ -192,22 +325,58 @@
         });
     }
 
+    let mut unresolved = pending_hosts;
     if policy.include_geometry {
-        for (entity_index, host_id) in pending_hosts {
-            if let Some(&host_index) = id_to_entity.get(&host_id) {
-                if let Some(entities::IfcEntity::BuildingElement {
-                    host_element_index, ..
-                }) = entities.get_mut(entity_index)
-                {
-                    *host_element_index = Some(host_index);
-                }
+        let mut still_pending = Vec::new();
+        for item in unresolved.drain(..) {
+            if id_to_entity.contains_key(&item.host_id) {
+                resolve_opening_hosts(entities, std::slice::from_ref(&item), &id_to_entity);
+            } else {
+                still_pending.push(item);
             }
         }
+        unresolved = still_pending;
     }
 
-    id_to_entity
+    (id_to_entity, unresolved)
 }
 
+fn storey_index_for_level_id(
+    level_id: Option<u32>,
+    level_id_to_storey: &HashMap<u32, usize>,
+) -> Option<usize> {
+    level_id.and_then(|id| level_id_to_storey.get(&id).copied())
+}
+
+fn level_elevation_for_level_id(
+    level_id: Option<u32>,
+    level_id_to_storey: &HashMap<u32, usize>,
+    building_storeys: &[Storey],
+) -> Option<f64> {
+    storey_index_for_level_id(level_id, level_id_to_storey)
+        .and_then(|idx| building_storeys.get(idx))
+        .map(|storey| storey.elevation_feet)
+}
+
+fn opening_dimensions_from_decoded(decoded: &DecodedElement) -> (Option<f64>, Option<f64>) {
+    let mut width = None;
+    let mut height = None;
+    for (field_name, value) in &decoded.fields {
+        let InstanceField::Float { value: v, .. } = value else {
+            continue;
+        };
+        if !v.is_finite() || *v <= 0.0 {
+            continue;
+        }
+        match normalise_field_name(field_name).as_str() {
+            "width" | "overallwidth" | "roughwidth" | "openingwidth" => width = Some(*v),
+            "height" | "overallheight" | "roughheight" | "openingheight" => height = Some(*v),
+            _ => {}
+        }
+    }
+    (width, height)
+}
+
 fn storey_from_level(decoded: &DecodedElement) -> Option<Storey> {
     let level = Level::from_decoded(decoded);
     let elev = recover_level_elevation(&level).ok()?;
@@ -227,11 +396,15 @@
 struct RecoveredWallGeom {
     location_feet: [f64; 3],
     rotation_radians: f64,
-    extrusion: Extrusion,
+    extrusion: Option<Extrusion>,
     property_set: Option<PropertySet>,
 }
 
-fn wall_geometry_from_decoded(decoded: &DecodedElement) -> Option<RecoveredWallGeom> {
+fn wall_geometry_from_decoded(
+    decoded: &DecodedElement,
+    building_storeys: &[Storey],
+    level_id_to_storey: &HashMap<u32, usize>,
+) -> Option<RecoveredWallGeom> {
     let wall = Wall::from_decoded(decoded);
     let curve = recover_wall_location_curve_from_wall(&wall, decoded).ok()?;
     let (start, end) = curve.line_endpoints_xy()?;
@@ -244,11 +417,12 @@
     if !height_feet.is_finite() || height_feet <= 0.0 {
         return None;
     }
-    let z = wall
-        .location_start
-        .map(|p| p.z)
-        .or(wall.base_offset_feet)
-        .unwrap_or(0.0);
+    let level_elev =
+        level_elevation_for_level_id(wall.base_level_id, level_id_to_storey, building_storeys)
+            .unwrap_or(0.0);
+    let offset = wall.base_offset_feet.unwrap_or(0.0);
+    let curve_z = wall.location_start.map(|p| p.z).unwrap_or(0.0);
+    let z = level_elev + offset + curve_z;
     let location_feet = [(start[0] + end[0]) / 2.0, (start[1] + end[1]) / 2.0, z];
     let rotation_radians = wall_segment_angle_radians(start, end);
     let mut properties = vec![
@@ -270,12 +444,9 @@
     Some(RecoveredWallGeom {
         location_feet,
         rotation_radians,
-        extrusion: Extrusion {
-            width_feet: length_feet,
-            depth_feet: UNRESOLVED_ARCWALL_THICKNESS_FEET,
-            height_feet,
-            profile_override: None,
-        },
+        // Walker walls do not yet resolve type thickness — do not
+        // claim an extruded body with a placeholder depth.
+        extrusion: None,
         property_set: Some(PropertySet {
             name: "RvtWallGeometry".into(),
             properties,

diff --git a/src/ifc/mod.rs b/src/ifc/mod.rs
--- a/src/ifc/mod.rs
+++ b/src/ifc/mod.rs
@@ -683,7 +683,7 @@
     // the mode asks for it. Walker failure falls through with no
     // element entities — we never regress the metadata-only baseline.
     let mut building_storeys = Vec::new();
-    append_production_walker_elements(
+    let (mut id_to_entity, pending_opening_hosts) = append_production_walker_elements(
         rf,
         &mut entities,
         &mut building_storeys,
@@ -711,6 +711,8 @@
             );
             if building_storeys.is_empty() {
                 building_storeys = recovery.storeys;
+            } else {
+                export_content::merge_building_storeys(&mut building_storeys, &recovery.storeys);
             }
             for wall in &scan.walls {
                 let geometry = if policy.include_geometry {
@@ -726,6 +728,10 @@
                     Some(id) => format!("ArcWall-{id}"),
                     None => format!("ArcWall-{}-{}", wall.partition, wall.offset),
                 };
+                let entity_index = entities.len();
+                if let Some(id) = wall.element_id() {
+                    id_to_entity.insert(id, entity_index);
+                }
                 entities.push(entities::IfcEntity::BuildingElement {
                     ifc_type: "IFCWALL".to_string(),
                     name,
@@ -743,6 +749,13 @@
                     representation_map_index: None,
                 });
             }
+            if policy.include_geometry {
+                export_content::resolve_opening_hosts(
+                    &mut entities,
+                    &pending_opening_hosts,
+                    &id_to_entity,
+                );
+            }
         }
     }
 
@@ -992,18 +1005,23 @@
     building_storeys: &mut Vec<Storey>,
     policy: export_content::ExportContentPolicy,
     walker_limits: crate::walker::WalkerLimits,
+) -> (
+    std::collections::HashMap<u32, usize>,
+    Vec<export_content::PendingOpeningHost>,
 ) {
     if let Ok(decoded_iter) = crate::walker::iter_elements_with_limits(
         rf,
         crate::walker::PRODUCTION_ELEMENT_MIN_SCORE,
         walker_limits,
     ) {
-        let _ = export_content::append_typed_production_elements(
+        export_content::append_typed_production_elements(
             decoded_iter,
             entities,
             building_storeys,
             policy,
-        );
+        )
+    } else {
+        (std::collections::HashMap::new(), Vec::new())
     }
 }

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

Comment thread src/ifc/export_content.rs
extrusion: Extrusion {
width_feet: length_feet,
depth_feet: UNRESOLVED_ARCWALL_THICKNESS_FEET,
height_feet,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Walls emit invented thickness

High Severity

Recovered walls emit an extruded solid whose depth is the ArcWall placeholder UNRESOLVED_ARCWALL_THICKNESS_FEET (8 inches), not a decoded width. geometry and strict IFC therefore ships a fabricated body, unlike floors which only annotate when thickness is unresolved.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

Comment thread src/ifc/export_content.rs
.map(|p| p.z)
.or(wall.base_offset_feet)
.unwrap_or(0.0);
let location_feet = [(start[0] + end[0]) / 2.0, (start[1] + end[1]) / 2.0, z];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Walls ignore level elevation

High Severity

Wall placement Z uses only location_start.z or base_offset_feet, never the hosting Level elevation recovered into building_storeys. Upper-storey walls land at Z=0 even when their level elevation is known.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

Comment thread src/ifc/mod.rs
building_storeys = recovery.storeys;
if building_storeys.is_empty() {
building_storeys = recovery.storeys;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Level storeys drop ArcWall storeys

Medium Severity

If the walker recovers any Level storey, ArcWall-derived storeys are discarded. Partition walls then match elevations against a different storey list, so previously assigned ArcWall storeys can become uncontained or attach to the wrong storey.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

Comment thread src/ifc/export_content.rs
material_profile_set_index: None,
solid_shape: None,
representation_map_index: None,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elements skip recovered storey assignment

Medium Severity

Walker walls, floors, doors, and windows are always emitted with storey_index: None. The STEP writer then places every element on storey 0, so recovered multi-level storeys never contain their elements.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

Comment thread src/geometry/recovery.rs
if pts.len() >= 3 {
return Some(pts);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Floor loops misread XY as XYZ

Medium Severity

Flat sketch floats whose length is divisible by both 2 and 3 are always taken as XYZ. A 6-vertex XY boundary (12 floats) becomes 4 wrong points, so recovery can accept a degenerate loop or drop a valid one.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

Comment thread src/ifc/export_content.rs
let window = Window::from_decoded(&decoded);
if let Some(host) = recover_window_host(&window).ok() {
pending_host_id = Some(host.host_element_id);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opening host links never emit

Medium Severity

Door and window host ids are stored on the entity, but openings never get an extrusion, and partition ArcWalls are appended after the host map is closed. The writer only emits void/fill rels when both a host index and an extrusion exist, so recovered hosts do not appear in the IFC.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6eac930. Configure here.

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review August 29, 2026 10:07
@DrunkOnJava
DrunkOnJava merged commit e193ec8 into main Aug 29, 2026
22 checks passed
@DrunkOnJava
DrunkOnJava deleted the ifc/export-modes branch August 29, 2026 11:13
DrunkOnJava added a commit that referenced this pull request Aug 29, 2026
…ery (#131)

## Summary

Lane Eight (viewer) — surface decode/export confidence and IFC quality
bars from Lane Seven diagnostics, refine in-app supported-file guidance
for synthetic vs real expectations, and stage the redistributable
`corpus/tier1/` fixtures in the demo gallery.

Depends on Lane Seven (`ifc/export-modes`, PR #130).

## Motivation

Closes the M6 viewer-beta path for confidence messaging and
redistributable demos (Refs #42, #43, #44). Users need honest scaffold
~25% feedback on synthetics and a same-origin gallery that does not
require Autodesk samples.

## Changes

- `src/wasm.rs` — `openRvtBytesWithDiagnosticsMode` / `…AndLimits` for
Lane Seven quality modes
- `viewer/src/worker.ts` — parse with selected IFC bar via the new WASM
binding
- `viewer/src/main.ts` + `viewer/index.html` — Decode / Export
confidence rows, IFC bar selector + validation messaging, refined
support matrix
- `docs/viewer-demos.json` + `viewer/scripts/stage-demos.mjs` — stage
`architectural-2024`, `structural-2023`, `mep-2024` (with license
sidecars) from `corpus/tier1/`
- `viewer/tests/viewer-regression.spec.ts` — gallery +
confidence/IFC-bar coverage
- `viewer/README.md` — workflow docs for tier1 / confidence

## Testing

- [x] `wasm-pack build --target web -- --features wasm
--no-default-features`
- [x] WASM network-import audit (VW1-21) — PASS
- [x] `npm run stage:demos` — 6/8 demos staged (tier1 + synthetic + IFC;
optional RAC RFAs absent)
- [x] `npm run typecheck` / `npm run build`
- [x] `rvt-ifc` on `architectural-2024` — confidence `scaffold` / score
`0.25`
- [x] Playwright browser regressions — 3 passed, 1 skipped (no external
project corpus)
- [x] Manual GUI against localhost:5173 — tier1 gallery load,
Decode/Export rows, IFC bar geometry fail-closed messaging
- [x] `cargo fmt --check`

N/A: IFC exporter byte-stability and element-decoder unit-test checklist
(viewer/WASM surface only).

## Audit-honesty checklist

- [x] README / viewer docs state scaffold ~25% for tier1 synthetics;
typed real-project extraction remains unsolved
- [x] No over-claim of geometry/typed coverage
- [x] Commit messages describe WHAT/WHY
- [x] No emojis / private paths
- [x] No Autodesk proprietary content — only Apache-2.0 corpus/tier1
synthetics and committed IFC fixtures

## Breaking changes

None. New WASM exports are additive. Demo catalog gains tier1 entries;
`synthetic-mvp` remains as a gen-fixture fallback.

## Screenshots or output samples

Cloud Agent artifacts: gallery landing, File status Decode/Export
confidence (~25%), IFC bar geometry warning, supported-profile matrix,
walkthrough video.

## Related issues

- Refs #42 (M6-01 confidence — already closed; this extends Lane Seven
fields)
- Refs #43 (M6-02 guidance — already closed; copy refined)
- Closes #44 (M6-03 demo gallery with redistributable tier1 files)
- Depends on #130 (`ifc/export-modes`)

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
DrunkOnJava added a commit that referenced this pull request Aug 31, 2026
## Summary

Implements Lane Seven (IFC quality) on top of Lane Six geometry
recovery: `scaffold` / `typed-no-geometry` / `geometry` / `strict` now
shape *emission* as well as post-export validation gates, HostObjAttr
proxies stay out of production export, and diagnostics sidecars remain
schema-shaped.

Depends on Lane Six (`geometry/wall-floor`, PR #129) which includes
typed decoders (#127). Aligns with Lane Nine (#128) forward-compatible
mode names that fail closed for stronger modes.

## Motivation

Quality modes previously acted mainly as validation gates on a single
default export. Lane 7 makes mode content real where data allows:
typed-only inventory without geometry claims, geometry attachment via
Lane Six recovery when present, and strict fail-closed behavior without
misleading proxies.

Refs M5-01 / M5-02 / M5-04 (TODO.md). Downstream: Lane 8 viewer
confidence UI.

## Changes

- `src/ifc/export_content.rs` — content policy per quality mode;
HostObjAttr/HostObject/Element/Symbol filter; Level → storey via
elevation recovery; Wall curve / Floor boundary / Door·Window host
attachment; geometry strip helper
- `RvtDocExporter::export_with_diagnostics_mode_and_limits` — mode-aware
emission
- `rvt-ifc --mode` + Python `write_ifc(mode=...)` pass mode into export
content
- Default/scaffold never emits `HostObjAttr-*` proxies (diagnostic
exporter unchanged)
- Diagnostics sidecar unchanged schema
(`docs/schemas/export-diagnostics.schema.json`); docs note content
policy
- `tests/ifc_export_modes.rs` — always-on tier1 coverage for all four
modes + CLI

### Mode semantics

| Mode | Emission | Gate |
|------|----------|------|
| `scaffold` | Framework + production elements; geometry when recovered;
no HostObjAttr proxies | Always accepts valid envelope |
| `typed-no-geometry` | Mapped/typed only; geometry fields stripped |
Requires typed elements |
| `geometry` | Mapped/typed; Lane Six curves/loops/hosts/elevations when
present | Requires typed + geometry |
| `strict` | Same as geometry | Typed + geometry +
metadata/units/storeys + no warnings/unsupported |

On synthetic / tier1 fixtures only `scaffold` succeeds — honest
scaffold-only, no invented geometry.

## Testing

- [x] `cargo test --release --lib ifc::export_content` — 6 passed
- [x] `cargo test --release --lib ifc::` — 325 passed
- [x] `cargo test --release --test ifc_export_modes` — 8 passed
- [x] `cargo test --release --test ifc_synthetic_* --test
rvt_ifc_diagnostics_cli --test walker_to_ifc_integration` — passed
(corpus tests skip without samples)
- [x] `cargo fmt --check`
- [x] `cargo clippy --all-targets --all-features -- -D warnings`
- [x] `cargo clippy -p rvt-py --all-targets -- -D warnings`
- [x] Smoke: `gen-fixture` + `rvt-ifc --mode
scaffold|typed-no-geometry|geometry|strict` — HostObjAttr absent;
stronger modes fail closed with diagnostics

## Audit-honesty checklist

- [x] Tier1/synthetic remain scaffold-only; no invented wall/floor
geometry
- [x] HostObjAttr proxies absent from default/scaffold; diagnostic path
retained
- [x] Mode docs do not claim geometry/strict success on scaffold
fixtures
- [x] No Autodesk samples committed
- [x] Commit messages describe what/why

## Legal and contribution hygiene

- [x] Apache-2.0 licensable
- [x] No Autodesk proprietary / decompiled content
- [x] Fixtures remain synthetic (`gen-fixture` / corpus/tier1)

## Breaking changes

None for callers of `RvtDocExporter::export` (still scaffold content).
New `export_with_*_mode_*` APIs are additive. CLI/Python `--mode` /
`mode=` now also shapes content (typed-no-geometry strips geometry).

## Related issues

Refs #37 (M5-01), #38-class HostObjAttr (M5-02), #40 (M5-04). Depends on
#129 (Lane Six). Aligns with #128 (Lane Nine mode names).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> IFC export behavior changes for non-scaffold modes and production
element filtering; broader surface area (partition scanner version
gates, committed binaries) but synthetic corpus and fail-closed
validation limit blast radius.
> 
> **Overview**
> Adds a **two-tier test corpus** (in-repo Apache-2.0 synthetic
`corpus/tier1/` plus optional CI-cloned magnetar tier 2), CI jobs
`corpus-tier1` / `corpus-tier2`, SHA256 license checks, and known-count
manifests—while allowing committed `.rvt` files under `corpus/` via
`.gitignore` exceptions.
> 
> Introduces **partition scanning** (`partition_scanner`), a typed
**ArcWall** partition decoder, ElemTable linkage helpers, and a
`partition_scanner_json` example for JSON diagnostics.
> 
> Adds **Lane Six geometry recovery** (`geometry/recovery`) with
fail-closed wall curves, floor boundaries, opening hosts, and level
elevations; extends typed **Wall** / **Level** projection for
`gen-fixture` fields (`m_height`, location endpoints) and centralizes
MVP typed decode via `decode_typed` / `decoder_for_class`.
> 
> Implements **Lane Seven IFC content policy** in `export_content`:
`--mode` / Python `mode=` now drives emission (not just
validation)—`typed-no-geometry` strips geometry, `geometry`/`strict`
attach recovery when present, production export drops **HostObjAttr**
proxies, and Levels become storeys from recovered elevations.
`RvtDocExporter::export_with_diagnostics_mode_and_limits` wires
CLI/Python through to export.
> 
> New integration tests cover tier1 corpus health, geometry honesty on
synthetics, and all four IFC export modes (including CLI strict
fail-closed on tier1).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f1974e6705096145c37d515b16c39137ac1f4c25. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
DrunkOnJava added a commit that referenced this pull request Aug 31, 2026
…ery (#131)

## Summary

Lane Eight (viewer) — surface decode/export confidence and IFC quality
bars from Lane Seven diagnostics, refine in-app supported-file guidance
for synthetic vs real expectations, and stage the redistributable
`corpus/tier1/` fixtures in the demo gallery.

Depends on Lane Seven (`ifc/export-modes`, PR #130).

## Motivation

Closes the M6 viewer-beta path for confidence messaging and
redistributable demos (Refs #42, #43, #44). Users need honest scaffold
~25% feedback on synthetics and a same-origin gallery that does not
require Autodesk samples.

## Changes

- `src/wasm.rs` — `openRvtBytesWithDiagnosticsMode` / `…AndLimits` for
Lane Seven quality modes
- `viewer/src/worker.ts` — parse with selected IFC bar via the new WASM
binding
- `viewer/src/main.ts` + `viewer/index.html` — Decode / Export
confidence rows, IFC bar selector + validation messaging, refined
support matrix
- `docs/viewer-demos.json` + `viewer/scripts/stage-demos.mjs` — stage
`architectural-2024`, `structural-2023`, `mep-2024` (with license
sidecars) from `corpus/tier1/`
- `viewer/tests/viewer-regression.spec.ts` — gallery +
confidence/IFC-bar coverage
- `viewer/README.md` — workflow docs for tier1 / confidence

## Testing

- [x] `wasm-pack build --target web -- --features wasm
--no-default-features`
- [x] WASM network-import audit (VW1-21) — PASS
- [x] `npm run stage:demos` — 6/8 demos staged (tier1 + synthetic + IFC;
optional RAC RFAs absent)
- [x] `npm run typecheck` / `npm run build`
- [x] `rvt-ifc` on `architectural-2024` — confidence `scaffold` / score
`0.25`
- [x] Playwright browser regressions — 3 passed, 1 skipped (no external
project corpus)
- [x] Manual GUI against localhost:5173 — tier1 gallery load,
Decode/Export rows, IFC bar geometry fail-closed messaging
- [x] `cargo fmt --check`

N/A: IFC exporter byte-stability and element-decoder unit-test checklist
(viewer/WASM surface only).

## Audit-honesty checklist

- [x] README / viewer docs state scaffold ~25% for tier1 synthetics;
typed real-project extraction remains unsolved
- [x] No over-claim of geometry/typed coverage
- [x] Commit messages describe WHAT/WHY
- [x] No emojis / private paths
- [x] No Autodesk proprietary content — only Apache-2.0 corpus/tier1
synthetics and committed IFC fixtures

## Breaking changes

None. New WASM exports are additive. Demo catalog gains tier1 entries;
`synthetic-mvp` remains as a gen-fixture fallback.

## Screenshots or output samples

Cloud Agent artifacts: gallery landing, File status Decode/Export
confidence (~25%), IFC bar geometry warning, supported-profile matrix,
walkthrough video.

## Related issues

- Refs #42 (M6-01 confidence — already closed; this extends Lane Seven
fields)
- Refs #43 (M6-02 guidance — already closed; copy refined)
- Closes #44 (M6-03 demo gallery with redistributable tier1 files)
- Depends on #130 (`ifc/export-modes`)

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
DrunkOnJava added a commit that referenced this pull request Sep 19, 2026
…names (#267)

## Summary

A Revit 2024 partition element record names the `Level` that hosts the
element, in the counted reference list at `+0x88`. Binding on that —
accepted only when the list names exactly one recovered Level — moves
storey containment on `2024_Core_Interior.rvt` from **801 to 853 of
872** emitted building elements, with **0 disagreements** against the
existing elevation join across the 537 elements both answer. Separately,
an element with no recovered storey is now contained in the
`IfcBuilding` instead of being written into whichever storey happens to
be first.

## Motivation

#219 asked for a storey for 82 unbound elements: 64 plan-loop `IFCSLAB`
and 18 name-only `IFCSPACE`. **Measured first, that set no longer
exists.** #212 replaced the plan-loop annotations with 100 record-backed
plates and #218 replaced the eleven column-derived elevations with the
fifteen real Revit Levels, so the unbound set on `main` is **71**:

| unbound | count | why the elevation join cannot reach it |
|---|---:|---|
| `IFCSLAB` | 36 | top face 0.1667 ft (2 in) below a storey — the
structural-slab / architectural-topping interface |
| `IFCSHADINGDEVICE` | 10 | same |
| `IFCWINDOW` | 6 | record base is a sill height, 4.73 ft above its
level |
| `IFCWALL` | 1 | base 56.4167 ft, mid-storey |
| `IFCSPACE` | 18 | recovered from a partition string; no element record
at all |

And all 71 were nevertheless emitted as contained in `IfcBuildingStorey`
**`Basement 2`** at −40 ft, because the writer clamped a missing index
with `storey_index.unwrap_or(0)` — 71 containment claims nothing had
measured, indistinguishable from the 5 that belong there.

## The rule

```text
level_id = the single recovered Level ElementId in the record's
           counted reference list at +0x88
```

A record that names **no** Level, or **two or more**, resolves to
nothing and keeps whatever the elevation join gives it. That is not a
tuning threshold: a Revit column or wall carries a *base constraint* and
a *top constraint* and both are in the list, so every one of the 344
`OST_Columns` records that names a Level names two, as do 432 of 638
`OST_Walls`. Nothing in the bytes says which slot is the base, so
picking one would be a guess. The columns lose nothing — all 256 already
bind exactly on their base elevation.

The uniqueness test runs against the **broader** id set (every
standalone `OST_Levels` record, not only the fifteen RE-24's
name/elevation recovery validates), so a Level the full recovery would
drop still makes a record ambiguous. The binding half then uses only the
validated fifteen; a named Level outside them binds nothing.

Measured agreement, per category (placed instances):

| category | instances | no Level | exactly one | two or more | both
joins answer | agree | disagree |
|---|---:|---:|---:|---:|---:|---:|---:|
| `OST_Floors` | 146 | 25 | 121 | 0 | 64 | 64 | **0** |
| `OST_BuildingPad` | 2 | 1 | 1 | 0 | 0 | — | — |
| `OST_Columns` | 463 | 119 | 0 | 344 | 0 | — | — |
| `OST_Walls` | 1487 | 849 | 206 | 432 | 206 | 206 | **0** |
| `OST_Doors` | 320 | 53 | 267 | 0 | 267 | 267 | **0** |
| `OST_Windows` | 7 | 1 | 6 | 0 | 0 | — | — |
| **total** | | | | | **537** | **537** | **0** |

537 of 537 agree, which is why the stated join runs first and the
inferred one fills in behind it.

## Changes

- `src/element_record_level_refs.rs` (new) — `unique_level_reference`,
the `m_levelId` field and `LevelElementId` property names, and five unit
tests covering both fail-closed edges.
- `src/partition_level_records.rs` — `scan_partition_level_ids`: the
broad Level id set in one sweep, no name/elevation blocks.
- `src/partition_schema_mvp.rs` — `element_record_decoded` attaches
`m_levelId` and flips `m_level_bound`; the level-id set is recovered
**once** in `recover_partition_schema_mvp` and threaded to every
category rather than re-scanned per category.
- `src/ifc/export_content.rs` — `LevelBindResolved` is now `true` when a
Level was named, with `LevelElementId` and `LevelBindSource` beside it.
- `src/ifc/mod.rs` — `apply_record_level_reference_storeys`, running
before the #213 elevation join, which now leaves an already-bound
element alone; `apply_partition_level_storeys` records the Level id →
storey index map into a `LevelStoreyBind`; the stale "ElementId↔Level
binding is still pending" warning now reports the real count.
- `src/ifc/step_writer.rs` — storey-less elements are contained in the
`IfcBuilding`, not in `storey[0]`.
- `tests/iter_elements_typed.rs` — new corpus gate
`core_interior_2024_storey_containment_is_evidence_backed` (skips when
the sample is absent).
- `tests/ifc_synthetic_project.rs` +
`tests/fixtures/synthetic-project.ifc` — the storey-less element now
gets its own containment relation on the building; see "IFC output"
below.
- `reports/element-framing/RE-27-level-reference-storey-bind.md` +
`examples/probe_re27_level_reference.rs` — the finding and its
reproducible probe.
- `docs/status.md`, `docs/user-guide.md`, `docs/export-diagnostics.md`,
`docs/support-matrix.json`, `CHANGELOG.md`, both project-count
manifests, both `rvt-rs` witness observations.

## IFC output

`target/ci/rvt-ifc _project_corpus/Revit/2024_Core_Interior.rvt --mode
geometry`:

| type | level reference | base elevation | top elevation | unbound |
|---|---:|---:|---:|---:|
| `IFCCOLUMN` | 0 | 256 | 0 | 0 |
| `IFCDOOR` | 132 | 0 | 0 | 0 |
| `IFCSHADINGDEVICE` | 20 | 0 | 0 | 0 |
| `IFCSLAB` | 80 | 0 | 0 | 0 |
| `IFCSPACE` | 0 | 0 | 0 | 18 |
| `IFCWALL` | 134 | 225 | 0 | 1 |
| `IFCWINDOW` | 6 | 0 | 0 | 0 |
| **total** | **372** | **481** | **0** | **19** |

Before: 0 / 747 / 54 / **71**.

| | before | after |
|---|---:|---:|
| elements in a specific `IfcBuildingStorey` | 801 | **853** |
| elements on a storey nothing measured | **71** | **0** |
| `IFCRELCONTAINEDINSPATIALSTRUCTURE` | 13 | 14 |
| `IFCPROPERTYSINGLEVALUE` | 8435 | 9231 |
| `IFCPROPERTYSET` / `IFCBUILDINGSTOREY` / `IFCRELFILLSELEMENT` /
`IFCMATERIAL` / every `by_ifc_type` | — | unchanged |
| `Basement 2` contained elements | 76 | 6 |

Every element bound in both exports keeps the same storey: 801 of 801, 0
moved, 0 lost.

`tests/fixtures/synthetic-project.ifc` is **not** byte-identical, and
the diff is the intended behaviour change: the one element with
`storey_index: None` moves out of `#146` (Ground Floor) into its own
`#148=IFCRELCONTAINEDINSPATIALSTRUCTURE(...,(#130),#20)` on the
`IfcBuilding`, and its `IfcLocalPlacement` parent moves from the Ground
Floor placement to the building placement (both are at the origin, so no
coordinate changes). The header timestamp moved because the fixture was
regenerated.

## What is NOT claimed

- **Reference side NOT MEASURED.** The paired Revit IFC exports (`IFC
Exports/2024_Core_Interior_slim.ifc`, `Revit/2024_Core_Interior.ifc`)
are not in this checkout, so none of the 853 is scored against Revit's
own `IfcRelContainedInSpatialStructure`. Every number above is measured
on the `.rvt` and on rvt-rs's own emitted STEP. No `expected_*` value in
either manifest was touched.
- **The 18 `IFCSPACE` rows stay unbound** and are not placed by
proximity — they come from partition strings, carry no element record,
and have no elevation evidence of any kind. So does `Wall 55840`, whose
record names no single Level. #219 is therefore `Refs`, not `Closes`.
- **This is not the #86 / RE-20 typed level bind.** `level_bind.rs`
binds a typed `Floor` / `Room` through an `m_level_id` schema field;
that field is still unrecovered and `level-elementid-storey-bind` stays
`unsupported` in the support matrix. A new, narrower
`record-level-reference-storey-bind` row carries this claim with its
scope stated.
- **Scope is Revit 2024 partition element records.** Where
`partition_element_records` or `partition_level_records` decline, the
level-id set is empty, the join resolves nothing, and every element
keeps the elevation join it had. Verified unchanged on the 2023 Einhoven
sample.

## Testing

- [x] `cargo test --all` passes locally — `tools/check-local.sh` green
(fmt, clippy `-D warnings`, rustdoc `-D warnings`, `cargo test
--workspace --all-targets --all-features`)
- [x] `cargo clippy --all-targets --all-features -- -D warnings` passes
- [x] `cargo fmt --check` passes
- [x] New / changed code has unit tests — 5 in
`element_record_level_refs`, 3 in `ifc::tests`
(`a_named_level_reference_binds_an_element_no_elevation_join_reaches`,
`an_unknown_level_reference_stays_unbound`,
`the_elevation_join_leaves_a_level_reference_bind_alone`), all written
failing first
- [x] IFC exporter: `tests/fixtures/synthetic-project.ifc` diff
documented above with rationale
- [x] Corpus run with `RVT_PROJECT_CORPUS_DIR` set (both magnetar `.rvt`
samples): 54 suites green, including `iter_elements_typed` (11),
`witness_verdict` (2), `ifc_roundtrip`, `ifc_export_modes`,
`arc_wall_corpus`, `support_matrix`, `json_schema_contracts`,
`witness_registry`
- [ ] **NOT MEASURED:**
`project_count_fixtures::project_count_manifests_match_available_corpus`
cannot complete locally — it panics at manifest resolution on `reference
IFC missing at .../IFC Exports/2024_Core_Interior_slim.ifc`, which is
absent from this corpus checkout, before any decoder work runs. It fails
identically on `main` here. The schema half
(`project_count_manifests_are_complete_and_explicit`) passes, and no
`decoder_*` value in either manifest moved.
- [ ] N/A: not a performance change (`tools/bench.sh` not rerun; export
wall time on the 33.7 MB sample went 25.2 s → 27.2 s for the one added
partition sweep)
- N/A: no new element decoder

## Audit-honesty checklist

- [x] README / docs reflect the current state — `docs/status.md`,
`docs/user-guide.md`, `docs/export-diagnostics.md` and
`docs/support-matrix.json` all updated, including correcting the #218
row's now-stale "46 plates remain unbound" sentence
- [x] Limitation resolved → documented: the 46 plates / 6 windows are
named in `status.md`, the RE-27 report and the manifest notes
- [x] New limitations documented in the PR body and in-code — the 19
that stay unbound, the NOT MEASURED reference side, and the 2024-only
scope
- [x] Commit message describes what changed and why
- [x] No emojis
- [x] No private paths, personal emails, or internal jargon in committed
files
- [x] RE finding: reproducible probe at
`examples/probe_re27_level_reference.rs` and a dated report at
`reports/element-framing/RE-27-level-reference-storey-bind.md`, matching
where RE-21…RE-26 live. `docs/rvt-moat-break-reconnaissance.md` carries
no RE-2x addenda and was not touched.

## Legal and contribution hygiene

- [x] Licensable under Apache-2.0
- [x] No Autodesk proprietary source, decompiled internals, or NDA'd SDK
content — the finding is byte-level observation of a file plus
Autodesk's published `BuiltInCategory` constants
- [x] No new fixtures with real-world PII

## Breaking changes

Rust API only, within the pre-1.0 crate:
`partition_schema_mvp::{columns,walls,slabs,openings,instances}_from_partition_category_records`
and `{column,wall,opening}_instances_from_records` /
`instances_from_records` / `columns_from_records` take a
`&BTreeSet<u32>` of Level ElementIds (obtain it with the new
`partition_schema_mvp::level_element_ids`, or pass an empty set to keep
the old behaviour). IFC output changes as described above.

## Related issues

Refs #219. Refs #86 / RE-20 (still unsupported for the typed
`m_level_id` join).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes IFC spatial containment semantics and export ordering (record
Level bind before elevation); scope is Revit 2024 partition records with
fail-closed rules, but downstream viewers comparing containment will see
different grouping for previously mis-placed elements.
> 
> **Overview**
> **Revit 2024 IFC export now binds building elements to storeys using
the host Level ElementId named in each partition element record** (#219,
RE-27), when the record’s `+0x88` reference list names exactly one
recovered Level. That join runs before the existing elevation match,
leaves already-bound elements alone, and surfaces `LevelBindResolved`,
`LevelElementId`, `LevelBindSource`, and `StoreyBindSource =
record_level_reference` on emitted elements. Columns and walls that name
two Levels (base/top constraints) are declined and keep the elevation
join.
> 
> **Elements with no recovered storey are no longer written into the
first storey.** The STEP writer used to use `storey_index.unwrap_or(0)`;
they are now related to **`IfcBuilding`** via a separate
`IfcRelContainedInSpatialStructure`, so “storey unknown” is explicit
instead of falsely placing items (e.g. 71 elements into `Basement 2` on
Core Interior).
> 
> On `2024_Core_Interior.rvt`, measured containment rises **801 → 853 of
872** building elements in a named storey (plates below level, windows
at sill height, etc.), with **19** still unbound (18 name-only spaces,
one wall). Docs, support matrix, corpus gates, RE-27 report, and witness
observation hashes reflect the new properties and relation count.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
0ba6217. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

BREAKING CHANGE: the five `partition_schema_mvp` entry points now take
the recovered `Level` ElementId set (`&BTreeSet<u32>`, see
`level_element_ids`) so the record reference list can be tested for a
unique Level; callers that used the previous two-argument forms must
pass it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants