Skip to content

perf(reader): a large export holds its bytes once, not several times (#1075) - #1329

Merged
DrunkOnJava merged 11 commits into
mainfrom
perf/1075-peak-memory
Nov 4, 2026
Merged

DrunkOnJava merged 11 commits into
mainfrom
perf/1075-peak-memory

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Cuts the peak memory of rvt-ifc and rvt-gltf on large projects without changing an export: the peak was several copies of the same bytes held at once, and four are removed. Measured on the BIM4LCA office; the reporter's 438 MB model is not available here and is not measured.

Motivation

Refs #1075 (not closing it: the reporter has to confirm on their 438 MB model, 10.3 GB at the export stage with --large-model). Their stage table put 3.4 GB in the handle's inflated partitions and the rest in the export; a counting allocator on the BIM4LCA office, the largest model Measure has, says where the rest goes.

Changes

  • compression.rs, reader.rs: RevitFile::inflated_partition inflated every gzip member into a buffer of its own and then joined them (the whole stream twice at once, 2.3x its inflated size at the peak), after copying the stored stream and again stripping its checksum pages. Members now inflate onto the end of one buffer, and the stored pages strip in place (pub(crate) strip_revit_page_checksums_in_place, prepare_stream_owned). wasm32 keeps the exact-size join, since its linear memory is never returned.
  • native_document.rs, native_family_forms.rs, reader.rs (read_prepared_stream): each native pass read a partition and stripped a copy of it; it strips in place.
  • native_segments.rs: a continuation group of consecutive whole members of the cache is borrowed from it (InflatedStream::members_span) instead of copied into a buffer of its own. The group budget checks are the same.
  • object_graph.rs: the partition's string records were scanned in a copy of the whole partition, joined by 16 bytes of FF. Each chunk is scanned where it lies, after the records that begin in the separator before it (a chunk that opens where a record's tag ended: the office has such records, which is why a first version that fell back to the copy whenever one was found never took the new path).
  • native_saved_scene.rs, ifc/saved_meshes.rs: the saved graphics of every door and window, and of the symbols they share, were decoded before the first was meshed. The split probe: 538 owners hold 1,614 graph objects (9 MiB), 105 symbols hold 158,121 (752 MiB). extract_in_batches_with_control decodes the owners, then their symbols a batch at a time, meshes the owners against the batch and frees it. A batch is the closure of its owners, as the one-shot read finds it: the symbols they name, those the symbols name, and, through any owner either names, the symbols that owner names. It is sized from the graph objects the one before decoded, to a budget of 20,000 graph objects (about 95 MiB). extract_at_detail* is unchanged.
  • probes/examples/probe_1075_heap_stages.rs (counting allocator: exact live and peak heap bytes per stage, the live bytes by block size at the peak, the walker's progress events, the saved graphics split into owners and symbols), probe_1075_heap_sites.rs (dhat: the call sites that hold the heap at the peak and after the export, and in the saved-graphics pass; it adds dhat to the probes crate, which was already in the lockfile) and probe_1075_saved_batches.rs (the batched read against the one-shot read, element by element, on the doors and windows, on those with the symbols they draw from selected as owners too, and on every element with a Tag).
  • changelog.d/changed/1075-export-peak-memory.md.

Testing

  • Verified end to end on real Revit files: the BIM4LCA office as built and at building permit, its two terrain variants (CC BY-SA 4.0) and Core Interior (MIT), exported by main and by this branch in one Measure run (-f base=main -f nordic=true -f models="nordic-office-* core-interior" -f scorers=none, run 41781699897 at d1fc5d3). ifc.sha256 is equal on all five, and on all 111 exports of the unfiltered run below.
  • probe_1075_saved_batches (run 41782387823 at 4df2d66) read the owners both ways on those five models and found every element equal as JSON (meshes, diagnostics, status, identity, source, referenced sources), selection by selection. Owners whose mesh draws from another selected owner (owners_naming_owners): doors and windows, 0 on all five (none of them name an owner); doors and windows with the symbols they draw from selected as owners too, 538 of 643 on the office as built, 534 of 633 at permit, 138 of 149 on Core Interior and 0 of 14 on each terrain variant; every tagged element (Core Interior 970 owners and the terrain variants 31 each; the offices' 12,974 and 13,020 are over the probe's 8,000 and skipped), 0. The two terrain variants have no door or window, so their first selection is empty, which selects every record: 10,033 and 10,078 elements, equal. That run reported a count per batch, which tests/rvt_gltf_progress_cli.rs rejects (saved-graphics is pinned to 0 then 1/1); the next commit reports the one-shot read's sequence and the probe now compares the two sequences too.
  • Unfiltered Measure, run 41785668359 at 64db442 (-f base=main -f nordic=true -f r2025=true -f samples=true -f holdout=true -f timing=true -f probe=probe_1075_saved_batches): ifc.sha256 is unchanged on all 111 exports (the reference models, the BIM4LCA office files, puzzbobb's Revit 2025 models, Autodesk's sample projects, the held-out models). probe_1075_saved_batches printed 246 identical true and 184 same_progress true across them, and no false. The only entries in the scorer diff are the probe.txt files, which exist on the head side alone.
  • No unit tests. The probes reproduce the stage table: gh workflow run measure.yml --ref perf/1075-peak-memory -f ref=<sha> -f base=none -f nordic=true -f models="nordic-office-* core-interior" -f scorers=none -f probe=probe_1075_heap_stages.
  • Performance, same runner, median of three alternating runs of rvt-ifc per file, run 41785668359 (-f timing=true; GNU time's maximum resident set): table below. Of the 68 files none peaks higher, 57 run 3 % to 17 % faster, and two run slower: the office as built by 3 % and Snowdon Towers architectural by 1 %. The one-buffer inflate grows by doubling before it shrinks, which could cost a realloc copy beyond the requested bytes the heap count shows; the office as built peaks at 918 MiB resident against 868 MiB of heap at its highest stage, so it does not show.
File (Revit release) main (ms) this branch (ms) main peak (MiB) this branch peak (MiB) peak ratio
BIM4LCA office as built (2024) 28,330 29,194 1,680 918 0.55
BIM4LCA office at building permit (2024) 27,350 26,166 1,634 979 0.60
Snowdon Towers architectural (2024) 29,796 29,981 1,351 1,073 0.79
Snowdon Towers plumbing (2024) 10,713 10,466 669 549 0.82
MEP basic sample (2024) 12,379 12,168 623 519 0.83
Core Interior (2024) 5,542 5,017 324 322 0.99
rac basic sample (2024) 4,656 4,446 339 218 0.64
RE1 architecture (2025) 1,672 1,428 125 95 0.76

Stages, measured on the BIM4LCA office as built (Revit 2024, 90,842 entities), exact live heap at the highest point of each stage, MiB. Main is run 41778285915 (b228624, main's code with the probe); this branch is run 41781699897 (d1fc5d3), at the shipped batch size of 20,000 graph objects.

Stage main this branch
inflate the 361 MiB partition 901 633
inflate the 361 MiB partition, resident 907 489
partition string records 838 459
export 848 770
saved graphics (decode and mesh) 1,568 868
the highest stage 1,568 868

The saved graphics read the 105 symbols in 9 batches; the stage took 1.85 s here and 1.77 s on main (different runners; the same-runner totals are in the table above). Core Interior's dhat profile (run 41779346905): the export's heap at the peak is the inflated partitions (179 of 276 MiB) and the file (32); every other call site is under 6 MiB.

Audit-honesty checklist

  • No claim of a feature not shipped. Nothing user-visible changes in an export; the memory figures are measured on the office and say so.
  • Changelog fragment under changelog.d/changed/.
  • Introduced limitation: the saved graphics now decode in batches, so a model with many symbols walks the partitions once more per batch (about 0.1 s a pass on the office, which takes nine). The reporter's model is not measured.
  • No emojis, no private paths.

Breaking changes

None to an export. rvt::research::native_saved_scene gains extract_in_batches_with_control.

Related issues

Refs #1075

…ages strip in place, and continuation groups borrow the cache (#1075)
…e heap, and heap_stages splits the saved graphics into instances and symbols (#1075)
… and the partition's strings are scanned in place (#1075)
…hat begin in a separator, and the batches are sized to 20,000 graph objects (#1075)
…ough the owners they name, and probe_1075_saved_batches compares it with the one-shot read (#1075)
… progress, and the probe compares the two sequences (#1075)
…exports byte-identical and the same-runner resident memory and time (#1075)
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 4, 2026 07:11
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 4, 2026 07:11
@DrunkOnJava
DrunkOnJava merged commit 2bfccab into main Nov 4, 2026
28 of 29 checks passed
@DrunkOnJava
DrunkOnJava deleted the perf/1075-peak-memory branch November 4, 2026 07:24
DrunkOnJava added a commit that referenced this pull request Nov 4, 2026
…time, byte-identical (#1237) (#1333)

## Summary

Exports of Revit 2015 to 2023 files take 0.54 to 0.78 of the time they
took on `main`, and all 111 exports of the unfiltered Measure (every
Measure model: the offices, Core Interior, R2025, the held-out models
and the samples of every year, run 41793618569) are byte-identical, IFC
and diagnostics. Against 0.11.0 they now take 1.09 to 1.65 times as
long, where 0.12.0 took 2.0 to 3.4 times. The cuts are in what the
native passes read, not in what they decide.

## Motivation

#1237: 0.12.0 added native record passes on Revit 2015 to 2023 and
exports took 2 to 3.4 times as long. #1239, #1240, #1275 and puzzbobb's
#1301 took off the first part (the definitions read once, no family or
material records in the named-parameter read, no per-record digest, the
decoder borrowing the schema, and only the types the elements name).
This takes the next part. The stages that cost the time were measured
first, with a timing line on each native pass and each export step
(scratch commits, archived below), on the 33 sample projects of 2015 to
2023.

## What the profile found

Autodesk's 2015 `rac_advanced`, whose export `main` takes 2.8 s on a
quiet runner and 0.11.0 0.7 s. The profile runs export many files at
once on one runner, so milliseconds are not comparable between the two
runs; each step's share of its run's export is.

| step | before (Measure 41777773390) | share | after the first three
commits (41781975396) | share |
|---|---:|---:|---:|---:|
| parameter definitions pass | 560 ms | 13% | 236 ms | 13% |
| named-parameter read: elements | 948 ms | 22% | 56 ms | 3% |
| named-parameter read: types | 72 ms | 2% | none | |
| phase read of every record | 485 ms | 11% | 284 ms | 16% |
| wall records and wall types | 341 ms | 8% | 193 ms | 11% |
| whole export | 4,251 ms | | 1,775 ms | |

- The named-parameter read decoded 5,608 records and 6 of them held the
id of a definition it reads (`ids=5608`, `decoded=5608`, `hits=6`, 646
of its 647 ms decode on records with none). It checked 64 accepted
definitions in the file; none is named `IsExternal`, so no type value
could be used and the 72 ms type read was never needed. A scratch check
that every record contributing a parameter holds an id found 0
exceptions in all 33 samples (`violations 0`; in 2015 `rme_advanced`,
516 of 6,724 records hold one).
- The phase read decodes the Element base of all 17,099 records of 2015
`rac_advanced`; `decode_base` was 425 of its 485 ms, mostly a scan of
every class for the name `Element` and a JSON object for each of 20
fields and 17 nested objects.
- The definitions pass decodes 400 `FamilySymbol` records for 117 ms,
for two root fields. See "What remains".

## Changes

- `src/research/native_parameters.rs`: the graph decoder builds a
class's field keys once for each class a record uses (a `ClassPlan`,
kept per decode), copies no `Field` for the items of a container, and
keeps field spans only for the caller that reads one (`Spans`,
`decode_object_fields_spanning`).
- `src/research/schema_registry.rs`: `Registry::named` finds a class
through an index built on first use, not by scanning every class.
- `src/research/native_element.rs`: `decode_base` reads the Element base
fields straight from the bytes where the schema has the layout its
checks measured, and by the graph decoder, as before, for anything else
(a field with flags, a class with a parent of its own, an unknown
pointer class, a flag above 1, more than 1,024 constraint references, a
short body).
- `src/research/native_document.rs`:
`Options::filtered_parameters_only`, which with `definition_filter`
leaves out a selected record whose body does not hold the first four
bytes of the id of any definition the filter accepts. It assumes a value
is saved against its definition's id itself, a whole little-endian
integer in the record (an `Identifier`: 4 bytes on 2015 to 2023, 8 from
2024), so that a record without the integer's first four bytes holds no
value for the definition. That is measured, not proven: on the 33
samples of 2015 to 2023 every record that gave an accepted parameter
held an id, and the exports of every Measure model are unchanged with
the filter (run 41793618569, 111 exports). The definitions pass also
asks once for each class tag whether it owns a definition.
- `src/research/native_element_parameters.rs`,
`src/research/partition_schema_mvp/parameters.rs`:
`read_property_values` replaces `read_defined_values`. It reads the
types the elements name only if a definition the reader takes a type
value for (a plain `IsExternal`) exists; otherwise the read is as
before, and so is the read on a file that defines one.
- `changelog.d/changed/1237-native-pass-cuts.md`.

## Testing

Unit tests are banned in this repository: none added. The change is
shown on real files, end to end.

- [ ] `tools/check-local.sh`: nothing is built on this Mac (no local
compute); CI's fast jobs run the draft, the full set runs when it is
marked ready.
- [x] Verified end to end on Autodesk's sample projects, with the
offices, Core Interior, R2025 and the held-out models for the exports
(the unfiltered Measure, run 41793618569), and 58 samples of 2015 to
2027 for the Element base reader (fetched for the run by
`tools/fetch-autodesk-samples.sh`, never stored; terms in
`research/autodesk-sample-projects.tsv`). The exports are compared with
`main`'s: no Revit export is the oracle, since the change is meant to
leave every value as it was.
- [x] Byte identity: `ifc.sha256` and `diagnostics.json` of all 111
exports of the unfiltered Measure (`-f base=main -f nordic=true -f
r2025=true -f samples=true -f holdout=true -f timing=true`, every
scorer; run 41793618569, the merged head ea69551 against `main` at
2bfccab, every job succeeded) equal `main`'s, 111 of 111: 30 models
including R2025, the 4 office files, 19 held-out models and 58 samples.
Earlier, the 33 samples of 2015 to 2023 at 0fdfd49 (run 41780471217)
and at 6f387fd (run 41782871819).
- [x] The Element base reader against the graph decoder, on every record
the phase read decodes (scratch commit archived at
`refs/archive/2026-11-04/scratch/1237-timings-3`, Measure 41782852434,
samples 2015 to 2027): 1,014,473 records compared by their full
`ElementBase` (pointers, offsets, ids, flags, `end`), 0 differences, 0
fallbacks, all 58 exports exit 0. That branch's `read_base` is
byte-identical to this head's: a diff of
`src/research/native_element.rs` between the two shows only the
comparison lines.
- [x] Time: Measure's `timing` job, the median of three exports each,
alternating order: the merged head ea69551 against `main` at 2bfccab
on one runner (run 41793618569), and 6f387fd against v0.11.0 on another
(run 41782874568); compare ratios, not seconds, between the two runs.
- [x] The witness verdicts replay: Core Interior's export is
byte-identical to `main`'s in run 41793618569, so its observations do
not change.
- [ ] `tools/bench.sh`: not rerun. It times `rvt-info`, `rvt-schema`,
`rvt-history` and `rvt-analyze` on the family corpus, none of which runs
these passes, and rewrites `docs/data/bench-2024.*`.

Reproduce, naming the commit (the workflow comes from `main`):

```bash
gh workflow run measure.yml --ref main -f ref=ea69551f0cd4ac8a601547a61d7c718963904a1f -f base=main -f nordic=true -f r2025=true -f samples=true -f holdout=true -f timing=true
gh workflow run measure.yml --ref main -f ref=6f387fd1155ed6ad1af3aed784c49c6926545e19 -f base=main -f samples=true -f sample_years="2015 2023" -f models="-" -f scorers=none -f timing=true
gh workflow run measure.yml --ref main -f ref=6f387fd1155ed6ad1af3aed784c49c6926545e19 -f base=v0.11.0 -f samples=true -f sample_years="2015 2023" -f models="-" -f scorers=none -f timing=true
```

### Time, this change against `main` and against 0.11.0

Against `main`: the merged head ea69551, the `timing` job of run
41793618569 (one runner for every file, the median of three exports
each, base and head in turn). Against 0.11.0: 6f387fd in run
41782874568, on a runner of its own. Totals of the medians; compare
ratios, not seconds, between the two runs.

| group | files | `main` (s) | this PR (s) | PR / `main` | peak memory,
PR / `main` | PR / 0.11.0 (run 41782874568) |
|---|---:|---:|---:|---:|---:|---:|
| samples 2015 | 6 | 17.6 | 10.9 | 0.62 | 0.87 to 0.97 | 1.49 |
| samples 2016 to 2018 | 9 | 16.8 | 11.0 | 0.66 | 0.86 to 0.99 | 1.51 |
| samples 2019 to 2022 | 15 | 35.4 | 23.0 | 0.65 | 0.84 to 0.98 | 1.47 |
| samples 2023 | 3 | 7.4 | 5.1 | 0.69 | 0.96 to 0.99 | 1.13 |
| samples 2024 to 2027 | 25 | 218.5 | 187.1 | 0.86 | 0.90 to 1.00 | |
| reference models and 4 offices | 10 | 71.8 | 60.9 | 0.85 | 0.93 to
1.04 | 0.80 to 0.98 (the 6 reference models) |

The issue's table for 0.12.0 against 0.11.0 (run 41228075400) was 3.37
for 2015, 2.9 to 3.0 for 2016 to 2018, 2.8 to 3.2 for 2019 to 2022 and
2.01 for 2023. Per sample, PR / `main` is 0.54 to 0.78 for 2015 to 2023
and 0.80 to 0.89 for 2024 to 2027; PR / 0.11.0 is 1.09 to 1.65 for 2015
to 2023. Over all 33 samples of 2015 to 2023 it is 1.43.

| sample | `main` (ms) | PR (ms) | PR / `main` | PR / 0.11.0 |
|---|---:|---:|---:|---:|
| 2015 rac_advanced | 2,764 | 1,644 | 0.59 | 1.65 |
| 2015 rac_basic | 1,662 | 1,279 | 0.77 | 1.26 |
| 2015 rme_advanced | 5,242 | 3,285 | 0.63 | 1.50 |
| 2015 rme_basic | 4,767 | 2,899 | 0.61 | 1.48 |
| 2015 rst_advanced | 1,971 | 1,069 | 0.54 | 1.54 |
| 2015 rst_basic | 1,161 | 701 | 0.60 | 1.58 |
| 2019 rac_advanced | 2,892 | 1,758 | 0.61 | 1.51 |
| 2019 rac_basic | 1,673 | 1,278 | 0.76 | 1.28 |
| 2019 rme_advanced | 5,188 | 3,361 | 0.65 | 1.46 |
| 2019 rme_basic | 4,748 | 2,984 | 0.63 | 1.48 |
| 2019 rst_advanced | 1,943 | 1,155 | 0.59 | 1.47 |
| 2019 rst_basic | 1,113 | 691 | 0.62 | 1.52 |

Reference models and offices, PR / `main`: 0.84 Core Interior, 0.85 and
0.85 the two office files (30.3 s to 25.7 s and 27.0 s to 22.9 s), 0.86
and 0.84 the two terrain files, 0.87 RE1 Architecture, 0.83 Electrical,
0.86 Mechanical, 0.85 Plumbing, 0.75 Einhoven. Peak memory is 0.93 to
1.04 of `main`'s; Core Interior is the 1.04 (309 to 322 MiB), against
1.01 in run 41782871819, which had `main` before #1329.

The Element base reader's own effect: 2015 `rac_advanced` went from 0.73
to 0.63 of `main`'s time and `rst_basic` from 0.83 to 0.63 between runs
41780471217 (without it) and 41782871819 (with it), where the whole
export is 1.8 s and the phase read it replaces was 16% to 26% of that.

## What remains over 0.11.0

The remaining cost is 1.43 times 0.11.0's time over all 33 samples
(1.49, 1.51, 1.47 and 1.13 by release group, single samples 1.09 to
1.65). The issue's done-when is met as written: the stages that cost the
time are measured, each is cut, and the timing against 0.11.0 states
what is left per release.

The rest is tracked in #1335: the `FamilySymbol` definitions read, the
wall records, what is left of the phase pass, and the preamble.

The definitions pass's full `FamilySymbol` decode (117 ms of 1,775 on
2015 `rac_advanced`) is not cut here because a root-only read is not
value-neutral.

From the profile after the first three commits (2015 `rac_advanced`,
1,775 ms: definitions 236, wall records 173 of which the native preamble
45 and the first pass's record index 23, phase read 284 before the
direct reader):

- the parameter definitions pass decodes every `FamilySymbol` and
`Family` record in full (117 and 18 ms), but reads two root fields of
them (`m_id` and `m_familyId` or `m_categoryId`). A root-only read would
ingest a record whose full decode fails and which the pass now skips, so
`symbol_families` could differ. Not done, since it is not value-neutral;
- the wall records' top joins and type ids read the `SWall` graphs (180
records, 700,000 values);
- the preamble (schema, history, ElemTable, extensible-storage catalog)
is read once, 45 ms.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR: no
capability changes; `docs/status.md` already says `main` is ahead by the
fragments.
- [x] A user-visible change has its entry as a fragment under
`changelog.d/changed/`.
- [x] Not applicable: no limitation resolved or added. The read of the
parameters named for a property reads fewer records and the same values.
- [x] Commit messages say what changed and why.
- [x] No emojis in code, docs, or commit messages.
- [x] No private paths, personal email addresses, or internal jargon in
committed files.
- [x] Not a reverse-engineering finding.

## Legal and contribution hygiene

- [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] No new fixtures.

## Breaking changes

None to the stable API, the CLIs or any export (every Measure model, run
41793618569, 111 exports). `rvt::research` (unstable):
`native_element_parameters::read_defined_values` is replaced by
`read_property_values`; `native_document::Options` gains
`filtered_parameters_only`; `native_parameters` gains `Spans` and
`decode_object_fields_spanning`; `schema_registry::Registry` gains a
private field (it is built only by `parse`).

## Screenshots or output samples

N/A: IFC and diagnostics are byte-identical (above; every Measure model,
run 41793618569, 111 exports).

## Related issues

Closes #1237. Refs #1335, which tracks the remaining cost over 0.11.0.
Credit to puzzbobb for #1301, which this goes on from, and for naming
the same costs (the schema copy, the types decoded and never used, the
per-record digest) in #1237's step-level profile.

The profiling commits are archived at
`refs/archive/2026-11-04/scratch/1237-timings` (bb0c048, per-pass
timing and the check that a contributing record holds a definition's
id), `1237-timings-2` (1187a65, the profile after the first three
commits) and `1237-timings-3` (a57e12a, the Element base comparison).
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant