Repository navigation
feat(ifc): the provenance of every decoded element, down to the byte (#1325) - #1350
Merged
Merged
Conversation
…1325) The export diagnostics gain decoded.element_provenance, keyed by ElementId: the carrier of the element's record, its stream and byte offset in the inflated stream (rvt-dump's Partitions_NN.decomp), where its ElementId is stored, its class tag and the class that names in the file's schema, its BuiltInCategory and its native record with the current copy where several partitions hold one. Built from the memoised walk, the inflated partitions and the native record index; never written into the IFC. rvt-rs-mcp returns the fields in every element's provenance. tests/element_provenance_offsets.rs re-reads every reported offset on Core Interior, the RE1 models and the BIM4LCA office.
The table made the diagnostics 140 times larger on the BIM4LCA office as built (52,677 to 7,370,747 bytes, Measure run 41831418684) and built it on every export. ExportOptions::with_element_provenance(bool), default off, builds it after the exporter only when set; decoded.element_provenance is an Option skipped when absent, so the diagnostics are the bytes they were. rvt-ifc --element-provenance (with --diagnostics) and Python's export_diagnostics(element_provenance=True) ask for it; the MCP server asks for it when it opens a model, keeps it beside the model and does not return it in get_diagnostics. The offsets test runs with the switch on, checks the plain export has no table and prints the table's build and JSON times and bytes.
DrunkOnJava
marked this pull request as ready for review
November 4, 2026 13:10
2 tasks done
…veat and what is unmeasured (#1325) Documents the Revit 2008 to 2023 newest-frame rule beside the 2024 extent rule, that offset is the selected frame and not necessarily the copy a body came from, that Einhoven confirmed 13 of 13 frames and 71 of 71 native records while 2008 to 2022 and 2023's second prologue are unmeasured, that the schema-walk carrier has no element on any test model, and the compact-JSON size (4,462,401 bytes against 38,640). Entries that cannot be read again lose their stream and offset, the class tag lookup keeps the last class of a name as the walk does, the native counts are documented as covering every element, and an element past the table's cap says so in the MCP provenance, with omitted_entries on the file. The second-prologue check reads the record header's size and constant itself, the diagnostics schema is validated against rvt-ifc --element-provenance output, and rvt_to_ifc_diagnostics takes element_provenance.
DrunkOnJava
enabled auto-merge (squash)
November 4, 2026 13:33
DrunkOnJava
added a commit
that referenced
this pull request
Nov 4, 2026
…n number, not stream name, on Revit 2024 and later (#1356) ## Summary `RevitFile::partition_stream_names` sorted the `Partitions/NN` streams as text. Text order puts `Partitions/9` after `Partitions/46`, and `Partitions/189` before it. Every reader that keeps the first or last copy of an element framed in several partitions inherits that order. So when the partition numbers had different digit counts, a reader could keep the wrong copy. Three copy pickers on Revit 2024 and later also compared stream names as text themselves. ## Changes - **At the source:** - `partition_stream_names` sorts by partition number, then name. - `partition_stream_name` returns the lowest-numbered stream. - **Copy pickers:** `PartitionElementRecord::frame_order()` (partition number, then name, then offset) replaces the text comparison in: - `select_instance_records`' newest-frame tie-break; - the first copy of a sketch line; - the first copy of a roof's sketch line. - **Readers fixed through the sort:** every first-copy reader of `scan_category_records_multi`, such as `attach_shaft_voids`. - **One parser:** the number parser is `partition_room_parameters::partition_number`, shared, with a few failure-first tests of that pure helper (Griffin's 2026-11-04 exception): number order, names without a number, and overflow. - **Wording:** - stale `(stream, offset)` comments are corrected; - #1350's provenance docs and MCP contract now say a tie goes to the higher-numbered partition; - a changelog fragment is under `fixed/`. Found by #1350's second read, which also traced the root cause. ## Testing - **Measure 41838182217** (the three call-site fixes) and **Measure 41839840717** (the source sort, head baa618b). Both ran every model against `main`: `-f nordic=true -f r2025=true -f samples=true -f holdout=true -f families=true -f scorers=none`. - 111 of 111 exports are byte for byte `main`'s, and so are the 93 diagnostics files with both sides present. - No export moves on any Measure model, so the fix is unmeasured on a file where it changes the copy kept. - The commits after baa618b change only wording. - The pure helper's tests run in CI's `cargo test --profile ci --lib`. ## Audit-honesty checklist - [x] No emojis, private paths or internal jargon. ## Legal and contribution hygiene - [x] Apache-2.0; no Autodesk proprietary source, decompiled internals or NDA'd SDK content. ## Breaking changes None in signatures. `RevitFile::partition_stream_names` returns the same names in partition-number order, and `partition_stream_name` the lowest-numbered. ## Related issues Refs #1325.
This was referenced Nov 4, 2026
DrunkOnJava
added a commit
that referenced
this pull request
Nov 4, 2026
…drawn to their joins, and a line off the axes refuses only the Areas it touches (#1261) (RE-330) (#1351) ## Summary An Area of a Revit 2015 to 2024 file is now drawn from its area boundary lines joined as their records say, and a line that is not along a plan axis refuses only the Areas whose region it touches, not every Area of its scheme on its Level. Autodesk's `rac_advanced`: 16 of its 25 Areas are drawn on every save but 2021's (3 before), 10 of them `area_boundary_joined` and 6 `area_boundary` (measured on every save, run 41840118424). **What the check rests on** (Griffin's "ship, labelled"): - the only external check is **an IFC2X3 export from the three.js repository, by a build of Revit 2021's exporter whose string ends "IU alternativa 21.0.0.383" (publisher not established), showing the 2015 to 2020 state**; the 2020 save's 16 drawn Areas are within 0.1% in area and 0.01 ft in outline of it, none is written that it lacks; - **that agreement is in-sample**: the joins were read off this same export, and that a reference list means a join is inferred from the fit; - the 2022 and 2023 saves are also checked against the 2024 save's reader (the pair probe, run 41840127226), which is an agreement between two readings, not an external check; - **no Revit IFC4 export of these Areas exists**; - that export is never used to remove a value or to settle a disagreement between exporters; - BIM Whale is byte-identical to `main` because it draws no Area body (RE-324 §7, §8), so its 0 extras are **vacuous for the joins**. The file's terms are **not known**: the repository is MIT, the file carries no licence of its own that could be found, and Autodesk's terms for the sample it exports were not checked. No workflow fetches it; it is scored by hand from a pinned URL (RE-330 §1, §8). **The 2024 save moves too.** 13 of its Areas are new, numbers 9 and 11 to 22: they gain a body (3 before, 16 now; RE-317's reader drew 23, 24 and 25, still `area_boundary`), and the other 9 keep their refusal. The same 13 are new `IfcSpace` on the 2015 to 2020, 2022 and 2023 saves (94 to 107). `SpaceOutlineSource` is `area_boundary_joined` for 9, 12, 14, 16, 17, 18, 19, 20, 21 and 22 and `area_boundary` for 11, 13 and 15 (the Python version of the rule; the kept IFC of run 41840118424 has the same split on each save). Their evidence: the pair probe, where the 2022 and 2023 saves equal the 2024 save, and the IFC2X3 export of the 2015 to 2020 state; nothing else. ## Motivation #1261: "Areas bounded partly by walls" and "boundary lines that are not along the plan axes". RE-330 shows that the 4 Areas called bounded partly by walls are bounded by lines alone: the lines stop short of the lines they join, and the export carries them on. No wall bounds any Area drawn. Of the four lines whose box is not a line along an axis, one is a straight line off the axes (178310, Areas 7 and 8), two are axis lines whose record box is 0.497 ft wider than the line (177377 and 177363, Areas 1 to 5) and one is an arc (178788, Area 10); Area 6 has a join its records do not name. Reading Areas bounded by those is the next step, and the probe holds their stored ends. ## Changes - `src/research/partition_area_boundaries.rs`: `Arrangement::new` takes each line's named ElementIds. A free end is carried on to the farthest perpendicular line within 1 ft that names it and is named by it, **only if that line, after its own carry, spans the place reached** (else the end stays free); the free ends of two parallel lines within 1 ft that name each other, stop at the same place and run away on opposite sides are joined by a connector, a flag on the segment rather than the id `u32::MAX`. `AreaFace.joined`, `Arrangement::reads`. The stored ends of a line are nodes, so an edge lies wholly on the stored extent or wholly past it. - `src/research/partition_area_records.rs`: a line off the axes is left out of the group's arrangement with its box (and the readable lines that name it); an Area whose region's box comes within `UNREAD_MARGIN_FEET` of such a box is refused `boundary_lines_not_readable`. `LineRecord` equality includes the reference list. `m_area_body_joined`. - `src/ifc/export_content.rs`: `SPACE_OUTLINE_AREA_BOUNDARY_JOINED`; `contain_in_spaces` leaves both out of the spaces that hold furniture. - `rvt-mcp/src/schema.rs`, `server.rs`, `docs/mcp-tools.json`, `docs/mcp-tools.md` (regenerated by `tools/ci/render-mcp-tools.py` after the merge with #1350), `docs/mcp.md`: the `space_outline_source` descriptions name the new value. - `probes/examples/probe_re330_area_line_curves.rs`, `tools/re/area_joins_vs_ifc.py` (the same rule and caps in Python), `tools/re/space_profiles_vs_ifc.py` (the new value counts as an Area), `reports/element-framing/RE-330-area-joins.md`, `docs/rooms.md`, `docs/status.md`, `docs/evidence.md`, `docs/supported-profile.md`, `docs/export-diagnostics.md`, `docs/support-matrix.json`, `changelog.d/changed/1261-area-joins.md`. - The scorer fix for millimetre exports is #1353 (merged). ## Testing Unit tests are banned in this repository: none added. - [ ] `tools/check-local.sh` passes (CI is the build here; fmt is checked, the Rust has not been compiled locally) - [ ] Verified end to end on real Revit files: see RE-330 sections 4 and 7 - [ ] The witness verdicts replay: the office's IFC must stay byte for byte `main`'s Runs (Measure, `--ref main`, filtered). At `35a9d322` and `cf8d807d`: read in RE-330 §4 and §7. At `dc56e83b` (the stored ends as nodes), all green, read: every `rac_advanced` save of 2015 to 2020 and 2022 to 2024 has 10 `area_boundary_joined` and 6 `area_boundary` (41840118424), the 2021 save none; office 41840110952 and BIM Whale 41840122975 byte for byte `main`'s; of 43 samples (41840114594) only those nine saves move; the pair probe 41840127226. At `a883a238` (the carry checks its target, caps of 1 ft, connectors on opposite sides, the label, the wording of RE-330 §5), **not yet read**: office 41843487977; samples against `main` 41843493504; all samples 2015 to 2024 with the IFC kept 41843497745; BIM Whale 41843502531. They are to show the same 16 per save (10 and 6), the office and BIM Whale unchanged, and the same nine saves moving. ## Audit-honesty checklist - [x] Docs, support matrix, changelog fragment and report say what the check rests on, that it is in-sample, and that no Revit IFC4 export of these Areas exists - [x] A user-visible change has its fragment under `changelog.d/changed/` - [x] Known limitations documented: 9 Areas of `rac_advanced` are not written (RE-330 §5); the 2021 save is still refused; the export's licence is unknown; farthest-over-nearest, the opposite-sides condition and the caps are unmeasured where they would decide - [x] No emojis, no private paths ## Legal and contribution hygiene - [x] Apache-2.0; no Autodesk source or SDK content: the check is a public output of Autodesk's sample project (three.js at commit 7c1f4773, sha256 pinned in RE-330 §8), fetched by hand and never stored in the repository; `revit-ifc` is read for what it writes only (CLEANROOM.md source 5), not copied. ## Breaking changes None. `Arrangement::new` gains a parameter and `AreaFace` a field (research API, `unstable-research`).
DrunkOnJava
added a commit
that referenced
this pull request
Nov 4, 2026
… entry per element (#1326) (#1358) ## Summary Each fail-closed decision the exporter makes about an element is recorded, on request, as an entry with the ElementId, a stage, a reason code and the stream and byte offset its record was read from where known. The diagnostics' `skipped` section is now counted from the same decisions and is unchanged. `rvt-rs-mcp` gains `explain_element(model, element)`: the element's provenance, its trust markers and every decision recorded for it. ## Motivation Closes #1326 (milestone 0.15.0). `SkippedExportItem` counts what was left out by reason and class, with sample names; it cannot answer "why does this door have no opening?" or "why is this room a box?". Builds on #1325's provenance table. ## Changes - `src/ifc/export_decisions.rs` (new): `ExportDecision` (`stage`, `reason`, `element_id`, `class`, `stream`, `offset`, `detail`), `DecisionStage` and `ExportDecisionLog`, capped at 5,000 entries a reason, sorted by reason and ElementId, with `total`, `recorded` and `dropped` per reason and in all. - Each scan behind a `skipped` item now returns its elements rather than counts: `scan_unattributed_frames`, `scan_volumeless_instances`, `scan_non_primary_option_instances`, `scan_phase_excluded_instances`, `scan_empty_curtain_panels`, the Areas left unwritten and the family spaces left out for want of a body (`RevitFile` keeps them as lists), the elements below the confidence floor and the schema-scan candidates. `build_export_diagnostics_and_decisions` makes each `SkippedExportItem` from those decisions, in the order and with the classes, phases and sample names it had; the geometry gaps are made in the same pass as their decisions. `ExportResult::decisions` carries the uncapped list (not serialised). - The decisions behind `exported.bounding_box_bodies`, `bounding_box_spaces` and `area_body_refusals` are read from the final model (`body_is_record_box`, `space_outline_is_record_box`, `area_body_refused`). - **One switch or two: two.** `ExportOptions::with_export_decisions(bool)` (last field, default off; `rvt-ifc --export-decisions`, requires `--diagnostics`; Python `export_decisions=` on `export_diagnostics`, `export_diagnostics_json` and `rvt_to_ifc_diagnostics`) is separate from `with_element_provenance`. The log is bounded at 5,000 entries a reason whatever the model, where the provenance table lists every element (about 116 times the diagnostics in compact JSON on the BIM4LCA office); and it needs no table in the sidecar: where an entry's evidence is an element the walk decoded, its stream and offset come from a table built for the purpose and dropped. Someone asking why an element was left out should not pay for the table, and someone checking offsets should not get the log. The MCP server and the tests turn both on. Without either switch the diagnostics have no new key. - Stages: `element_skipped`, `body_not_drawn`, `body_left_as_box`, `opening_not_cut`, `outline_not_read`, `storey_not_bound` (the geometry gaps need the last two) and `value_left_out_exporters_disagree`. - `rvt-mcp`: the decode asks for the log; `Computed` takes it out of the diagnostics beside the provenance table. New tool `explain_element` (`model`, `element`: a Revit ElementId whether or not the export holds the element, or an exported element's GlobalId; `id` is accepted as the name `get_element` uses) returns `exported`, the provenance and trust markers where it is exported, `decisions`, and `capped_reasons`. `docs/mcp.md`, `docs/mcp-tools.json` and `docs/mcp-tools.md` follow. - `docs/export-diagnostics.md`, `docs/schemas/export-diagnostics.schema.json`, `docs/python.md`, the stub, `docs/user-guide.md` and the changelog fragment follow. - `tests/export_decisions_counts.rs` (class `real`) and `tests/json_schema_contracts.rs` (the diagnostics schema against `rvt-ifc --export-decisions` output, and no key without it); CI's Corpus health prints the first's report and uploads it as `export-decisions`. ## Testing Nothing was built or run locally (lane rule: CI and Measure are the build). Everything that needs a build is NOT MEASURED until the runs on this PR's head finish. - [ ] `tools/check-local.sh`: `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. - [ ] Done when, on Core Interior and the office: `tests/export_decisions_counts.rs` exports each model with the log off, then on, and checks that the diagnostics are the same JSON but for the log; that for every reason of `skipped` the log's `total` is the sum of the items' counts, `recorded` plus `dropped` is `total`, and, for a reason that dropped none, the entries by class (by detail for an Area, by phase for a room) are the item's `classes`; that `body_is_record_box`, `space_outline_is_record_box` and `area_body_refused` equal `exported.bounding_box_bodies`, `bounding_box_spaces` and `area_body_refusals`; that the log has no reason in neither; that on Revit 2024 and later the bytes at a frame entry's stream and offset are the record it says (no id for a frame with none; the id, or a second-prologue frame, for an element); and that an entry the log placed from the provenance table agrees with the table. Its report (counts per reason, dropped, the log's size in JSON) is the `export-decisions` artifact. The same models also run the RE1 models and Einhoven. Core Interior has nothing left out (`skipped` empty, box bodies, box rooms and Area refusals 0 in the Measure run on this head), so its log is empty and equal to that; each other model names reasons its diagnostics count (measured), and each must have entries, so an empty log cannot pass. - [ ] `explain_element` through the MCP E2E (`rvt-mcp/tests/mcp_stdio.rs`): an exported element's answer equals `get_element`'s provenance, trust markers and file; an unknown id is a tool error; a decision the same decode records, found by running the export in the test with the log on, is in the answer; `get_diagnostics` carries neither the log nor the table; the tool list has ten tools. - [ ] Byte-identity with the log and the table off: see below. Measure: the diagnostics must be byte-identical to main's and so must the IFC. A filtered run (`-f base=main -f nordic=true -f r2025=true -f samples=true -f holdout=true -f families=true -f scorers=none`) is dispatched on the head; `diagnostics.json` of each non-held-out model is in its `measure-head` and `measure-base` artifacts, to compare with `cmp` (the compare job hashes only `ifc.sha256`; editing measure.yml would start an unfiltered Measure on this PR). A filtered timing run (switch off, head against main) is dispatched too, since every export now builds its decisions as lists where it counted: a few allocations per element left out, NOT MEASURED. Code head f5895c8, PR head ab39e6a (on top: `--anonymize` scrubs the log, the log sorts by partition number, `rvt-ifc` help text, tests, docs and the MCP contract text, and a merge of main's #1351; none of the src changes runs with the switch off, so these runs measure the PR head's switch-off path too) (the runs at 360e8e6, 41844130797 and 41844135457, stopped at a lib build error and measured nothing): byte-identity run 41846513208; timing run 41846517960 (`-f timing=true -f nordic=true -f models="core-interior nordic-office-as-built" -f scorers=none`). Results NOT MEASURED until they finish. ## Audit-honesty checklist - [x] README / docs reflect the current state after this PR - [x] Changelog fragment `changelog.d/added/1326-export-decisions.md` - [x] Limitations documented in the PR body and in code (below) - [x] No emojis, no private paths in committed files - [ ] Reverse-engineering finding: N/A Limitations, stated: - `value_left_out_exporters_disagree` records nothing. Those values are left out by a rule for a whole class of element in the reader that would write them (the type `IsExternal`, a type's common set where two elements disagree, a property outside IFC4's sets); no step decides it per element and no aggregate counts it. The stage exists so a reader that starts counting has somewhere to put it. - `stream_not_read_resource_limit` counts streams, not elements, and has no entries. A frame with no ElementId (`element_record_without_element_id`) has an entry with its place and no ElementId, so `explain_element` cannot return it. - Beyond 5,000 entries a reason the log drops entries (counted per reason and in all); `explain_element` names those reasons in `capped_reasons`. Entries are kept by ElementId, so the highest ids go first. - An entry about an element the walk decoded takes its stream and offset from the provenance table, which is the frame the exporter selected (see #1350's limits); a frame scan's own entries carry the frame they read, and on Revit 2008 to 2023 the bytes are not re-read by the test. - `docs/mcp-tools.json` was edited by hand for the new tool and the types it adds (the server's `tools/list` is the contract and `tool_contract_is_committed` compares it byte for byte): if that test fails, the failed job uploads the server's own file as the `mcp-tools` artifact, to commit with `python3 tools/ci/render-mcp-tools.py`. - `docs/mcp.md` states no size or time for the log; the test prints them. ## Breaking changes None. New pub items are additive: `rvt::ifc::export_decisions`, `ExportOptions::with_export_decisions` (one new field on the `#[non_exhaustive]` struct, last), `ExportResult::decisions` (`#[non_exhaustive]`), `ExportDiagnostics::export_decisions` (`#[non_exhaustive]`, optional, skipped when absent), a defaulted keyword on three Python callables. The research scans named above return lists instead of counts; they are behind `unstable-research` and their one caller is the diagnostics builder. ## Screenshots or output samples N/A: the IFC and the default diagnostics are unchanged by construction; the byte-identity run is the check. ## Related issues Closes #1326
Merged
4 of 9 tasks
DrunkOnJava
added a commit
that referenced
this pull request
Nov 4, 2026
…enance table (#1360) (#1364) ## Summary The provenance table (`--element-provenance`) now lists, for each element, the copy each body reader took a value from, where that is not the frame the entry's `offset` names: the reader, the rule that chose the copy (`selected`, `agreeing`, `current`, `native`), how many partitions held a copy, the copy's stream and offset, and whether it is in another partition than the frame. The table counts, by reader, the elements whose source is in another partition than their frame. The IFC and the default diagnostics are not changed. ## Motivation Closes #1360 (milestone 0.15.0). #1325 gives each element one byte location, the frame the exporter selected; on Core Interior 171 of 360 walls carry two frames that disagree, and the readers that draw a body, profile or outline often take their data from another copy. #1350 stated that as a caveat. This replaces the caveat with the recorded source. The readers that record no source yet (`NotYet` in `tests/value_sources_offsets.rs`) are the follow-up #1368. ## Changes - `src/ifc/element_provenance.rs`: `CopyRule`, `ValueSource`, `ValueSourceCount`, `ElementProvenanceEntry::value_sources`, `ElementProvenanceTable::value_source_counts`, and `attach_value_sources`, which runs once the model is final and joins what the readers noted with the final model's `BodySource` (`body_readers`: a source is listed only where the body is drawn from that reader, so a line read for a wall drawn as its box is not claimed). - `src/reader.rs`: the readers note on the handle (`note_value_source`), the pattern `unwritten_areas` and `bodiless_family_spaces` use, and only while `record_value_sources` is on. The pipeline turns it on only for `options.element_provenance`, so the default export does no extra work. Turning it on drops the memoised walk (a walk made without notes has none); `reset_export_notes` clears the notes with the others. - Readers that note the copy where they choose it, no re-scan: - `partition_beam_axes::scan_first_records` (a wall's or beam's location line and arc, `Agreeing`; the sketch curves, circles, lines and splines, `Current`): `collect_copies` now also gives each copy's element-data header offset, and the one choice point notes the copy taken. - `partition_instance_transforms::scan_instance_transforms` (`agreeing` or `current`). - `native_document::extract_records`, behind a new `Options::value_source`: the partition and offset of each selected current record, noted as `native`. Set for saved graphics (`saved_meshes`), stair runs (`run_graphs`) and landings (`native_landings_and_type_names`, `native_tread_landings`). - The frame itself, rule `selected`, for `partition_element_record_bbox`, `..._join_trimmed`, `..._join_cut` and `partition_element_record_column_cut`: reader `selected_frame`. Where the body is the box but its profile is read from another record (a floor's sketch lines, a column's type section: `ProfileResolved` with a `ProfileSource` other than the `BodySource`), the reader is `selected_frame_box`: the frame for the box and the placement only, and the profile's copy has no source yet. - `copies` is the number of partitions whose data named the element (the `holders`); for `agreeing`, `partitions` lists them, and `differs_from_frame` is false when the frame's partition holds one (Core Interior's 9 walls differed only because the rule names the lowest-numbered partition). - The offsets maps are built only while the handle records. - Not noted yet, so the element has no value source (which is not a claim that it read the frame): `partition_area_boundary_lines`, `family_type_hollow_section`, `family_type_i_section`, `partition_pipe_axis`, `partition_roof_slope`, `partition_roof_extrusion`, `family_extrusions`, `partition_stair_run_sketch`, `partition_landing_slab` (its outline is the landing lines; the native record gives top and thickness only), and values other than the body's line, transform and native records (a wall's layers, a floor's sketch curves, a roof's slopes). - MCP: `ElementProvenance` gains `value_sources`; `get_element` and `explain_element` fill it, `list_elements` and `list_rooms` do not. **An MCP tool's output 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 "Value sources" section with the BodySource to reader to rule table), `docs/mcp.md`, `docs/schemas/export-diagnostics.schema.json` (`value_sources`, `value_source_counts`) and the changelog fragment replace the caveat. - `tests/value_sources_offsets.rs` (class `real`, registered in `integration/main.rs` and `test-targets.txt`); CI's Corpus health prints its report and uploads it as `value-sources`. `tests/element_provenance_offsets.rs` compares the pipeline's table to `build`'s with the value sources cleared. ## Testing Nothing was built or run locally (lane rule: CI and Measure are the build). Everything that needs a build is NOT MEASURED until the runs on this PR's head finish. - [ ] `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. - [ ] Done when, on Core Interior and the office: `tests/value_sources_offsets.rs` looks up every element's `BodySource` in a table (`COVERAGE`) that names the reader and rule it must have a value source from, or says no reader notes its copy yet (`NotYet`); a `BodySource` that is in neither fails the test. It reads the bytes at each recorded offset: for the element-data readers the header, then the element's id, then a record that decodes to the value the reader returns when asked again; for a native record the ElementId at the offset. It checks `differs_from_frame` against the streams and `value_source_counts` against its own count, and requires each model's `MIN_READERS` to have sources. - [ ] An element whose frame and value source differ is counted by reader: `value_source_counts` (printed per model in the `value-sources` artifact). - [ ] Byte-identity with the table off and on: see below. Measure: filtered on `core-interior` and `nordic-office-as-built`, `-f base=main`, once plain and once with `-f ifc_flags=--element-provenance`; the IFC hash must equal main's in both, and the plain run's diagnostics must too. Final head ef2a2a2: plain run 41866940082; `--element-provenance` run 41866944978 (the earlier pair, 41860801237 and 41860806523 at fa36d88, finished: IFC hash equal on and off for both models, the plain diagnostics equal to the flag-on diagnostics without the table; the figures in the docs come from the second). The final pair is NOT MEASURED until it finishes. ## Audit-honesty checklist - [x] README / docs reflect the current state after this PR - [x] Changelog fragment `changelog.d/added/1360-value-sources.md` - [x] Limitations documented in the PR body and in code (below) - [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. `agreeing` copies are equal by construction; `current` is `native_document::current_partitions` (RE-216), which this does not measure. The test shows that the bytes at the recorded copy decode to the value the reader used, not that the reader chose well. - `MIN_READERS` requires `saved_graphics` on every project model; the default export's saved-mesh scope is doors and windows, so a model with neither would fail it. Core Interior, RE1 and Einhoven have them. - `selected_frame` for a trimmed or cut body names the element's own frame, and the test does not read the frame's bytes again (the #1325 test does); the joined elements' frames it also reads are not named. - No CI model exercises the `current` rule or `bounded_arc`: on Core Interior and the office every `agreeing` copy set agrees (9 walls on Core Interior; 393 lines and 326 transforms on the office), so the `Current` branches of `scan_first_records` and `scan_instance_transforms` and the arc reader have run on no corpus file. The test checks them only through the readers' own re-reads. - The office has 11,586 entities with a `partition_element_record_bbox` or `..._join_trimmed` body against 11,539 `selected_frame` sources (Measure run 41860806523). The test now prints how many entities share an ElementId with another (the pieces of a floor), and how many elements are not in the table; the 47 are not yet attributed. - The sketch readers (`sketch_curve`, `sketch_circle`, `sketch_line`, `sketch_spline`) are noted by sketch-line id, not by the sketched floor, roof or stair that uses them, so they are not listed for any element yet. Attributing them needs the owner map each caller already holds. - Revit 2008 to 2023 element-data layouts: the notes are made on every release the scans support, but the test re-reads only what the corpus has (Core Interior, the RE1 models, Einhoven (2023, native records), the office).
2 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Nov 5, 2026
…dumps and Jev scores the diff (#1334) (#1419) ## Summary The advisory semantic merge check of #1334. Measure diffs the two sides' MCP dumps for each openly licensed model, and a `workflow_run` workflow gives the diff to Jev `jev-1.13.0` beside the pull request's own `## Summary` and `## Testing` and asks whether the export moves in a way they do not state specifically (Griffin, 2026-11-05: a described, intended change passes, an unexplained move fails; the main session, 2026-11-05: a move that only a general description such as "improves how walls are exported" covers fails too). The verdict is the check run `semantic diff (advisory)` on the commit Measure measured: not in the ruleset, no pull request comment, and a `fail` is a red check. Only a Measure run of every open model with a base on main writes it, it is written on the commit Measure measured and no other, and it cannot be a pass unless all 34 open models are compared in full and a same-repository pull request has that commit as its head. ## Motivation Measure is the byte-level oracle. A pull request that moves meaning should say so, specifically, before it is armed, not only show that bytes moved. The agent that makes a change also writes its Summary, so a sweeping Summary must not cover a change. Refs #1334. ## Changes - `tools/re/semantic_diff.py`: a pure function of two dumps. Elements added, removed and changed with the value before and after; byte offsets inside `provenance` dropped; order ignored; values compared to the dump's six decimals; an empty object or list the same as no field; identical changes collapsed by the whole (path, before, after) triple. Its `measure` mode is what the compare job runs: it fails the job on a dump in a model that is restricted or on neither list, and records in the manifest the open models no diff covers (`OPEN_MODEL_NAMES`, 34), each skipped model with its own reason, the groups dropped for size, and whether the run was asked for every open model (`--requested-all`). The measured commit and the base are the ones the compare job passes from the plan job's resolved refs (`--head-sha`, `--base-sha`); the `commit.txt` of a result folder is written by a shard job that runs the measured code and is read only when none is passed. - `tools/re/test_semantic_diff.py` and `tools/ci/test_jev_check.py`: failure-first tests of pure helpers, run in the PII guard job. The diff: 0.35 vs 0.3500001, a reorder with moved offsets, a bulk collapse that hides a different value, an uncovered model. The verdict logic: a model with no dump, a diff that failed, a dropped group, an unscored chunk or partial coverage never reads as a pass; an answer whose probabilities do not add up is refused; a chunk of non-ASCII text is never sent over the 16,000-character cap; a head commit that is not a 40-character SHA, a manifest with a non-string model, HTML and invisible characters in the pull request's text, and control characters in printed text. Each was checked to fail under the mutation it guards against. - `.github/workflows/measure.yml`: the compare job checks out the script, runs `measure` when there is a base, tells it whether the run was dispatched with no `models` filter and the office and Revit 2025 models on, and uploads `semantic-diff`. The documented command is `-f base=main -f nordic=true -f r2025=true` with no `models` filter. - `tools/ci/jev_check.py`: merges findings across models, chunks them (at most 8 findings, 16,000 characters as sent), reads the same-repository pull request whose head is the measured commit through the API, takes its `## Summary` and `## Testing` (HTML element tags and invisible characters removed, each cut at 2,500 characters as sent, all of it shown in the check's summary; text in angle brackets that is not an HTML element, such as `<set>.<property>`, stays), and asks Jev blind (labels A and B randomised per chunk; no model name, pull request number, title or branch in the state). Per finding Jev chooses: stated specifically / follows from a specific change they state / covered only by a general description / unstated / only rounding, a reordering or a spelling; "general" plus "unstated" is the finding's score, and the probabilities must add up to 1. A finding at 0.85 or more is a fail in a chunk rated 1.5 or more and a warn in one rated 1.0 or more. NOT MEASURED, never a pass, for no key, no same-repository pull request whose head is the measured commit (a fork's included, and an empty diff does not excuse it: the lookup is first), a check asked for on a commit other than the measured one (both commits in the title), a base that is missing or could not be checked, a pull request with no `## Summary` where the diff has findings, HTTP 402, a refused key, another model's reply, a time-out, an error (named by its type), no model compared, any open model not compared in full, a dropped group or a missing count, sampled property sets that one of a model's dumps alone holds too often (none held by both while either holds any, or more than a tenth of them), or an unscored chunk. A run whose base is not main or an ancestor of main writes no check, and names the base. The Jev call does not follow a redirect. An empty diff passes without a call and needs no Summary, but only on a complete run. - `.github/workflows/semantic-check.yml`: `workflow_run` on Measure (environment `jev`, main only), `workflow_dispatch` with a run id, and a keyless run on a pull request that changes the check. It scores only a Measure run whose event is `workflow_dispatch` and whose head repository is this repository, from `measure.yml` at that path; any other run posts nothing, with a notice. It writes the check on the commit the artifact names as measured, not on a pull request's live head. actionlint reports nothing on it and zizmor 1.32.0 reports nothing on it, `measure.yml` and `ci.yml` (the one `dangerous-triggers` finding, on `workflow_run`, is ignored inline with its reason). - `docs/maintaining.md` (where to find the verdict: it is on the measured commit, not necessarily the head, which the pull request page does not show, so look it up with `gh api repos/<repo>/commits/<sha>/check-runs?check_name=...`; a later commit does not clear a fail, only a new score of the same pull request does; a filtered Measure run writes no verdict, so a pull request that changes output needs its final unfiltered run; the Summary must state each change specifically: which classes, which property or geometry, how many where measured; a fail is fixed by changing the code or by stating the change in the Summary; a warn is answered in the body; the complete command; what a pass means: the dumps agree, not that the exports are identical, since the dump samples five elements per entity; what is sent, including element names and values that can hold an ElementId), a changelog fragment. ## Testing No local build (the lane runs no cargo); the tests above are the pure-helper exception and run in CI's PII guard job. End to end on real dumps: - [x] N/A for `tools/check-local.sh`: no Rust changed. - [x] Verified end to end on real Measure runs: see "Output samples". The keyed path (main's `workflow_run` job with the secret) is not yet exercised. ## Audit-honesty checklist - The keyed path cannot run before the workflow is on main: `environment: jev` takes only main, and a `workflow_run` workflow runs from the default branch. After the merge: `gh workflow run semantic-check.yml --ref main -f run_id=<a complete Measure run with a base>`. - The keyless path is exercised by this pull request's own run of the workflow, and it can only say NOT MEASURED: it writes on the pull request's head, which is never the commit Measure measured. At c36b71f (before the delta review) it did so with the wrong reason: Measure run 41987903774 (dispatched from this branch for #1425's head c8e55f5 against main 182ed21, `-f nordic=true -f r2025=true -f scorers=mcp_answers_vs_ifc`, no `models` filter) compared all 34 open models (0 skipped, 0 uncovered, `requested_all` true; findings only in the two office files, 7 each), and this workflow's run 41987854258 (attempt 2) wrote check run 127117767677 on c36b71f through `GITHUB_TOKEN` saying only "no Jev key", a check on a commit Measure had not measured. At b4d1932 such a check says "this check is for <the head>, but Measure measured <the other commit>" in its title (local scenario below; the CI proof is Measure run 41993282068 on #1425's head 722244e against main a4044dc, and this workflow's pull-request run after it: not yet measured on this head). Measure's own pull-request run 41987854320 covered 6 of 34 models and its compare step says "the semantic check writes no check run (this run was not asked for every open model)", the filtered path in a real run. An earlier pass of the keyless path (run 41966963563, attempt 2, on fd90cdc: no semantic difference in 6 models) predates the coverage rule and the commit check. - A pass means the dumps agree, not that the exports are identical: the dump samples five elements per entity, and a mesh vertex or a profile point is not in it. - The thresholds and the wording of the per-finding question were set on the in-sample cases below, so those cases are in-sample for them. The held-out round is the second table. Jev's answers move by about 0.02 between two calls with the same request (#1412's own Summary passes at 0.84 and fails at 0.86 on byte-identical requests, against a gate of 0.85), so a verdict within 0.05 of the gate is not stable. - B3 (a fork's run) and the redirect behaviour are tested by reading the code and the unit helpers, not by a fork's run: no fork pull request was opened. ## Breaking changes None. ## Output samples Everything below was scored with `tools/ci/jev_check.py` and `tools/re/semantic_diff.py` as committed at 49d5378, and the delta-review block below as committed at b4d1932 (which changes who may write a check, the gaps, and the stripping of HTML and invisible characters in the pull request's text; no prompt, threshold or chunking), and the key from the Keychain on this Mac, from the `semantic-diff` and `measure-*` artifacts of the Measure runs named. Nothing was scored with a threshold or a prompt other than the committed ones. **Ground truth is `ifc.sha256` per model**, not a pull request's title. Of 13 pull requests in the in-sample set (Core Interior, Einhoven, RE1 and the Revit 2025 models in every run; 34 models with the BIM4LCA office where `nordic` was on, 30 for #1402 and #1403 and 6 for #1398), the IFC differs on the two office files for #1388, #1400, #1401 and #1405 and on no model measured for the other nine. The semantic diff has findings on exactly those two models in each of those four runs, and none on any model whose IFC is identical, except the dump-only changes of #1373, #1379 and #1412. The documented command (no `models` filter) is what finds them: the earlier documented command, which filtered to Core Interior, Einhoven and RE1, reads "pass" on all four. **In-sample: the 7 pull requests whose diff is not empty** (runs 41972569847 #1388, 41972650013 #1400, 41972664107 #1401, 41972583508 #1405, 41972597118 #1373, 41972610208 #1379, 41972636527 #1412; each 34 models). "Own" is the pull request's real Summary and Testing. "Sweeping" is a one-line Summary that names an area and no kind of change ("Improves how walls and floors are exported." for #1388, "Improves how openings are written in the export." #1400, "Improves how walls are drawn in the export." #1401, "Improves how floors and walls are exported." #1405, "Improves how rooms, profiles and pipes are exported." #1373, "Improves how roofs are exported." #1379, "Improves the MCP server's answers." #1412), alone and beside the pull request's real Testing. "Wrong" is another pull request's full body: #1329 (a memory change that states the output does not change) and one other. The number in parentheses is the highest probability that Jev gave a finding as not stated specifically. | Pull request | Findings | Own | Sweeping alone | Sweeping + its Testing | Wrong: #1329 | Wrong: other | | --- | --- | --- | --- | --- | --- | --- | | #1388 | 7 | pass (0.31) | fail (0.99) | pass (0.74) | fail (0.99) | #1412: fail (0.95) | | #1400 | 14 | **fail (0.94)** | fail (0.99) | fail (0.98) | fail (0.98) | #1373: fail (1.00) | | #1401 | 12 | pass (0.63) | fail (1.00) | pass (0.77) | fail (0.96) | #1379: fail (1.00) | | #1405 | 2 | pass (0.51) | warn (0.99) | warn (0.90) | warn (0.96) | #1379: **pass (0.78)** | | #1373 | 88 | pass (0.63) | fail (1.00) | fail (0.99) | warn (0.97) | #1400: fail (1.00) | | #1379 | 94 | pass (0.24) | fail (0.99) | warn (0.90) | fail (0.96) | #1401: fail (1.00) | | #1412 | 23 | pass (0.84) | fail (1.00) | fail (0.89) | fail (0.99) | #1388: fail (1.00) | - **No sweeping Summary alone passes (0 of 7): 6 fail, 1 warns.** Beside the pull request's own Testing two pass (#1388 and #1401), because their Testing states the figures: that is the rule working, since a measured figure in Testing counts as stated. - **False positives: 1 of 22 expected passes, a fail.** The 22 are the 7 own Summaries, 6 jitter controls, 6 reordered controls and 3 empty-diff pull requests on complete runs (#1329, #1377, #1382: no finding on any model, IFC identical, each a pass without a call to Jev). #1402 and #1403 ran without the office, so under the new rule they write no check and are not counted. #1400 is a diff of 14 counters of the diagnostics, and the figure its Summary and Testing leave unstated is `parameter_value_count` +188 (office as built) and +174 (permit); its Motivation, which Jev is not given, gives 182. #1412's own Summary sits at the gate: the same request scored 0.84 (pass) at 4e81a95, 0.86 (fail) in one rescoring on this head's code and 0.84 (pass) in the table above, so it is a verdict the gate cannot hold; it could as well be counted a second false positive. - **False negatives: 1 of 21 expected non-passes** (7 sweeping alone, 7 with #1329's body, 7 with another's): #1405's whole diff is `total_entities` +8 on each office file, which a roofs Summary does not state (0.78, below the gate). - **Controls, complete** (all 34 models on both sides, one model changed; built from the dumps of run 41972569847): six jitter controls pass, a move of 1e-6 in every measurement of the sampled elements, the rooms' areas and the levels' elevations in Core Interior, RE1 architecture and mechanical, Einhoven, the office as built and a Revit 2025 model, scored beside #1329's body: highest probability 0.73 to 0.79, highest chunk rating 0.6 to 0.7, below the 1.0 rating gate; 412 findings in 65 chunks on the office. Six reordered controls (every row, set and room in another order, every byte offset shifted) are empty diffs. - **Coverage, on #1401's stored diff** (run 41972664107, own Summary), changing only the manifest: complete, **pass**; one model with no dump on the head side, **NOT MEASURED** naming it; one model whose diff failed, **NOT MEASURED** with that reason; a dropped group, **NOT MEASURED**; the same missing model with a run not asked for every open model, **no check run**; a manifest with a non-string model, an error and no check run. - **Unchanged by the review fixes:** 34 of 35 verdicts of the in-sample matrix are as scored at 4e81a95 (the one that moved is #1373 with #1329's body, fail to warn; both are non-passes), and #1401 and #1405 (the two the review asked for, runs 41972664107 and 41972583508) are unchanged in all five bodies. 18 of the 35 requests are byte-identical to the earlier scoring; the other 17 carry a Summary or Testing that is now cut by its length as sent (a newline or a quote in the text counts two, so a section over the cap is cut about 20 characters earlier), which is the review's cap fix and not a change of method. **Delta review (b4d1932).** Run on stored complete runs, with the key from the Keychain and real GitHub lookups, nothing posted: - Run 41972569847 (#1388's merge commit, base 240c7d7): the pull request is found through the API from the measured commit, the base is on main, Jev is asked with #1388's real Summary and Testing: **pass (7 findings in 34 models)**, as before. Run 41972583508 (#1405's merge commit): **pass (2 findings)**, as before. Run 41972664107 (#1401's head 2a35ede, which has since moved): NOT MEASURED, "no pull request of this repository has this commit as its head", the head-moved case in a real run; scored offline with #1401's real body the verdict is **pass**, and all five of its bodies give the verdicts of the table above (pass, fail, pass, fail, fail). #1388's five bodies and #1405's five are the same verdicts as the table, except #1405 with #1329's body, warn to fail (a non-pass either way, at a rating of 1.5). - Run 41987903774 (PR #1425's head c8e55f5 when measured): its head has since moved to 722244e, so the real-lookup scenario reads NOT MEASURED, "no pull request ... has this commit as its head". Asked to write on another commit (c36b71f), the same run reads NOT MEASURED with "this check is for c36b71f, but Measure measured c8e55f5". An empty diff on a merged pull request's commit (run 41980023307, #1358) is a pass; the same empty diff with a commit no pull request has is NOT MEASURED; a base that is the pull request's own head writes no check and names the base. - **Property sets held by one dump only** (`details_one_side`) are a gap per model only when none is held by both while either holds any, or when more than a tenth of all of them are held by one dump only (exactly a tenth is not a gap; main session, 2026-11-05). The dump samples the five lowest ElementIds of each entity, so a change that adds or removes elements of an entity moves the sample and a few are held by one dump only: that is not a defect, and the literal rule (any non-zero count) would have turned #1412's pass into NOT MEASURED. The defect it guards against is a head that lost its details. The check's summary says how many are held by one dump only, gap or not. On run 41972636527 (#1412, 1 of 115 sampled elements held by one dump only in each office file, no gap), scored offline with #1412's body three times: pass (0.84), fail (0.85), pass (0.83), all with no gap and the same chunk (a finding at the 0.85 gate, in a chunk rated 3.6), so its own Summary is a pass again, at the gate, and not a stable one. No other stored complete run has a non-zero count. **Held-out, thresholds and wording unchanged since they were set above.** Ten merged pull requests that were not used to set them, run with the same 34 models (`nordic` and `r2025` on): - #1337, #1352, #1356, #1372, #1341 and #1344 (Measure runs 41973688732, 41973701739, 41973714367, 41973727101, 41973740400, 41973754042): the IFC is identical on all 34 models and the dumps agree, so each has an empty diff and passes without a call to Jev, with its own Summary, a sweeping one, #1329's or another's alike. **They test the empty-diff path and nothing else**: none of their changes lands on an open model. - #1350, #1358, #1364 and #1370 (provenance and diagnostics additions; the IFC is identical on all 34 models in each, so these are dump-only changes), Measure runs 41980008692, 41980023307, 41980037727 and 41980053223, scored with the same four bodies per pull request (own Summary and Testing, a sweeping one-liner written before the runs finished, that line beside the real Testing, #1329's body, and another pull request's body). Scored first with `jev_check.py` as it was at 4e81a95 and again with the code of this head; nothing was changed after seeing a result, and the 20 verdicts are the same in both. | Pull request (run) | Findings | Own | Sweeping alone | Sweeping + its Testing | Wrong: #1329 | Wrong: other | | --- | --- | --- | --- | --- | --- | --- | | #1350 (41980008692) | 1034 in 142 chunks | **warn** (0.86, one chunk, rated 1.13) | fail (1.00) | fail (0.88) | fail (0.99) | #1358: **pass (0.84)** | | #1358 (41980023307) | 0 | pass, empty diff | pass, empty diff | pass, empty diff | pass, empty diff | pass, empty diff | | #1364 (41980037727) | 159 in 37 chunks | pass (0.14) | fail (1.00) | pass (0.60) | fail (0.97) | #1370: fail (0.92) | | #1370 (41980053223) | 98 in 16 chunks | **warn** (0.90, one chunk, rated 1.33) | fail (1.00) | fail (0.95) | fail (0.97) | #1350: **pass (0.21)** | The sweeping lines were "Improves what the export records about elements." (#1350), "Improves the diagnostics of the export." (#1358), "Improves what the export records about bodies." (#1364) and "Improves what the export records about profiles and stairs." (#1370). - **The held-out result is weaker than the in-sample one.** Real Summaries: 1 of 3 non-empty pull requests passes, 2 warn and none fail. Sweeping alone: 0 of 3 pass (all fail). #1329's body: 0 of 3 pass. Another pull request's body: 2 of 3 pass. With the empty diff counted, false positives are 2 warns (no fail) of 4 expected passes, and false negatives 2 of 9 expected non-passes. - **Why the two warns.** #1350 added fields to the dump's `summary.file` block (`layout_release`, `omitted_entries`, `partition_count`), which its Summary and Testing do not name: one chunk of 0.86 at a rating of 1.13, where a warn needs 0.85 and 1.0. #1370's warn is one chunk of `value_sources` parts of Core Interior's shading devices at 0.90, rated 1.33; a fail needs 1.5. Both are near their gates. - **The two cross-body passes are neighbours, not strangers.** #1350 (the provenance of every decoded element), #1358 (why an element was left out) and #1370 (value sources for profiles, stair runs and landings) all add provenance and diagnostics, so another's Summary covers part of the diff. They are counted as false negatives as defined. - **Run-to-run movement.** Jev's answers move by about 0.02 between two calls with the same request, and by more in the maximum of very many findings: with #1358's body on #1350 (1,034 findings) the highest scored 0.83, 0.97 and 0.84 in three scorings, only the middle one on a different grouping of the chunks (since reverted: a chunk is packed at full context). A verdict near a gate (0.85) is not stable. - **What it says about the thresholds.** On provenance and diagnostics additions Jev's probabilities for a change the pull request states sit near 0.9 where in-sample they sat at 0.2 to 0.8, so the 0.85 gate is close to the edge for real Summaries. A recalibration follow-up is warranted. #1314, #1316 and #1328 cannot be calibrated: their parents predate the server crate (71c0677), so Measure builds no `rvt-rs-mcp` there. ## Related issues Refs #1334
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Where each decoded element was read from, down to the bytes, on request:
decoded.element_provenanceof the export diagnostics lists, by ElementId, the carrier of the element's record, its stream and byte offset in the inflated stream (the bytesrvt-dumpwrites asPartitions_NN.decomp), where its ElementId is stored, its class tag and the class that names in the file's own schema, itsBuiltInCategory, and the native record the export's native passes indexed for it. It is off by default (ExportOptions::with_element_provenance,rvt-ifc --element-provenance, Pythonexport_diagnostics(element_provenance=True)andrvt_to_ifc_diagnostics(..., element_provenance=True)), because it is large: on the BIM4LCA office as built the table is 4,462,401 bytes of compact JSON (what the library and Python write) against 38,640 bytes of diagnostics without it, about 116 times; the CLI's pretty-printed sidecar grows from 52,677 to 7,370,747 bytes (140 times), Core Interior's from 27,588 to 571,989 and RE1 Architecture's from 13,956 to 85,470 (Measure run 41831418684).rvt-rs-mcpasks for it when it opens a model. Nothing is written into the IFC.Motivation
Refs #1325 (milestone 0.15.0): an answer about an element has to be checkable against the file, and #1326 (per-element export decisions) builds on this table. The MCP server already named the body, profile and outline sources; it lacked where the record sits.
Changes
src/ifc/element_provenance.rs(new):ElementProvenanceTable, one entry per ElementId. Carrier:partition_element_record_first_prologue,partition_element_record_second_prologue(the enclosing partition record's start and id, RE-35),global_latest_schema_walk,partition_arc_wall,partition_area_record,partition_derived(no frame, no offset) andother(no stream or offset either). Built from the walk the handle memoised, the inflated partitions it holds and the native record index; no reader changed what it writes.ExportOptions::element_provenance(last field, default off,with_element_provenance).run_export_with_limits_and_controlbuilds the table right after the exporter, only when set and not for the placeholder exporter.DecodedExportDiagnostics::element_provenanceis anOptionwithskip_serializing_if = "Option::is_none", so without the switch the diagnostics JSON has no such key and is the bytes it was.rvt-ifc --element-provenance(requires--diagnostics, conflicts with--placeholder); documented indocs/export-diagnostics.mdanddocs/user-guide.md. Python: theelement_provenancekeyword onexport_diagnostics,export_diagnostics_jsonandrvt_to_ifc_diagnostics(stubs anddocs/python.mdfollow). wasm: unchanged, so the viewer's result and download are as before.GroupSourcegainsinflated_offset(where a reassembled group starts in the partition inflated, only when its segments are consecutive whole members of it), the record index keeps each record's header offset, and the entry names the copy the export reads where several partitions hold one (current_partitions, RE-145, RE-216).by_carrier(every element: with an offset, without),unkeyed_elements,native(every element, the omitted ones included). The listing is capped at 250,000 elements; the counts cover all.rvt-mcp: the decode asks for the table;Computedtakes it out of the diagnostics and keeps it beside the model, soget_diagnosticsand the exports' summaries carry no table.carrier,stream,offset,record_offset,enclosing_record_id,class_tag,class_name,native_recordandprovenance_omitted(an element past the cap says so) on every element'sprovenance;partition_count,layout_releaseandomitted_entrieson the file's.docs/mcp.md,docs/mcp-tools.jsonanddocs/mcp-tools.mdfollow.tests/element_provenance_offsets.rs(classreal): exports each model without the switch (asserts no table and no key in the diagnostics JSON), times what the switch adds on the warm handle (table build, its JSON) and the bytes it adds, exports with the switch, then reads the bytes at every reported offset without the reader that reported it. A second-prologue frame is checked against the record header's own bytes (the id, the header constant, theu32size that must span the frame's offset), not through the builder's chain walk.tests/json_schema_contracts.rsvalidates the diagnostics schema againstrvt-ifc --element-provenanceoutput and checks the key is absent without the flag.Testing
tests/element_provenance_offsets.rsonRVT_PROJECT_CORPUS_DIR(Core Interior, the four RE1 models, Einhoven; MIT) andRVT_NORDIC_LCA_DIR(BIM4LCA as-built office; CC BY-SA 4.0), seven models. A first-prologue frame decodes at its offset (decode_at_with_marker) to the same ElementId, category and class tag; a second-prologue frame carries no id and sits in the record whose header starts with the id; an Area chain record and a native record start with the id. Einhoven (Revit 2023) confirmed 13 of 13 first-prologue frames and 71 of 71 native records. The per-carrier counts are in the Corpus health job's "Print the element provenance report" step and theelement-provenanceartifact.-f base=main -f nordic=true -f r2025=true -f samples=true -f holdout=true -f families=true -f scorers=none); itsmeasure-headandmeasure-baseartifacts hold each non-held-out model'sdiagnostics.json, to compare withcmp(the compare job hashes onlyifc.sha256and excludesdiagnostics.json; editing measure.yml would start an unfiltered Measure on this PR). The held-out models keep only counts andifc.sha256. Not read by the author of this body.ifc_flagsgoes to both), so the table's time is measured in the offsets test on the warm handle: 5 ms on Core Interior and 28 ms on the office (CI at 41569e8). Run 41833805887 times head (switch off) against main on the reference models and the four office files: it checks the off path costs nothing; not read by the author of this body.Audit-honesty checklist
changelog.d/added/1325-element-provenance.mdLimitations, stated:
offsetnames. Among an element's partition element record frames, Revit 2024 and later (select_instance_records) select the one with the greatest vertical extent and, on a tie, the greater(stream, offset), the stream name compared as text; Revit 2008 to 2023 (select_newest_instance_records, RE-107) select the newest, the highest-numbered partition and then the latest offset, with no extent test. A body reader may take another copy (the sketch-line readers take the current one,Copies::Current,current_partitions, RE-216), which is also the copynative_record.streamnames. Sooffsetandnative_record.streamcan name different partitions, and neither is guaranteed to be the copy a body came from;body_sourcenames the reader, not its copy. This is in the field descriptions (rvt-mcp/src/schema.rs, the diagnostics schema),docs/export-diagnostics.md,docs/mcp.mdand the changelog.global_latest_schema_walk) has no element on any of the seven models, so its offset check has not run on any. Its offsets indexGlobal/Latestas the walk inflates it (inflate_stream_auto);rvt-dumpinflates that stream with its own routine, and the two are not compared.select_instance_recordscomparesstreamas text, soPartitions/9is later thanPartitions/46; it is unchanged here and is its own issue.docs/mcp-tools.jsonwas edited by hand to match the schemars output for the new fields (the server'stools/listis the contract andtool_contract_is_committedcompares it byte for byte): if that test fails, the failed job uploads the server's own file as themcp-toolsartifact, to commit withpython3 tools/ci/render-mcp-tools.py.docs/mcp.mdsays the table's time is printed by the offsets test and states no figure; the figures above (5 ms, 28 ms) are CI's at 41569e8.Breaking changes
None. New pub items are additive:
rvt::ifc::element_provenance,ExportOptions::with_element_provenance(one new field on the#[non_exhaustive]struct, last), one new optional field on the#[non_exhaustive]DecodedExportDiagnostics, a defaulted keyword on three Python callables.Screenshots or output samples
N/A: IFC output unchanged by construction; the byte-identity run is the check.
Related issues
Refs #1325, #1326
Default path measured (added by the maintainer session)
main):ifc.sha256are equal.diagnostics.jsonof every model with one on both sides is equal byte for byte: 93 of 93. The held-out models' diagnostics are scrubbed and were not compared.main, each pair on one runner):main's on Core Interior, the four BIM4LCA office files, RE1 and Einhoven.main's on all of them but Core Interior, at 309 to 323 MiB (1.04). Core Interior's peak has measured 309 to 325 MiB onmainacross runs.