Skip to content

fix(ifc): full IFC4 attribute lists on every emitted instance, and storeys from element-record bboxes - #217

Merged
DrunkOnJava merged 1 commit into
mainfrom
fix/ifc4-predefined-type-and-storeys
Aug 30, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
fix/ifc4-predefined-type-and-storeys

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Aug 30, 2026 •

Copy link
Copy Markdown
Owner

Two IFC4 writer fixes that share the same emitted files, so they are measured together.

#214 — every emitted instance now carries the full IFC4 attribute list

The writer emitted building elements with IfcProduct's seven attributes plus Tag and stopped. IFC4 requires an instance to list every attribute its entity type declares — an unknown optional occupies its slot as $, it is not dropped — so those records were non-conformant, and reading the attribute raised:

>>> c.PredefinedType
RuntimeError: Index 8 is out of range for variant of size 8

IfcEntity::BuildingElement now carries a predefined_type populated from category_map, and emission is driven by a per-type attribute layout table.

Attribute arity, before → after

Measured with IfcOpenShell 0.8.5 by counting top-level attributes in the STEP text and comparing with schema_by_name("IFC4").declaration_by_name(<name>).attribute_count().

2024_Core_Interior.rvt (sha256 c805df44…), emitted by rvt-ifc:

Entity written before written after IFC4 declares instances
IFCCOLUMN 8 9 9 256
IFCSLAB 8 9 9 64
IFCSPACE 8 11 11 18

Mismatching instances on that file: 338 → 0, across all 33 emitted entity types.

tests/fixtures/synthetic-project.ifc:

Entity before after declares instances
IFCWALL 8 9 9 4
IFCSLAB 8 9 9 1
IFCSTAIR 8 9 9 1
IFCBUILDINGELEMENTPROXY 8 9 9 1
IFCDOOR 10 13 13 1
IFCWINDOW 10 13 13 2

10 → 0 mismatching.

tests/fixtures/synthetic-structural.ifc:

Entity before after declares instances
IFCCOLUMN 8 9 9 2
IFCBEAM 8 9 9 2
IFCFURNITURE 8 9 9 1
IFCDOOR 10 13 13 3
IFCISHAPEPROFILEDEF 8 10 10 3

11 → 0 mismatching.

Three further arity defects the same audit surfaced, not exercised by the files above but fixed at the emission site:

Entity before after declares missing attribute(s)
IFCISHAPEPROFILEDEF 8 10 10 FlangeEdgeRadius, FlangeSlope (IFC4 additions over IFC2X3)
IFCCLASSIFICATIONREFERENCE 5 6 6 Sort
IFCMATERIALLAYERSETUSAGE 4 5 5 ReferenceExtent

Plus IfcBuildingStorey.Elevation, which was written as a bare integer literal (…,.ELEMENT.,0);) where ISO-10303-21 requires a REAL — now 0.000000.

PredefinedType values

category_map already held them; they are now written. Cross-checked against Revit's own export of the same file:

Revit class rvt-rs emits Revit's export emits
Column / StructuralColumn .COLUMN. .COLUMN. (256/256)
Floor .FLOOR. .FLOOR. (78/80; 2 are .ROOF.)
Wall / ArcWall .STANDARD. .NOTDEFINED.
Room .INTERNAL. .SPACE.

Where category_map has no value the slot is written as $ — the writer never invents an enum token. Two related changes fell out:

  • IFCSPACE slot 8 is LongName, not Tag. IfcSpace is an IfcSpatialStructureElement and declares no Tag at all, so the type GUID the writer used to put there was in the wrong slot. It now carries the element name, with CompositionType = .ELEMENT. matching Revit's export.
  • A hostile PredefinedType degrades to $. A STEP enumeration reference is written bare between dots and has no escape form, so a value with a quote or a dot in it would corrupt the record; tests/fuzz_regressions.rs drives adversarial names through the path.

Making the gap impossible to reintroduce

tools/ci/ifc_schema_arity.py re-derives every entity's declared attribute count from the IFC4 EXPRESS schema and compares it with the count actually written, for every instance in the file, plus a null check on PredefinedType for the entity types where every category_map row supplies one (IfcBeam, IfcColumn, IfcCovering, IfcMember, IfcSlab, IfcWall). This is the check that was missing: IfcOpenShell's open() happily parses a short record, so the existing count-only gate never saw the defect.

Wired into three places:

  • the ifcopenshell-validate CI job, over both committed fixtures and the freshly emitted real-project IFC;
  • tools/ci/validate-real-ifc.py, so the existing real-project gate covers it too;
  • tools/check-local.sh --ifcopenshell.

Plus Rust-side tests that need no Python toolchain: a table of the 28 emitted entity types with their schema-declared arity, asserted against both the writer's layout table and the emitted text; a sweep proving every category_map row resolves to a covered type; slot-position assertions for PredefinedType; and the hostile-token test.

Local validation output

$ python tools/ci/ifc_schema_arity.py tests/fixtures/synthetic-project.ifc tests/fixtures/synthetic-structural.ifc
IFC schema conformance passed: tests/fixtures/synthetic-project.ifc
  schema: IFC4
  instances checked: 147 across 42 entity type(s)
  PredefinedType populated: IfcSlab=1, IfcWall=4
IFC schema conformance passed: tests/fixtures/synthetic-structural.ifc
  schema: IFC4
  instances checked: 149 across 42 entity type(s)
  PredefinedType populated: IfcBeam=2, IfcColumn=2

$ python tools/ci/ifc_schema_arity.py core-interior.rvt-rs.ifc
IFC schema conformance passed: core-interior.rvt-rs.ifc
  schema: IFC4
  instances checked: 5584 across 33 entity type(s)
  PredefinedType populated: IfcColumn=256, IfcSlab=64

$ python tools/ci/validate-real-ifc.py walker-real-project.ifc walker-real-project.diagnostics.json
Real-project IfcOpenShell validation passed:
  schema: IFC4
  entities: 725
  schema arity: 725 instance(s) across 33 entity type(s) match their declared attribute count
  PredefinedType populated: IfcSlab=13, IfcWall=24
  exported.by_ifc_type: {'IFCSLAB': 13, 'IFCSPACE': 14, 'IFCWALL': 24}
  spatial containment: 4 rel(s), 51 related element(s) across 4 storey(s)
  geometry-backed elements: 24
  material count: 42
  unit assignments: 6

Both committed fixtures were regenerated. Entity text changes; entity counts do not.

#213 — storey elevations from the element-record bbox distribution, then bind

src/element_record_storeys.rs turns the distinct base z of the partition element records into building storeys, and ifc::apply_element_record_storeys contains each recorded element in the storey whose elevation equals its base.

Storey measurements on 2024_Core_Interior.rvt

Reference is IFC Exports/2024_Core_Interior_slim.ifc (sha256 bfdf36ff…), read with IfcOpenShell 0.8.5. That file's length unit is FOOT (IfcConversionBasedUnit … 'FOOT'), so its Elevation values are feet; rvt-rs writes metres and is converted for the comparison.

reference (ft): [-40.0, -20.0, 0.0, 15.0, 31.0, 46.0, 61.0, 76.0, 91.0, 106.0, 121.0, 136.0, 151.0, 166.0, 185.5]
rvt-rs    (ft): [0.0, 31.0, 46.0, 61.0, 76.0, 91.0, 106.0, 121.0, 136.0, 151.0, 166.0]
exact matches: 11/11 emitted, 11/15 of the export
missed by rvt-rs: [-40.0, -20.0, 15.0, 185.5]
rvt-rs only     : []
before after
diagnostics.exported.storey_count 12 11
storey elevations matching the export exactly 1 of 12 (0.0, by accident) 11 of 11
false-positive elevations 11 0
export storeys recovered 1 of 15 11 of 15
IFCRELCONTAINEDINSPATIALSTRUCTURE 1 11
elements in a specific storey 0 of 338 (all defaulted to storey[0]) 256 of 338
unsupported_geometry_missing_level 274 18

Column distribution across the recovered storeys (24/24/24/24/23/23/23/23/23/23/22 = 256):

    0.0000 ft    24 columns      91.0000 ft    23 columns
   31.0000 ft    24 columns     106.0000 ft    23 columns
   46.0000 ft    24 columns     121.0000 ft    23 columns
   61.0000 ft    24 columns     136.0000 ft    23 columns
   76.0000 ft    23 columns     151.0000 ft    23 columns
                                166.0000 ft    22 columns

The remaining 82 unbound elements are the 64 plan-loop IFCSLAB boundary annotations and 18 name-only IFCSPACE rows, neither of which carries a record bbox — they keep storey_index: None and fall to the writer's default container, which is the honest state.

Note on #213's premise: the issue predicted ten distinct base elevations; the measurement on the recovered record set is eleven, with 166 ft (the export's Level 12) the additional one.

What is not claimed

Storey names are not recovered with the elevations, and this is a measured refusal rather than an omission. There are 12 recovered Level-like name candidates against 11 measured elevations, so the fail-closed rule the ArcWall path already uses (transfer names only when the counts match) does not fire — and checking a rank join against the reference confirms it would be wrong: it puts Level 6 at 91 ft where the export puts Level 7. Every storey is therefore labelled Elevation N ft, the 12 names stay visible in diagnostics.decoded.production_class_counts.Level, and a diagnostics warning states the situation:

11 building storey elevation(s) were measured from partition element-record bounding boxes
and 256 building element(s) bound to them by base elevation (#213); the 12 recovered Level
name string(s) could not be paired with those elevations and are not asserted as storey names.

Level ElementId binding stays unsolved — #86 / RE-20 is untouched, LevelBindResolved stays false, and elements bound by elevation additionally carry StoreyBindSource = record_base_elevation so the two joins can never be confused.

Fail-closed on both halves

  • The storey set is replaced only when the recovered Level rows carry no elevation of their own (all at one value) and at least two distinct elevations were measured. The 2023 ArcWall path, which already recovers real elevations, is untouched — verified on the Einhoven sample: 4 storeys, 4 containment relations, byte-identical behaviour.
  • The join is elevation equality within 1e-3 ft and returns None both on a miss and on an ambiguity (two storeys inside the window).
  • Representative elevations are quantised to 1e-4 ft (0.03 mm), because bbox arithmetic leaves the Level 1 base at -1.9e-14 ft rather than 0.0.

Diagnostics

New: exported.storey_elevations_feet (aligned with the existing storey_names; an all-zero list is the honest signal that only name strings were recovered) and exported.storey_bound_elements. Documented in docs/export-diagnostics.md under a new Storey provenance section.

Witness observations and verdicts

The #214 change alters entity text, not counts, so it needed no regeneration on its own. The #213 change does move counts, so both rvt-rs.json observations were regenerated per docs/verification-protocol.md § OctetProof alignment:

field before after
IFCBUILDINGSTOREY 12 11
IFCRELCONTAINEDINSPATIALSTRUCTURE 1 11
IFCLOCALPLACEMENT 352 351
IFCPROPERTYSINGLEVALUE 1536 1792
storey_count 12 11

observation_hash_sha256 for both artifacts: 8f2282bc280c2c103dd54fa7fe6e20dae71811598064871b790e033676ae62be → b1ae3c34ebf7b6261c11d65b67af240e1c398ac046f4e8838ca3a356080181d8. The two bridge observations (IfcOpenShell, IFClite) read the reference IFC and are unchanged.

Both committed verdicts re-ran and are byte-identical — still PASS, three lineages, 0 diffs — because entity_counts.IFCBUILDINGSTOREY is a decoder_baseline field and sits outside the claimed surface:

magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs
  surface: 7 fields, excluded: 5, diffs: 0
  replay ifc-lite: match / replay ifcopenshell: match / replay rvt-rs: match
magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs
  surface: 5 fields, excluded: 8, diffs: 0
  replay ifc-lite: match / replay ifcopenshell: match / replay rvt-rs: match

Docs and manifests

  • levels.decoder_expected 12 → 11 in both project-count manifests, tolerance 0, with the measurement recorded in the notes.
  • New record-elevation-storey-bind row in docs/support-matrix.json (verified, scope stated: elevations only, Revit 2024, one decoded category). level-elementid-storey-bind stays unsupported.
  • docs/status.md storey paragraph and the IFC4-writer capability row; docs/export-diagnostics.md field table + Storey provenance section; CHANGELOG.md under Added / Changed / Fixed.

Gate

cargo fmt --all · cargo clippy --all-targets -- -D warnings · cargo +1.85.0 check --all-targets (MSRV, no let-chains) · cargo test --profile ci with RVT_PROJECT_CORPUS_DIR set, including --test ifc_roundtrip --test ifc_synthetic_project --test ifc_synthetic_structural --test project_count_fixtures --test witness_verdict · tools/check-local.sh --ifcopenshell — all green (916 lib tests).

Lane note

src/ifc/export_content.rs carries a deliberately minimal two-line hunk (predefined_type: mapping.predefined_type.map(str::to_string) at the one construction site, plus the same field in one test literal) — the wall/door/window lane owns that file. src/partition_schema_mvp.rs is untouched: the #213 join reads the record base elevation back off the emitted element via its BodySource property, so nothing in the recovery path had to change, and a round-trip test pins that coupling.

Closes #214
Closes #213

https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C


Note

Medium Risk
Changes core IFC export (STEP writer and spatial containment) and shifts real-project diagnostics/witness hashes, but behavior is heavily regression-tested and gated by schema-arity CI.

Overview
This PR fixes IFC4 STEP conformance (#214) and measured storey containment on Revit 2024 Core Interior (#213), with regenerated fixtures, witness observations, and new CI gates.

#214 — writer emits every declared attribute. Building elements were one or more attributes short (e.g. IFCCOLUMN at 8 vs 9), which broke PredefinedType reads in strict consumers. step_writer now uses per-type tail layouts, fills unknown optionals with $, maps predefined_type from category_map, fixes IFCSPACE (LongName vs Tag), and patches arity on IFCISHAPEPROFILEDEF, IFCCLASSIFICATIONREFERENCE, and IFCMATERIALLAYERSETUSAGE. Storey elevations are emitted as REAL literals. Hostile enum tokens degrade to $. tools/ci/ifc_schema_arity.py compares EXPRESS-declared arity (and required PredefinedType) against every STEP instance; it runs in CI, validate-real-ifc.py, and check-local.sh --ifcopenshell, with matching Rust arity tests.

#213 — storeys from partition element-record base z. New element_record_storeys derives distinct bbox elevations into IfcBuildingStorey rows when existing levels have no elevation evidence, then binds record-sourced columns by exact elevation (fail-closed on miss/ambiguity). Core Interior goes 12 → 11 storeys (measured vs name-only), 1 → 11 IfcRelContainedInSpatialStructure, 256 elements storey-bound; names stay Elevation N ft when 12 Level strings cannot pair with 11 elevations. Diagnostics add storey_elevations_feet and storey_bound_elements.

Reviewed by Cursor Bugbot for commit 8c9b1e7. Configure here.

…bboxes

Two fixes to the IFC4 STEP writer that share the same emitted files.

#214 — every emitted instance now carries the full attribute list its
entity type declares. The writer stopped after IfcProduct's seven
attributes plus Tag, so IFCCOLUMN / IFCSLAB / IFCWALL / IFCBEAM were one
short of the schema's nine, IFCDOOR / IFCWINDOW three short of thirteen,
and IFCSPACE three short of eleven. IFC4 requires an instance to list
every attribute its type declares — an unknown optional occupies its slot
as `$` — so these records were non-conformant, and reading PredefinedType
off one raised "Index 8 is out of range for variant of size 8". 338
instances on 2024_Core_Interior.rvt, 21 across the two committed
fixtures.

Emission is now driven by a per-type attribute layout, and
IfcEntity::BuildingElement carries a predefined_type populated from
category_map, so a Column emits .COLUMN., a Floor .FLOOR., a Wall
.STANDARD., a Room .INTERNAL. IFCSPACE also stops writing the type GUID
into slot 8: IfcSpace is a spatial element with no Tag, so that slot is
LongName. A value that is not a legal STEP enumeration name degrades to
`$` rather than corrupting the record, since an enumeration reference has
no escape form.

The same audit surfaced three more arity defects, all fixed here:
IFCISHAPEPROFILEDEF wrote 8 against IFC4's 10 (FlangeEdgeRadius,
FlangeSlope), IFCCLASSIFICATIONREFERENCE 5 against 6 (Sort), and
IFCMATERIALLAYERSETUSAGE 4 against 5 (ReferenceExtent). Elevation on
IFCBUILDINGSTOREY was a bare integer literal where ISO-10303-21 wants a
REAL. The emitted Core Interior IFC goes from 338 mismatching instances
to 0 across all 33 entity types.

tools/ci/ifc_schema_arity.py re-derives every entity's declared attribute
count from the IFC4 EXPRESS schema and compares it with what the STEP
text wrote, for every instance in a file, plus a null check on
PredefinedType where category_map always supplies one. IfcOpenShell's
open() accepts a short record, so the existing count-only gate could not
see this class of defect. Wired into the ifcopenshell-validate job over
both fixtures and the freshly emitted real-project IFC, into
check-local.sh --ifcopenshell, and into validate-real-ifc.py; a Rust
regression test pins the same table without needing Python.

#213 — storey elevations now come from the partition element-record
bounding-box distribution, and each recorded element is contained in the
storey whose elevation equals its base. On 2024_Core_Interior.rvt the 256
recovered OST_Columns records stand on exactly 11 distinct base
elevations (0, 31, 46, 61, 76, 91, 106, 121, 136, 151, 166 ft) and all 11
equal an IfcBuildingStorey.Elevation in Revit's own export of the same
file, with no false positives; the export's other four (-40, -20, 15,
185.5 ft) carry no column record and are not claimed.
IfcRelContainedInSpatialStructure goes 1 -> 11 and 256 of 338 elements
land in a specific storey instead of all 338 defaulting to the first.

Both halves fail closed. The storey set is replaced only when the
recovered Level rows carry no elevation of their own, so the 2023 ArcWall
path is untouched (Einhoven: 4 storeys, 4 containment relations,
unchanged). An element whose base matches no storey, or more than one,
stays unbound. Level names are deliberately not paired with the measured
elevations: 12 name candidates against 11 elevations is not a pairing,
and a rank join puts Level 6 at 91 ft where the export puts Level 7, so
every storey is labelled "Elevation N ft" and the names stay visible in
diagnostics.decoded.production_class_counts.Level. Level ElementId
binding remains unsolved (#86 / RE-20) and is not what this does.

storey_count moves 12 -> 11 in both project-count manifests; both rvt-rs
observations were regenerated (IFCBUILDINGSTOREY 12 -> 11,
IFCRELCONTAINEDINSPATIALSTRUCTURE 1 -> 11, IFCLOCALPLACEMENT 352 -> 351,
IFCPROPERTYSINGLEVALUE 1536 -> 1792, storey_count 12 -> 11), so their
observation_hash_sha256 changed; both committed verdicts still PASS
byte-identically because entity_counts.IFCBUILDINGSTOREY is a
decoder_baseline field outside the claimed surface.
unsupported_geometry_missing_level drops 274 -> 18.

Closes #214
Closes #213

Claude-Session: https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C
@cursor

cursor Bot commented Aug 30, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_5a434650-a811-4d69-9b9e-f5f2c3ddff23)

@DrunkOnJava
DrunkOnJava merged commit f4b88df into main Aug 30, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/ifc4-predefined-type-and-storeys branch August 30, 2026 15:12
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
…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
Adds `ParameterValueSource` enum distinguishing the three kinds
of parameter-value sources Revit supports:

- UserSet (default): user types / picks; writable.
- Calculated: formula-driven. Revit recomputes from a formula
  string ("= 2 * Height + Width") on every input change. Not
  user-editable.
- Reporting: value pulled from geometry / element properties at
  read time (e.g., Dimension reporting its length). Not user-
  editable.

`ParameterElement` gains `value_source: Option<ParameterValueSource>`.
`from_decoded` reads `m_is_calculated` / `m_is_formula` /
`m_is_reporting` flags (all three aliases accepted — different
schema versions use slightly different field names). Precedence
when both flags are set: reporting > calculated > user-set
(reporting is the stronger read-only constraint; calculated can
coexist with formula-evaluated writes, but reporting never
writes).

New helper `is_user_writable()` returns `true` for UserSet or
missing flags (safe default), `false` for calculated / reporting.

6 new tests covering:
- flags-absent → None / writable
- calculated=true, reporting=false → Calculated / not-writable
- reporting=true → Reporting / not-writable
- both flags true → Reporting wins (stronger constraint)
- both flags false → UserSet / writable
- `m_is_formula` alias accepted alongside `m_is_calculated`

374 lib tests pass (was 368, +6). Closes L5B-56 (#217).
DrunkOnJava added a commit that referenced this pull request Aug 31, 2026
…oreys from element-record bboxes (#217)

Two IFC4 writer fixes that share the same emitted files, so they are
measured together.

## #214 — every emitted instance now carries the full IFC4 attribute
list

The writer emitted building elements with `IfcProduct`'s seven
attributes plus `Tag` and stopped. IFC4 requires an instance to list
**every** attribute its entity type declares — an unknown optional
occupies its slot as `$`, it is not dropped — so those records were
non-conformant, and reading the attribute raised:

```
>>> c.PredefinedType
RuntimeError: Index 8 is out of range for variant of size 8
```

`IfcEntity::BuildingElement` now carries a `predefined_type` populated
from `category_map`, and emission is driven by a per-type attribute
layout table.

### Attribute arity, before → after

Measured with IfcOpenShell 0.8.5 by counting top-level attributes in the
STEP text and comparing with
`schema_by_name("IFC4").declaration_by_name(<name>).attribute_count()`.

**`2024_Core_Interior.rvt`** (sha256 `c805df44…`), emitted by `rvt-ifc`:

| Entity | written before | written after | IFC4 declares | instances |
|---|---:|---:|---:|---:|
| `IFCCOLUMN` | 8 | **9** | 9 | 256 |
| `IFCSLAB` | 8 | **9** | 9 | 64 |
| `IFCSPACE` | 8 | **11** | 11 | 18 |

Mismatching instances on that file: **338 → 0**, across all 33 emitted
entity types.

**`tests/fixtures/synthetic-project.ifc`**:

| Entity | before | after | declares | instances |
|---|---:|---:|---:|---:|
| `IFCWALL` | 8 | **9** | 9 | 4 |
| `IFCSLAB` | 8 | **9** | 9 | 1 |
| `IFCSTAIR` | 8 | **9** | 9 | 1 |
| `IFCBUILDINGELEMENTPROXY` | 8 | **9** | 9 | 1 |
| `IFCDOOR` | 10 | **13** | 13 | 1 |
| `IFCWINDOW` | 10 | **13** | 13 | 2 |

10 → 0 mismatching.

**`tests/fixtures/synthetic-structural.ifc`**:

| Entity | before | after | declares | instances |
|---|---:|---:|---:|---:|
| `IFCCOLUMN` | 8 | **9** | 9 | 2 |
| `IFCBEAM` | 8 | **9** | 9 | 2 |
| `IFCFURNITURE` | 8 | **9** | 9 | 1 |
| `IFCDOOR` | 10 | **13** | 13 | 3 |
| `IFCISHAPEPROFILEDEF` | 8 | **10** | 10 | 3 |

11 → 0 mismatching.

Three further arity defects the same audit surfaced, not exercised by
the files above but fixed at the emission site:

| Entity | before | after | declares | missing attribute(s) |
|---|---:|---:|---:|---|
| `IFCISHAPEPROFILEDEF` | 8 | **10** | 10 | `FlangeEdgeRadius`,
`FlangeSlope` (IFC4 additions over IFC2X3) |
| `IFCCLASSIFICATIONREFERENCE` | 5 | **6** | 6 | `Sort` |
| `IFCMATERIALLAYERSETUSAGE` | 4 | **5** | 5 | `ReferenceExtent` |

Plus `IfcBuildingStorey.Elevation`, which was written as a bare integer
literal (`…,.ELEMENT.,0);`) where ISO-10303-21 requires a REAL — now
`0.000000`.

### PredefinedType values

`category_map` already held them; they are now written. Cross-checked
against Revit's own export of the same file:

| Revit class | rvt-rs emits | Revit's export emits |
|---|---|---|
| `Column` / `StructuralColumn` | `.COLUMN.` | `.COLUMN.` (256/256) |
| `Floor` | `.FLOOR.` | `.FLOOR.` (78/80; 2 are `.ROOF.`) |
| `Wall` / `ArcWall` | `.STANDARD.` | `.NOTDEFINED.` |
| `Room` | `.INTERNAL.` | `.SPACE.` |

Where `category_map` has no value the slot is written as `$` — the
writer never invents an enum token. Two related changes fell out:

- **`IFCSPACE` slot 8 is `LongName`, not `Tag`.** `IfcSpace` is an
`IfcSpatialStructureElement` and declares no `Tag` at all, so the type
GUID the writer used to put there was in the wrong slot. It now carries
the element name, with `CompositionType = .ELEMENT.` matching Revit's
export.
- **A hostile `PredefinedType` degrades to `$`.** A STEP enumeration
reference is written bare between dots and has no escape form, so a
value with a quote or a dot in it would corrupt the record;
`tests/fuzz_regressions.rs` drives adversarial names through the path.

### Making the gap impossible to reintroduce

`tools/ci/ifc_schema_arity.py` re-derives every entity's declared
attribute count from the IFC4 EXPRESS schema and compares it with the
count actually written, **for every instance in the file**, plus a null
check on `PredefinedType` for the entity types where every
`category_map` row supplies one (`IfcBeam`, `IfcColumn`, `IfcCovering`,
`IfcMember`, `IfcSlab`, `IfcWall`). This is the check that was missing:
IfcOpenShell's `open()` happily parses a short record, so the existing
count-only gate never saw the defect.

Wired into three places:

- the `ifcopenshell-validate` CI job, over both committed fixtures
**and** the freshly emitted real-project IFC;
- `tools/ci/validate-real-ifc.py`, so the existing real-project gate
covers it too;
- `tools/check-local.sh --ifcopenshell`.

Plus Rust-side tests that need no Python toolchain: a table of the 28
emitted entity types with their schema-declared arity, asserted against
both the writer's layout table and the emitted text; a sweep proving
every `category_map` row resolves to a covered type; slot-position
assertions for `PredefinedType`; and the hostile-token test.

### Local validation output

```
$ python tools/ci/ifc_schema_arity.py tests/fixtures/synthetic-project.ifc tests/fixtures/synthetic-structural.ifc
IFC schema conformance passed: tests/fixtures/synthetic-project.ifc
  schema: IFC4
  instances checked: 147 across 42 entity type(s)
  PredefinedType populated: IfcSlab=1, IfcWall=4
IFC schema conformance passed: tests/fixtures/synthetic-structural.ifc
  schema: IFC4
  instances checked: 149 across 42 entity type(s)
  PredefinedType populated: IfcBeam=2, IfcColumn=2

$ python tools/ci/ifc_schema_arity.py core-interior.rvt-rs.ifc
IFC schema conformance passed: core-interior.rvt-rs.ifc
  schema: IFC4
  instances checked: 5584 across 33 entity type(s)
  PredefinedType populated: IfcColumn=256, IfcSlab=64

$ python tools/ci/validate-real-ifc.py walker-real-project.ifc walker-real-project.diagnostics.json
Real-project IfcOpenShell validation passed:
  schema: IFC4
  entities: 725
  schema arity: 725 instance(s) across 33 entity type(s) match their declared attribute count
  PredefinedType populated: IfcSlab=13, IfcWall=24
  exported.by_ifc_type: {'IFCSLAB': 13, 'IFCSPACE': 14, 'IFCWALL': 24}
  spatial containment: 4 rel(s), 51 related element(s) across 4 storey(s)
  geometry-backed elements: 24
  material count: 42
  unit assignments: 6
```

Both committed fixtures were regenerated. Entity **text** changes;
entity **counts** do not.

## #213 — storey elevations from the element-record bbox distribution,
then bind

`src/element_record_storeys.rs` turns the distinct base `z` of the
partition element records into building storeys, and
`ifc::apply_element_record_storeys` contains each recorded element in
the storey whose elevation equals its base.

### Storey measurements on `2024_Core_Interior.rvt`

Reference is `IFC Exports/2024_Core_Interior_slim.ifc` (sha256
`bfdf36ff…`), read with IfcOpenShell 0.8.5. That file's length unit is
`FOOT` (`IfcConversionBasedUnit … 'FOOT'`), so its `Elevation` values
are feet; rvt-rs writes metres and is converted for the comparison.

```
reference (ft): [-40.0, -20.0, 0.0, 15.0, 31.0, 46.0, 61.0, 76.0, 91.0, 106.0, 121.0, 136.0, 151.0, 166.0, 185.5]
rvt-rs    (ft): [0.0, 31.0, 46.0, 61.0, 76.0, 91.0, 106.0, 121.0, 136.0, 151.0, 166.0]
exact matches: 11/11 emitted, 11/15 of the export
missed by rvt-rs: [-40.0, -20.0, 15.0, 185.5]
rvt-rs only     : []
```

| | before | after |
|---|---:|---:|
| `diagnostics.exported.storey_count` | 12 | **11** |
| storey elevations matching the export exactly | 1 of 12 (`0.0`, by
accident) | **11 of 11** |
| false-positive elevations | 11 | **0** |
| export storeys recovered | 1 of 15 | **11 of 15** |
| `IFCRELCONTAINEDINSPATIALSTRUCTURE` | 1 | **11** |
| elements in a specific storey | 0 of 338 (all defaulted to storey[0])
| **256 of 338** |
| `unsupported_geometry_missing_level` | 274 | **18** |

Column distribution across the recovered storeys
(24/24/24/24/23/23/23/23/23/23/22 = 256):

```
    0.0000 ft    24 columns      91.0000 ft    23 columns
   31.0000 ft    24 columns     106.0000 ft    23 columns
   46.0000 ft    24 columns     121.0000 ft    23 columns
   61.0000 ft    24 columns     136.0000 ft    23 columns
   76.0000 ft    23 columns     151.0000 ft    23 columns
                                166.0000 ft    22 columns
```

The remaining 82 unbound elements are the 64 plan-loop `IFCSLAB`
boundary annotations and 18 name-only `IFCSPACE` rows, neither of which
carries a record bbox — they keep `storey_index: None` and fall to the
writer's default container, which is the honest state.

**Note on #213's premise:** the issue predicted ten distinct base
elevations; the measurement on the recovered record set is **eleven**,
with 166 ft (the export's `Level 12`) the additional one.

### What is not claimed

Storey **names** are not recovered with the elevations, and this is a
measured refusal rather than an omission. There are 12 recovered
Level-like name candidates against 11 measured elevations, so the
fail-closed rule the ArcWall path already uses (transfer names only when
the counts match) does not fire — and checking a rank join against the
reference confirms it would be wrong: it puts `Level 6` at 91 ft where
the export puts `Level 7`. Every storey is therefore labelled `Elevation
N ft`, the 12 names stay visible in
`diagnostics.decoded.production_class_counts.Level`, and a diagnostics
warning states the situation:

```
11 building storey elevation(s) were measured from partition element-record bounding boxes
and 256 building element(s) bound to them by base elevation (#213); the 12 recovered Level
name string(s) could not be paired with those elevations and are not asserted as storey names.
```

Level **ElementId** binding stays unsolved — #86 / RE-20 is untouched,
`LevelBindResolved` stays `false`, and elements bound by elevation
additionally carry `StoreyBindSource = record_base_elevation` so the two
joins can never be confused.

### Fail-closed on both halves

- The storey set is replaced **only** when the recovered `Level` rows
carry no elevation of their own (all at one value) and at least two
distinct elevations were measured. The 2023 ArcWall path, which already
recovers real elevations, is untouched — verified on the Einhoven
sample: 4 storeys, 4 containment relations, byte-identical behaviour.
- The join is elevation equality within 1e-3 ft and returns `None` both
on a miss **and** on an ambiguity (two storeys inside the window).
- Representative elevations are quantised to 1e-4 ft (0.03 mm), because
bbox arithmetic leaves the `Level 1` base at `-1.9e-14` ft rather than
`0.0`.

### Diagnostics

New: `exported.storey_elevations_feet` (aligned with the existing
`storey_names`; an all-zero list is the honest signal that only name
strings were recovered) and `exported.storey_bound_elements`. Documented
in `docs/export-diagnostics.md` under a new **Storey provenance**
section.

## Witness observations and verdicts

The #214 change alters entity **text**, not counts, so it needed no
regeneration on its own. The #213 change does move counts, so both
`rvt-rs.json` observations were regenerated per
`docs/verification-protocol.md` § OctetProof alignment:

| field | before | after |
|---|---:|---:|
| `IFCBUILDINGSTOREY` | 12 | 11 |
| `IFCRELCONTAINEDINSPATIALSTRUCTURE` | 1 | 11 |
| `IFCLOCALPLACEMENT` | 352 | 351 |
| `IFCPROPERTYSINGLEVALUE` | 1536 | 1792 |
| `storey_count` | 12 | 11 |

`observation_hash_sha256` for both artifacts:
`8f2282bc280c2c103dd54fa7fe6e20dae71811598064871b790e033676ae62be` →
`b1ae3c34ebf7b6261c11d65b67af240e1c398ac046f4e8838ca3a356080181d8`. The
two bridge observations (IfcOpenShell, IFClite) read the reference IFC
and are unchanged.

Both committed verdicts re-ran and are **byte-identical** — still
`PASS`, three lineages, 0 diffs — because
`entity_counts.IFCBUILDINGSTOREY` is a `decoder_baseline` field and sits
outside the claimed surface:

```
magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs
  surface: 7 fields, excluded: 5, diffs: 0
  replay ifc-lite: match / replay ifcopenshell: match / replay rvt-rs: match
magnetar-2024-core-interior-slim: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs
  surface: 5 fields, excluded: 8, diffs: 0
  replay ifc-lite: match / replay ifcopenshell: match / replay rvt-rs: match
```

## Docs and manifests

- `levels.decoder_expected` 12 → 11 in both project-count manifests,
tolerance 0, with the measurement recorded in the notes.
- New `record-elevation-storey-bind` row in `docs/support-matrix.json`
(`verified`, scope stated: elevations only, Revit 2024, one decoded
category). `level-elementid-storey-bind` stays `unsupported`.
- `docs/status.md` storey paragraph and the IFC4-writer capability row;
`docs/export-diagnostics.md` field table + Storey provenance section;
`CHANGELOG.md` under Added / Changed / Fixed.

## Gate

`cargo fmt --all` · `cargo clippy --all-targets -- -D warnings` · `cargo
+1.85.0 check --all-targets` (MSRV, no let-chains) · `cargo test
--profile ci` with `RVT_PROJECT_CORPUS_DIR` set, including `--test
ifc_roundtrip --test ifc_synthetic_project --test
ifc_synthetic_structural --test project_count_fixtures --test
witness_verdict` · `tools/check-local.sh --ifcopenshell` — all green
(916 lib tests).

## Lane note

`src/ifc/export_content.rs` carries a deliberately minimal two-line hunk
(`predefined_type: mapping.predefined_type.map(str::to_string)` at the
one construction site, plus the same field in one test literal) — the
wall/door/window lane owns that file. `src/partition_schema_mvp.rs` is
untouched: the #213 join reads the record base elevation back off the
emitted element via its `BodySource` property, so nothing in the
recovery path had to change, and a round-trip test pins that coupling.

Closes #214
Closes #213

https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes core IFC export (STEP writer and spatial containment) and
shifts real-project diagnostics/witness hashes, but behavior is heavily
regression-tested and gated by schema-arity CI.
> 
> **Overview**
> This PR fixes **IFC4 STEP conformance** (#214) and **measured storey
containment** on Revit 2024 Core Interior (#213), with regenerated
fixtures, witness observations, and new CI gates.
> 
> **#214 — writer emits every declared attribute.** Building elements
were one or more attributes short (e.g. `IFCCOLUMN` at 8 vs 9), which
broke `PredefinedType` reads in strict consumers. `step_writer` now uses
per-type tail layouts, fills unknown optionals with `$`, maps
`predefined_type` from `category_map`, fixes `IFCSPACE` (`LongName` vs
`Tag`), and patches arity on `IFCISHAPEPROFILEDEF`,
`IFCCLASSIFICATIONREFERENCE`, and `IFCMATERIALLAYERSETUSAGE`. Storey
elevations are emitted as REAL literals. Hostile enum tokens degrade to
`$`. **`tools/ci/ifc_schema_arity.py`** compares EXPRESS-declared arity
(and required `PredefinedType`) against every STEP instance; it runs in
CI, `validate-real-ifc.py`, and `check-local.sh --ifcopenshell`, with
matching Rust arity tests.
> 
> **#213 — storeys from partition element-record base `z`.** New
`element_record_storeys` derives distinct bbox elevations into
`IfcBuildingStorey` rows when existing levels have no elevation
evidence, then binds record-sourced columns by exact elevation
(fail-closed on miss/ambiguity). Core Interior goes **12 → 11** storeys
(measured vs name-only), **1 → 11** `IfcRelContainedInSpatialStructure`,
**256** elements storey-bound; names stay `Elevation N ft` when 12 Level
strings cannot pair with 11 elevations. Diagnostics add
`storey_elevations_feet` and `storey_bound_elements`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
db39abf401a2e901e3d9f6ee2fe68f33eb84fa26. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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
…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 -->
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.

IFC4 writer omits the trailing PredefinedType attribute on building elements Bind recovered columns to storeys via the record bbox base elevation

1 participant