Skip to content

feat(elements): recover the real plan profile of all 80 exported slabs from OST_SketchLines records (#31) (RE-25) - #231

Merged
DrunkOnJava merged 3 commits into
mainfrom
feat/slab-profiles-from-plan-loops
Aug 30, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
feat/slab-profiles-from-plan-loops

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Aug 30, 2026 •

Copy link
Copy Markdown
Owner

RE-22 (#225) recovered all 80 exported IFCSLAB by ElementId and closed the
thickness half of #31, leaving one sentence open: "The profile is still the
bbox rectangle, not the recovered floor boundary polygon: ProfileResolved
stays false."
This closes it, exactly, for all 80.

Report: reports/element-framing/RE-25-slab-plan-profiles.md.

Where the profile is not

The plan-loop scanner is a measured dead end. Inventoried over all eight
inflated Partitions/* streams with the shipped constants (4–8 points,
span ≥ 5 ft, closure ≤ 0.05 ft): 2317 closed plan-polyline candidates —
2310 of 4 points, 4 of 5, 3 of 6 — and zero with the plan bounds of any
of the 100 record-backed plates. The perimeter profile needs 26 vertices.
Searching all 187 MiB of inflated partitions for the export's polygon as a
packed run of (x, y) doubles — in the project frame, in the export's own
profile frame, at strides of 2/3/4/5/6/8 doubles — finds no ordered vertex
run at all. Revit does not store this boundary as a polyline.

The join rule, and its evidence

Each boundary line of a Revit sketch is its own partition element record.
BuiltInCategory OST_SketchLines = -2000045 (Autodesk's published
constant; the bytes are 53 7b e1 ff ff ff ff ff in the same signed i64
slot at +0x12 that RE-21 documented). These decode through the unmodified
RE-21 header — declared ElementId at +0x00, 0x059f at +0x0c, the fixed
bbox marker at +0x50, the box at +0x58 — and the box is the segment:
the boundary line at x = 136.5, y = 115 … 123 is recorded as
136.5, 115 – 136.5, 123, degenerate in x.

RE-23 read the first counted list at +0x88. A second list is framed
identically right after it, and its last slot names the sketched element:

+0x88  u32    n1 = 5
+0x8c  5×u64  20309, 20310, 20312, 20313, 20315   (sibling sketch lines)
+0xb4  u32    n2 = 2
+0xb8  2×u64  20308, 20311                        ← 20311 is the slab

Measured over all 3688 OST_SketchLines records on
2024_Core_Interior.rvt (Partitions/46 3070, /51 570, /55 48;
3070 distinct ids; 0 frames of one id disagreeing on box or owner):

owners named by the second list's last slot count
exported IFCSLAB ElementIds 80 / 80
exported IFCSHADINGDEVICE ElementIds 20 / 20
other elements (walls, the superseded container twin 16925, …) 26
distinct owners 126

The join is by ElementId only — no geometry, no proximity, no
containment.
A sketch line belongs to the element the byte names, or to
nothing. Geometric containment was used once, as a check, and is not the
rule: the recovered profile's plan bounds are asserted equal to the record's
own plan box in the corpus gate.

Reconstruction: closure, not fitting

A box is not a segment when the segment is diagonal, and 37 of the 1454 plate
segments carry a box looser than the line (the top boundary of every
rectangular plate is recorded 20,113 – 167,115 for a line the export puts
at y = 114). Both are resolved by the loop, never by the reference export:

  1. Every segment degenerate on exactly one axis contributes its endpoints.
  2. Every remaining segment is placed only when exactly one pair of
    still-open vertices fits its box — corner pairs (the box's own diagonals)
    first, and only when no corner pair is open, a pair that spans the box
    lengthwise and is degenerate across it.
  3. An ambiguous segment, a vertex that does not finish at degree 2, an unused
    edge, a zero-extent box or a loop under three vertices rejects the whole
    element
    . There is no partial or best-effort profile.

Collinear vertices are then merged — Revit splits the ring's north-east run
at x = 167, so the raw chain has 27 outer segments where the export has 26
edges.

Profile agreement

Recovered profile vs the reference export's IfcExtrudedAreaSolid swept
areas (IFC Exports/2024_Core_Interior_slim.ifc, sha256 bfdf36ff…, read
with IfcOpenShell 0.8.5), both reduced to the project plan frame, compared as
cyclic vertex sequences with orientation normalised, tolerance 1e-3 ft per
vertex:

slabs recovered export swept area outer verts voids segments exact near miss
42 outer ring + 1 void IfcArbitraryProfileDefWithVoids 26 1 (4 verts) 31 42 0 0
38 single loop IfcArbitraryClosedProfileDef 4 0 4 38 0 0
80 80 0 0

122 loops compared (80 outer + 42 inner). Worst vertex deviation
1.563e-12 ft
— the recovered vertices are the same doubles as the export's,
differing only in the floating dust of Revit's own transform
(177.00000000000011 for a nominal 177 ft, which the record box and the
export's profile carry identically). Re-measured on the emitted IFC after the
metre round-trip: 0 mismatches, worst deviation 2.842e-14 ft. No frame
alignment was needed — the 2024 project frame and the export frame coincide.

Before this, all 80 were rectangles: accidentally exact on the 38 whose
profile is the box, and filling a courtyard on the 42 perimeter rings.

The 20 exported IFCSHADINGDEVICE are declined, with the reason. The
same join names all 20; each carries 57 sketch lines — 1 with a zero-extent
box, 35 axis-parallel, 21 diagonal. The first zero-extent box rejects them
outright, and the export writes each as a 29-vertex rotated ring
(0 … 182.3333 by 8.6936 … 130.3064) with no axis-parallel anchor to force
a first choice. They keep the record box rectangle and
ProfileResolved: false. Five further owners are declined the same way
(16925 — the container-member twin of 20953 already excluded by RE-21 — plus
31636, 31637, 34362, 55840). Twenty-one non-plate owners do close and are
recovered but not emitted; nothing here maps them to an IFC entity.

Verdict outputs — unchanged

magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs
  surface: 6 fields, excluded: 10, diffs: 0
  replay ifc-lite: match / ifcopenshell: match / rvt-rs: match

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

Both committed verdict.json files are byte-identical. The two committed
rvt-rs observations were regenerated because the observation payload counts
every emitted entity type; the four bridge-witness observations are
byte-identical. Building-element counts and the diagnostics sidecar are
unchanged, and the sidecar is byte-identical to main (a0044f4):

entity before after
IFCRECTANGLEPROFILEDEF 992 912
IFCARBITRARYCLOSEDPROFILEDEF 0 38
IFCARBITRARYPROFILEDEFWITHVOIDS 0 42
IFCPOLYLINE 0 122
IFCCARTESIANPOINT 1847 3381
IFCPROPERTYSINGLEVALUE 5371 5611
total instances 18209 20105
IFCSLAB / IFCSHADINGDEVICE / IFCWALL / IFCDOOR / IFCWINDOW / IFCCOLUMN 80 / 20 / 360 / 132 / 6 / 256 unchanged
IFCBUILDINGSTOREY 15 15
storey_bound_elements 801 801

Gates run

cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, RUSTDOCFLAGS=-D warnings cargo doc --no-deps --lib, cargo +1.85.0 check --all-targets (MSRV, no let-chains),
cargo test --workspace --all-targets --all-features with
RVT_PROJECT_CORPUS_DIR + RVT_CORPUS_TIER1_DIR (152 test binaries ok),
the four named targets (witness_verdict, witness_registry,
project_count_fixtures, support_matrix), the seven #209 tier-2 targets,
tools/ci/ifc_schema_arity.py on a fresh export (20 105 instances across 43
entity types; IfcArbitraryClosedProfileDef at its declared arity of 3,
IfcArbitraryProfileDefWithVoids at 4, IfcPolyline at 1), and
tools/check-local.sh --ifcopenshell.

New gates: tests/iter_elements_typed.rs::core_interior_2024_slab_plan_profiles
(the 100 record-backed plates partition exactly — 80 resolve a profile, and
the 20 that do not are exactly the export's IFCSHADINGDEVICE Tag set;
42 × (26 outer, 1 void), 38 × (4 outer, 0 voids); each profile's plan bounds
equal the record's own plan box) and 15 unit gates in
src/element_record_plan_profiles.rs.

Support-matrix status

New row element-record-slab-plan-profile at partial, not verified:
the agreement is measured and regression-gated, but profile geometry is not a
field of either OctetProof claimed surface — no witness compares it — so it
has not met the two-independent-witnesses bar in
docs/verification-protocol.md.

Follow-ups

Refs #31 #227


Note

Medium Risk
Touches partition decoding, geometry reconstruction, and IFC STEP emission for all record-backed slabs; scope is gated to Revit 2024 and fail-closed closure, but wrong profile logic would change exported solid geometry without shifting entity counts.

Overview
Slab IFC geometry now uses recovered sketch boundaries instead of bounding-box rectangles for Revit 2024 partition-backed floors where sketch lines close unambiguously (#31 / RE-25).

The change reads OST_SketchLines element records, joins each segment to its owner slab via the last slot of the second reference list at +0x88 (owner_reference), and chains segment bounding boxes into closed loops (fail-closed on ambiguity). Those polygons flow through partition_schema_mvp::slabs_from_partition_category_records (single multi-category partition scan) into decoded fields, then ifc::export_content emits IfcArbitraryClosedProfileDef or IfcArbitraryProfileDefWithVoids with ProfileResolved: true and related diagnostics. scan_category_records_multi avoids re-inflating partitions when floors, pads, and sketch lines are needed together.

On the Core Interior corpus this matches 80/80 reference slab profiles (including courtyard voids); 20 shading devices still use the record box because closure rejects their diagonal sketch envelopes. Docs, support matrix, changelog, corpus tests (core_interior_2024_slab_plan_profiles), a research probe, and witness entity-count observations reflect the richer IFC profile chain while building-element counts and OctetProof verdicts stay unchanged.

Reviewed by Cursor Bugbot for commit 07e0a8a. Configure here.

…s from OST_SketchLines records (#31)

Each boundary line of a Revit sketch is its own partition element record
(BuiltInCategory OST_SketchLines, -2000045) carrying the segment's own
bounding box, and the last slot of the second counted reference list at
+0x88 names the sketched element. That join is exact by ElementId over
the whole recorded edge: the 3688 sketch-line records on
2024_Core_Interior.rvt name 126 owners, among them all 80 exported
IFCSLAB and all 20 exported IFCSHADINGDEVICE ids.

Segments are chained by closure, not by fitting: a box degenerate on one
axis contributes its endpoints, and every other box is placed only when
exactly one pair of still-open vertices fits it. Anything ambiguous
rejects the whole element.

Measured against the reference export's IfcExtrudedAreaSolid swept areas:
80/80 slabs exact, 122 loops (80 outer + 42 voids), worst vertex
deviation 1.563e-12 ft. 42 perimeter plates emit
IFCARBITRARYPROFILEDEFWITHVOIDS (26-gon + one rectangular void), 38 emit
IFCARBITRARYCLOSEDPROFILEDEF. The 20 shading devices decline and keep the
box rectangle with ProfileResolved false.

Building-element counts, the diagnostics sidecar and both OctetProof
verdicts are unchanged.

Refs #31 #227
…om-plan-loops

# Conflicts:
#	research/witness/magnetar-2024-core-interior-slim/observations/rvt-rs.json
#	research/witness/magnetar-2024-core-interior/observations/rvt-rs.json
… RE-25)

RE-25 gets the post-#230 before/after numbers; docs/status.md, the
support matrix (new element-record-slab-plan-profile row at `partial` —
the agreement is measured and regression-gated but is not a field of
either OctetProof claimed surface, so it has not met the two-witness bar
in docs/verification-protocol.md), the slim project-count manifest notes,
CHANGELOG, README, ROADMAP and the user guide all carry the measurement:
80 of 80 slab profiles exact across 122 loops, worst vertex deviation
1.563e-12 ft.

The same sweep retires three stale claims those files still carried —
that the recovered floor boundary polygon is unsolved, that slab bodies
are envelopes with no profile, and that door/window host IFC binding is
open (closed by #222/RE-23).

Refs #31 #227
@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_246ea92c-14ad-4d96-9ccd-04b0728f1c16)

@DrunkOnJava
DrunkOnJava merged commit 5da2570 into main Aug 30, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/slab-profiles-from-plan-loops branch August 30, 2026 19:28
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
…s from OST_SketchLines records (#31) (RE-25) (#231)

RE-22 (#225) recovered all 80 exported `IFCSLAB` by ElementId and closed
the
thickness half of #31, leaving one sentence open: *"The profile is still
the
bbox rectangle, not the recovered floor boundary polygon:
`ProfileResolved`
stays false."* This closes it, exactly, for all 80.

Report: `reports/element-framing/RE-25-slab-plan-profiles.md`.

## Where the profile is not

The plan-loop scanner is a measured dead end. Inventoried over all eight
inflated `Partitions/*` streams with the shipped constants (4–8 points,
span ≥ 5 ft, closure ≤ 0.05 ft): **2317** closed plan-polyline
candidates —
2310 of 4 points, 4 of 5, 3 of 6 — and **zero** with the plan bounds of
any
of the 100 record-backed plates. The perimeter profile needs 26
vertices.
Searching all 187 MiB of inflated partitions for the export's polygon as
a
packed run of `(x, y)` doubles — in the project frame, in the export's
own
profile frame, at strides of 2/3/4/5/6/8 doubles — finds no ordered
vertex
run at all. Revit does not store this boundary as a polyline.

## The join rule, and its evidence

**Each boundary line of a Revit sketch is its own partition element
record.**
`BuiltInCategory` `OST_SketchLines` = **-2000045** (Autodesk's published
constant; the bytes are `53 7b e1 ff ff ff ff ff` in the same signed
`i64`
slot at `+0x12` that RE-21 documented). These decode through the
*unmodified*
RE-21 header — declared ElementId at `+0x00`, `0x059f` at `+0x0c`, the
fixed
bbox marker at `+0x50`, the box at `+0x58` — and the box **is** the
segment:
the boundary line at `x = 136.5, y = 115 … 123` is recorded as
`136.5, 115 – 136.5, 123`, degenerate in `x`.

RE-23 read the *first* counted list at `+0x88`. A **second** list is
framed
identically right after it, and its last slot names the sketched
element:

```text
+0x88  u32    n1 = 5
+0x8c  5×u64  20309, 20310, 20312, 20313, 20315   (sibling sketch lines)
+0xb4  u32    n2 = 2
+0xb8  2×u64  20308, 20311                        ← 20311 is the slab
```

Measured over all 3688 `OST_SketchLines` records on
`2024_Core_Interior.rvt` (`Partitions/46` 3070, `/51` 570, `/55` 48;
3070 distinct ids; **0** frames of one id disagreeing on box or owner):

| owners named by the second list's last slot | count |
|---|---:|
| exported `IFCSLAB` ElementIds | **80 / 80** |
| exported `IFCSHADINGDEVICE` ElementIds | **20 / 20** |
| other elements (walls, the superseded container twin 16925, …) | 26 |
| **distinct owners** | **126** |

**The join is by ElementId only — no geometry, no proximity, no
containment.** A sketch line belongs to the element the byte names, or
to
nothing. Geometric containment was used once, as a check, and is not the
rule: the recovered profile's plan bounds are asserted equal to the
record's
own plan box in the corpus gate.

## Reconstruction: closure, not fitting

A box is not a segment when the segment is diagonal, and 37 of the 1454
plate
segments carry a box *looser* than the line (the top boundary of every
rectangular plate is recorded `20,113 – 167,115` for a line the export
puts
at `y = 114`). Both are resolved by the loop, never by the reference
export:

1. Every segment degenerate on exactly one axis contributes its
endpoints.
2. Every remaining segment is placed only when exactly **one** pair of
still-open vertices fits its box — corner pairs (the box's own
diagonals)
first, and only when no corner pair is open, a pair that spans the box
   lengthwise and is degenerate across it.
3. An ambiguous segment, a vertex that does not finish at degree 2, an
unused
edge, a zero-extent box or a loop under three vertices rejects the
**whole
   element**. There is no partial or best-effort profile.

Collinear vertices are then merged — Revit splits the ring's north-east
run
at `x = 167`, so the raw chain has 27 outer segments where the export
has 26
edges.

## Profile agreement

Recovered profile vs the reference export's `IfcExtrudedAreaSolid` swept
areas (`IFC Exports/2024_Core_Interior_slim.ifc`, sha256 `bfdf36ff…`,
read
with IfcOpenShell 0.8.5), both reduced to the project plan frame,
compared as
cyclic vertex sequences with orientation normalised, tolerance 1e-3 ft
per
vertex:

| slabs | recovered | export swept area | outer verts | voids | segments
| exact | near | miss |
|---:|---|---|---:|---:|---:|---:|---:|---:|
| 42 | outer ring + 1 void | `IfcArbitraryProfileDefWithVoids` | 26 | 1
(4 verts) | 31 | **42** | 0 | 0 |
| 38 | single loop | `IfcArbitraryClosedProfileDef` | 4 | 0 | 4 | **38**
| 0 | 0 |
| **80** | | | | | | **80** | **0** | **0** |

122 loops compared (80 outer + 42 inner). **Worst vertex deviation
1.563e-12 ft** — the recovered vertices are the same doubles as the
export's,
differing only in the floating dust of Revit's own transform
(`177.00000000000011` for a nominal 177 ft, which the record box and the
export's profile carry identically). Re-measured on the emitted IFC
after the
metre round-trip: 0 mismatches, worst deviation **2.842e-14 ft**. No
frame
alignment was needed — the 2024 project frame and the export frame
coincide.

Before this, all 80 were rectangles: accidentally exact on the 38 whose
profile *is* the box, and filling a courtyard on the 42 perimeter rings.

**The 20 exported `IFCSHADINGDEVICE` are declined, with the reason.**
The
same join names all 20; each carries 57 sketch lines — 1 with a
zero-extent
box, 35 axis-parallel, 21 diagonal. The first zero-extent box rejects
them
outright, and the export writes each as a 29-vertex rotated ring
(`0 … 182.3333` by `8.6936 … 130.3064`) with no axis-parallel anchor to
force
a first choice. They keep the record box rectangle and
`ProfileResolved: false`. Five further owners are declined the same way
(16925 — the container-member twin of 20953 already excluded by RE-21 —
plus
31636, 31637, 34362, 55840). Twenty-one non-plate owners do close and
are
recovered but not emitted; nothing here maps them to an IFC entity.

## Verdict outputs — unchanged

```text
magnetar-2024-core-interior: PASS — witnesses ifc-lite, ifcopenshell, rvt-rs
  surface: 6 fields, excluded: 10, diffs: 0
  replay ifc-lite: match / ifcopenshell: match / rvt-rs: match

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

Both committed `verdict.json` files are **byte-identical**. The two
committed
`rvt-rs` observations were regenerated because the observation payload
counts
*every* emitted entity type; the four bridge-witness observations are
byte-identical. Building-element counts and the diagnostics sidecar are
unchanged, and the sidecar is byte-identical to `main` (9ce43f7):

| entity | before | after |
|---|---:|---:|
| `IFCRECTANGLEPROFILEDEF` | 992 | 912 |
| `IFCARBITRARYCLOSEDPROFILEDEF` | 0 | 38 |
| `IFCARBITRARYPROFILEDEFWITHVOIDS` | 0 | 42 |
| `IFCPOLYLINE` | 0 | 122 |
| `IFCCARTESIANPOINT` | 1847 | 3381 |
| `IFCPROPERTYSINGLEVALUE` | 5371 | 5611 |
| total instances | 18209 | 20105 |
| `IFCSLAB` / `IFCSHADINGDEVICE` / `IFCWALL` / `IFCDOOR` / `IFCWINDOW` /
`IFCCOLUMN` | 80 / 20 / 360 / 132 / 6 / 256 | unchanged |
| `IFCBUILDINGSTOREY` | 15 | 15 |
| `storey_bound_elements` | 801 | 801 |

## Gates run

`cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets
--all-features -- -D warnings`, `RUSTDOCFLAGS=-D warnings cargo doc
--no-deps --lib`, `cargo +1.85.0 check --all-targets` (MSRV, no
let-chains),
`cargo test --workspace --all-targets --all-features` with
`RVT_PROJECT_CORPUS_DIR` + `RVT_CORPUS_TIER1_DIR` (152 test binaries
ok),
the four named targets (`witness_verdict`, `witness_registry`,
`project_count_fixtures`, `support_matrix`), the seven #209 tier-2
targets,
`tools/ci/ifc_schema_arity.py` on a fresh export (20 105 instances
across 43
entity types; `IfcArbitraryClosedProfileDef` at its declared arity of 3,
`IfcArbitraryProfileDefWithVoids` at 4, `IfcPolyline` at 1), and
`tools/check-local.sh --ifcopenshell`.

New gates:
`tests/iter_elements_typed.rs::core_interior_2024_slab_plan_profiles`
(the 100 record-backed plates partition exactly — 80 resolve a profile,
and
the 20 that do not are exactly the export's `IFCSHADINGDEVICE` `Tag`
set;
42 × (26 outer, 1 void), 38 × (4 outer, 0 voids); each profile's plan
bounds
equal the record's own plan box) and 15 unit gates in
`src/element_record_plan_profiles.rs`.

## Support-matrix status

New row `element-record-slab-plan-profile` at **`partial`**, not
`verified`:
the agreement is measured and regression-gated, but profile geometry is
not a
field of either OctetProof claimed surface — no witness compares it — so
it
has not met the two-independent-witnesses bar in
`docs/verification-protocol.md`.

## Follow-ups

- **The 20 shading devices.** Sketch present and joined; only the
closure
declines. Resolving 21 mutually constraining diagonal boxes needs either
a
  second carrier for the segment endpoints or a global search with a
  uniqueness proof.
- **`IfcExtrudedAreaSolid.Position` is the element's own
`IfcAxis2Placement3D`**, which is also the `IfcLocalPlacement`'s
relative
placement, so a consumer composing both applies the element translation
  twice. This predates RE-25 and affects every emitted element on every
  release; the profile is expressed in the same element-local frame the
rectangle profile always used, so nothing regressed. Needs its own
issue.
- **Walls, doors, windows, columns** still carry the record box. Wall
sketches are not `OST_SketchLines`; the 26 non-plate owners here are a
hint
  of what else is sketched, not a claim.
- **#227** is untouched. Note that the perimeter ring's void is
*profile*
geometry, not an opening element, so the 42 slab penetrations #227 asks
for
  are a different set.

Refs #31 #227

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches partition decoding, geometry reconstruction, and IFC STEP
emission for all record-backed slabs; scope is gated to Revit 2024 and
fail-closed closure, but wrong profile logic would change exported solid
geometry without shifting entity counts.
> 
> **Overview**
> **Slab IFC geometry now uses recovered sketch boundaries instead of
bounding-box rectangles** for Revit 2024 partition-backed floors where
sketch lines close unambiguously (#31 / RE-25).
> 
> The change reads **`OST_SketchLines`** element records, joins each
segment to its owner slab via the **last slot of the second reference
list** at `+0x88` (`owner_reference`), and **chains segment bounding
boxes into closed loops** (fail-closed on ambiguity). Those polygons
flow through
**`partition_schema_mvp::slabs_from_partition_category_records`**
(single multi-category partition scan) into decoded fields, then
**`ifc::export_content`** emits **`IfcArbitraryClosedProfileDef`** or
**`IfcArbitraryProfileDefWithVoids`** with **`ProfileResolved: true`**
and related diagnostics. **`scan_category_records_multi`** avoids
re-inflating partitions when floors, pads, and sketch lines are needed
together.
> 
> On the Core Interior corpus this matches **80/80** reference slab
profiles (including courtyard voids); **20 shading devices** still use
the record box because closure rejects their diagonal sketch envelopes.
Docs, support matrix, changelog, corpus tests
(`core_interior_2024_slab_plan_profiles`), a research probe, and witness
**entity-count** observations reflect the richer IFC profile chain while
**building-element counts and OctetProof verdicts stay unchanged**.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
d08c80c6aa7d4629b9538cda5a242ad8cfbb78b7. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
DrunkOnJava added a commit that referenced this pull request Aug 31, 2026
…on PredefinedType (#236)

Two conformance fixes to the IFC4 writer, both measured against Revit's
own export of the same project. Corpus: `.rvt` sha256
`c805df445d613b408e37337765572021265e3f5dfdc7d1fa53b22ba1600b8014`, slim
IFC sha256
`bfdf36ffb0bb768f3409d818403990e64d4c262c6780603be87f8077387ad86d`.

## #232 — every element was placed twice

The writer emitted the element's own `IfcAxis2Placement3D` in **both**
the `IfcLocalPlacement`'s `RelativePlacement` and the swept solid's
`Position`. IFC4 has a conforming consumer compose `ObjectPlacement ×
Position`, so the element translation was applied twice. Viewers that
ignore `Position` drew the file correctly, which is exactly why it
shipped on every release: two tools could disagree about the same bytes
with neither of them misreading.

### The Position decision, and the export's evidence

Read with IfcOpenShell 0.8.5 on `2024_Core_Interior_slim.ifc`, Revit's
own exporter is consistent about one thing — **the element translation
appears exactly once** — and splits it two different ways depending on
the frame the profile is authored in:

| Revit entity | `ObjectPlacement.RelativePlacement.Location` |
`IfcExtrudedAreaSolid.Position.Location` |
|---|---|---|
| `IfcWall` #2240 (`SweptSolid` body) | `(48.0, 57.667, 0.0)` | `(0.0,
0.0, 0.0)` — identity |
| `IfcSlab` #1590 | `(0.0, 0.0, 0.0)` — identity | `(90.444, 71.185,
-0.167)` |
| `IfcSlab` #1619 | `(0.0, 0.0, 0.0)` — identity | `(93.5, 69.5, 0.0)` |
| `IfcSpace` #186 | `(0.0, 0.0, 0.0)` — identity | `(51.694, 69.556,
0.0)` |

Never both. Revit's walls put the location in the placement and leave
`Position` at identity because the wall profile is authored in the
element-local frame; its slabs and spaces do the mirror image because
those profiles are authored in storey coordinates.

rvt-rs authors **every** profile in the element-local frame — the
rectangle always did, and the plan profile recovered in #231 uses the
same frame — and it already carries the location on the element's own
`IfcLocalPlacement`. So the correct half of Revit's own convention is
the `IfcWall` row: **`Position` becomes the project-level identity
placement**, and the placement carries the translation once. That is
what this PR does. No entity is added or removed — the per-element axis
is still emitted, the solid just stops pointing at it.

The representation-map path is deliberately left alone, with a comment
saying why: a mapped item resolves as `MappingTarget × MappingOrigin⁻¹ ×
geometry`, so a `Position` equal to the `MappingOrigin` cancels against
the inverse instead of compounding, and `origin_feet` is `[0,0,0]` on
every map rvt-rs builds today anyway.

### World-coordinate verification

IfcOpenShell geometry iterator, `use-world-coords`, matched by `Tag`
against the Revit export, deltas in feet.

**BEFORE**

| Class | shared Tags | max centroid delta | max min-vertex delta | Tags
within 1e-3 ft |
|---|---:|---:|---:|---:|
| IfcColumn | 256 | 166.0000 ft | 166.0000 ft | 0/256 |
| IfcSlab | 80 | 185.3333 ft | 185.3333 ft | 0/80 |
| IfcWall | 360 | 170.2500 ft | 166.2500 ft | 0/360 |
| IfcDoor | 132 | 166.0748 ft | 166.0000 ft | 0/132 |
| IfcWindow | 6 | 157.1805 ft | 155.7300 ft | 0/6 |

| Class | Tag | rvt-rs world centroid (ft) | Revit world centroid (ft) |
delta (ft) |
|---|---|---|---|---|
| IfcColumn | 20375 | (48.0000, 220.0000, 159.1667) | (23.8750,
110.0000, 81.5833) | (24.1250, 110.0000, 77.5833) |
| IfcColumn | 20376 | (98.0000, 220.0000, 159.1667) | (49.1250,
110.0000, 81.5833) | (48.8750, 110.0000, 77.5833) |
| IfcSlab | 20311 | (181.3000, 139.0000, 151.7500) | (88.3000, 69.5000,
75.9167) | (93.0000, 69.5000, 75.8333) |
| IfcSlab | 20345 | (187.0000, 139.0000, 151.7500) | (93.5000, 69.5000,
75.9167) | (93.5000, 69.5000, 75.8333) |
| IfcWall | 20796 | (122.7500, 162.0000, 159.5000) | (60.1042, 81.0000,
81.7500) | (62.6458, 81.0000, 77.7500) |
| IfcWall | 20797 | (96.0000, 138.7500, 159.5000) | (48.0000, 69.1667,
83.5000) | (48.0000, 69.5833, 76.0000) |
| IfcDoor | 20810 | (194.0874, 118.9189, 156.1247) | (97.0437, 58.0499,
80.0499) | (97.0437, 60.8689, 76.0748) |
| IfcWindow | 20898 | (65.4902, 172.2757, 165.9056) | (30.8441, 86.1378,
83.7251) | (34.6460, 86.1378, 82.1805) |

The doubling reads straight off the table: the rvt-rs value is 2×
Revit's wherever the element's own frame is the whole story — slab 20345
at `(187.0, 139.0)` against `(93.5, 69.5)`, column 20375 at `220.0`
against `110.0`.

**AFTER**

| Class | shared Tags | max centroid delta | max min-vertex delta | Tags
within 1e-3 ft |
|---|---:|---:|---:|---:|
| IfcColumn | 256 | 1.5833 ft | 0.3333 ft | 107/256 |
| IfcSlab | 80 | 0.2083 ft | **0.0000 ft** | 79/80 |
| IfcWall | 360 | 2.5336 ft | 0.7500 ft | 78/360 |
| IfcDoor | 132 | 1.5095 ft | 3.0022 ft | 0/132 |
| IfcWindow | 6 | 1.9010 ft | 0.8012 ft | 0/6 |

| Class | Tag | rvt-rs world centroid (ft) | Revit world centroid (ft) |
delta (ft) |
|---|---|---|---|---|
| IfcColumn | 20375 | (24.0000, 110.0000, 83.1667) | (23.8750, 110.0000,
81.5833) | (0.1250, -0.0000, 1.5833) |
| IfcColumn | 20376 | (49.0000, 110.0000, 83.1667) | (49.1250, 110.0000,
81.5833) | (-0.1250, 0.0000, 1.5833) |
| IfcSlab | 20311 | (88.3000, 69.5000, 75.9167) | (88.3000, 69.5000,
75.9167) | (-0.0000, 0.0000, 0.0000) |
| IfcSlab | 20345 | (93.5000, 69.5000, 75.9167) | (93.5000, 69.5000,
75.9167) | (-0.0000, 0.0000, 0.0000) |
| IfcWall | 20796 | (60.1875, 81.0000, 81.8123) | (60.1042, 81.0000,
81.7500) | (0.0833, 0.0000, 0.0623) |
| IfcWall | 20797 | (48.0000, 69.3750, 83.5000) | (48.0000, 69.1667,
83.5000) | (0.0000, 0.2083, 0.0000) |
| IfcDoor | 20810 | (97.0437, 59.4594, 80.1247) | (97.0437, 58.0499,
80.0499) | (-0.0000, 1.4095, 0.0748) |
| IfcWindow | 20898 | (32.7451, 86.1378, 85.1756) | (30.8441, 86.1378,
83.7251) | (1.9010, -0.0000, 1.4505) |

**All 80 slabs now agree with Revit's export on every world-space vertex
to 0.0000 ft.** That is the class where rvt-rs recovers a real plan
profile (#231), so it is the class where a placement fix can be checked
at full precision, and it is exact.

The residuals that remain elsewhere are **geometry recovery fidelity,
not placement composition**, and each is an existing tracked gap:
columns sit 0.125 ft off in plan and 1.58 ft off in Z (insertion point
and base elevation), walls up to 2.53 ft on location-curve-derived
bodies, and doors and windows carry the record's bounding-box envelope
rather than a panel (#86, #82). None of them scales with the element's
distance from the origin any more, which is the signature the doubling
had.

### The gate

`tools/ci/ifc_schema_arity.py` closes the class two ways, both
fail-closed:

1. **Structural invariant, every file, every product** — a swept solid's
`Position` may not be the very `IfcAxis2Placement3D` instance its
product's `IfcLocalPlacement` already uses as `RelativePlacement`. Run
against the pre-fix export it produces 992 findings, first one: `#216
IfcColumn reuses #207 as both its ObjectPlacement's RelativePlacement
and its IfcExtrudedAreaSolid.Position`.
2. **Pinned composition** — for five elements the gate computes
`ObjectPlacement × Position × first-profile-point` explicitly
(`ifcopenshell.util.placement`, no geometry kernel) and compares against
a pinned coordinate at 1e-6. Two are in `synthetic-project.ifc`, one in
`synthetic-structural.ifc` and two are the recorded artifact's column
`20375` and slab `20345`, so the probe fires in the fixture-only CI step
*and* on the real export. A file that does not hold the Tag skips the
probe rather than failing.

## #220 — PredefinedType follows the authoring witness

The issue's suggested rule is adopted: where a recorded edge shows the
witness's choice, take it. Agreement with the export is what the
OctetProof verdicts score, and a value the witness demonstrably wrote is
a recorded observation, not an invention.

### Per-type agreement, measured with IfcOpenShell

| Entity | Revit's export writes | rvt-rs before | rvt-rs after | rvt-rs
count | agreement |
|---|---|---|---|---:|---|
| IfcWall | `.NOTDEFINED.` ×360 | `.STANDARD.` | `.NOTDEFINED.` | 360 |
360/360 exact |
| IfcSpace | `.SPACE.` ×116 | `.INTERNAL.` | `.SPACE.` | 18 | 18/18
exact (recall gap tracked separately) |
| IfcDoor | `.DOOR.` ×132 | `$` | `.DOOR.` | 132 | 132/132 exact |
| IfcWindow | `.WINDOW.` ×6 | `$` | `.WINDOW.` | 6 | 6/6 exact |
| IfcColumn | `.COLUMN.` ×256 | `.COLUMN.` | `.COLUMN.` | 256 | 256/256
exact (unchanged) |
| IfcSlab | `.FLOOR.` ×78, `.ROOF.` ×2 | `.FLOOR.` | `.FLOOR.` | 80 |
inside the witness's value set (unchanged) |
| IfcShadingDevice | `.NOTDEFINED.` ×20 | `$` | `$` | 20 | **not changed
— see #235** |

`Area`, `Space` and `GenericModel` keep `$`: no recorded edge shows what
the witness does with those Revit classes, and inventing a value is the
thing this table exists to avoid. `IfcSlab` keeps `.FLOOR.` for all 80
because splitting floors from roofs is a per-element decode, not a
mapping default; the gate accepts `{FLOOR, ROOF}` for that type.

`IfcShadingDevice` is the one row the witness rule reaches that this PR
does not change — `category_map.rs` carries an explicit prior decision
for it ("`$`, not an invented `.NOTDEFINED.`"), and flipping a
written-down decision deserves its own verdict rather than riding along
here. Filed as **#235**.

### No new observation surface class

`PredefinedType` is an attribute value; the observation payload counts
entity **type names** plus relations and storeys. Both changes are
therefore invisible to the observation hash, which was confirmed rather
than assumed — see below. So instead of widening the surface, the
agreement check went into the arity gate as `--witness-agreement`, run
on the recorded artifact in CI:

```
PredefinedType agrees with the witness: IfcColumn.COLUMN=256, IfcDoor.DOOR=132,
  IfcSlab.FLOOR=80, IfcSpace.SPACE=18, IfcWall.NOTDEFINED=360, IfcWindow.WINDOW=6
```

`IfcDoor` and `IfcWindow` also joined `PREDEFINED_TYPE_REQUIRED`, since
every `category_map` row for them now supplies a value.

## Observations did not move

Regenerated all three witnesses on both recorded edges and diffed
against the committed files:

| Edge | rvt-rs | ifcopenshell | ifc-lite | verdict |
|---|---|---|---|---|
| `magnetar-2024-core-interior` | byte-identical | byte-identical |
byte-identical | PASS, 6 fields, 0 diffs, replay match ×3 |
| `magnetar-2024-core-interior-slim` | byte-identical | byte-identical |
byte-identical | PASS, 13 fields, 0 diffs, replay match ×3 |

**Nothing under `research/witness/` was regenerated, because nothing
moved.** Entity counts, relations and storeys are unchanged.

## Fixtures

Both committed fixture IFCs are regenerated with their test pins, since
the writer change alters them:

- `synthetic-project.ifc` — 7 `IFCEXTRUDEDAREASOLID` rows repoint from
the element axis to `#14` (the project identity placement), 4 `IFCWALL`
move to `.NOTDEFINED.`, the door and two windows gain `.DOOR.` /
`.WINDOW.`.
- `synthetic-structural.ifc` — 4 `IFCEXTRUDEDAREASOLID` rows repoint to
`#14`. Its `predefined_type` values are hardcoded in the test model, not
looked up, so they are untouched.

`synthetic-project.ifc` also picks up a change it should have carried
since #222: it was last dumped at `55491d7` (#217), before `7f00dce`
gave `IfcOpeningElement` the `Tag` of the element that fills it, so its
one opening still wrote `$` there. Fixtures only regenerate behind
`DUMP_IFC=1`, which is how it drifted a commit behind the writer with no
test noticing.

Two Rust tests moved with the mappings: `lookup_known_class` now expects
`.NOTDEFINED.`, and `door_and_window_have_no_predefined_type_by_default`
— which asserted the old decision — is rewritten as
`door_and_window_follow_the_witness_predefined_type`, with a comment
recording why the old reading (type variance belongs on `IfcDoorType`)
is defensible and still wrong here: Revit populates both. A new
`witness_following_predefined_types` covers all five changed rows.

## Verification run

| Gate | Result |
|---|---|
| `cargo fmt --all` | clean |
| `cargo clippy --all-targets -- -D warnings` | clean |
| `cargo +1.85.0 check --all-targets` | clean |
| `cargo test --profile ci` × 6 named targets, corpus set | 16 passed, 0
failed |
| Tier-two decoder gates (#209), 7 targets, corpus set | 40 passed, 0
failed |
| `cargo test --profile ci --workspace --all-targets`, corpus set | 152
result blocks, 0 failed |
| `tools/ci/ifc_schema_arity.py --witness-agreement` on a fresh export |
pass — 20105 instances, 992 solids, 2 pinned probes matched |
| Same gate on the pre-fix export | fails, 992 composition findings |
| `tools/ci/validate-real-ifc.py` (Einhoven) | pass |
| `tools/check-local.sh --ifcopenshell` | all requested gates passed |
| OctetProof verdicts, both edges, `--compare-committed` | PASS, replay
match on all six observations |

## Follow-ups

- **#235** (filed) — `IFCSHADINGDEVICE` emits `$` where Revit writes
`.NOTDEFINED.` on all 20; the #220 rule reaches it but a documented
prior decision guards it.
- Column Z is 1.58 ft off and plan position 0.125 ft off against the
export; wall bodies up to 2.53 ft. Both are geometry recovery, now
measurable for the first time because the placement no longer swamps
them.
- Revit splits 80 slabs into 78 `.FLOOR.` + 2 `.ROOF.`; rvt-rs writes
`.FLOOR.` for all 80.

Closes #232
Closes #220

https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes core IFC geometry placement and attribute emission for all
extruded products; mitigated by new fail-closed CI gates and unchanged
OctetProof observation hashes per the PR description.
> 
> **Overview**
> Fixes two IFC4 writer conformance issues measured against Revit's
export of the 2024 Core Interior project.
> 
> **Placement (#232).** Swept solids no longer reuse the element's
`IfcAxis2Placement3D` as both `IfcLocalPlacement.RelativePlacement` and
`IfcExtrudedAreaSolid.Position`. Translation lives only on the local
placement; solid `Position` is the project identity frame so
`ObjectPlacement × Position` is not applied twice. The same rule applies
to extrusions, openings, and the generic `emit_solid_shape` path
(mapped-item geometry is documented as a separate composition case).
> 
> **PredefinedType (#220).** `category_map` now emits witness-aligned
values where a recorded edge exists: walls `.NOTDEFINED.`, rooms
`.SPACE.`, doors `.DOOR.`, windows `.WINDOW.` (replacing `.STANDARD.`,
`.INTERNAL.`, and `$`). Tests and docs/compatibility tables are updated
accordingly.
> 
> **CI and gates.** `tools/ci/ifc_schema_arity.py` adds
placement-composition checks on every file (no shared placement
instance; pinned Tag probes) and optional `--witness-agreement` for the
real-project export in CI. Synthetic IFC fixtures are regenerated (solid
positions, enum values, opening `Tag` catch-up from #222).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
dff9f2eccb02b3ffe3008181ebbca89253db4970. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant