Skip to content

fix(ifc): a project whose last phase holds no room writes the rooms of the latest phase that holds any (#1359) (RE-326) - #1435

Merged
DrunkOnJava merged 11 commits into
mainfrom
fix/1359-room-phase-fallback
Nov 5, 2026
Merged

DrunkOnJava merged 11 commits into
mainfrom
fix/1359-room-phase-fallback

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Where no phase is named and a project's last phase holds no room, the export writes the rooms of the latest phase that holds any. Only placed rooms count, both for "the last phase holds a room" and for "the latest phase that holds any". Every other element still follows the last phase, a phase named (rvt-ifc --phase, Python phase=, the MCP phase), the last included, is exact, and a project with a placed room in its last phase is unchanged.

Motivation

#1359: an outside importer reports Autodesk's rac_basic_sample_project going from 14 rooms (decoded_elements(), IfcSpace) in 0.13.0 to 0 in 0.14.0. The cause is the room-phase rule of RE-326 (#1328): all 14 rooms are in Working Drawings, the second of three phases, and the last, Learning Content, holds none. Measure run 41985023986 (ref b510ff3c): the 2016 to 2027 saves hold IFCSPACE 0 and room_not_in_export_phase 14, all in Working Drawings; the 2015 save holds 14 and counts none (both phase rules start at Revit 2016, #1332).

This is a choice by Griffin (2026-11-05, "Fall back to rooms' phase"), not a measurement of Revit's default: rooms all in one phase cannot overlap, and the only Revit export of this model holds the 14. No Revit export made at the last phase of such a project exists.

Changes

  • src/research/native_phases.rs: PhaseFilter::room_fallback and room_fallback_rooms, found from the placed rooms only (placed_room_ids, is_placed, the test scan_phase_excluded_instances counts the left-out rooms by; the scan runs only when a RoomElem record names a phase before the last, and where placement cannot be told there is no fallback), export_named (named versus defaulted), room_fallback_in_effect, room_export_phase, with_default_export_phase, differs_in_effect_from (the walk-drop predicate); room_outside_export_phase judges rooms against room_export_phase. Elements still use excluded, which the fallback does not touch.
  • src/reader.rs: RevitFile::room_phase_fallback; set_export_phase and clear_export_phase drop the memoised walk by differs_in_effect_from (naming the last after a fell-back default, and back).
  • src/ifc/mod.rs, src/ifc/export_pipeline.rs: ExportDiagnostics::room_phase_fallback (RoomPhaseFallback { phase, rooms }, from the same filter as the handle's answer, absent when not applicable, replaced under --anonymize), ExportNote::RoomPhaseFallback (appended last) with anonymized().
  • src/bin/rvt_ifc.rs (help; the note, with the phase replaced under --anonymize), rvt_gltf.rs (the note), rvt_schedule.rs and rvt_sheet.rs (a line each).
  • rvt-py/src/lib.rs, python/rvt/__init__.pyi: a RuntimeWarning from every export call and from schedule_csv, decoded_elements and element_counts. tests/python/test_room_phase_fallback.py and a step of the wheel job that fetches the 2018 save (pinned by sha256).
  • viewer/src/main.ts, viewer/index.html: the last phase's label and hint say so; the downloaded diagnostics redact the phase.
  • rvt-mcp/src/args.rs: the phase description says that naming the last phase differs from leaving it out (the contract files follow from the watcher).
  • Docs: docs/schemas/export-diagnostics.schema.json, docs/export-diagnostics.md, docs/rooms.md, docs/evidence.md, docs/python.md, docs/user-guide.md, docs/status.md, docs/supported-profile.md, docs/mcp.md, docs/viewer-api.md, docs/format-reconnaissance.md, README.md, reports/element-framing/RE-326-room-phases.md (new section 9), changelog.d/changed/1359-room-phase-fallback.md.

Testing

Unit tests are banned in this repository; the only ones are failure-first tests of pure helpers with no I/O, the exception the operator policy allows: room_fallback_phase (no phases, no room, a room in the last phase, a phase not in the project, rooms in two earlier phases, one phase, an order that is not ascending by ElementId) and PhaseFilter's state (the default, a phase named, the last named, going back, differs_in_effect_from). Nothing was built or run locally; cargo fmt --all -- --check and tools/release/changelog.py check pass.

  • tools/check-local.sh passes: not run locally; CI runs it (the fast jobs passed at b0abb7b6).
  • Verified end to end on real Revit files, by four Measure runs at ea0c74499bdc4346435cf89c8fd95856371127cb (this PR's code merged with main at a0639777, SpaceKind included; what follows is documentation). The commands and the reading are in RE-326 section 9.4.
    • Unfiltered, run 42035308270 (-f base=main -f nordic=true -f r2025=true -f holdout=true -f samples=true): 111 exports compared; 12 moved, the 2016 to 2027 saves of rac_basic_sample_project, each now 14 IfcSpace (0 before) of SpaceKind room 14 (space_kinds_vs_ifc: area 0, mep_space 0, family_instance 0, no SpaceKind 0), no room_not_in_export_phase (14 in Working Drawings before), room_phase_fallback {Working Drawings, 14}, 464 entities (450 before) and the rvt-ifc log line; the other 99 are byte for byte as before by ifc.sha256, the 2015 save and 18 held-out exports among them (counts only, none moved). The scorer diff names only those 12 models; IfcOpenShell's WHERE rules read findings 0 on all 13 saves; no space_kinds_vs_ifc.txt of the head side reports a space without a kind; the semantic check of the MCP dumps of 34 models reports 0 changes.
    • Last phase named, run 42035311977 (--phase 961604, 2018 to 2027): 14 room_not_in_export_phase, 0 IfcSpace, no fallback field, ifc.sha256 equal to main's default on 10 of 10 saves. Its Same-project gates job failed and its exports did not: the phase id exists only in rac_basic, so rac_advanced writes no IFC under the flag and the Areas gate saw nothing, a false red that fix(ci): the same-project gates skip a run with ifc_flags (#1435) #1446 fixes.
    • Working Drawings named, run 42035315319 (--phase 86961): 14 IfcSpace of kind room, and ifc.sha256 equal to this PR's default on 10 of 10 saves.
    • GlobalId, run 42035335073 (2018 save, kept IFC, equal to the unfiltered default by ifc.sha256) against the public Revit 2018 export of RE-326 section 5, fetched again and its sha256 checked (1114ce91…): rvt-rs 14 IfcSpace, Revit 17, in both 14, only rvt-rs 0, only Revit 3 (the MEP Spaces), as section 6 found for --phase 86961. Counted with a regular expression over the IFCSPACE GlobalIds because IfcOpenShell was not installed where it ran; the scratch copy was deleted and the export is not committed.
    • Coverage: 12 of the 111 exports exercise the fallback, all saves of one project whose 14 rooms are all placed and in one earlier phase. No real file has two earlier phases holding rooms (that branch is covered by the pure helper alone), an unplaced record in the last phase or in a later phase than the placed rooms, a placed room whose phase did not read, or an Area beside rooms of an earlier phase.
    • Not measured: mcp answers for rac_basic (the MCP scorer and dump run only on models with a Revit export); Revit's default at the last phase of such a project (no export exists); the Python warnings, which have tests/python/test_room_phase_fallback.py in the wheel job of the full CI and have not run on this head (the draft ran the fast jobs); the viewer's label, which has no browser test.
  • If this touches the IFC exporter: no witness observation changes (the scorer diff names only the 12 rac_basic_sample_project saves, which are in no witness set).
  • If this is a performance change: N/A.

Audit-honesty checklist

  • README / docs reflect the current state after this PR; every figure names its run and ref
  • A user-visible change has its entry under changelog.d/changed/
  • If a limitation was resolved, the docs are updated: the "left out by default" statements for rac_basic_sample_project are replaced
  • The limitations below are in the PR body, RE-326 sections 9.4 and 9.5 and the docs
  • Commit messages describe WHAT changed and WHY
  • No emojis
  • No private paths, personal email addresses, or internal jargon in committed files
  • Reverse-engineering finding: N/A (a behaviour choice; the probes of RE-326 stand)

Limitations introduced:

  • A project with no room in its last phase gets earlier rooms that Revit's default might leave out. Revit's default on such a project is unmeasured.
  • The viewer cannot name the last phase exactly: its last option is the default, so it shows the fallback rooms. rvt-ifc --phase, Python and the MCP server can.
  • A placed room whose phase is unset, unread or not one of the project's is written as before and counts as nothing: if it is in the last phase, the fallback brings in earlier rooms that Revit's default would not write beside it. An Area and an unplaced record are no room.
  • rvt-elements, rvt-info and the other CLIs that read the walk write the fallback rooms and print nothing about it.

Legal and contribution hygiene

  • Apache-2.0
  • No Autodesk proprietary source, decompiled internals, or NDA'd SDK content
  • No new fixtures (the Python test reads Autodesk's published sample, fetched by the wheel job and never stored)

Breaking changes

None to the API: the ExportNote variant is appended to a #[non_exhaustive] enum, ExportDiagnostics is #[non_exhaustive] and the field is skipped when absent. A caller that matched on the 0.14.0 result for rac_basic_sample_project (0 rooms by default) now gets 14, which is the point; phase="Learning Content" (or the last phase's ElementId) keeps the 0.14.0 result.

Screenshots or output samples

The log line rvt-ifc prints on each of the 12 saves, from run 42035308270: rvt-ifc: the project's last phase holds no room, so the 14 room(s) of "Working Drawings", the latest phase that holds any, are written; every other element is of the last phase. Naming the export phase (rvt-ifc --phase, Python's phase=, the MCP phase argument) is exact: naming the last writes no room

Related issues

Refs #1359 (the issue also holds a report on doors and windows, which this does not address).

…f the latest phase that holds any (#1359) (RE-326)

RE-326 left out every room whose own phase is not the project's last. Autodesk's
rac_basic_sample_project has its 14 rooms in Working Drawings and none in its
last phase, Learning Content, so 0.14.0 wrote none and an importer's room count
went from 14 to 0.

Where no phase is named and the last phase holds no room, the rooms are judged
against the latest phase that holds any (Griffin, 2026-11-05): rooms all in one
phase cannot overlap, and the only Revit export of this model holds them. Every
other element still follows the last phase, a phase named (rvt-ifc --phase,
Python phase=, the MCP phase argument), the last included, is exact, and a
project with a room in its last phase is unchanged.

The diagnostics name the phase and count its rooms (room_phase_fallback), rvt-ifc
and rvt-schedule print a line, the Python bindings raise a RuntimeWarning, and
RevitFile::room_phase_fallback gives the phase. It is a choice, not a
measurement of Revit's default.
@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 5, 2026 10:58
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
… the diagnostics and the notes read one answer (#1359) (RE-326)

The fallback took every RoomElem record with a set phase for a room. With 14
placed rooms in one phase and one unplaced record in a later one it chose the
later phase, left the 14 out and printed nothing; an unplaced record in the last
phase stopped the fallback on a project that has placed rooms only before it.

Both "the last phase holds a room" and "the latest phase that holds any" now
count placed rooms, by the test scan_phase_excluded_instances counts the left-out
rooms by (a placed instance of the rooms category, not in a non-primary design
option), on Revit 2016 to 2023 and on the releases supported from 2024. The scan
runs only when some RoomElem record names a phase before the last, and where
placement cannot be told there is no fallback. The placed rooms in the fallback
phase are counted in the filter, so RevitFile::room_phase_fallback, the
diagnostics' room_phase_fallback and the note agree, and a failed
scan_phase_excluded_instances no longer hides the field.

Also: rvt-gltf and rvt-sheet say so; --anonymize replaces the phase in the note
on stderr; PhaseFilter::differs_in_effect_from is the walk-drop predicate, with
failure-first tests of the filter's state logic and of a project whose phase
order is not ascending by ElementId; a Python test on Autodesk's
rac_basic_sample_project runs in the wheel job; the MCP phase description, the
anonymize and run_export docs and the diagnostics doc say what is known.
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
…no IFC for the gates, and the docs say a gate's run has no flags (#1435)
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
)

## Summary

The two same-project gates in Measure (`bodies_across_saves`,
`areas_across_saves`) now skip a run dispatched with `ifc_flags`, and
say so in a notice and the run summary, instead of turning it red. Their
claim is about the default export.

## Motivation

Measure run 42035311977 (`-f ifc_flags="--phase 961604" -f
samples=true`, #1435's named-phase check) failed in `Same-project
gates`: `areas across saves: FAILED: 2024: the IFC is missing`, on all
four saves. That phase belongs to `rac_basic`, so `rac_advanced` refuses
it and writes no IFC. A false red is a CI defect, and any run naming a
phase or another flag hits it.

## Changes

- `tools/ci/measure-reference-models.sh`: with a flag in `RVT_IFC_FLAGS`
(a whitespace-only value is no flag, since `export_ifc` passes it
unquoted and `rvt-ifc` gets none), `areas_across_saves` writes
`skipped:` and `bodies_across_saves` writes `SKIPPED` for each
candidate, naming the flags. The check scripts already print those as
notices, and neither counts as a pass. A flagged run keeps no IFC for
the gates, and a retained IFC is still deleted afterwards.
- `docs/maintaining.md`, `measure.yml`'s comment and the two check
scripts' headers: a run with `ifc_flags` checks neither gate, so the run
a gate judges has no `ifc_flags`.

## Testing

Unit tests are banned: none added. `bash -n` and `shellcheck -S warning`
pass. Ran `tools/ci/check-areas-across-saves.sh` and
`tools/ci/check-bodies-across-saves.sh` on fake results holding the new
lines: both exit 0 with a notice for each file, and neither prints a
pass. The real path is the next Measure with `ifc_flags`; #1435's
named-phase runs are the case.

Not measured: a real run on this head. A default run is unaffected:
`RVT_IFC_FLAGS` is empty or only spaces there. Tested the guard on an
empty value, one space, three spaces and `--phase 1`.

## Audit-honesty checklist

- [x] No capability claim changes, and no export changes.
- [x] No changelog fragment: a change to Measure only.
- [x] No emojis, private paths or personal addresses in committed files.

## Legal and contribution hygiene

- [x] Apache-2.0. No Autodesk proprietary source, decompiled internals
or NDA content.

## Breaking changes

None.

## Related issues

Refs #1435.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 5, 2026 14:08
@DrunkOnJava
DrunkOnJava merged commit dd3dc11 into main Nov 5, 2026
35 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/1359-room-phase-fallback branch November 5, 2026 14:19
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
…p from the native record (#1357) (RE-343) (#1438)

## Summary

#1357 asks for a door's or window's hand flip and facing flip, or how to
derive them. They are two booleans of the instance's native
`FamilyInstance` record, `m_flippedX` and `m_flippedY`. The decoded Door
and Window records now carry them as `m_hand_flipped` and
`m_facing_flipped`, and the typed Door view's `flip_hand` and
`flip_facing` read them. No door or window is stored as a reflection, so
the transform (and `m_opening_facing`, its Y axis) holds neither flip as
such; `reports/element-framing/RE-343-door-window-flips.md` gives both
answers with counts.

## Motivation

#1357. The reporter's two questions, answered in the report from Measure
runs 42014420180, 42015182768, 42021277032, 42021280392, 42021284465,
and 42024103319, 42024107131, 42024111444 (the last three at
`e2f8accc`), and 42037268099 and 42037272808 (at `18954f33`) and Snowdon
Towers scored locally:

- A mirrored transform: none is stored. The first orthonormal block has
determinant 1 on 1,439 doors and windows scored against Revit's export,
and the native `InstanceInfo.m_Trf.m_3x3` on all 1,219 of the open
models'; and on 1,820 of the 2024 to 2027 samples.
- `m_opening_facing` turns with `m_flippedX` only. For a door or window
set in a plain wall rvt-rs binds, Revit's own placement is the stored
axes reversed where the two booleans differ, so the direction it faces
(the placement's +Y) is `m_opening_facing` reversed there: exact on 653
doors and 626 windows (0 wrong), and on 41 doors and 105 windows of
held-out models. The two office files are one building and R2025 models
12 to 17 one layout six times: counted once, 456 doors and 346 windows.
The case where the booleans differ (287 doors, 286 windows; 186 and 146
counted once) is measured on three 2024 buildings, one 2025 door, one
2026 house and no 2027 element. The 160 doors rvt-rs binds to no plain
wall follow the rule on 111 and not on 49 (exact inversions, uniform by
`IfcDoorType`, which fits revit-ifc's `StyleTransform`: report sections
1 and 3, not shown); nothing is claimed for them.
- The fields are carried, equal to the booleans, by 1,820 of the 1,820
doors and windows of the 2024 to 2027 samples and by none of 2015 to
2023, whose doors and windows are not decoded as Door and Window
records.

## Changes

- `src/research/native_symbol_cuts.rs`,
`partition_schema_mvp/openings.rs`, `fields.rs`,
`../partition_schema_mvp.rs`: `OPENING_FLIP_FIELDS`. On 2024 and 2025
the flips are read in the pass `instance_cuts_and_symbols` already makes
over the doors' and windows' records (`attach_cut_loop_sizes` passes it
every door and window, those that are an opening alone too; the symbols
it sizes are still those of the doors with a body): no pass is added.
`InstanceCuts` is now a struct. On 2026 and 2027, and on no other
release, `attach_opening_flips` makes one pass of its own
(`graph_classes` limited to `FamilyInstance`). Both take the element's
one current record (`native_document` allows one per channel and id).
- `src/elements/openings.rs`: the typed `Door` view matched `fliphand`
and `flipfacing`, names no record carries; it now matches the new
fields, and its module doc no longer promises a hinge side.
- `probes/examples/probe_re343_door_flips.rs`,
`tools/re/door_flips_vs_ifc.py`: the probe and scorer;
`tools/ci/scrub-holdout-results.sh` keeps the scorer's count lines for
held-out models, a `field ... values` line only with values true, false,
null or under 100.
- `reports/element-framing/RE-343-door-window-flips.md`, a
`docs/format-reconnaissance.md` addendum, `docs/status.md`,
`docs/support-matrix.json` and
`changelog.d/added/1357-door-window-flips.md`.
- Revit's IFC as rvt-rs writes it is not changed (nothing reads the
fields). What rvt-rs writes for a door's local axes is not measured
here; a follow-up issue measures and decides it.

## Testing

No unit tests (banned). End to end on real files:

- [x] Measure runs of the probe and scorer on the open reference models,
the office, the R2025 models, the 58 Autodesk samples and the 18
held-out models (runs above); Snowdon Towers (local only) scored on a
Mac, counts only.
- [x] At `e2f8accc`: the unfiltered Measure against `main` (run
42024095189): `ifc.sha256` equal on all 111 models; the timing run
(42024099050), 64 files: no peak memory moves by more than 1 MiB, export
time within 1.2% of `main` on the files of 2023 to 2025 and within 1.6%
on those of 2026 and 2027, against 7% either way on the 33 files of 2015
to 2023 that the change does not touch.
- [x] At the head `18954f33` (the second review's changes): G
42037262675, a filtered byte-identity run (the two office files and the
58 samples) against `main` at `a0639777`: `ifc.sha256` equal on all 60
models, no semantic finding. D'' 42037268099 and F'' 42037272808, the
probe on the open models and the samples: the fields and the typed Door
view equal to the booleans on 132 of 132 doors of Core Interior, 5 of 5
of RE1 Architecture, 268 of 268 of the office (as built, and at permit),
1 of 1 of R2025 model 12, and 1,588 of 1,588 doors of the 2024 to 2027
samples; none of the 1,540 doors of 2015 to 2023.
- [x] Merged with `main` at `dd3dc116` (signed; the last merge brought
#1435 and #1446, which this change does not touch). The measured code
differs from what the run at `e2f8accc` measured (the second review's
edits and everything `main` gained), so the unfiltered run was repeated
on the merged head `80a9d72c`, with `main` at `afec5e37` as its base:
run 42040585454 (`-f base=main -f nordic=true -f r2025=true -f
holdout=true -f samples=true`), read. All 15 jobs that ran succeeded
(the three timing jobs are skipped by design). `ifc.sha256` is the same
on head and base on all 111 models (the 58 samples among them), the
semantic diff has no finding on its 111 folders, and the scorer diff's
one line is `Only in measure-head: areas_across_saves.txt`, the Areas
gate's own output. `Same-project gates` passed (bodies 6 of 6 samples;
the 25 Areas of `rac_advanced` equal on its four saves) but test beams,
stairs, sketch outlines and Areas, not doors or windows: the evidence
for this change is the byte identity. The run predates #1448, so the
PR's gates verdict is by override citing it. Since that run `main` has
moved to `dd3dc116`; this change's own `src/` files are unchanged (`git
diff 18954f3 HEAD` over the five).

## Audit-honesty checklist

- [x] Every figure names its run and head in the report; what is not yet
measured on this head is labelled.
- [x] A user-visible change has its fragment under `changelog.d/added/`;
`docs/status.md` and `docs/support-matrix.json` say what
`decoded_elements()` now shows.
- [x] No emojis, private paths, personal email addresses or internal
jargon in committed files; held-out data is not in them.
- [x] Reverse-engineering finding: the probe is included, with a dated
addendum to `docs/format-reconnaissance.md`.

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0
- [x] The changes in this PR are based on public byte observations of
the redistributable reference models and Autodesk's public sample
projects, the buildingSMART IFC specification, and Autodesk's
open-source exporter `revit-ifc` (CLEANROOM.md source 5), read for what
Revit's export writes (`DoorWindowInfo`, `FamilyInstanceExporter`,
`PlacementSetter`); `ExporterIFCUtils.GetTransformForDoorOrWindow` is
cited by its public name only. It cites no source outside CLEANROOM.md's
five: the assignment of `m_flippedX` to the hand and `m_flippedY` to the
facing rests on revit-ifc's `DoorWindowInfo` (source 5), with the API
names as exported symbols (source 2), and on the measurements. I have
not used Autodesk SDK source, ODA SDK source, leaked internal
documentation, NDA material, or decompiled internal Revit implementation
code beyond public symbol exports, and I have not copied or translated
code from revit-ifc.
- [x] No test fixtures

## Breaking changes

None. Two fields are added to decoded Door and Window records, and the
typed Door view's two fields stop being null.

## Related issues

Refs #1357
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