Skip to content

fix(research): pipe connectors, curve fields, room parameters and solids, sketch loops, empty faces, parameter bindings and family mesh checks are read through an index or under a work budget, so a crafted file cannot hang them (#1833) - #1849

Merged
DrunkOnJava merged 18 commits into
mainfrom
fix/1833-work-budgets
Nov 12, 2026

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

This bounds the rest of #1833: the readers that did work growing with the square or more of a count a crafted file sets. Each is fixed at its root. Where an index answers, the reader builds it once. Where none can, the reader counts its work against a budget no real model comes near. Past the budget, it leaves the element as an unread stream leaves it.

Every remaining #1833 site is here. The final unfiltered Measure runs on the head.

Motivation

Part of #1833. A and B are #1835; J, O and P are #1847. The designs came from Tendrils workers, a challenger tested each one's premises, and I re-read and reworked each against main. The challengers found eight of the sixteen designs flawed, and their cases shaped what is here. The plan with each site's repair is kept with the batch.

Changes

  • C, D, E src/research/partition_pipe_axes.rs:

    • scan_pipe_end_keys keeps each end's keys in order with a set beside them, where a contains made it quadratic.
    • BoxGrid::new stops, giving None, past MAX_GRID_CELLS (1,024 boxes at the per-box cap). Before, the per-box cap had no total.
    • The connector scans count each entry's near boxes or ends against MAX_CONNECTOR_TESTS (1e8). Past it they give nothing for the file. They do not truncate, since a match never reached could have decided a pipe (the challenger's case: a tie).
  • F src/research/partition_curve_fields.rs: the windows' entries and the boxes each is tested against count against the same budget, and a grid over its cells is skipped. The window is not narrowed: the challenger showed that could move a real element.

  • G src/research/partition_room_parameters.rs:

    • The three text, integer and name scans find each hit's data object in the stream's listed objects (memoised_partition_data_objects, data_object_owner), where each hit searched 200,000 bytes back. On the local corpus no verified header lies inside a listed object, so the owner is the one enclosing_data_object found.
    • data_objects reads each header's Adler-32 from sums kept every 256 bytes along the stream, so a header costs at most two blocks of reading whatever its size, and the pass is linear with no budget.
      • The first version capped verification at four times the stream. That cap was never measured, and real streams pass it. Headers that pass the size checks and fail their checksum cover Core Interior's Partitions/46 31.7 times over, one of them 94 MB of 99 MB. RE1 Architecture and Electrical reach 12.7x. The cap dropped nearly every data object (Corpus health, 9 tests).
      • Checked by a replica: 3,006 random ranges equal zlib's Adler-32, and the listing equals the full-checksum listing on every partition of Core Interior and RE1 Electrical.
  • H src/research/partition_room_boundaries.rs: the export reads solid_headers_for, which keeps headers for the stream's rooms alone, at most MAX_SOLIDS_PER_ROOM (16) each. A room is stored once or twice; past that it keeps its box. Probes keep the unbounded solid_headers_by_id.

  • I src/research/element_record_plan_profiles.rs: the loop solve charges each vertex lookup, edge check and candidate pair against SOLVE_WORK_BUDGET (1e8 a sketch owner) before it is spent.

    • A slab's sketch has tens of lines (Core Interior's plates own 57, RE-95).
    • Past it the owner has no plan profile and keeps its box. Each owner needs its own records, so the whole is linear in the file.
  • K src/research/native_empty_faces.rs: EmptyTrimIndex walks a graph once and answers every face. The saved-mesh pass keeps one per owner graph. Each answer is the one the per-face walk gave, which the challenger checked case by case.

  • M src/reader.rs: the header_hits memo is held under 64 MiB, dropped whole past it (RE-144: 0.4 MiB at most on the reference models). A reader keeps its Arc.

  • Each stop is reported (src/budget.rs, src/reader.rs, src/ifc/mod.rs record_work_budget_stops). A budget site notes its stop (budget::stopped("pipe_connector_tests"), and so on). The export writes a work_budget_reached skipped item counting each reader's stops, and a Work budget reached: warning per reader, as it does for a stream a limit kept out.

    • The readers that stop hold no handle, so each notes on its thread. A budget::Notes collects what is noted under the walk and under each export, and the handle keeps it, as it keeps its unread streams. The walk is memoised on the handle and holds every site here, so a second export, or an export after elements(), reads it back and still reports the stops.
    • A note under no Notes is dropped: a reader called on its own, or on a saved-mesh worker thread. Every site here runs on the export's thread.
    • ExportDiagnostics::is_partial is the one test of an incomplete export: an unread stream or a budget stop. rvt-ifc and rvt-gltf print the readers that stopped and exit 3 unless --allow-partial, as for an unread stream. Python's write_ifc raises ValueError unless allow_partial=True. The MCP server's exports refuse unless allow_partial, and list the readers in notes and partial.
    • The export-decisions count contract (tests/export_decisions_counts.rs, the schema text and docs/export-diagnostics.md) exempts the item, as it exempts stream_not_read_resource_limit: it counts stops, not elements.
  • changelog.d/security/1833-work-budgets.md.

  • N src/research/native_parameter_definitions.rs:

    • seal_bindings, called where the definitions pass ends, matches each (category, kind) a binding names once, with its backlink check. matching_bindings reads that answer.
    • Before, every record of a category rebuilt every matching definition's backlinks. Same order, same keys.
    • A failure keeps the message error.to_string() gave, which is all the record's diagnostic keeps. An unsealed registry computes as before.
  • Q src/research/native_form_geometry.rs:

    • The mesh comparison counts surface_samples' points and makes only the ones its stride takes, each from its place in that order (SurfacePlan). The points and the max are the same.
    • Before, every point was made first, up to millions for a crafted family. The probe keeps surface_samples.
  • R src/research/partition_scanner.rs: each stream scan takes the cap's remainder, the pattern partition_arc_walls uses. The candidates kept are the same first ones, and a stream can no longer double the cap.

    • The default stays None (the caller's choice; a research API with no in-tree caller). Setting one needs per-file totals over the corpus first, which the challenger asked for.
  • L src/reader.rs: the inflated-partition memo is held under INFLATED_MEMO_BUDGET_BYTES, 16 GiB (Griffin, 2026-11-12, "Bound it at 16 GiB").

    • Each stream's inflate was capped, but not their sum.
    • No real file comes near: the 1.13 GB client model peaks at 5.1 GB in all (docs/viewer-api.md).
    • Past it the memo is let go before the next stream joins, and a reader keeps its Arc.
    • Partition progress now counts each stream inflated once, held or not, so a release no longer lowers it (the challenger's note on release_inflated_partitions).

Testing

  • Unfiltered Measure, timed, against the merge-base 8421e655 on 13324f32: 43324820431. It replaces 43320809907, cancelled once Corpus health showed the first data-object cap dropping data on real files.

    • Every export and diagnostics hash equals the base's: ifc.sha256 on 146 of 146 models and diagnostics.json on 121 of 121. Every scorer file is equal too; the only difference is output the head alone writes (probe.txt, areas_across_saves*). No real file reaches a budget: one that did would move its pipes' ports, curve fields, room parameters, room outlines, slab profiles, saved-mesh counts, the parameter sets of --revit-property-sets or the family extrusions' mesh agreement, and its diagnostics would name the stop.
    • Timing row, registered before the run: median head/base at or below 1.00 over the 2023 to 2027 samples, no file above 1.03. It holds: median 0.962 (0.917 to 1.007) over those 29 samples, and none more than 3% slower. The models' median is 0.958, since the range sums read each data object's checksum from two blocks instead of its whole payload.
    • Peak memory was not a registered row. Every group's median is 1.000. Snowdon Plumbing reads 473 MiB at the base and 497 at the head (1.051), and Snowdon HVAC 250 and 235 (0.94). The base commit 8421e655 itself reads 474 and 496 for Plumbing and 235 for HVAC in run 43317496752, so both files land in one of two peaks run by run, whatever the code.
  • No repro. Each site needs a crafted file of thousands of elements. Each was verified by reading. No run exercises the new exit-3 path, since no real file stops.

  • tools/check-local.sh: not run locally (no local builds); CI runs it

  • Real files: the unfiltered Measure

Audit-honesty checklist

Legal and contribution hygiene

  • Apache-2.0; no Autodesk source

Breaking changes

None. Two new stable methods, ExportDiagnostics::is_partial and ExportDiagnostics::work_budget_stops, and rvt::cli::work_budget_report. In rvt::research there are two new items, solid_headers_for and EmptyTrimIndex, plus MAX_SOLIDS_PER_ROOM. rvt-ifc and rvt-gltf exit 3 where a reader stopped at a work budget, which no real file does.

https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge

@DrunkOnJava DrunkOnJava changed the title fix(research): pipe connectors, curve fields, room parameters and solids, sketch loops and empty faces are read through an index or under a work budget, so a crafted file cannot hang them (#1833) fix(research): pipe connectors, curve fields, room parameters and solids, sketch loops, empty faces, parameter bindings and family mesh checks are read through an index or under a work budget, so a crafted file cannot hang them (#1833) Nov 12, 2026
…rtition progress counts each stream once (#1833 L)

Each stream's inflate is capped and their sum was not, so a crafted file of
many streams held every one. Past 16 GiB (no real file comes near: the
1.13 GB client model peaks at 5.1 GB) the memo is let go before the next
stream joins it. Progress now counts streams inflated, held or not, so a
release no longer lowers it. Griffin, 2026-11-12: "Bound it at 16 GiB".

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…t, and a registry change unseals its bindings (#1833)

rvtReview's read of #1849: unused_qualifications failed the MSRV job at
reader.rs (size_of, and the new BTreeSet fields) and rooms.rs (BTreeSet).
Registry::insert and ingest_binding_context now clear the seal, so a caller
after a change matches afresh rather than reading a stale answer.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…rt's diagnostics, as a stream a limit kept out does (#1833, #1845)

The budgets left out what was past them silently. Each stop is now noted
(crate::budget, one thread-local recorder: the readers that stop hold no
handle, and the export reads on one thread), reset when an export starts,
and record_unread_streams writes a work_budget_reached skipped item counting
each reader's stops, with a "Work budget reached:" warning per reader. No
real model is known to reach a budget, so real exports' diagnostics are as
before. The CLIs' exit status is unchanged: no limit can be raised to lift a
budget, unlike --large-model for an unread stream. The export-decisions
count contract, its test and the schema text exempt the item as they exempt
stream_not_read_resource_limit.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…1833)

SurfacePlan's sample takes is_multiple_of, the sealed bindings' type is
named (type_complexity), and the pipe end match joins its two conditions
(collapsible_if).

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…its stream, so listing a stream's objects is linear and needs no budget (#1833)

The 4x budget #1849 gave data_objects was never measured, and real
streams pass it: a header that passes the size checks and fails its
Adler-32 is common, and on Core Interior's Partitions/46 such headers
cover the 99 MB stream 31.7 times over (one 94 MB), 32.6x in all; RE1
Architecture and Electrical 12.7x, Plumbing 7.6x, Mechanical 4.5x. The
budget stopped at byte 302,226 of Partitions/46 and the export lost
nearly every data object: its export overrides, type GlobalIds and the
slabs they make shading devices (Corpus health, 9 tests).

The checksum covers the class word and the payload less its last 4
bytes, which lie together. The sum of the bytes and of each byte times
its offset, kept modulo 65521 every 256 bytes, give Adler-32's A and B
for any range in at most two blocks of reading, so every header costs
the same whatever its size. Checked by a replica before this commit:
3,006 random ranges equal zlib's Adler-32, and the listing equals the
full-checksum one on every partition of Core Interior (61,445 objects on
Partitions/46) and RE1 Electrical. Nothing stops, so the reader no longer
notes a work-budget stop.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…thon and the MCP server refuse a partial export for them as for an unread stream (#1833)

The stops were a per-export thread-local, reset when an export began.
The walk is memoised on the handle and holds every #1849 reader (rooms,
slabs and MEP run under recover_partition_schema_mvp), so a second export
of a handle, or an export after elements(), read the walk back, stopped
nowhere, and reported nothing; native_phases' re-export test would fail
on any file that stopped. Now budget::Notes collects the stops noted
under the walk and under each export and the handle keeps them, as it
keeps its unread streams, and the diagnostics report what the handle
holds. A note under no Notes, from a reader called on its own or on a
saved-mesh worker, is dropped, as the module doc says.

ExportDiagnostics::is_partial is the one test of an incomplete export:
an unread stream or a work_budget_reached item. rvt-ifc and rvt-gltf
print the readers that stopped and exit 3 unless --allow-partial, as for
an unread stream; Python's write_ifc raises ValueError unless
allow_partial=True; the MCP server's exports refuse unless allow_partial
and list the readers in notes and partial. record_unread_streams keeps
its signature and its main behaviour; record_work_budget_stops is new
and crate-private. The help texts, docs/python.md, the stub and
docs/export-diagnostics.md say so, and the changelog fragment.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
@DrunkOnJava
DrunkOnJava merged commit 7693fc2 into main Nov 12, 2026
65 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/1833-work-budgets branch November 12, 2026 23:50
DrunkOnJava added a commit that referenced this pull request Nov 12, 2026
…cells and space containment note their stop, so an export that reaches one says so (#1845)

Each left its shape out or its element uncontained without a word. Each
now calls budget::stopped, as #1849's readers do: the export's
diagnostics list it under work_budget_reached, and rvt-ifc and rvt-gltf
exit 3 unless --allow-partial. All six run on the export's own thread,
inside the notes export_rvt_doc and run_export_with_limits_and_control
open. The diagnostics doc and work_budget_stops say a count is how often a
reader stopped on the open file (rvtReview's note on #1849).

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
…itten, with a warning, and only an unread stream makes it partial (#1833, #1845)

Griffin, 2026-11-12, asked whether an export that trips one of the new
stops should still be written: "Write it, with a warning". #1849 had made
any stop refuse the whole export (rvt-ifc and rvt-gltf exit 3 with no
model, Python raised, the MCP server refused), so one stop on a dense
curtain-wall grid would have blocked a real model.

ExportDiagnostics::is_partial now covers unread streams alone. rvt-ifc and
rvt-gltf print the stops as a warning and write the model; Python's
write_ifc and rvt_to_ifc give a RuntimeWarning; the MCP server's notes name
them. The diagnostics, the docs and the 1833 and 1845 fragments say so.
DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
…p writes streams whose names Windows refuses (#1845) (#1855)

## Summary

Batch 4's CLI auditor read 9 of the 19 binaries. I read the other ten:
gen-fixture, rvt-capabilities, rvt-diff, rvt-dump, rvt-elem-table,
rvt-ifc-compare, rvt-schedule, rvt-schema, rvt-sheet and rvt-write. None
can panic on a file. Two do the wrong thing with one:

- **`rvt-write`** decoded a manifest's unpadded base64 wrong. An
unpadded last group came out as three bytes whatever its length, and an
`=` inside the text as zeros, so the stream was patched with bytes the
manifest never gave.
- **`rvt-dump`** stopped on Windows at a stream whose name holds a
character Windows refuses in a file name or names a device. Two streams
whose names became one file name wrote to the same file, so the later
one replaced the earlier without a word.

It also takes a follow-up of #1833:

- **`partition_mep_systems` and `partition_curtain_materials`** verified
the data object around every place a class word occurs, each with a full
Adler-32 of its payload. That is quadratic on a crafted stream. They now
read the stream's listed data objects instead
(`memoised_partition_data_objects`), which give the same objects.

- **The bounds #1848 put on wall tops, envelopes, mullion grid cells and
space containment** left the shape out, or the element uncontained,
without a word. Each now notes its stop, as #1849's readers do, so an
export that reaches one is reported partial.

- **A stop no longer blocks the export (Griffin, 2026-11-12).** Asked
whether an export that trips one of the new stops should still be
written, Griffin chose "Write it, with a warning". #1849 had made any
stop refuse the whole export, so one stop on a dense curtain-wall grid
would have blocked a real model. Now the export is written and the stop
is named as a warning. Only a stream a resource limit kept from being
read still makes it partial.

This is the batch's fifth PR.

## Motivation

Part of #1845. The scoreboard of batch 4 records the auditor's coverage
gap. These two are what reading the rest found.

## Changes

- `src/bin/rvt_write.rs` `decode_base64`:
- `=` pads only the end, and a group of n characters (2 to 4) holds n −
1 bytes.
  - Text ending in a lone character is refused, as is an `=` inside it.
  - A padded manifest decodes as before.
- `src/bin/rvt_dump.rs` `file_stem_for`, the file name each stream is
written under:
- A stream name's `<>"|?*` and control characters become `_`, as `/`
does.
- A device name Windows reserves (`CON`, `PRN`, `AUX`, `NUL`, `CONIN$`,
`CONOUT$`, `COM0`–`9` and `LPT0`–`9`, the superscript `COM¹`–`³` and
`LPT¹`–`³`, whatever follows the first `.`) takes a `_` in front.
- A name another stream of the dump already has, compared without case
as macOS and Windows file systems compare names, takes `~2`, `~3` and so
on (rvtReview's two notes).
- A trailing dot or space cannot end a file name, since `.decomp` or
`.raw` follows it.
- The cfb crate already refuses `\`, `:` and `!` in entry names
(`direntry.rs` validates every name it reads), so no name leaves
`--out`.
- Revit's own stream names hold none of these and none collide, so their
files keep their names.
- `changelog.d/fixed/1845-cli-base64-and-dump-names.md`.

- `src/research/partition_mep_systems.rs` and
`src/research/partition_curtain_materials.rs`: each stream's objects of
the wanted classes come from its listed data objects.
- The loops keep their order, class first, then offset, since the first
class and the last material read win.
- The listing takes the first verified object, then the next past its
end. A verified object inside another's payload would be missed, and the
per-hit check would find it. A census of the local corpus finds none:
RE1 Architecture, Electrical, Mechanical and Plumbing, Einhoven,
rac_advanced 2024 and Core Interior hold 349,320 verified data objects,
all of them listed. #1849 made the same change for the room parameters'
owners, and its Measure moved no export.

- `budget::stopped` at #1848's bounds:
- `src/ifc/export_content/wall_tops.rs`: `wall_top_pieces` (the cut
pieces or the pieces held past `4 × MAX_RISERS`),
`wall_top_covered_parts` (`MAX_COVERED_PARTS`), and
`wall_top_embedded_pieces` (the stub test's pieces past `4 ×
MAX_RISERS`).
- `src/ifc/body_geometry.rs`: `envelope_pieces`, where the envelope's
pieces, their points or its sides pass their caps.
- `src/ifc/mesh_volume.rs`: `mullion_end_cells`, once per pass, where a
grid cell holds more than `MAX_ENDS_PER_CELL` mullion ends.
- `src/ifc/export_content.rs`: `space_containment`, past
`SPACE_CONTAINMENT_BUDGET`.
- All six run on the export's own thread, inside the notes
`export_rvt_doc` and `run_export_with_limits_and_control` open. None
runs on a saved-mesh worker, whose threads keep no notes.
- `docs/export-diagnostics.md` names them and what each leaves out. With
`ExportDiagnostics::work_budget_stops`, it says a count is how often a
reader stopped on the open file, since an export made again adds the
stops of a reader it runs again (rvtReview's note on #1849).
  - `changelog.d/security/1845-geometry-budget-stops.md`.

- **38cbd20c, a stop is a warning:**
- `ExportDiagnostics::is_partial` covers unread streams alone.
`work_budget_stops` still lists the stops.
- `rvt-ifc` and `rvt-gltf` print `warning: N reader(s) stopped at a work
budget ...` with each reader, then write the model. `--allow-partial`
and exit status 3 are for unread streams alone, and their help says so.
- Python's `write_ifc` and `rvt_to_ifc` give a `RuntimeWarning` naming
the stops (`warn_runtime`) and raise `ValueError` only for unread
streams.
- The MCP server's exports no longer refuse on a stop. Their notes say
`Warning: <reader> stopped N time(s) ...`.
- `docs/export-diagnostics.md`, `docs/python.md`,
`python/rvt/__init__.pyi` and the 1833 and 1845 fragments follow.

## Testing

- `rvt-write`: `tests/cli_real_files.rs` patches real files through the
CLI with padded base64, which decodes the same.
- The new decoding rule was checked in Python against its `base64`
module: 1,200 padded and 1,200 unpadded random encodings round-trip, and
`Q`, `QUJD=Q`, `Q=QQ` and `QUJDR` are refused.
- No Rust test is added: the helper sits in a binary, whose unit tests
CI does not run.
- `rvt-dump`: no export changes. No file in the corpus has such a name.
- Unfiltered Measure, timed, of `b6523d9c` against its merge-base
`7693fc29` (samples, families, Nordic, Revit 2025, BIMcollab,
rac_advanced, held-out):
[43332394339](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43332394339).
Rows registered before it ran:
1. Every `ifc.sha256` and `diagnostics.json` equals the base's, with no
model missing either. A stop makes the export partial, and `rvt-ifc`
then writes no model (exit 3), so a file that reached one of the new
stops would show as a missing `ifc.sha256` and a diagnostics file
gaining a `work_budget_reached` item, not as a moved export (rvtReview).
One whose MEP system or curtain material came from an object outside the
listing would move its export.
2. Timing: median head/base at or below 1.00 over the 2023 to 2027
samples, and no file above 1.03.
3. Peak memory is not judged from this run: Snowdon HVAC and Plumbing
each land in one of two peaks run by run on the same code (rvtReview's
control run 43329577007).
- Unfiltered Measure, timed, of `c88338b1` (38cbd20 with main merged)
against its merge-base `b411ca46`:
[43349709171](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43349709171),
with the same rows 1 to 3. No corpus file reaches a stop, so the warning
path changes no export.
- **43332394339, read against those rows: both hold.**
1. `ifc.sha256` is equal on 146 of 146 models and `diagnostics.json` on
121 of 121, with none missing and no `work_budget_reached` item in any.
The scorer diff has only output the head alone writes.
2. Median head/base 0.994 (0.959 to 1.006) over the 29 samples of 2023
to 2027, none above 1.03.
- Outside row 2's set, 2015 rac_advanced reads 1.038. On 2015 the change
adds only a `budget::stopped` call that never fires, and the other 29
samples of 2015 to 2022 have a median of 1.006. No peak is more than 2%
higher.

- [ ] `tools/check-local.sh`: not run locally (no local builds); CI runs
it
- [x] `rustfmt --edition 2024 --check`

## Audit-honesty checklist

- [x] No claim beyond what ships
- [x] Changelog fragment
- [x] No emojis or private paths

## Legal and contribution hygiene

- [x] Apache-2.0; no Autodesk source

## Breaking changes

None released. `rvt-write` refuses base64 text that ends in a lone
character or holds `=` inside it, which it used to decode wrongly. A
work-budget stop no longer makes an export partial: on `main` since
#1849 it refused the export, a behaviour no release shipped.

https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
DrunkOnJava added a commit that referenced this pull request Nov 15, 2026
…y default and says so, from what the 28 real files of Revit 2023 and 2024 keep (#1833) (#2031)

## Summary

`ScanOptions::default()` now stops at 16,777,216 candidates (2^24), and
`PartitionScan::truncated` says when a scan reached the cap. It was the
one site of #1833 left: the research API's partition scanner, which kept
every schema tag followed by two zero bytes with no limit.

## Motivation

#1833 site R: a stream holds up to one candidate for every four of its
bytes, and each takes about 250 bytes (160 inline, and three short
strings), so a crafted stream could take about 67 GB of candidates from
the 1 GiB the reader lets a stream inflate to. The comment on #1833 said
a default cap needs the candidate totals of real files first, so that it
never cuts a real scan. This is that measurement.

**Measured** (Measure
[43663157788](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43663157788),
`probe_1833_scan_candidates`, the 28 files of Revit 2023 and 2024 it
read; the scanner returns nothing on other releases):

- The most candidates in one file: 9,675,757 (the BIM4LCA timber office
at building permit, 696 MB inflated, 59 streams).
- The most in one stream: 6,531,651 (Autodesk's Snowdon Towers
architectural sample).
- The fullest stream holds 14.7% of the one-in-four-bytes maximum (the
BIM4LCA office at permit). The median file holds one candidate for every
82 bytes, and the range is 57 to 171.
- A candidate is 160 bytes inline (printed by the probe). The strings'
heap is counted at 3 x 32 bytes and is not measured.

So the default is 2^24, 1.7 times the most any of them keeps. A real
file at that figure takes about 2.4 GB of candidates today, so the cap
does not make the research scan cheap; it stops a crafted stream at
about 4 GB where it could take 67 GB.

## Changes

- `src/research/partition_scanner.rs`: `DEFAULT_MAX_CANDIDATES` (2^24)
with the measurement in its doc comment, the default `ScanOptions` and
`arcwall_2023_only` use it, `PartitionScan::truncated`
(`#[serde(default)]`), a "Budget" section in the module docs.
- `examples/partition_scanner_json.rs`: keeps the default cap unless
`--max-candidates` or the new `--no-cap` is given (it set `None` when
the flag was absent), and prints `truncated`.
- `probes/examples/probe_1833_scan_candidates.rs`: the probe, which
prints `truncated` too.
- `tests/partition_scanner.rs`: a real-file check
(`einhoven_scan_says_when_it_reached_the_cap`): Einhoven's default scan
is not truncated, and with `max_candidates` 10 the scan is truncated and
lists the first 10 candidates of the whole scan.
- `changelog.d/security/1833-scan-candidates-cap.md`.

## Testing

Measure
[43664481547](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43664481547),
unfiltered against the merge base, with samples, nordic, r2025 and
holdout, and the probe run
[43664485165](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43664485165)
on the 2023 and 2024 files. Rows registered before they are read:

1. Every export and every `diagnostics.json` is byte for byte the merge
base's: nothing in the export or the CLIs calls the scanner. **Held**
(run 43664481547, head `0dd5143c`, the commit holding every `src`
change; the later commit adds a test): 120 of 120 exports and 102 of 102
`diagnostics.json` identical to the merge base.
2. The probe reports `truncated=0` on all 28 files and the same
candidate counts as run 43663157788. **Held** (run 43664485165, head
`0dd5143c`): `truncated=0` on all 28 supported files, and release, scan,
streams, inflated bytes, candidates, largest stream and fill are
identical to run 43663157788 on all 33 models, the most candidates in a
file still 9,675,757.
3. `same-project gates` pass. **Held** on `0dd5143c`: 15 samples held to
their earlier saves, and the Areas on 4 saves and on the 2021 save; the
semantic diff finds no difference in 42 models.

- [ ] `tools/check-local.sh`: no local builds; `rustfmt --check` passes;
CI runs the rest.

## Audit-honesty checklist

- [x] The figures above are from the run named; the 250 bytes per
candidate is arithmetic on the measured 160 plus an assumed 96 for the
strings, and the changelog says "about".
- [x] A changelog fragment.
- [x] No emojis, private paths or jargon.

## Legal and contribution hygiene

- [x] Apache-2.0; no Autodesk source; no fixtures.

## Breaking changes

`PartitionScan` gains a field, and `ScanOptions::default()` now caps the
scan. Both are in `rvt::research` (behind `unstable-research`). A caller
that needs more than 2^24 candidates sets `max_candidates` to `None`.

Closes #1833: sites A to Q landed in #1835, #1847 and #1849, and this is
R.
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