Skip to content

feat(cli): rvt-diff --elements compares two saves of a model element by element, keyed by the GlobalId the IFC export writes (#1843) - #1852

Merged
DrunkOnJava merged 6 commits into
mainfrom
feat/1843-element-diff
Nov 13, 2026
Merged

DrunkOnJava merged 6 commits into
mainfrom
feat/1843-element-diff

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

rvt-diff --elements A B compares two saves of a model element by element. Each file is exported as rvt-ifc exports it, and the elements are keyed by the GlobalId the export writes. It lists the elements added, removed and changed, and for each changed one the fields that differ:

  • class, name, storey, type, predefined type and material;
  • where the body is placed, and a digest of the body;
  • each property the export writes.

--json writes the whole comparison against docs/schemas/rvt-diff-elements.schema.json, and --redact scrubs names and text values. The library is rvt::ifc::element_diff. Closes #1843.

Motivation

#1843, suggested by HWT-25 on #1829. They compared two saves of a Revit 2027 structural model by hand and found 163 beams and 10 columns added in one day, 84 framing members that one save drops (#1838), and the parts of a layered floor taking new GlobalIds on every save (#1840).

Shape. The issue left open whether this is an rvt-diff --elements mode or a new CLI. It is a mode: rvt-diff already compares two versions of a file, so no binary is added and the README's CLI sentence stays as it is.

Changes

  • src/ifc/element_diff.rs (new, public):
    • element_states gives one ElementState per element the export writes, leaving out a piece the writer folds into its owner's body;
    • diff_elements compares two lists by GlobalId into an ElementDiff.
    • The structs are #[non_exhaustive].
  • src/bin/rvt_diff.rs: --elements, --json PATH, --limit N (the elements listed per kind, default 20) and --redact. A stream a limit kept out is reported on stderr, as rvt-ifc reports it.
  • docs/schemas/rvt-diff-elements.schema.json and its row in docs/schemas/README.md.
  • tests/json_schema_contracts.rs, on the tier-1 synthetic projects with no corpus:
    • the JSON validates against the schema;
    • a file against itself has no added, removed or changed element;
    • between two projects, each file's elements are counted once, as removed or added, changed or unchanged.
  • probes/examples/probe_1843_element_diff.rs: the counts of a comparison, for Measure's probe_pair_release.
  • docs/library.md, changelog.d/added/1843-element-diff.md.

Testing

Unit tests are banned here. The contract test above runs the built binary in CI. The evidence on real files is a Measure run of the 2021 to 2027 samples with the probe and probe_pair_release=2026. Each sample is compared with the same project saved by Revit 2026, and the same run writes the same-project gates verdict.

Rows, registered before the run:

  1. Self-comparison. On every sample alone, the probe compares two exports of the same file and reports added=0 removed=0 changed=0, with unchanged equal to left. A nonzero count would mean an export is not deterministic, and is named.
  2. Pairs. On each sample paired with its 2026 save, every element of each side is counted once (left = removed + changed + unchanged, right = added + changed + unchanged), and the counts are reported per pair. No rule is asserted about how many elements an upgrade save keeps. What the pairs show is read and stated here, including any whole class that is added and removed rather than matched.
  3. No export moves. No export code changes, so no hash comparison is run. same-project gates pass.
  • rustfmt --edition 2024 --check passes. CI runs the rest of the gate.
  • Verified end to end on real Revit files: Measure run 43353012565 on 78516997, read in the comment below (rows 1 to 3 hold).
  • N/A: no exporter output change.
  • N/A: no performance change to an existing path.

Audit-honesty checklist

  • README / docs reflect the current state after this PR
  • A user-visible change has its entry as a fragment under changelog.d/<section>/
  • N/A: no limitation resolved or introduced. What it cannot see is stated in the module doc, the schema and the changelog: what rvt-rs does not read, and a change in how rvt-rs reads a file.
  • Commit messages describe WHAT changed and WHY
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • The probe under probes/examples/ states its FACT

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content
  • No new test fixtures

Breaking changes

None. A new public module, rvt::ifc::element_diff, and a new rvt-diff mode.

…by element, keyed by the GlobalId the IFC export writes (#1843)

HWT-25 compared two saves of a Revit 2027 structural model by hand (#1829) and found 163 beams and 10 columns added in a day, 84 framing members one save drops, and the parts of a layered floor changing GlobalId on every save. rvt::ifc::element_diff takes each element an IFC export writes (folded pieces apart) as its class, name, storey, type, predefined type, material, placement, a digest of its body and every property it writes, and compares two exports by GlobalId: added, removed, changed with the fields that differ, and unchanged. rvt-diff --elements A B prints a summary and, with --json, writes it all (docs/schemas/rvt-diff-elements.schema.json); --redact scrubs names and text values. The tier-1 contract test checks the schema, that a file against itself changes nothing, and that every element of two files is counted once; probe_1843_element_diff runs it on Measure's sample pairs.
…tween two exports, by key, with how often a side lacks one and the largest numeric change (#1843)
…value, and reports how much a changed one moves and whether its kind changes (#1843)
…d an element, which every later save moves (#1843)

Between Autodesk's 2025 and 2026 saves every element differed in
RvtElementRecordGeometry.SourceStream alone (run 43334394489): the stream a
save stores an element in is the file's layout, not the element.
@DrunkOnJava

DrunkOnJava commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner Author

Interim readings, against the rows above. These runs are on scratch/1862-selfdiff (d53c3e27): this branch at 20a6d32d with #1863 merged in. The registered run (2021 to 2027 samples, pairs to 2026) runs on this branch's head once #1863 lands and main is merged here.

Row 1, self-comparison.

Row 2, pairs (run 43337710630, each 2025 sample against its 2026 save). Every element is counted once on each side, on all five pairs.

Sample Elements Added / removed Changed Unchanged
rac_advanced 5,682 0 / 0 4,647 1,035
rac_basic 467 0 / 0 246 221
rme_advanced 6,743 25 / 25 2,244 4,474
rme_basic 6,788 25 / 25 2,244 4,519
rst_basic 455 0 / 0 21 434

What the changes are:

Row 3 is read on the registered run.

DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
…west vertex, so two exports of one file write the same GrossSideArea and GrossVolume (#1862) (#1863)

## Summary

Two exports of one file now write the same wall
`Qto_WallBaseQuantities.GrossSideArea` and `GrossVolume` to the last
bit. `outer_loop_area` (`src/ifc/mesh_wall_quantities.rs`) summed each
boundary loop of a wall side from whichever vertex a `HashMap` yielded
first. Each export added the same terms in another order, so the area
moved by up to 2e-14 of its value.

#1852's element diff, comparing a file's export with itself, listed 4 to
117 walls as changed on seven of eleven models (run
[43335692114](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43335692114),
table on #1862). No other field or property moved on any of the eleven.

## Motivation

`rvt-diff --elements` (#1843, PR #1852) compares the values an export
holds. A value that moves from one export to the next shows as a change
between two saves that did not change it.

## Changes

- `outer_loop_area` sums each loop from its lowest vertex: the loop
starts are sorted before the walk. Vertex ids follow the triangles'
order, which is the file's.
- Whether a face's boundary closes into loops, and so whether it gets a
gross area, does not depend on the start order and is unchanged.
- Changelog fragment `changelog.d/fixed/1862-outer-loop-order.md`.

## Testing

Rows, registered before the runs:

1. Unfiltered Measure against the merge-base: every export's
`ifc.sha256` and `diagnostics.json` identical. A written value can move
only at the sixth decimal of a wall `GrossSideArea` or `GrossVolume`
that sat on a rounding boundary; any such move is listed here by model
and wall. The same-project gates pass.
2. #1852's self-diff (`probe_1843_element_diff`, a file's export against
itself) on a scratch merge of this branch and #1852: no element changed
on any of the eleven models of run 43335692114.

Results will be posted here.

- [ ] `tools/check-local.sh`: CI is the compiler; `rustfmt --edition
2024 --check` passes locally
- [ ] Verified end to end on real Revit files: rows 1 and 2
- [x] Touches the IFC exporter: witness verdicts replay unless row 1
shows Core Interior moved
- [ ] Performance: n/a (one sort of a face's loop starts)

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR: no doc
states the gross areas move between exports
- [x] Changelog fragment under `changelog.d/fixed/`
- [x] No limitation resolved or introduced in the docs
- [x] Commit message says what and why
- [x] No emojis
- [x] No private paths or personal details
- [x] Not a format finding

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] No Autodesk proprietary source, decompiled internals or NDA
material
- [x] No fixtures

## Breaking changes

None.

## Screenshots or output samples

None; rows 1 and 2.

## Related issues

Closes #1862. Found by #1843's element diff (PR #1852).
DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
… so walls and the curtain parts on them get IsExternal there (#1860) (#1861)

## Summary

A wall's type Function is now read on Revit 2026 and 2027 saves as on
2015 to 2025. Walls there, and the curtain members, plates and curtain
walls that take `IsExternal` from their wall, get the value the same
project's 2025 save gets. Closes #1860.

## Motivation

#1852's element diff of each 2025 sample against its 2026 save (run
43334394489) found `IsExternal` present in the 2025 save and absent in
the 2026 save on 4,643 elements of `rac_advanced`, 244 of `rac_basic`,
2,244 of each `rme` sample and 9 walls of `rst_basic`. It was never the
other way round. `WALL_TYPE_FUNCTION_REVIT_VERSIONS` ended at 2025, the
last release measured when it was written, so
`attach_wall_type_functions` read nothing on 2026 and 2027.

## Changes

- `src/research/partition_schema_mvp/fields.rs`:
`WALL_TYPE_FUNCTION_REVIT_VERSIONS` takes 2026 and 2027, and its doc
names what measures them.
- `changelog.d/fixed/1860-wall-function-2026.md`.
- `docs/status.md`: the 2026 and 2027 paragraph lists walls' and their
curtain parts' `IsExternal` as written, not unread. RE-346 had left it
open ("Some other release list or rule gates it"), and this is that
list.

## Testing

Unit tests are banned here. The evidence is one unfiltered Measure of
this head against its merge-base with `main`: the samples of every year,
the BIM4LCA models, the R2025 set, `rac_advanced` and the held-out
models.

`readers_across_saves.py` (part of `same-project gates`) already holds
each 2026 and 2027 save's `Pset_*Common.IsExternal` to its 2025 save's.
It fails a value that differs or one written only on the later save, and
counts one written only on the 2025 save without failing. That count is
what this PR should empty.

Rows, registered before the run:
1. **Only 2026 and 2027 saves move.** The exports that differ are the
2026 and 2027 samples, and any 2026 or 2027 model Measure holds
(flowbim.ee's house). In each, the only change is `IsExternal` values
added to walls and to the curtain members, plates and curtain walls on
them. Every other export and `diagnostics.json` is equal except those
files' `IsExternal` counts.
2. **Equal to the 2025 save.** `same-project gates` pass, so no
`IsExternal` differs from the 2025 save's, and none is written only on
the later save. Reported per sample: the `IsExternal` values compared
equal before and after.
3. **Against Revit.** On every Revit export of a 2026 or 2027 model the
run scores, `IsExternal` "different" and "values Revit does not write"
are unchanged or lower. Any line that moves is named here.

- [x] `rustfmt --edition 2024 --check` passes. CI runs the rest.
- [ ] Exporter output changes: rows 1 and 3.

## Audit-honesty checklist

- [x] Changelog fragment, and `docs/status.md`'s 2026 and 2027
paragraph.
- [x] No emojis, private paths or jargon.

## Legal and contribution hygiene

- [x] Apache-2.0. No Autodesk proprietary content.

## Breaking changes

None.
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

The three rows, read: all hold. Run 43353012565 on 78516997 (main at 76c57f19 merged in): the samples of 2021 to 2027 and the reference models, probe_1843_element_diff, probe_pair_release=2026.

1. Self-comparison: holds. On all 41 models read alone, the probe compares two exports of the same file and reports added=0 removed=0 changed=0 with unchanged equal to left. Before #1863 (wall GrossSideArea summed in hash order) 7 of 11 models listed 4 to 117 walls as changed against themselves.

2. Pairs: holds. On all 25 pairs, left = removed + changed + unchanged and right = added + changed + unchanged. Each sample against its 2026 save, changed of left:

Saves rac_advanced rac_basic rme_advanced rme_basic rst_basic
2021, 2022 5,682 of 5,682 467 of 467 454 of 454
2023 5,682 of 5,682 467 of 467 6,763 of 6,763 454 of 454
2024 5,591 of 5,682 453 of 467 6,642 of 6,743 6,687 of 6,788 454 of 455
2025 4 2 0 0 12
2027 309 76 107 450 0

What the pairs show, as the row said it would:

3. No export moves: holds. same-project gates pass on 78516997: 15 samples held to their earlier saves, and the Areas on 4 saves and on the 2021 save.

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 13, 2026 03:19
…an export writes twice and says so, and --redact scrubs the paths in what it prints and the parameter names (#1843)
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

The registered run on 7206678c: all three rows hold. Run 43363853434 (the samples of 2021 to 2027 and the reference models, probe_1843_element_diff, probe_pair_release=2026), read against the rows registered for it.

1. Self-comparison: holds. On all 41 models read alone the probe reports added=0 removed=0 changed=0, unchanged equal to left and right, and set_aside left=0 right=0 duplicate_ids left=0 right=0. No export of the run has a GlobalId that two elements share.

2. Pairs: holds. On all 25 pairs left = removed + changed + unchanged + set_aside.left and right = added + changed + unchanged + set_aside.right, with set_aside 0 on both sides of every pair. Each pair's counts are those of run 43353012565 on 78516997 (the table above), so setting aside a repeated GlobalId changes no result where none repeats. What the code does where one does repeat is covered by the five failure-first tests of the pure helper and by the CLI assertion in tests/json_schema_contracts.rs, which runs the built rvt-diff.

3. No export moves: holds. The run has no base side, so this is read from what changed and from the gates. 7206678c differs from 78516997 in src/ifc/element_diff.rs, src/bin/rvt_diff.rs, the schema, the contract test, the probe, docs/library.md and the changelog fragment: nothing an export runs. same-project gates pass on 7206678c.

CI is green at this head. I have asked rvtDevelop to read the duplicate-GlobalId and --redact fixes and approve; it arms as a new CLI feature that closes #1843.

@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Approved at 7206678 by rvtReview, without a second reader. rvtDevelop had not answered the request to read the duplicate-GlobalId and --redact fixes, and the maintainer's decision of 2026-11-12 lets rvtReview approve its own pull request in that case, after re-reading it.

What the re-read covered, at this head:

  • src/ifc/element_diff.rs: diff_elements sets aside every element whose GlobalId either export writes twice and compares the rest, so each side balances (left_elements = removed + changed + unchanged + set_aside.left, and likewise for the right); the five failure-first tests cover a repeat on either side, on both and three copies.
  • src/bin/rvt_diff.rs: --redact runs the error text, both file labels, every name, storey, type, material, property key and text value through rvt::redact, and the unread-stream report names the label and never the path.
  • tests/json_schema_contracts.rs and the schema: a file against itself, two projects' identity, and an error that names a missing file under a user's folder.
  • Measure 43363853434 holds all three registered rows (read above), CI is green, and same-project gates pass on this head.

One gap, not this PR's: rvt::redact does not scrub /home/<name>/ (#1871), so an error naming a Linux home folder keeps the name until #1873 lands.

@DrunkOnJava
DrunkOnJava merged commit e57db42 into main Nov 13, 2026
37 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/1843-element-diff branch November 13, 2026 05:29
DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
…d of every path in a string, not the first of each kind (#1871) (#1873)

## Summary

`redact_path_str`, which every `--redact` runs a path through, now
scrubs the user name of `/home/<name>/` as it does `/Users/<name>/` and
`\Users\<name>\`, and scrubs every path of a string where it scrubbed
only the first of each kind (a message that named two files kept the
second one's user name). A name no separator follows, as in a path an
error echoes back (`No such file: /Users/alice`), is scrubbed up to the
first space, quote, closing bracket, comma, semicolon or colon, or the
end of the string (rvtDevelop's review of this PR; the first version
left it alone); a home folder with nothing after it is left as it is.

A second commit corrects a module doc that #1825's closing comment
promised to correct: `partition_column_nodes.rs` called a column node's
two boxes' x and y extents equal. The raw lines of the census's Measure
run show 3,519 of its 3,658 comparisons agree to 1e-12 ft (3,165
exactly) and 139 differ by more than 1e-6 ft, none between, so the doc
says that and what the test requires of the boxes (1e-9 ft). The closing
comment said "equal to 1e-12" without the 139; they are all in
`column_cut_extents` (Core Interior 80, Snowdon Towers Architectural 58,
the BIM4LCA timber office at permit 1). No code changes there.

## Motivation

#1871, found while reading #1852: `rvt-diff --elements --redact` runs
its error text through this function, and CI's PII guard already treats
`/home/<name>/` as a home path in committed files, so the scrubber and
the guard disagreed. The first-path-only behaviour is the same bug in
the same loop.

## Changes

- `src/redact.rs`: `HOME_PARENTS` holds the three folders that hold one
folder per user; `redact_after` walks the whole string and moves past
each replacement, so a string that is already redacted comes back
unchanged. The doc example shows a Linux path and a string of two.
- `changelog.d/fixed/1871-redact-home-paths.md`.
- `src/research/partition_column_nodes.rs`: module doc only.

## Testing

- The helper is pure, so it has failure-first tests next to it (the
pure-helper exception), seven, written as the ways it can leave a name
behind or take more than a name: a Linux home folder (fails on `main`),
five paths of three kinds in one string (fails on `main`: the second
`\Users\` path and both `/home/` paths keep their names), a name no
separator follows, as in an echoed path (fails on `main`), a home folder
with nothing after it, a folder that only starts like a home folder
(`/srv/homework/...`), names with spaces, dots and accents, and a second
pass over redacted text. CI's Linux test job runs them with `cargo test
--profile ci --lib`.
- Committed redacted output: `git grep -I '/home/'` on `main` finds
three tracked files, a Dockerfile's `ENV PATH`, CI's PII guard pattern
and CONTRIBUTING.md's description of it. None is output of a `--redact`
run, so none changes.
- Measure, rows registered on #1871 before the run (run 43368277871,
unfiltered, against `main` at `9bb58fe1`): `ifc.sha256` identical on 146
of 146, `diagnostics.json` on 121 of 121, no scorer differs beyond what
only the head writes, and `same-project gates` pass on `9a7ce531`. The
run reads no `--redact` output, so it shows only that no export moves;
the helper's behaviour is the seven tests above. The rule for a name no
separator follows came after that run, so a second run on `7e825868` (no
base side, rows registered on #1871) gives the gates verdict for it and
is compared with the first.

## Related issues

Closes #1871. Refs #1825.
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.

Element-level diff of two saves: what was added, removed or changed, keyed by GlobalId (#1829)

1 participant