Skip to content

fix(native): bound the storage increment table's values by its size (RE-78) - #758

Merged
DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
Persus1337:storage-increment-budget
Oct 18, 2026
Merged

DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
Persus1337:storage-increment-budget

Conversation

@Persus1337

Copy link
Copy Markdown
Contributor

Summary

On two Revit 2024 houses rvt-ifc --saved-meshes read no saved graphics at all: the native preamble stopped in Global/DocumentIncrementTable on the 100,000-value default budget, so every family instance stayed a box. The table's format is the same as in every other file; it is just bigger. Its value budget is now the larger of the default and the stream's byte length.

Motivation

rvt-ifc ARK_NordicLCA_Housing_Timber_BuildingPermit.rvt -o out.ifc --saved-meshes
rvt-ifc: saved graphics not read, bodies unchanged:
  DocumentIncrementTable.m_localIncrements at 418669:
  DocumentIncrement.m_incrementVersions at 418669:
  native field value budget exceeded (100000)

Decoded with a larger budget, the table holds 109,543 and 106,289 values on the two timber houses. On all 15 project files I have (twelve BIM4LCA models, Core Interior, Einhoven, the flowbim.ee 2026 house from RE-124) it spends 3.95 to 4.49 bytes per value, so one value per byte bounds it with about 4x margin without capping large documents. What would falsify this: a table that needs more values than it has bytes.

Changes

  • src/native_parameters.rs: decode_object_fields_with_limits takes explicit GraphLimits; decode_object_fields calls it with the defaults (no behaviour change).
  • src/native_index.rs: storage_increments decodes with max_values = max(default, bytes.len()). Every other decode keeps the default.
  • reports/element-framing/storage-increment-table-budget.md: the per-file table, the measurement and what is not claimed.

Testing

  • tools/check-local.sh passes (fmt, clippy, rustdoc, build, real-file / CLI / contract checks), with RVT_SAMPLES_DIR and RVT_PROJECT_CORPUS_DIR set: 231 passed, 0 failed.
  • Verified end to end on real Revit files:
    • Files: BIM4LCA / Nordic LCA architectural models (Gravicon 2024, Revit 2024 build 20230411_1515), published by Nordic Sustainable Construction under CC BY-SA 4.0 with Revit's own IFC4 export of each (ARCH.zip, linked from VTT's "BIM files to download" page). Not committed. One caveat: the publisher's site footer says "all rights reserved", which the page does not reconcile with the CC BY-SA statement for the models; only measurements on them are in this PR.
    • Command: rvt-ifc <model>.rvt -o <model>.ifc --saved-meshes --diagnostics <model>.diagnostics.json
    • Housing_Timber_BuildingPermit: bodies from saved meshes 0 -> 1,022 of 1,083. Housing_Timber_As-Built: 0 -> 1,026 of 1,087.
    • Against Revit's export with tools/re/saved_meshes_vs_ifc.py (IfcOpenShell 0.8.5), as in RE-78: python3 tools/re/saved_meshes_vs_ifc.py <rvt-rs.ifc> ARK_NordicLCA_Housing_Timber_BuildingPermit_Revit.ifc --source saved_graphics_mesh --rotate-deg -60.631748527001605 (Revit's site placement turns its export by that angle; the residual offset is then zero). Of 1,022 bodies: 867 within 0.01 ft, 44 within 0.1, 59 within 1, 9 over 1 ft, 43 with no reference in Revit's export; the per-class table is in the report. The bodies outside 0.01 ft are saved meshes native_saved_mesh decodes only in part (51 of them doors whose frame Geometry is dropped by one rejected face), a separate gap.
    • Every other file's IFC is unchanged (header timestamp aside); Core Interior and Einhoven give byte-identical glb and diagnostics.
  • IFC exporter: only the two timber houses' output changes. I ran ci.yml's IFC steps locally (Python 3.12, IfcOpenShell 0.8.5, release build instead of --profile ci): tier-1 export + ifcopenshell.validate + schema arity, validate-real-ifc.py on Einhoven, schema validation of Einhoven and Core Interior, and both OctetProof verdicts for Core Interior (full and slim): status: PASS, replay match for rvt-rs, IfcOpenShell and IFClite against the committed observations.
  • N/A: not a performance change.

No test is registered: the change needs the BIM4LCA files, which are not among CI's corpora, and on the corpora CI has the output is unchanged.

Audit-honesty checklist

  • No docs claim changes: --saved-meshes stays experimental; docs/status.md and docs/support-matrix.json are untouched.
  • N/A: no listed limitation is resolved by this alone.

Provenance

The changes in this PR are based on byte observations on the BIM4LCA sample files and comparison with Revit's own IFC export of the same files. I have not used Autodesk SDK source, ODA SDK source, leaked internal documentation, NDA material, or decompiled internal Revit implementation code beyond public symbol exports.

🤖 Generated with Claude Code

@helenkwok

helenkwok commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Independent check of this fix in a separate fork, done on the same two files, Revit 2024 BIM4LCA Housing_Timber (CC BY-SA 4.0). Nothing from the files is quoted, only counts.

Same change, same effect. On the base, rvt-ifc --saved-meshes fails on both houses with "native field value budget exceeded (100000)" in DocumentIncrementTable.m_localIncrements (BuildingPermit at offset 418669, As-Built at 418705). With max_values = max(default, bytes.len()) for the increment table only, bodies from saved meshes go from 0 to 1,022 of 1,083 (BuildingPermit) and from 0 to 1,026 of 1,087 (As-Built). These are exactly your numbers.

saved_meshes_vs_ifc.py against Revit's IFC4 for BuildingPermit, with --rotate-deg -60.631748527001605: file-wide offset (0.0, 0.0, 0.0) ft, 1,022 bodies, 867 within 0.01 ft, 44 within 0.1 ft, 59 within 1 ft, 9 beyond 1 ft, 43 without a reference. Per-class rows are identical to your table. With the same angle As-Built gives 1,025 scored (the 1,026th is an IfcOpeningElement, which the script skips): 870 / 44 / 59 / 9 / 43.

No side effects seen. On the 27 models we test (12 Nordic LCA, 7 Snowdon Towers, DACH and 7 other Autodesk samples), the export without --saved-meshes is unchanged (header timestamps aside). With --saved-meshes, only the two timber houses change: the other 25 give identical IFC on base and fix. Reading the saved graphics takes about 12 s more on these houses (7 s to 19 s), the same ratio as the other houses we measured (concrete house 7 s to 18 s).

We added a real-file test that asserts the four numbers above. It fails on the base with the budget message and passes with the fix. Your report says no test is registered because the files are not in CI; it is a skipped test when the folder variable is unset, so it could be registered the same way as column_cut_body.

Persus1337 and others added 2 commits October 18, 2026 05:08
…RE-78)

Global/DocumentIncrementTable grows with the document. On the two BIM4LCA
timber houses (Revit 2024) it holds 109,543 and 106,289 values, past the
100,000-value default budget, so the native preamble failed and no saved
graphics were read: every family instance stayed a box. The table's
format is the same as in the other files.

On all 15 project files measured the table spends at least 3.9 bytes per
value, so its value budget is now the larger of the default and its byte
length. Other decodes keep the default.

Housing_Timber_BuildingPermit: 0 -> 1,022 of 1,083 box bodies from saved
meshes, 867 of 979 scored bodies within 0.01 ft of Revit's IFC export (the
rest are saved meshes decoded only in part). Housing_Timber_As-Built
0 -> 1,026 of 1,087. Every other file's IFC unchanged; Core Interior and
Einhoven glb and diagnostics identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DrunkOnJava
DrunkOnJava force-pushed the storage-increment-budget branch from 872722c to 8f3ab99 Compare October 18, 2026 09:08
@DrunkOnJava

Copy link
Copy Markdown
Owner

Thank you, and sorry for the wait. GitHub holds a new account's CI until a maintainer approves the run, and nobody was watching the queue for two weeks.

The change is right, and its bound is the right shape: max(default, bytes.len()) only for the increment table. The budget stays proportional to the input, so a hostile stream can't buy more values than it has bytes, and a large document is no longer capped. Thanks also to @helenkwok for reproducing your numbers independently on the same two houses.

As on #737 and #738, I replaced your two commits with the same changes, signed and rebased onto current main (main requires signed commits), with you still the author. CI on the original base passed everything except the lockfile advisory #747 fixed. I approved the new run. Your account is new to GitHub, so each push still needs that approval until your first PR has merged.

On tests: as your report says, CI has no BIM4LCA file, so a corpus-gated test would skip there. It's fine to land without one. Getting the BIM4LCA set into a CI tier, so tests like this actually run, is maintainer work I'm tracking separately. This lands once CI is green.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 18, 2026 09:13
@DrunkOnJava
DrunkOnJava merged commit 51ef747 into DrunkOnJava:main Oct 18, 2026
25 checks passed
DrunkOnJava added a commit that referenced this pull request Oct 18, 2026
[Unreleased] becomes [0.5.0] — 2026-10-18, with an introduction, the
contributors, and what to change when upgrading from 0.4. The community
pull requests' entries are added and credited (#737, #738, #744, #751,
#752, #753, #755, #757, #758), and the repeated Added, Changed, Fixed and
Research headings are folded into one each, keeping every entry (107) and
its order; everything from [0.4.0] down is unchanged.

CITATION.cff said 0.1.2 (2026-04-20), though RELEASE.md has it agree with
Cargo.toml at every tag. Its abstract now describes the project as the
README does, without the "first open-source tool" and "verified against
11 releases" claims.
DrunkOnJava added a commit that referenced this pull request Oct 18, 2026
## Summary

Prepare v0.5.0. Merging this is not the release: the release is the signed `v0.5.0` tag on the merged commit, which runs `publish.yml` (crates.io, PyPI, the release binaries and the container image). The tag waits for the maintainer's go-ahead.

## Motivation

`main` is 0.4.0 plus everything under `[Unreleased]`: Revit 2026 projects (experimental), MEP ports, connections and systems, Revit's level, category, family, type and phase properties, rooms aggregated into their storeys, Snowdon Towers exporting again, and the first pull requests from outside contributors. Before 1.0 a breaking change bumps the minor version, and these are breaking for a 0.4 user:

- The MSRV is 1.87 (was 1.85).
- `rvt` has no `wasm` feature; the bindings are the `rvt-wasm` crate (C6).
- Each `IfcSpace` is aggregated into its storey instead of contained in it (#744).
- `ElemTableHeader::record_count` is a `u32` (#764).
- Type objects take Revit's GlobalIds (RE-167).

## Changes

- **Versions 0.4.0 → 0.5.0:** `rvt`, `rvt-py` and its pin, `rvt-wasm`, the `stream_evidence` pin, both lockfiles (only the workspace crates' version lines change), `.release-please-manifest.json` and `viewer/package.json`.
- **`CHANGELOG.md`:** `[Unreleased]` becomes `[0.5.0] — 2026-10-18`.
  - An introduction, the contributors, and an **Upgrading from 0.4** section.
  - The community pull requests' entries are added and credited (#737, #738, #744, #751, #752, #753, #755, #757, #758).
  - The repeated Added, Changed, Fixed and Research headings, which later merges had appended, are folded into one each. All 107 entries are kept as written (checked as a multiset) and in their order, and everything from `[0.4.0]` down is byte-identical.
  - #778's clean-room policy change is added under Changed, so the section has 108 entries.
- **`CITATION.cff`:** it said 0.1.2 (2026-04-20), though `RELEASE.md` has it agree with `Cargo.toml` at every tag. Its abstract now describes the project as the README does, without the "first open-source tool" and "verified against 11 releases" claims.
- **Registry descriptions:** crates.io showed 0.4.0's description, which leaves out Revit 2023, and PyPI one that called element extraction and geometry "active research" and the export "document-level IFC4 scaffolding". `Cargo.toml` and `pyproject.toml` now say what the README says: typed elements from Revit 2023 to 2025 projects, 2026 experimental.
- **Witnesses:** the IFC header carries the version (#417), so both Core Interior `rvt-rs.json` observations and their verdicts are refreshed from this pull request's CI run.

## Testing

- CI on this pull request: every job `CI passed` requires, the witness replays among them.
- On the tag, the publish workflow runs its own checks before anything is published: wheel install and model open on each OS, `cargo install` and the CLI sample smoke, the docs.rs build preview and the viewer load smoke. crates.io and PyPI publish only after all of them pass, and PyPI only after crates.io.

## Audit-honesty checklist

- The docs keep describing 0.4.0 as the latest release until each 0.5.0 channel has been checked from what was published. That follows in a separate pull request (`docs/install.md`, `docs/python.md`, `docs/status.md`, `docs/supported-profile.md` and the README's release section).
- crates.io's trusted publisher (repository DrunkOnJava/rvt-rs, workflow `publish.yml`, environment `crates-io`) has to be in place before the tag, as `docs/maintaining.md` says; it is a registry-side setting this repository cannot check.

## Legal and contribution hygiene

N/A: release metadata only. Contributors are credited by their GitHub names in the CHANGELOG.

## Breaking changes

Listed under Motivation, with the migration for each in the CHANGELOG's **Upgrading from 0.4**.
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.

3 participants