Skip to content

feat(ifc): Areas from Revit's plan topology, and on Revit 2025–2027 (#1261, #1194) - #1371

Closed
puzzbobb wants to merge 10 commits into
DrunkOnJava:mainfrom
puzzbobb:feat-1261-area-topology-re330
Closed

puzzbobb wants to merge 10 commits into
DrunkOnJava:mainfrom
puzzbobb:feat-1261-area-topology-re330

Conversation

@puzzbobb

@puzzbobb puzzbobb commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Two commits.

  1. Areas from Revit's plan topology. An Area that the arrangement of its lines leaves without a region (RE-317) now takes the loop Revit's own plan topology keeps for it. The loop is checked against the area Revit saves for it and against the Area's point.
  2. Revit 2025 to 2027. Areas of these releases are now read. On a file saved by 2025 or later, the reader skips the block of entries that may come before a chain record's body.

Results:

  • Autodesk's rac_advanced writes all 25 Area bodies on every save from 2015 to 2027 (22 on 2021), where main writes 3, or none on 2021 and 2025 to 2027.
  • Snowdon Towers Architectural (2025) writes all 101 of the Area spaces in a Revit 2025 export of it, and 95 of its 96 bodies have Revit's area within 0.1%.
  • Every file without Areas exports byte-identical to main, the BIM4LCA office's included.

Motivation

#1261: BIM Whale's 2021 Areas are not written. #1316 left the next step as "Areas that Revit bounds partly by walls". RE-317 §6 named the 4 Areas of rac_advanced's third Level whose point lies in no loop of their lines as the case to look at. Together with the 18 in groups that have an arc or a slanted line, 22 of that sample's 25 Areas have no body on any release.

The 4 are not bounded by walls. On that sample 71 of the 127 area boundary lines carry an area rule's offset: their area is measured 0.497 ft or 0.041 ft to their right, to a wall's face. A line's record box is the measured line, so lines that meet where they are drawn have boxes that do not meet. Revit keeps the loops it computes for each scheme on each Level, with their areas, and each Area names its loop. That is what the first commit reads.

#1194: Areas were read on 2015 to 2024 only. The chain record that gives an Area its number, name, Level and height is the 2024 one on 2025 to 2027. A file saved by those releases may put entries before a record's body, which hid every Area of 2027 rac_advanced and of Snowdon Towers (2025).

Changes

  • src/research/native_area_regions.rs (new):
    • reads the LevelRoomPlan records (their PlanTopology: segments, circuits with area and sides, components) and the Areas' RoomElem (m_cachedCircuitId, m_point) through native_document, on 2015 to 2027;
    • reads, for the lines those loops name, each line's CurveElem (GLine or GArc) and its AreaMeasureCurveData.m_schemeSegments offsets;
    • rebuilds each loop: each side's piece of curve over its parameter range, moved to its right by its offset, met with the next where their curves cross (a straight step where they do not cross near the lines' shared end);
    • takes the holes from the components the loop encloses, and drops points where two straight edges continue straight, as Revit's profile does (RE-317 §3);
    • from Snowdon (second commit): a spur, a segment the loop runs out and straight back, is left out, and a line is cut only where its offset changes. Neither changes anything on rac_advanced or the office.
  • The checks: the loop's exact area (arcs integrated) equals the circuit's saved area to 1e-6 relative, each hole's equals its circuit's, the curve passes through the segment's saved ends, and the Area's point is inside. Anything not read or not checked gives no region (fail closed).
  • src/research/partition_area_records.rs:
    • locate takes the plan topology's region only where the lines' arrangement finds none (point_in_no_single_region, boundary_lines_not_readable) or the partition point is not read (point_not_read). Every other check (named lines, Levels, height, design options, two Areas in one region) applies to it unchanged, and every region drawn before is drawn as before.
    • AREA_SUPPORTED_REVIT_VERSIONS gains 2025 to 2027.
    • On 2024 and later a chain record is read after the 22-byte entries counted by the u16 at +0x0e (chain_entries). Each entry is an i64 BuiltInParameter, an i64 -1, a u16 and a u32.
    • None of the 2024 files read has such entries. RE1 Architecture has up to 11 per record and Snowdon Towers Architectural up to 1,815 (both 2025), and 2027 rac_advanced up to 15. Its 2025 and 2026 saves have none.
  • src/lib.rs, src/research.rs: the module's re-export and its line in the module list.
  • probes/examples/probe_re330_area_plan_topology.rs: each Area's region or refusal, each area boundary line's curve and offsets, and the census of chain records by entry count.
  • reports/element-framing/RE-330-area-plan-topology.md: the report.
  • Docs: docs/format-reconnaissance.md (addenda), docs/rooms.md, docs/evidence.md, docs/supported-profile.md, docs/export-diagnostics.md.
  • Changelog: changelog.d/added/1261-area-plan-topology.md, changelog.d/added/1194-areas-2025-2027.md.

Testing

Unit tests are banned in this repository: do not add them. Show the change working end to end on real files instead.

  • tools/check-local.sh passes (fmt, clippy, rustdoc, build, real-file / CLI / contract checks)
  • Verified end to end on real Revit files: the command, the files (and their licence), and the measured result against Revit's own export are in the PR body, with the script or probe that reproduces it
  • If this touches the IFC exporter: the witness verdicts replay (see CONTRIBUTING.md) or the changed observations are refreshed in this PR
  • If this is a performance change: reran tools/bench.sh and attached the before / after

Gate. tools/check-local.sh --corpus passes on the branch's head, rebased onto 5afb95c (after #1342): family corpus phi-ag/rvt bec25470, project corpus magnetar-io/revit-test-datasets fd755e1, 287 integration tests. The byte comparisons below were made on 4893028 and the Area counts rechecked on the head.

The loops against Revit's own figures. probe_re330_area_plan_topology (the region less its holes per Area):

file Revit Areas with a region check
Autodesk rac_advanced 2015, 2016, 2017, 2019, 2021, 2023, 2024, 2026, 2027 25 of 25 on each each loop's area equals the area Revit saves for it, to 1e-15 relative with straight sides and 1e-9 with the arc; the point is inside on all
BIM4LCA office, as built 2024 30 of 30 the region's area equals Revit's own IFC export of the Area, paired by GlobalId, on 30 of 30, worst 2.1e-10 relative
BIM4LCA office, building permit 2024 30 of 30 the same, 30 of 30, worst 2.1e-10
Snowdon Towers Architectural 2025 96 of 101 the other 5 miss the saved area by 4e-6 to 1.6e-3, each over a sub-millimetre piece of line with an offset of its own, and are refused

No 2015 to 2023 or 2026 to 2027 file with Areas has a Revit export here. Those saves are checked against the areas Revit saves in the file for the same loops, which are Revit's own figures, not its IFC.

The export. rvt-ifc FILE -o out.ifc --diagnostics out.json, SOURCE_DATE_EPOCH=1700000000, main at 4893028 against this branch, both --profile ci:

  • rac_advanced:

    • 2015, 2016, 2017, 2019, 2023, 2024: Area bodies (exported.body_sources.partition_area_boundary_lines) go from 3 to 25. skipped loses area_without_proven_body (22 on 2015 to 2023), and exported.area_body_refusals is empty on 2024.
    • 2021: 0 to 22. The other 3 Areas have a region, but they name lines whose two copies in that save disagree (it holds two states of the model, RE-324), so RE-317's named_lines_not_in_scheme_and_level still refuses them.
    • 2025, 2026, 2027: 0 to 25 Area spaces with bodies, the 2024 save's 25 with the same GlobalId, number, name, storey, body area and height.
  • rst_basic 2025 to 2027: its one Area is written as on 2024, without a body (next_storey_not_proven).

  • Snowdon Towers Architectural (2025; a Revit 2025 export of it, exporter 25.4.50.6, local only):

    • rvt-rs writes 101 Area spaces, all 101 of Revit's by GlobalId with the same number and name, and none extra. main writes none.
    • Of the 96 bodies, 95 have Revit's area within 0.1% (worst 2.1e-4, Revit's arcs traced in chords to compare). The 96th, P4, is an Area Revit's export writes without a Representation, for no reason found.
    • 5 Areas Revit draws have no body here (above).
  • No Revit export to compare: Snowdon Towers Structural (7 Areas) and a Japanese sample project (80 Areas, all without a body, levels_not_recovered) now write their Areas.

  • Byte-identical IFC and diagnostics on every file without Areas: 54 of 78 local files. They include:

    • both BIM4LCA offices and the terrain housing;
    • Core Interior and the four RE1 models;
    • Einhoven;
    • Autodesk's samples without Areas;
    • the Snowdon MEP, Facades and Site models;
    • puzzbobb's R2025 models.

    Every one of the 24 that change has Areas.

  • Where both rules give a region: on the office the plan topology's has the same area and perimeter on all 30. RE-317's is kept, so its export does not move.

Witness. Core Interior's export is byte-identical, so its observations are unchanged.

Held-out. BIM Whale's AdvancedProject (2021) is held out and was not opened. A Measure run with -f holdout=true gives its counts. Whether its 8 Areas are now written, and whether any space is written that Revit's export lacks, is the result this PR cannot give.

Reading the plans and lines takes 80 to 95 ms on rac_advanced and about 0.3 s on the office (the probe, one local machine). The pass runs only on a file with placed Areas.

cargo run --profile ci -p rvt-probes --example probe_re330_area_plan_topology -- rac_advanced_sample_project.rvt
python3 tools/re/space_profiles_vs_ifc.py office.ifc office_Revit.ifc --match globalid

Audit-honesty checklist

  • README / docs reflect the current state after this PR — no claims of features that are not actually shipped in this PR
  • A user-visible change has its entry as a fragment under changelog.d/<section>/ (see changelog.d/README.md), not in CHANGELOG.md
  • If a limitation was resolved, the "Known limitations" / "What works today" section in the relevant docs is updated
  • If a new limitation was introduced, it is documented in the PR body and in-code
  • Commit messages describe WHAT changed and WHY, not "fix things" or "updates"
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • If this is a reverse-engineering finding: a reproducible probe under probes/examples/ and a dated addendum to docs/format-reconnaissance.md are included

Not measured (also in RE-330 §5 to §7):

  • Revit 2026 and 2027 against a Revit export: they are checked against the same project's 2024 save.
  • Readers other than the Area reader that read a chain record's category at +0x12 are not changed, though a 2025 to 2027 file may put entries before it.
  • P4 on Snowdon, and the 5 Areas whose loops miss by a sub-millimetre piece.
  • A scheme with more than one plan on a Level (design options, phases): an Area held by two plans keeps RE-317's refusal.
  • An Area Revit reports "not enclosed": none here.
  • The straight step where two offset curves do not cross: none on these files.
  • Revit 2008 to 2014.

RE-330 is the next free number as far as main and the open pull requests show (RE-327 went to #1342 while this was in progress). Renumber it if it is taken.

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0 (see CONTRIBUTING.md)
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content (see CLEANROOM.md)
  • Any new test fixtures use synthetic values (testuser, 111111, FY-20XX, etc.) and contain no real-world PII

The class and field names come from the schema each file embeds (Formats/Latest), as rvt-schema prints them. Autodesk's samples are fetched for the run and never stored. The office is CC BY-SA 4.0, read by byte range and never stored. Snowdon Towers' Revit export is local only and is quoted by its counts.

Breaking changes

None. native_area_regions is a new public module, and Areas of Revit 2025 to 2027 files are new IfcSpace. partition_area_records' public functions keep their signatures.

Screenshots or output samples

probe_re330_area_plan_topology on the 2024 and 2027 rac_advanced:

line	177355	GLine	0.000000-0.139080:0.497047 0.139080-0.732613:0.497047 0.732613-1.000000:0.497047
area	177460	6	0	1039.451635
summary	areas 25	with a region 25	area boundary lines 127	with an offset 71
chain	records by entry count 0:6972 1:2165 2:842 3:459 5:948 6:57 7:4913 8:312 9:40 10:382 11:27 12:91 13:14 14:23 15:2	well formed 17247	Areas 25	area boundary lines 127

Related issues

Refs #1261, #1194, #763

…es the loop of Revit's plan topology (DrunkOnJava#1261) (RE-330)

For each area scheme on each Level Revit keeps a LevelRoomPlan whose
PlanTopology holds the scheme's area boundary lines cut where they meet,
the closed loops they make, each with its area and its sides, and which
loop encloses which. Each Area names its loop (m_cachedCircuitId). An
area boundary line that follows a wall carries the area rule's offset
over each part of it (AreaMeasureCurveData.m_schemeSegments): its area
is measured that far to its right, to the wall's face.

native_area_regions rebuilds an Area's loop from its lines, each moved
by its offset and met where the moved curves cross, arcs included, and
keeps it only where its area is the one Revit saves for the loop and the
Area's point is inside. partition_area_records takes it where the lines'
boxes give no region.

On Autodesk's rac_advanced, 71 of 127 lines are offset: lines that meet
in plan do not meet once offset, so RE-317 found no loop for 4 Areas it
put down to walls, and groups with an arc were not read. Every save from
2015 to 2027 rebuilds all 25 loops to Revit's saved areas, and the 2015
to 2024 exports write 25 Area bodies where main writes 3 (22 on 2021,
where 3 Areas name lines whose copies disagree). On the BIM4LCA office
all 30 loops have the area of Revit's own export to 2.1e-10, and both
exports are byte-identical to main's, as is every other file compared.
…ecord after the entries before its body (DrunkOnJava#1194) (RE-330)

An Area's partition chain record was read on 2015 to 2024 only. On
2025 to 2027 it is the 2024 record, but a file saved by those releases
may put a block of 22-byte entries before a record's body, counted by
the u16 after the class tag (+0x0e): an i64 BuiltInParameter, an i64 -1,
a u16 and a u32 each. None of the 2024 files read has one; 2027
rac_advanced has up to 15 per record, Snowdon Towers Architectural
(2025) up to 1,815. The Area reader now reads a record after them.

Snowdon Towers Architectural, against a Revit 2025 export of it (local
only), gave three rules for the plan topology's regions:
- a spur (a segment the loop runs out and straight back) is left out:
  offset, its two sides leave a notch Revit's area does not have;
- a line is cut only where its offset changes, not where its saved
  parts meet with the same offset at a segment's end;
- an Area whose partition point is not read takes the topology's
  region, checked against the point the topology's Area saves.

rac_advanced 2025 to 2027 write the 25 Areas of the 2024 save, with the
same GlobalId, number, name, storey and body. Snowdon writes all 101 of
Revit's Area spaces, none extra; 95 of its 96 bodies have Revit's area
within 0.1%, and the other is one Revit writes without a shape. The
BIM4LCA office, Core Interior, RE1 and every file without Areas export
byte-identical to main.
@puzzbobb
puzzbobb requested a review from DrunkOnJava as a code owner November 4, 2026 17:32
@DrunkOnJava

Copy link
Copy Markdown
Owner

Thanks for this. Reading each Area from Revit's own plan topology and checking the loop against the area Revit saves for it (PlanCircuit m_area) is evidence from the file itself, stronger than what main has for these Areas. A review read found these before it can land:

  1. A crafted 2015 to 2023 file can panic: partition_area_records.rs slices buf[body..span.end] with body = start + 0x12 on every layout, but a narrow record can be 12 to 17 bytes. Splice only for the wide layout, or use get.
  2. locate falls back to the topology on any Err, including REFUSED_GROUP, so a group refused for a non-primary design option, stray heights or conflicting lines can still be drawn. Fall back only for the region and off-axis cases.
  3. Arcs are written as 2 degree chords under SpaceOutlineSource area_boundary. rvt-rs writes approximations only for stairs, labelled. Please write Revit's own form (the writer has ProfileDef::IndexedPolyCurve for three-point arcs), or refuse the Area.
  4. The Snowdon Towers Architectural 2025 file and its Revit 2025 IFC (exporter 25.4.50.6), the Japanese sample and Snowdon Structural have no recorded source, sha256 or licence (research/autodesk-sample-projects.tsv holds only the 2024 set). Under CLEANROOM.md their figures cannot go in the report or changelog. If they are Autodesk downloads, the URL and sha256 would make them admissible.
  5. The branch is 9 commits behind main and conflicts with feat(elements): an Area whose area boundary lines name each other is drawn to their joins, and a line off the axes refuses only the Areas it touches (#1261) (RE-330) #1351 (joined Areas, RE-330), which also rewrites locate. Main writes 16 of rac_advanced's 25 Areas, not 3. RE-330 to RE-332 are taken, so this would be RE-333.
  6. Smaller: the five REFUSED_* reasons are dropped by .and_then(Result::ok) and never reach diagnostics; -sub - 1 overflows on i64::MIN (the i686 overflow-checks job runs it); docs/status.md and docs/support-matrix.json still say 2015 to 2024.

Since the branch allows maintainer edits, we can rebase it onto main and do 1, 2, 5 and 6 here, with you as the author, then measure it against main on every sample save and the held-out models. Items 3 and 4 need you: whether you want to write the arcs yourself, and where the 2025 Snowdon files come from. If you would rather do all of it yourself, say so and we will wait.

…kOnJava#1194)

Order: the plan topology's region first where it is read and passes its
checks, then the lines' arrangement with RE-330's joins; a group of lines
that cannot be read as a whole gives neither. Renumbered RE-333.
…t the IFC2X3 export, the joins cross-checked, the office's vertices (DrunkOnJava#1261, DrunkOnJava#1194)
… says area_plan_topology, and warns about dropped chain records only where an Area could be lost (DrunkOnJava#1261, DrunkOnJava#1194) (RE-333)
…dPolyCurve with three-point arcs, and the Snowdon 2025 figures leave the report and docs (DrunkOnJava#1261, DrunkOnJava#1194) (RE-333)
…: Area 10's arc against the IFC2X3 export in both tessellations, the vertex rule, the office's exact differences, the warning scope (DrunkOnJava#1261, DrunkOnJava#1194) (RE-333)
DrunkOnJava added a commit that referenced this pull request Nov 4, 2026
… pipe axes (#1368) (#1373)

## Summary

Part 2 of #1368; Refs #1368 (it stays open for the rows listed below).
The provenance table (`--element-provenance`) now names the records a
room's outline, a hollow or I section column and a pipe's axis were read
from:

- a room whose outline is read from its stored solid lists the header of
each solid that gave it (`room_solid_faces`, `parts`, in the room's own
partition). These were the `selected_frame_box` left after #1370 (116 on
Core Interior, 234 on the office);
- a column drawn as its type's hollow section lists the four parameter
entries (`b`, `Ht`, `t`, `kr`) it took the section from
(`type_hollow_section`); a column drawn as its type's I section the six
entries of the I section (`type_i_section`), with `instance_transform`
for the plan angle of its X axis;
- a pipe drawn from its connector entries lists the two entries whose
points are its ends (`pipe_connectors`). At a connected end the entry is
keyed by the element connected there, so a part's `element_id` may be a
neighbouring fitting, not the pipe (RE-131).

Opt-in as before: nothing is noted unless the table is asked for, so the
IFC and the default diagnostics are not changed.

## Changes

- `partition_room_boundaries::{outline_of_solids_at,
resolved_outline_of_solids_at}`: the same readers, also giving, when
asked, the headers of the solids that gave the outline.
`attach_room_outlines` notes them (rule `frame`: only the room's own
partition is read, its solids in other partitions are not compared). No
new pass.
- `partition_type_parameters`: `scan_partition_length_places`,
`type_i_sections_at`, `type_named_lengths_at` and `type_lengths_at` give
the offset of the first copy of each entry the same pass reads, kept
only when asked (`want_places`); `note_parameter_source` builds the
source for an element from its type's entries. `attach_column_sections`
and `attach_beam_sections` call it where they attach the section.
`I_SECTION_PARAMETERS` is the one list of the I section's parameters.
`VALUE_BLOCK_MARK` is public for the test.
- `partition_pipe_axes::connector_points` also gives the offset of each
kept entry, only when asked; `scan_pipe_bodies` notes the two entries
that are the first body's ends, for the bodies that agree across
partitions.
- `element_provenance`: `body_readers` for `family_type_hollow_section`,
`family_type_i_section` and `partition_pipe_axis` (each with the frame
for the box the section or radius is held to), `profile_readers` for a
room outline, and the new readers in `PROFILE_FRAME_READERS`, so an
element with one is `selected_frame`, not `selected_frame_box`.
- MCP: `ValueSourceOut` doc comments list the new readers and the rule
`frame`. **An MCP tool's output description changed, so
`docs/mcp-tools.json` and `docs/mcp-tools.md` need CI's `mcp-tools`
artifact; I did not edit them.**
- `docs/export-diagnostics.md` (a row for each reader, the remaining
list), the schema description and
`changelog.d/added/1368-value-sources-part2.md`.
- `tests/value_sources_offsets.rs`, each new part re-read by what it is,
and as a set:
- a room's solid is the room's id and the solid's tag, and read again
(`room_outline_at`, or `resolved_outline_of_solids` with the kind its
profile source names) it gives an outline with the vertex count the room
holds;
- a type's parameter entry is `f64`, `ff` x 8 and an `i64`, in the value
block of the nearest mark whose owner is declared (as the reader's
blocks are) and is the type. An I section's parts are the six expected
parameter ids, distinct; a hollow section's are four distinct entries
whose parameters the `ParamElemFamily` elements caption `b`, `Ht`, `t`
and `kr`;
- a pipe's entry is the keyed element's `u64`, an index of at most 255,
the `u32` 1 and a point; the two parts are distinct and their points
make a cylinder with the pipe's record box (`pipe_body`).
- Pinned in `MIN_READERS`: `room_solid_faces`, `type_hollow_section` and
`pipe_connectors` on the office, `room_solid_faces` on Core Interior,
`pipe_connectors` on RE1 Mechanical and Plumbing.

## Measured (final head af26e4d, runs 41890988954 and 41890994176)

- Flag off (41890988954): the IFC and `diagnostics.json` are
byte-identical to main's (208e8c5) on Core Interior, the office, RE1
Mechanical and RE1 Plumbing. Flag on (41890994176): the IFC hash equals
main's on all four. The earlier head 9878143 (runs 41887783776 and
41887789579) gave the same.
- Counts with the flag on (rules: `room_solid_faces` is `frame`;
`type_hollow_section` and `pipe_connectors` are `agreeing`):

  | | before (main) | now |
  | --- | --- | --- |
| Core Interior | selected_frame_box 116 | room_solid_faces 116; no
selected_frame_box |
| Office | selected_frame_box 234 | room_solid_faces 234,
type_hollow_section 79, pipe_connectors 12; no selected_frame_box |
  | RE1 Mechanical | no pipe source | pipe_connectors 6 |
  | RE1 Plumbing | no pipe source | pipe_connectors 63 |

`type_i_section` appears on none of the four: no element has the I
section body, so that reader is untested on real files (the docs say
so). No source has the rule `current`. The `type_section` counts (176 on
Core Interior, 1 on the office) are #1370's, for the columns whose
`profile_source` is `family_type_symbol_envelope`, unchanged here.
- Table size, from run 41890994176's `diagnostics.json` (compact JSON of
`decoded.element_provenance`; main measured in the same run). The docs
and changelog fragments carry these figures.

  | | main | this PR |
  | --- | --- | --- |
| Office, table compact | 6,131,584 | 6,202,130 (+1.2%; 160.5 times the
38,640-byte diagnostics) |
| Office, pretty sidecar | 10,927,629 | 11,098,081 (211 times the
52,677-byte flag-off sidecar) |
| Core Interior, table compact | 718,828 | 733,326 (+2.0%; 35.7 times
the 20,563-byte diagnostics) |
| Core Interior, pretty sidecar | 1,511,498 | 1,549,080 (56 times the
27,588-byte flag-off sidecar) |
| RE1 Mechanical, compact / pretty | 41,824 / 87,442 | 43,745 / 91,938 |
| RE1 Plumbing, compact / pretty | 51,675 / 101,270 | 71,361 / 147,585 |

Since #1360 (5,987,841 and 440,909 bytes compact on the office and Core
Interior) the value sources of #1368 add 3.6% and 66%.

## Still without a source (#1368 stays open)

- `partition_area_boundary_lines`: left for last, as #1371 rewrites the
Area readers.
- `partition_roof_slope` and `partition_roof_extrusion`: each is made of
several readers (edge slopes, arrow heights, fascia depth, rafter cuts;
sketch lines, arcs and splines) keyed by sketch line and mapped to the
roof, which is its own change; not started here.
- `family_extrusions`: drawn from the family's own document
(`FormDocument`), not from an instance's native record, so its records
are the document's; a different mechanism, not started here.
- The I section of a beam (`BEAM_AXIS` body), a wall's layers and a
rectangular column's sides have no source either; they are values of
bodies that already have other sources.

## Testing

Nothing was built or run locally (lane rule: CI and Measure are the
build); the results below are CI's and Measure's.

- [x] `cargo fmt --all -- --check`, `tools/release/changelog.py check`
and `tools/ci/api-doc-ids.py` were run locally and are clean; clippy,
rustdoc and the build are CI's.
- [x] Final head af26e4d, filtered Measure on `core-interior`,
`nordic-office-as-built`, `re1-mechanical` and `re1-plumbing`: plain run
41890988954 and `--element-provenance` run 41890994176 are green and
read above.
- CI on 6c1799b (af26e4d plus the watcher's MCP contract commit; run
41891745041) passed in full, including Corpus health, which runs
`tests/value_sources_offsets.rs` with the new part checks on Core
Interior, the RE1 models and the office. The commit after it changes
docs and doc-comment figures only.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
- [x] Changelog fragment `changelog.d/added/1368-value-sources-part2.md`
- [x] Limitations documented in the PR body and in code
- [x] No emojis, no private paths in committed files
- [ ] Reverse-engineering finding: N/A

Limitations, stated:

- Which copy is the right one is not measured. A type parameter entry is
the first copy found; every copy holds the same value (a parameter two
partitions disagree on, or whose value block holds two values, is
skipped by the reader and leaves no section), so `agreeing` there means
the values agree, not that the copies are the same bytes.
- A room's source is `frame`: its solids in other partitions are not
read. A room none of whose solids closes has no outline and no source.
- A pipe's connector entries are in the partition of the pipe's record;
where its body came from two partitions the first is listed, and they
agree. An entry is listed because its point is the pipe's end, not
because it belongs to the pipe.
- The hollow and I section sources do not cover the box the section is
compared to: that is the element's `selected_frame`, listed beside them.
DrunkOnJava added a commit that referenced this pull request Nov 4, 2026
…n extrusion (#1368) (#1379)

## Summary

Part 3 of #1368; Refs #1368 (it stays open for the rows listed below).
Under `--element-provenance`:

- a roof drawn from its slopes (`partition_roof_slope`) lists the slope
block of each sketch line the slope was made from (`roof_slope_edges`:
the defining edges, or the slope arrow and the boundary lines it rises
from), those lines' own data (`roof_line_data`), its fascia depth and
rafter cut where they were read (`roof_fascia_depth`, `roof_rafter_cut`)
and the layers of its type that give its thickness (`roof_type_layers`),
beside the outline (`sketch_lines`, `sketch_list`) and the box
(`selected_frame`) it already listed;
- a roof drawn from an extrusion (`partition_roof_extrusion`) lists the
first frame of each of its sketch lines (`sketch_lines`, rule `frame`:
the other frames are not compared), their data (`roof_line_data`), its
Sketch's curve list (`sketch_list`) and `roof_type_layers`.

Opt-in as before: nothing is noted unless the table is asked for, so the
IFC and the default diagnostics are not changed.

## Changes

- Each owner map is built where the roof reader already resolves its
sketch, with no new pass: `attach_roof_slopes` (the lines of `defining`,
`sloped_by_arrow` and `sloped_by_arrows`) and `attach_extrusion_roofs`
(`lines_of`). `note_line_source` joins the notes the line scans made, by
line id, into one source of the roof, one part per line.
- The scans that read the blocks note their choice where they make it,
through a new `CopyTrail`: `scan_edge_slopes` (`edge_slope`),
`scan_arrow_heights` (`arrow_heights`), `scan_fascia_depths`
(`roof_fascia_depth`, keyed by the roof) and `scan_type_layers`
(`type_layers`, keyed by the type and attributed to each roof of it with
`attribute_value_source`, as for a stair run's type). `scan_rafter_cuts`
notes the roof's native record through `Options::value_source` and takes
the note back for a roof that gave no cut.
- `element_provenance`: `body_readers` for `partition_roof_slope` and
`partition_roof_extrusion`; `CopyTrail`.
- `tests/value_sources_offsets.rs`: both rows are `Recorded`
(`roof_slope_edges`; `roof_line_data`). A roof's slope block is read
again and must decode to a slope or a slope arrow (`edge_slope_in`,
`arrow_heights`); its sketch line to a line, an arc, a circle, a curve
or a spline; its type's layers are an element-data header and the type's
id. A new test reads puzzbobb's Revit 2025 models (`RVT_R2025_DIR`):
`MIN_READERS` pins `02_1Slope` and `05_1Slope_ArrowDefined`
(roof_slope_edges, roof_line_data, roof_type_layers) and
`11_RoofByExtrusion` (sketch_lines, roof_line_data, roof_type_layers) by
name, the models must be in the set, and the set together must have
sources from `R2025_READERS`.
- `.github/workflows/ci.yml`: Corpus health restores puzzbobb's models
from the Actions cache under the key Measure uses for them (`r2025-<hash
of research/r2025-models.tsv and tools/ci/fetch-r2025-models.sh>`),
fetches them with `tools/ci/fetch-r2025-models.sh` on a miss, and saves
them on main. An unreachable host leaves `RVT_R2025_DIR` unset and the
target skips; an archive that no longer matches its pin fails the job.
This was not asked for: the brief asked for a Measure pair with `-f
r2025=true`, but no model of the CI gate has a roof drawn from these
readers (the `value-sources` report of run 41891745041 shows no
`partition_roof_slope`, `partition_roof_extrusion` or
`family_extrusions` body on Core Interior, RE1, Einhoven or the office),
and Measure does not run the test. Without these models the new parts
are read by nothing.
- `docs/export-diagnostics.md` (a row for each reader, the remaining
list, the Revit 2025 models),
`changelog.d/added/1368-value-sources-roofs.md`.
- No MCP edits: the reader names in `rvt-mcp/src/schema.rs` were removed
by #1378, which this branch merged (a signed merge of `origin/main`), so
the contract does not move.
- `docs/export-diagnostics.md`: the one size table gains three Revit
2025 rows (run 41902619175); the first four rows are unchanged.

## Still without a source (#1368 stays open)

- `partition_area_boundary_lines`: waits for #1371, which rewrites the
Area readers.
- `family_extrusions`: drawn from the family's own document
(`FormDocument`), not from an instance's native record; last.

## Testing

Nothing was built or run locally (lane rule: CI and Measure are the
build); the results are CI's and Measure's, read at head fff508e (CI
run 41902701866) and the runs below.

- [x] `cargo fmt --all -- --check`, `tools/release/changelog.py check`,
`tools/ci/api-doc-ids.py` and `tools/ci/render-mcp-tools.py --check`
were clean locally, also after the merge of main. `yaml.safe_load` was
not available; `actionlint` parses `ci.yml` and reports only the seven
existing `uses: $/.github/actions/fetch-corpus` errors, none in the new
steps.
- [x] Corpus health passed on its first run on this change.
`r2025_value_sources_name_the_copy_the_reader_took` ran on all 24 Revit
2025 models (and the pins in `MIN_READERS`, `R2025_READERS` and the
existence of the pinned models held), and every report line reads
"re-read and confirmed" in full: for example 02_1Slope 13 of 13 sources
and 7 of 7 records, 11_RoofByExtrusion 11 of 11 and 3 of 3,
13_Rooms_Stairs 37 of 37 and 10 of 10, which reads the 2025 stair
sources of #1370 (`native_run`, `native_run_type`) for the first time.
No fix was needed.
- [x] Filtered Measure, 26 models (`core-interior`,
`nordic-office-as-built`, 24 `r2025-*`), head fff508e against main
29a715d: flag off (run 41902614550) the IFC and `diagnostics.json` are
byte-identical to main's on all 26; flag on (run 41902619175) the IFC
hash equals main's on all 26. Every Revit 2025 model with a roof drawn
from its slopes lists `roof_slope_edges`, `roof_line_data`,
`roof_type_layers`, `roof_fascia_depth` and `roof_rafter_cut`;
`11_RoofByExtrusion` lists `sketch_lines`, `roof_line_data` and
`roof_type_layers`. Core Interior and the office have none, and their
flag-on tables are byte-identical to main's.
- **Corpus health cost.** The job took 13.9 min on this head against 7.2
(#1373) and 8.3 min (#1378) on recent green PR runs and 8.3 and 9.4 min
on pushes to main, but 6.9 min of it was the existing step "Fetch the
Revit 2025 oracle (Drshelden/IFC-ECS RE1, MIT)", 3 s in the other runs:
a slow download unrelated to this change. What this change adds:
restoring the R2025 cache and the fetch step took 1 s (a cache hit:
Measure saved it on main); "Tier-two gates" took 4.4 min, the same as
#1373's 4.4 min (5.8 min on the push to main that merged it); the new
test took 8.4 s, in parallel with the others (the office test, 26.8 s,
ends the step). So it adds no measurable time on a hit, and it stays in
Corpus health. A cache miss was not measured (every run found the
cache): it downloads three archives of 26 MB in all and extracts them,
seconds at the runner's rate, and the cache is saved on main.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
- [x] Changelog fragment `changelog.d/added/1368-value-sources-roofs.md`
- [x] Limitations documented in the PR body and in code
- [x] No emojis, no private paths in committed files
- [ ] Reverse-engineering finding: N/A

Limitations, stated:

- `roof_slope_edges` and `roof_line_data` list the sketch lines the
slope was made from; the roof's box (its height and plan centre) is the
element's `selected_frame`. The thickness is the type's layers, whose
copies agree (a type whose copies differ is dropped by the reader).
- `edge_slope`, `arrow_heights` and `type_layers` are `agreeing` because
a line or type whose copies disagree is dropped by its reader;
`roof_line_data` is `current` where a line's copy was chosen as the
current partition's (RE-216).
- The `sketch_lines` source of a roof by extrusion is `frame`: the first
frame of each line by frame order, as the roof reader keeps it, without
comparing the others.
- A roof whose body is its box (a slope that does not reproduce its box)
gets none of these sources: the sources are listed only where the final
`BodySource` is drawn from them.
@puzzbobb puzzbobb closed this Nov 4, 2026
@puzzbobb
puzzbobb deleted the feat-1261-area-topology-re330 branch November 4, 2026 21:23
@DrunkOnJava

Copy link
Copy Markdown
Owner

You closed this without a note, so we want to check before doing anything with it. With the maintainer fixes on top, it wrote all 25 of rac_advanced's Areas on the 2020 save against the public IFC2X3 export, a check it was not fitted to, and it reproduced the 16 Areas main already draws.

If you closed it on purpose and would rather it not land, we will leave it. If you are fine with it, we will open it again from a branch here, with your commits keeping you as author, and credit you in the release notes. If you would rather reopen it yourself, that works too.

DrunkOnJava added a commit that referenced this pull request Nov 4, 2026
…es' own extrusions (#1368) (#1382)

## Summary

Part 4 of #1368; Refs #1368 (area boundary lines, which wait for #1371,
are the one body left). With `--element-provenance` and
`--family-extrusions` both on, a family instance drawn from its family's
own extrusions (`family_extrusions`) lists the records of the family's
embedded document that its extrusions were rebuilt from (`family_forms`,
`parts`): each visible extrusion (`ExtrusionElem`), its sketch plane
(`SketchPlane`) and the curves of its sketch (`CurveElem`), at the place
the document's group puts the record in its partition. Beside it the
instance lists the `instance_transform` that places the extrusions and
the `selected_frame` they are drawn at.

With either flag off nothing is built or retained: the document is only
read at all under `--family-extrusions`, and the places of its records
and the list of the records an instance was rebuilt from are collected
only while the handle records value sources (`--element-provenance`).
The IFC and the default diagnostics are not changed.

## Changes

- `native_family_forms::family_records_at`: `family_records_in`, also
giving, when asked, where each record starts (the partition and the
offset in it inflated: the group's own `inflated_offset` plus the
record's position in the group). `family_records_in` is the wrapper. A
group whose bytes are not the partition's own (joined from segments that
are not consecutive) has no place, and its records none.
- `family_extrusions`: `family_parts` also returns, only while
recording, the records of the document it used; `attach_with_control`
notes them for each instance it replaces (`note_forms`). If any record
of an instance's family has no place, nothing is noted for the instance
(it keeps its other sources): a list that left one out would not be the
records the body was rebuilt from.
- `element_provenance`: `body_readers` for `family_extrusions`
(`selected_frame`, `instance_transform`, `family_forms`); `family_forms`
in `PROFILE_FRAME_READERS`. The saved mesh the extrusions are checked
against is not a source of the body.
- The rule is `frame`: the family's document is read once, as it is
embedded. A record the file holds in several partitions is named at one
copy (see the next section); the other copies are not compared. A part's
`element_id` is the family document's record id, not the model's, so it
can equal another element's.
- `tests/value_sources_offsets.rs`: the `family_extrusions` row is
`Recorded`. A new test exports the office, RE1 Architecture and RE1
Electrical (the models #1372 measured that draw family extrusions; the
terrain files are not in the test's set) with `--family-extrusions` as
well, as `<model>+family-extrusions`, and `FAMILY_MIN_READERS` pins
`selected_frame`, `family_forms` and `instance_transform` on each.
- `docs/export-diagnostics.md` (the row, the remaining list, the test's
description),
`changelog.d/added/1368-value-sources-family-extrusions.md`,
`changelog.d/fixed/1368-family-forms-partition-order.md`, and the older
#1368 fragments, which no longer say family extrusions are without a
source.
- No MCP edits: the descriptions no longer list readers (#1378).

## Which copy a part names (second read)

`FormDocument::insert` keeps the last copy's graph of a record, but
`family_records_at` recorded the first copy's place, and `load()` took
the partitions in name order, not partition-number order (the #1356 bug
class). Chosen: place and geometry come from the same copy, the last,
not skip-on-duplicate.

- `load()` takes `RevitFile::partition_stream_names` (numeric order, the
newest copy last) instead of sorting names.
- The place is last-wins, matching `insert`. A later copy whose group
has no place removes the earlier copy's place, so a place never belongs
to a copy other than the one the geometry came from; the instance then
gets no `family_forms` source, as for any record without a place.
- The numeric order reaches the other readers of a family's document on
the default path (the materials of a family, `instances_without_body`):
they `push` or `insert` per copy, so only the order the records are read
in changes, and only for a file whose partition numbers have unequal
digit counts. Core Interior (46 to 65), RE1 Architecture (80 to 84) and
RE1 Electrical (114 to 120) do not; the office and the terrain files are
what the Measure pair below settles.

## Test fixes (second read)

- A pinned model that the corpus lacks fails the family test where its
directory variable is set (`RVT_PROJECT_CORPUS_DIR` for RE1 Architecture
and RE1 Electrical, `RVT_NORDIC_LCA_DIR` for the office), as `check_all`
does; unset, that directory is skipped. Corpus health fetches RE1
Electrical with the other RE1 files, by hash.
- An extrusion roof's `roof_line_data` is compared with its
`sketch_lines` by ElementId, not by count (the lists are compared sorted
when both are whole; the counts when either was cut at the listing's
cap).
- The test reads each instance's family document again
(`family_records_in`, a `FormDocument`) and requires the instance's
parts to be exactly the records its visible extrusions are made of:
every `ExtrusionElem`, its `SketchPlane` and its `CurveElem` curves,
none left out, none extra. Each part is read from its bytes at its
offset by its role: the class tag there must be the role's class, not
any of the three.
- Docs and fragments: an instance whose record has no place gets no
`family_forms` source; "nothing is built" is now true (`family_parts`
collects the record set only while recording).

## Folded in from the second read of #1379

The merge of main brought #1379 in; its fixes are in the first merge
commit because they edit what the merge brings: the R2025 test skips
only when `RVT_R2025_DIR` is unset and fails when a pinned model is
absent (an empty or missing directory included); `roof_type_layers` is
read again by `find_layers` with its window, `roof_fascia_depth` by
`fascia_depth` with `EDGE_SLOPE_WINDOW`, and `roof_rafter_cut` by
`scan_rafter_cuts`, all three pinned in `R2025_READERS`; a sloped roof's
`roof_line_data` comes only from the slope scan's `sketch_line` notes;
an extrusion roof's `roof_line_data` must have a part for each of its
`sketch_lines`; the rafter-cut note is taken back only while recording;
and the docs say that a roof with one arrow lists the arrow's line
alone, that the reader compares decoded slopes, not bytes, and that
`sketch_list` of an extrusion roof appears only when the Sketch lists
its curves (`11_RoofByExtrusion` has none).

## Still without a source (#1368 stays open)

- `partition_area_boundary_lines`: waits for #1371.

## Testing

Nothing was built or run locally (lane rule: CI and Measure are the
build); the results below are CI's and Measure's. The second-read
changes below were written without a compiler: CI's first run on
216126c is their first check.

- [x] `cargo fmt --all -- --check`, `tools/release/changelog.py check`,
`tools/ci/api-doc-ids.py` and `tools/ci/render-mcp-tools.py --check`
were clean locally, before and after the merges and the second-read
changes.
- [x] Corpus health passed on its first run on this change (CI run
41907417882, head dcb435e, before the second read): the family test ran
on the office, RE1 Architecture and RE1 Electrical, and every report
line read "re-read and confirmed" in full: RE1 Architecture 8 instances
with `family_forms` (128 of 128 sources, 160 of 160 records), RE1
Electrical 8 (65 of 65, 30 of 30; all 8 in another partition than their
frame), the office 129 (13,927 of 13,927, 2,482 of 2,482). It took 32.6
s then; the second read adds a document read per model (watch the time).
- [x] Filtered Measure at dcb435e, `--element-provenance
--family-extrusions`, run 41907345226, against main with the same flags:
the IFC hash equals main's on all 7 models. Family instances with the
new source: office as built and at permit 129, the terrain files 11
each, Core Interior 37, RE1 Architecture 8, RE1 Electrical 8.
- [ ] The pair on the final head 216126c (the numeric order and the
last-wins place are new since the last pairs, which were byte-identical
at 1ea948d): no flags (run 41915552784) and `--element-provenance
--family-extrusions` (run 41915557479), models `core-interior
re1-architecture re1-electrical nordic-*`. Both must leave the IFC
byte-identical to main's with the same flags and the first the
diagnostics too. NOT MEASURED until they finish; arming waits on them.
- [x] The size table (`docs/export-diagnostics.md`, "Provenance table
size"): the family sources add 1.1% to the office's compact table, 10%
to Core Interior's, 17% and 15% to RE1 Architecture's and Electrical's,
13% to each terrain file's (run 41907345226); the first rows are
unchanged. The named copy is now the last, so an offset can have another
digit count: the new pair's table sizes settle whether a figure moves.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
- [x] Changelog fragments
`changelog.d/added/1368-value-sources-family-extrusions.md` and
`changelog.d/fixed/1368-family-forms-partition-order.md`
- [x] Limitations documented in the PR body and in code
- [x] No emojis, no private paths in committed files
- [ ] Reverse-engineering finding: N/A

Limitations, stated:

- The records listed are those the rebuild read (each visible extrusion,
its plane and its curves); an extrusion hidden by its `Visible`
parameter is set aside and not listed. A family with a void or an
extrusion the reader does not rebuild draws nothing and has no source.
- Which instance of a family the extrusions fit is checked against the
instance's own saved mesh, not recorded as a source; the instance's
parameter values that differ from the family's are not sources either
(the checks refuse an instance they make differ).
- The terrain variants of the office draw family extrusions too (#1372)
but are not in the test's model set; the Measure run covers them for
byte-identity and counts.
- Not measured: that two copies of a family's record, where a file holds
them, agree; the last is named.
@puzzbobb

puzzbobb commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Apologies, I thought it was done, it can be reopened on a branch here.

@DrunkOnJava

Copy link
Copy Markdown
Owner

No need to apologise, and thanks. It's open again as #1428, on a branch here, with your two commits keeping you as author. It lands once its final Measure run reads clean, and you'll be credited in the 0.16.0 notes.

Your other PR, #1426, needed main merged in and its report renumbered to RE-341, since RE-340 on main is a different report. I did both on your branch; no reader changed.

DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
#1261, #1194) (#1428)

## Summary

This reopens #1371 by puzzbobb on a branch of this repository, as
puzzbobb agreed on that pull request ("it can be reopened on a branch
here"). puzzbobb's two commits are cherry-picked in order and keep them
as author (`fec15008`, `c4889e7f`, signed by the committer, as
`main-protection` requires); the maintainer's five commits that followed
on #1371's branch come after them, with the archived head
`refs/archive/2026-11-04/pr1371-area-plan-topology` (`e5b1c8be`) as the
source. Their reader is the substance: an Area that the arrangement of
its lines leaves without a region takes the loop of Revit's own plan
topology, checked against the area Revit saves for it, and the Areas of
Revit 2025 to 2027 are read.

It supersedes the wall-line rule of #1367, which was worked out from the
same IFC2X3 export it is scored against; #1367 becomes research notes
only once this lands (Griffin, 2026-11-04).

## The gate (Griffin, 2026-11-05, "Ship, labelled", then "Same-project
gate")

The Areas of Revit 2025 to 2027 and the 108 Area spaces of the recorded
Autodesk 2024 Snowdon Towers samples are written by default. They are
**not measured against any Revit export**; RE-333 section 9, the
changelog fragments and `docs/rooms.md`, `status.md`, `evidence.md` and
`supported-profile.md` say so and name the evidence: the drawn loop
equals the area Revit saves in the file for it and holds the Area's
point, and on 2025 to 2027 the same project's 2024 save gives the same
Areas.

**The marker (Griffin, 2026-11-05, "Mark 2025 to 2027 in the file").**
His earlier "their own outline source value" had two readings, and the
docs-only one was mine; he wants the file to show it. Areas read from
Revit 2025, 2026 and 2027 now get `SpaceOutlineSource`
`area_plan_topology_unchecked`, wherever the marker shows: the IFC
property, `list_rooms` (`space_outline_source`), the schedule CSV's
outline source column, and the MCP field's description (the watcher
syncs the contract). Snowdon Towers 2024 and every other 2024 file keep
`area_plan_topology`, because they share a release and a code path with
the office and a release is not split; 2015 to 2023 keep it too (they
are the Areas with the IFC2X3 check). It is decided by release in one
place, `partition_area_records::area_release_unchecked`
(`AREA_UNCHECKED_RELEASES`, 2025 to 2027), which sets a field of the
decoded Area that `export_content` reads. `BodySource` and
`exported.body_sources` do not split: the body is read by the same code,
and the marker says how far it is checked, not how it was read.
`tools/re/areas_across_saves.py` expects exactly that per release: a
2025 Area reading `area_plan_topology` and a 2024 Area reading the
unchecked value are failures. Consumers checked: `export_content`
(marker, `contain_in_spaces`), `schedule_csv` and
`element_record_plan_profiles` (keyed on `ProfileSource`, which does not
split), `element_provenance` and the COVERAGE rows (keyed on
`BodySource`, unchanged), `rvt-mcp` (passes the text through;
descriptions updated), `space_profiles_vs_ifc.py` (knows the value).
`#1439`'s `SpaceKind` scorer has its own list of Area values, and that
lane adds the new one.

**The first gate tested nothing, and I recommended it.** It was "no Area
written that Revit's export lacks (`only in rvt-rs` 0) on every held-out
Revit 2025 to 2027 model with Areas". None of the seven held-out Revit
2025 to 2027 models writes an Area, and all seven exports are
byte-identical to main's (Measure run 42003913780 on `bcb02107`), so
`only in rvt-rs` 0 could not have failed. I did not count what it would
count before recommending it.

**The gate now (Griffin's "Same-project gate"): this lands only if
rac_advanced's 25 Areas on its 2025, 2026 and 2027 saves equal its 2024
save's, Area by Area.** The fields are GlobalId, number, name, storey,
outline source (the value each release gets, above), body area (1e-6
relative), top surface (the symmetric difference of the two top
surfaces, 1e-6 relative), height (1e-5 ft) and lowest vertex (1e-5 ft);
Griffin's list is the first six and the rest are a floor raised, so that
a translation, a rotation, a shear that keeps the area, a raised base or
another outline source is a difference. `tools/re/areas_across_saves.py`
compares them. `tools/ci/measure-reference-models.sh` runs it on the
head side of any Measure run of the samples that holds the four
rac_advanced samples (whatever `sample_years` says, as long as it
includes 2024 to 2027), once every export is done and before any
sample's IFC is deleted; with fewer than the four it checks nothing and
prints a notice. The job "The Areas agree across rac_advanced's saves"
in `measure.yml` turns the run red unless the output ends `exit 0` and
has the scorer's `passed` line. It fails on a missing or unreadable
save, on other than 25 Areas or other than 25 Areas with a body on any
save (so 26 fails the same way the workflow's grep does), on an Area
with no storey, and on any difference, missing or extra Area; a pass on
nothing is impossible. **Measure is not a required check, so "blocks
landing" means by the landing rule: the result is read before merging.**
It prints counts by field and the number of Areas compared on each save,
nothing else.

**What the first two passes got wrong, found by the second review.**
Runs 42008539696 and 42010805118 read "storey 25 equal" on `None` equal
to `None`: the first version of the scorer read the storey with
`get_container`, and rvt-rs writes a space under its storey with
`IfcRelAggregates`, so the storey was never compared; and it pinned 25
Areas but not 25 bodies, so all four saves losing their bodies stayed
green. Both are fixed (`get_aggregate`, a missing storey, other than 25
bodies and a missing body are failures). The real storeys of the four
saves are `01 - Entry Level` (9), `02 - Floor` (9) and `03 - Floor` (7)
with 0 differences, so the fix cannot turn a correct head red.

**The proof, run through `read_areas` on written IFC and not through
`compare()` on dictionaries.** The reviewer's generator (IfcOpenShell)
writes the four saves, each Area an `IfcSpace` aggregated under an
`IfcBuildingStorey` with its `SpaceOutlineSource` and an extruded body,
and the fixed scorer reads them as it reads an export, then the
workflow's own check reads its output file. 23 cases, 0 wrong. Green:
the control (25 Areas, 25 with a body, every field equal) and a height
5e-6 ft off (within the tolerance). Red: (1) no body on any save; (2)
one body on every save; (3) later saves that lose their bodies; (4) one
Area moved to another storey; (5) storeys renamed on a later save; (6)
no storey on any save; (7) every body of a later save moved 100 ft; (8)
every body turned a quarter turn; (9) one body sheared to the same area;
(10) the base of every body raised 5 ft; (11) a different outline source
on a later save; (11b) one 2025 Area reading `area_plan_topology`; (11c)
one 2024 Area reading `area_plan_topology_unchecked`; (11d) every later
Area reading `area_plan_topology`, the release rule not applied; (11e) a
lines value on 2027; (12) 26 Areas on every save; (13) 24 on every save;
(14) one Area missing from the last save; (15) a save missing; (16) a
height 2e-4 ft off; (17) a body area 1e-4 relative off. The harness is
in the lane's scratch directory (it needs IfcOpenShell to write files),
not in the repository.

**Tried on real data.** Run 42008535484, main's exports of the four
saves (this branch's scorer and workflow, main's binaries at `ce0b2398`,
no #1428): 2024 has 25 Areas, 16 with a body, and 2025, 2026 and 2027
have 0, so each later save fails and the job turned red. Run 42008539696
and run 42010805118 (the pushed head `401f5244`, finished green): 25
Areas on each of the four saves, the gate passed, and the 58 sample
exports' hashes are identical to run 42003913780's (I read the second
run's myself). Both ran the scorer before the fix above, so their
"storey equal" counts were `None` against `None`; the final run below is
the first with the fixed scorer on real files.

**What it cannot catch:** an error that the 2024 read shares with the
later reads (the same wrong region, number, name or height on all four
saves), and an error in how the saves are exported that is the same in
all of them. It compares rvt-rs with itself, on one project of 25 Areas.

## The 2021 save does not move (a measured residual)

Autodesk's `rac_advanced` 2021 save keeps its 25 Areas as
`area_without_proven_body` (22 `boundary_lines_not_readable`, 3
`named_lines_not_in_scheme_and_level`), as on main, although RE-333
section 4 says the topology has a region for all 25 on it. From the
code: the save holds both states of the model (RE-324 section 4), so 16
area boundary lines have two disagreeing copies; `group_arrangement`
returns `Group::Unreadable` for a group that holds one, and `locate`
returns that before the plan topology is asked; `draw_area` refuses the
3 Areas that name such a line. That order is the refusal about safety
that the review of #1371 asked for (no fallback to the topology after
conflicting copies, stray heights or a design option), so it is not
changed here. Measured (probe run 42008543772): the topology's 25
regions on the 2021 save equal the 2022 save's and the 2023 save's, Area
by Area, in vertex count, holes, arcs and area, so its current native
copy holds the later state; no Revit export of that state exists. It
gets its own issue.

## Motivation

#1261: BIM Whale's 2021 Areas were not written, and on Autodesk's
`rac_advanced` main writes 16 of the 25 Areas (the 9 it leaves out are
the ones the plan topology draws; #1367's "18 of the 25 drawn" is not on
main). #1194: Areas were read on Revit 2015 to 2024 only. RE-333 has the
measurements and the reasons.

## Changes

- **puzzbobb's reader** (`fec15008`, `c4889e7f`):
`src/research/native_area_regions.rs` (the plan topology's loops,
offsets, holes and checks) and the chain-entry count that lets Revit
2025 to 2027 records be read (`partition_area_records.rs`).
- **The maintainer's commits on #1371's branch, cherry-picked**: the
joins cross-check and RE-333 measurements, the vertex where a third line
meets, `SpaceOutlineSource` `area_plan_topology`, the warning for
dropped chain records only where an Area could be lost, arcs written as
arcs (an `IfcIndexedPolyCurve`), the Snowdon Towers 2025 figures removed
(below), `tools/re/space_profiles_vs_ifc.py` and the MCP tool
descriptions for the new value. The archive's generated contract commit
(`e5b1c8be`) is not carried: `docs/mcp-tools.json` and `.md` are never
hand-edited, and `rvt-mcp/src/schema.rs` and `server.rs` gain the new
`space_outline_source` value, so CI's `tool_contract_is_committed` needs
the watcher's contract sync before the full CI is green.
- **This branch's own commit** (`94cd0fd7`), the reconciliation with
what landed on main since the merge base (`fdff7018`), whose conflicts
git reported in `src/reader.rs`,
`src/research/partition_area_records.rs`, `docs/status.md`,
`docs/export-diagnostics.md` and `docs/format-reconnaissance.md`:
- **Value sources (#1368).** #1403 gave Areas `area_boundary_lines` and
`area_point`, noted for the lines' frames and the partition's point. An
Area drawn from the plan topology was not drawn from either, so it no
longer carries them; it carries `area_plan_topology` (rule `native`,
`parts`): the Area's own `RoomElem`, the `LevelRoomPlan` that holds its
circuit and the `CurveElem` of each line that bounds it, each at its
place in its partition (`native_area_regions.rs` `record_place`, kept
only while the handle records value sources, so the flag-off path
allocates nothing; `partition_area_records.rs` `note_topology_source`).
`tests/value_sources_offsets.rs` has the reader in `COVERAGE`, reads
each part's id at its offset, and reads the records again from their
ElementIds (`check_topology_areas`): the Area's record names a circuit
and a point, exactly one part is the plan whose topology holds that
circuit and the Area, and the other parts are the lines of that circuit
and of the circuits it encloses, all of them and no others. The office's
`MIN_READERS` pin `area_plan_topology`; `area_boundary_lines` and
`area_point` are no longer pinned on any model of the gate, because the
office's 30 Areas all take the topology first, and the test says so
beside the row.
- **Export decisions (#1326).** `exported.area_body_refusals` and
`model_decisions` both derive from the Area's `AreaBodyRefusal`
property, so the new reasons (`area_not_in_one_plan_topology`,
`area_circuit_not_found`, `area_circuit_side_not_read`,
`area_circuit_area_differs`, `area_arc_not_finite`,
`area_point_outside_circuit`) are counted by both and there is no list
to extend. The diagnostics schema and `docs/export-diagnostics.md` list
them (`area_arc_not_finite` was missing from both).
- **`SpaceOutlineSource` values and descriptions** (#1351, #1405,
#1412): auto-merged; `area_plan_topology` is in the MCP tool
descriptions and the docs.
- `src/reader.rs` keeps #1389's record stages beside the new
dropped-chain-entries note. The two merges of main that #1371's branch
carried are carried by this commit and by a signed merge of main.
- **The same-project gate** (this round):
`tools/re/areas_across_saves.py`; `tools/ci/measure-reference-models.sh`
runs it between the exports and the deletion of the samples' IFCs, on
the head side of a shard that holds the 2024 to 2027 saves of
rac_advanced; `measure.yml` turns the job red unless
`areas_across_saves.txt` ends `exit 0` and has the scorer's `passed`
line, and lists its counts in the summary. `actionlint` reports nothing
on the lines this adds (its only findings are the `uses: $/...` forms
already in main's workflows); the workflow parses with a YAML safe
loader (ruby's, no PyYAML here), and `bash -n` and `shellcheck` pass on
the script. No test target is added: `tools/ci/test-targets.txt` is
unchanged.
- **Docs and changelog** (`6dacca98`): `docs/rooms.md`,
`docs/status.md`, `docs/evidence.md`, `docs/supported-profile.md` and
`docs/support-matrix.json` say Revit 2015 to 2027 and name the plan
topology; the fragments `changelog.d/added/1261-area-plan-topology.md`
and `1194-areas-2025-2027.md` credit puzzbobb by name.

## The review findings on #1371, in code

1. **Crafted file panics.** `partition_area_records.rs:497-498`:
`buf.get(span.start..body)` and `buf.get(body +
span.entries..span.end)`; a narrow record is taken whole through
`buf.get(span.start..span.end)`, and a span that does not lie in the
partition is skipped. No raw slice of parsed spans is left in the
module.
2. **The fallback to the topology after a refusal about safety.**
`locate` returns `Group::Unreadable` (a non-primary design option, stray
heights, conflicting copies, a missing line) before the topology is
looked at (`partition_area_records.rs:1166`, from `group_arrangement` at
`:1043-1062`); the topology is asked for only where the lines are sound
but not arranged (`Group::Unarranged`) or an Area's region touches a
line off the axes (`group.blocks`). The refusals before it (no Levels,
an unaccounted line, no lines) refuse every Area as before.
3. **Arcs as chords.** Written as arcs, `IfcIndexedPolyCurve` with
three-point arcs (`src/ifc/export_content.rs`, `indexed_area_curve`);
the outline is checked as written, arcs as arcs, against the circuit's
saved area, and an arc that cannot be read finitely refuses the Area
(`area_arc_not_finite`).
4. **Unrecorded Snowdon Towers 2025 claims.** Out of the report, the
changelog and the docs (Griffin, 2026-11-04). The Snowdon Towers figures
that remain are the recorded Autodesk 2024 samples in
`research/autodesk-sample-projects.tsv` (sha256 `33271010...`,
`6dc833f9...`), quoted as counts of what rvt-rs writes. Nothing in the
tree cites the 2025 file, its Revit 2025 export or the Japanese sample
except RE-333 section 7's sentence that they await a recorded source.
5. **Behind main, RE number.** Rebuilt on main at 182ed21, then a
signed merge of `a4044dc8`; RE-333 is free on main and in the open pull
requests.
6. **Smaller.** The `REFUSED_*` reasons reach the diagnostics
(`topology.remove(&u64::from(id))` is passed whole, with no
`.and_then(Result::ok)`). `!sub` replaces `-sub - 1`
(`native_area_regions.rs:784`, `:836`). `docs/status.md` and
`docs/support-matrix.json` say 2015 to 2027.

## The second review, in code

- **Bounds against a crafted file** (`native_area_regions.rs`): a
circuit is refused before its edges are built once they pass
`MAX_CIRCUIT_SIDES` (10,000), or once its lines' offset parts pass
`MAX_CIRCUIT_OFFSET_PARTS` (20,000); the edges are no longer cloned.
- **`checked_add`** in `chain_entries`; a circuit side whose line has no
`u32` ElementId refuses the Area (`add_line_ids`); `byte_range` includes
the skipped entry bytes (`AreaRecord::skipped`).
- **Two readers, one region.** Where Revit's plan topology and the
lines' arrangement both give a region and they are not the same one (net
area to 1e-6, the same corners within 1e-4 ft, no arc in the
topology's), the Area has no body and says `area_regions_disagree` in
`exported.area_body_refusals` (and in the decisions log). Measured at
`e9124b3a`, before the check: the regions were the same on 16 of 16 and
30 of 30; with the check, not yet measured, so whether it loses an Area
is what the new run says.
- **`dropped` chain records** are counted by ElementId, not by record
and partition, and the warning says an area boundary line among them is
not among the lines an Area is checked against. The Areas of the Snowdon
Towers samples are still written.
- **`BodySource` and `ProfileSource`** of an Area drawn from the
topology are `native_area_plan_topology`, with their own `body_readers`
row and `COVERAGE` row; `schedule_csv` and the plan-profile reader
accept it. This moves `exported.body_sources` (the count of
`partition_area_boundary_lines` splits) and nothing else that is
measured.
- **Tests.** The plan records are read with `NATIVE_RELEASES`.
`area_boundary_lines` and `area_point` are pinned on no gate model: the
office's 30 Areas all take the topology first and no other gate model is
known to draw an Area from its lines, so a regression in
`note_area_sources` would pass until one does (said at `MIN_READERS`).
- **Docs.** RE-333 keeps no per-Area data of the three.js export (counts
only, #1377; the archived commits of #1371 carry the earlier version,
which is already public, and the policy is applied from here on); six
plan-topology reasons, not five; the office's vertex wording is exact (3
outlines start at another vertex and the holes of 6 come in another
order as built; 2 and 6 at permit); every figure says which run measured
it: the counts of what is written come from Measure run 42003913780 on
`bcb02107`, the vertex-level and equality figures from the archived head
`e9124b3a`.

## The third round (the second review of this PR), in code

- **Hole bound** (`native_area_regions.rs`): a hole that a plan lists
again is one hole (`plan()` keeps the first listing of each pair); more
than `MAX_REGION_HOLES` (1,000) is `area_circuit_too_large`; one
`Budget` for sides, edges and offset parts covers the outer loop and
every hole of a region, so duplicates cannot each ask for a full budget.
- **A topology read and failed is not replaced by the lines**
(`partition_area_records.rs`, `locate`): when
`area_circuit_area_differs`, `area_point_outside_circuit`,
`area_arc_not_finite` or `area_circuit_too_large` is the topology's
answer and the lines draw the Area, the Area has no body and says that
reason, counted in `exported.area_body_refusals`. Where the saved area
disagrees with the face the lines give, the rule is fail closed. Where
the topology was not read (`area_not_in_one_plan_topology`,
`area_circuit_not_found`, `area_circuit_side_not_read`) the lines draw
as before. No public model had an Area in the first case in run
42003913780: none of its refusals is one of these but Snowdon
Architectural's single `area_circuit_area_differs`, and that Area was
refused, so the lines did not draw it.
- **`area_regions_disagree`, helpers and tests** (`regions_agree`,
`same_outline`, `near_outline`, `ring_perimeter`,
`point_segment_distance`): the comparison was by corner counts, which a
step jog of a few micrometres changes and a ring over 5,000 corners
refused outright. It is now by distance: every vertex of each outline
within 1e-4 ft of the other's edges, and the area difference within 1e-6
relative plus the band that tolerance allows along the outline. The
failure-first tests (a few, next to the helpers, under the pure-helper
exception) cover a region of another area, a shifted, a sheared and a
curved one, a hole one reader lacks and two holes matched to one, an
outline that is not finite, and then the same region called the same: a
ring turned to start elsewhere, a vertex on a straight edge, a 5e-5 ft
step, a ring of 6,000 vertices, and the same holes in another order.
**Which branch has run on real data:** the agree branch (16 of 16
`rac_advanced` joins and 30 of 30 office Areas at `e9124b3a`, and no
`area_regions_disagree` refusal on any public model in run 42003913780);
the refusal branch has run on no Revit file, only in those tests. A
scheme whose lines all have one offset, where the arrangement could
close at other positions than the topology, is not found in any file
here; if it exists the Area is refused, the fail-closed side.
- **Bounds on the gate's reach and wording**: see above. `arm.sh` should
read "blocks landing by the landing rule".
- **Docs.** No per-Area figure of the three.js export is left in the
tree (RE-333 said "three four-sided Areas of under 83 ft2" and how that
export writes the curved Area; `docs/rooms.md` said "worst 2.0e-7"; now
"all 25 within 1e-6 relative", counts only). `docs/rooms.md` and
`docs/status.md` name `area_regions_disagree`, mark `area_plan_topology`
"not measured" on Revit 2025 to 2027 and the Snowdon samples, say that
it is the Areas' own outline source and not per release (a 2024 Snowdon
Towers Area and an office Area take the same path), no longer say "Areas
as on 2024" beside models that write none, and say that the office no
longer writes `area_boundary`. Snowdon's counts say which head they are
from everywhere. RE-333 section 3 reports the disagree check measured
(it said "not yet measured").

## What the evidence is, exactly

- **Revit's IFC4 export has no export of these Areas.** The
`rac_advanced` check is against the one public export of it, from the
three.js repository: IFC2X3, by a build of Revit 2021's exporter whose
string ends "IU alternativa 21.0.0.383" (publisher not established),
showing the project's 2015 to 2020 state. It is counted apart, never
used to remove a value or to settle a disagreement between exporters,
and its Measure uploads are counts only (`racadv-*`, #1377).
- **It is out of sample for this rule.** The topology's loops, and the
areas Revit saves for them (`PlanCircuit m_area`) that every loop is
checked against, are in the file; nothing was read off the export. That
is the difference from #1367's wall-line rule, whose rule was worked out
from the export it was scored on. On the 2020 save, measured on the
archived head `e9124b3a`: 25 Areas written, 25 in that export, 0 extra,
all within 0.1% in area and 0.01 ft in outline; main's 16 joined Areas
equal their topology loops.
- **Revit 2025 to 2027** are checked against the same project's 2024
save only.
- Per Griffin (2026-11-04): Areas checked against a non-IFC4 or
third-party export may ship labelled; the trust marker
`area_plan_topology` names the rule, and RE-333, the docs and the
changelog name the oracle.

## Testing

Unit tests are banned in this repository: none added. The test that
changes is a real-file one (`tests/value_sources_offsets.rs`).

- [ ] `tools/check-local.sh` passes: not run locally (no local builds on
this checkout); `cargo fmt --all -- --check` and `python3
tools/release/changelog.py check` pass here, CI's clippy, MSRV and doc
jobs and the corpus tests are the gate. No let-chains; every nested
tuple in a collection has a `type` alias.
- [x] Verified end to end on real Revit files, **on `5008247d`, the code
before the `area_plan_topology_unchecked` marker**: Measure run
42017400629 (unfiltered, base main, nordic, r2025, holdout, samples,
racadv). These are the figures of record for that code; the run after
the marker (below) replaces them where it differs:
  - 26 of 117 exports move, the same set as in run 42003913780 (below);
  - `rules:` findings 0 on 90 models and on 18 held-out;
- held-out spaces move on one model only, from (0 in both, 0 only in
rvt-rs's, 8 only in Revit's) to (6, 0, 2);
- the racadv pairs 2015 to 2020: 116 in both files, 0 only in rvt-rs's,
0 only in Revit's;
  - MCP: 0 differ on 629 lines;
- refusals: `next_storey_not_proven` 9, `area_circuit_area_differs` 1,
`point_not_read` 4, and no `area_regions_disagree` and no
`area_circuit_too_large`;
- the gate passes on the `2024 2099` shard, 25 Areas and 25 with a body
on each of the 4 saves, every field equal, and says `skipped` on the
`2008 2023` shard;
- the semantic merge check (#1334) reads a pass, with 5 findings for
#1428.
Earlier, on `bcb02107`: Measure run 42003913780 and timing run
42003917325: 25 public exports move and one held out; bodies
`native_area_plan_topology` 30 on each office, 25 on each `rac_advanced`
save above, 96 on Snowdon Towers Architectural and 2 on Structural; time
over main's at most 1.05 (`rst_basic` 2026), peak memory at most 1.03
(`rme_advanced` 2027, 559 to 573 MiB), and the lost `samples-2008-2023`
job of run 41990405944 did not recur. The vertex-level and equality
figures in RE-333 section 8 are from the archived head `e9124b3a` and
were not re-read.
The check on the earlier pushed head `401f5244`: run 42010805118, green,
with the scorer that compared the storey as `None`; its `ifc.sha256`
equal to run 42003913780's on 58 of 58.
**The final unfiltered run on this head `7188e2e8`: 42023345111** (`-f
base=main -f nordic=true -f r2025=true -f holdout=true -f samples=true
-f racadv=true`), unread when this body is written. Expected, against
run 42017400629: only the exports of `rac_advanced` 2025, 2026 and 2027
move (their Areas read `area_plan_topology_unchecked`), the gate passes
on the new expectation, nothing else changes. No timing run: what
changed since the timing run bounds crafted input, compares two regions
by distance (quadratic in one ring's vertices, tens on the files
measured) and sets a marker.
- [ ] If this touches the IFC exporter: the witness verdicts replay or
the changed observations are refreshed. Core Interior has no Areas, so
its export is expected to be unchanged; the replay is CI's.
- [ ] If this is a performance change: N/A.

**Final unfiltered Measure on the code of this head, run 42023345111
(7188e2e; the later commit is the MCP contract sync), read by the
maintainer:** against 42017400629's head exactly 3 exports move,
`rac_advanced` 2025, 2026 and 2027, by the new marker. Against main 91
of 117 are identical and 26 move, the same set as before, 1 of them held
out. The same-project gate passes on the expected values: 25 Areas with
25 bodies on each of the 4 saves, every field equal,
`area_plan_topology` on 2024 and `area_plan_topology_unchecked` on 2025
to 2027. `rules:` findings 0 on 90 models and 18 held-out, MCP 0 differ
on 629 lines, semantic check `pass: 5 findings in 34 models`.

## Audit-honesty checklist

- [x] Docs reflect the state after this PR.
- [x] A user-visible change has its fragment under `changelog.d/added/`,
not in `CHANGELOG.md`.
- [x] Limitations: the RE-333 report's "not measured" list is kept
(Revit 2026 and 2027 against a Revit export, the Snowdon Towers 2025
file, a scheme with more than one plan on a Level, an Area Revit reports
as not enclosed, the straight step where two offset curves do not cross,
Revit 2008 to 2014).
- [x] Commit messages describe what changed and why.
- [x] No emojis, no private paths in committed files.
- [x] Reverse-engineering finding:
`probes/examples/probe_re333_area_plan_topology.rs`,
`reports/element-framing/RE-333-area-plan-topology.md` and an addendum
in `docs/format-reconnaissance.md`.

## Legal and contribution hygiene

The declaration is puzzbobb's on #1371, quoted here, and the
maintainer's commits are Apache-2.0 as the rest of the repository:

> - [x] I agree this work is licensable under Apache-2.0 (see
`CONTRIBUTING.md`)
> - [x] This PR contains no Autodesk proprietary source, decompiled
internals, or NDA'd SDK content (see `CLEANROOM.md`)
> - [x] Any new test fixtures use synthetic values (`testuser`,
`111111`, `FY-20XX`, etc.) and contain no real-world PII
>
> The class and field names come from the schema each file embeds
(`Formats/Latest`), as `rvt-schema` prints them. Autodesk's samples are
fetched for the run and never stored. The office is CC BY-SA 4.0, read
by byte range and never stored.

(The last sentence of that declaration on #1371 about a local Revit 2025
export of Snowdon Towers is not repeated: those figures are out of this
pull request.)

## Breaking changes

None. `native_area_regions` is a new public module and `AreaRegion` a
new public type. Areas of Revit 2025 to 2027 files are new `IfcSpace`,
and an Area that main draws from its lines now says `area_plan_topology`
where the topology is read.

## Output samples

`SpaceOutlineSource` on `rac_advanced` (the archived head `e9124b3a`,
run 41894715743): the 6 Areas main marks `area_boundary` and the 10 it
marks `area_boundary_joined` say `area_plan_topology`, as do the 9 it
did not write.

## Related issues

Refs #1261, Refs #1194, Refs #763. Reopens #1371. Supersedes the
wall-line rule of #1367.

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

---------

Co-authored-by: puzzbobb <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants