Repository navigation
fix(compression): bound the pre-decode reservation so multi-member streams fit wasm32 memory - #256
Merged
Merged
Conversation
…reams fit wasm32 memory inflate_at_with_limits reserved min(4 x remaining input, 256 MiB) for every gzip member, and inflate_all_chunks_with_limits keeps every member's buffer alive, so a stream with dozens of members reserved O(members x stream) bytes. Native allocators back untouched capacity lazily (rvt-ifc peaks at 427 MB RSS on 2024_Core_Interior.rvt); wasm32 linear memory commits every grown page, so the same call grew the viewer module to 4057 MB in 139 ms and trapped at the 4 GiB ceiling. Cap the reservation at 1 MiB in addition to the caller's output limit and trim the retained buffer. Route wasm panics to console.error so a trap reports its message and location instead of a bare unreachable. Core Interior now decodes under Node in 29 s with 419 MB of linear memory; Einhoven drops from 43 MB to 20 MB. Outputs are unchanged.
DrunkOnJava
enabled auto-merge (squash)
September 19, 2026 17:31
10 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Sep 19, 2026
…e CI audit path (#261) ## Summary Bring the prose docs up to what merged on `main` on 2026-09-19 (#256, #257, #258, #259, the four Dependabot bumps) and correct the slab-profile claim in `docs/status.md` that RE-25 had already invalidated. Docs, `README.md` and `CONTRIBUTING.md` only; no Rust, no `viewer/`, no `CHANGELOG.md`. ## Motivation `docs/status.md` reported 80 of 80 exact slab profiles from RE-25 and then, about 40 lines later, still said the slab profile "is still the bounding-box rectangle rather than the recovered boundary polygon (#31)". `docs/supported-profile.md` carried the same claim in its Unsupported list. Separately, nothing in the docs described the bounded wasm32 inflate reservation, the wasm panic hook, the hash-verified real-project demo gallery, or the `NOT MEASURED` npm audit path, and `docs/demos.md` still listed the web viewer as "not yet implemented". ## Changes - `docs/status.md` — review date to 2026-09-19; the stale slab-profile sentence now says the profile is the polygon its `OST_SketchLines` records close on 80 of 80 exported slabs, with the 20 rotated shading plates named as the remaining rectangle; new paragraph on the hash-pinned demo gallery; gzip and Browser viewer capability rows updated with the 1 MiB reservation cap and the real-project demos. - `docs/supported-profile.md` — the same stale slab claim replaced by the 20-shading-plate remainder, and the door/window host-wall binding no longer listed as unsupported (#222 matches Revit's `(host wall, filling element)` pair set on 138 of 138; it is the opening-index rows that carry no host claim). - `README.md` — viewer and demo-gallery paragraphs only: wasm32 memory behaviour and the panic hook, plus Einhoven / Core Interior sizes and measured load times. - `docs/viewer-api.md` — new "Panic reporting and wasm32 memory" section covering the seven byte-opening bindings that install `std::panic::set_hook`, `INITIAL_INFLATE_CAPACITY_BYTES`, and the before/after measurements. - `docs/viewer-build-pipeline.md` — states that VW1-01..24 shipped and the recipe is the built workflow; a "wasm32 linear memory is the real ceiling" subsection under VW1-20 so a future chunked path keeps the bound. - `docs/user-guide.md` — the two real-project demos and their honest decode times in the browser steps; the 801 of 872 storey-containment figure and the named 71. - `docs/demos.md` — the "Web viewer ... not yet implemented" bullet replaced by what actually ships and what is still missing (a broader redistributable real-project corpus). - `docs/supply-chain-policy.md` — the npm advisory 503 retry path, why a `NOT MEASURED` run is not evidence of clean dependencies, and how a measured advisory is still told apart by the output rather than the exit code (#258). - `CONTRIBUTING.md` — the same audit behaviour plus the narrower pull-request CI shape (#260, open as of 2026-09-19); a fuzz note explaining that `fuzz/` is outside the workspace gate, which is how `fuzz_step_writer` broke from #236 until #259. - `docs/contribution-map.md` — new "Open Remainders" section listing the six issues closed today and the named remainder behind each of #32, #33/#219, #23, #86 and #156. ## Testing N/A: docs-only PR. No Rust or TypeScript changed, so `cargo test` / `clippy` / `fmt` are unaffected by this diff. Verification performed instead: - Every number written was checked against the merged code or its commit: `INITIAL_INFLATE_CAPACITY_BYTES` and `shrink_to_fit` in `src/compression.rs`, the seven `install_panic_hook()` call sites in `src/wasm.rs`, the `sha256` / `size_bytes` entries in `docs/viewer-demos.json`, the two new Playwright tests in `viewer/tests/viewer-regression.spec.ts`, the retry block in `.github/workflows/ci.yml`, and the `#260` diff. - Relative Markdown links in all ten changed files resolve to existing paths. - `git diff --stat` confirms only `docs/`, `README.md` and `CONTRIBUTING.md` changed. ## Audit-honesty checklist - [x] README / docs reflect the current state after this PR - [x] A resolved limitation is updated: the slab boundary polygon moved out of the Unsupported list in `docs/supported-profile.md` and out of the stale sentence in `docs/status.md`, with the 20 rotated shading plates named as what is genuinely left - [x] No new limitation introduced - [x] Commit message describes what changed and why - [x] No emojis - [x] No private paths, personal email addresses, or internal jargon - [x] Not a reverse-engineering finding; no new probe or reconnaissance addendum needed ## Legal and contribution hygiene - [x] Licensable under Apache-2.0 - [x] No Autodesk proprietary source, decompiled internals, or NDA'd SDK content - [x] No new test fixtures; no real-world PII ## Breaking changes None. ## Screenshots or output samples N/A: docs-only PR. No UI or IFC output changed. ## Related issues Refs #256, #257, #258, #259, #260. Documents the 2026-09-19 closures of #30, #31, #66, #81, #83 and #87, and the named remainders on #32, #33, #219, #23, #86 and #156. Closes nothing. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Markdown-only changes with no runtime, CI workflow, or dependency edits in this diff. > > **Overview** > This **docs-only** PR brings README, CONTRIBUTING, and nine `docs/` pages in line with what landed on `main` on 2026-09-19 (#256–#259, related CI work), and fixes **stale capability wording** that still said slab plan profiles were bounding-box rectangles after RE-25. > > **Support-boundary honesty:** `docs/status.md` and `docs/supported-profile.md` now state that **80 of 80** exported slabs use closed sketch-line polygons; the **20 rotated shading plates** stay rectangle/`ProfileResolved: false`. Door/window **host-wall binding on the partition element-record carrier** is documented as closed (#222); opening-index rows remain unsupported for host claims. > > **Viewer and wasm:** README and `docs/viewer-api.md` / `docs/viewer-build-pipeline.md` describe the **1 MiB per gzip member** inflate reservation (#256), **wasm panic → `console.error`**, hash-verified **Einhoven / Core Interior** demo gallery (#257) with sizes and load times, and Playwright staging checks. `docs/demos.md` replaces “web viewer not yet implemented” with what ships vs a broader real-project corpus still missing. > > **Contributor / CI prose:** `CONTRIBUTING.md` and `docs/supply-chain-policy.md` explain **npm audit retries** and **`NOT MEASURED` warnings** when the advisory API is down (#258), plus **narrower pull-request CI** vs `main` (#260). CONTRIBUTING adds a **fuzz workspace** note: PR gates do not compile `fuzz/`—run nightly `cargo +nightly check --manifest-path fuzz/Cargo.toml` when changing types fuzz targets construct (#259). > > **Roadmap:** `docs/contribution-map.md` adds an **Open Remainders** table naming what is left after six issues closed the same day. `docs/user-guide.md` mirrors demo expectations and **801/872** storey containment with the named 71 unbound. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ac4354d. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
8 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Sep 19, 2026
## Summary Docs-only. PR #261 described the state at that moment; #266, #267/#268, #272, #273 and #274 landed after it and left several pages understating or contradicting what ships. Every number here is re-read from the linked report, the corpus gate, or the count manifest that backs it — nothing is carried over from the PR descriptions. ## Motivation Two pages disagreed with themselves. `docs/user-guide.md` gave both 853 of 872 and 801 of 872 storey containment in adjacent paragraphs, and quoted 336 of 360 walls, which #274 superseded. `docs/status.md` still said the wall-join decision "is in neither wall's box nor in 4 KiB past its record" — #274 found the carrier. Four pages still promised a ~28 second browser decode that #266 cut to about 3 seconds. The audit-honesty rule cuts both ways here: the same pass also had to avoid over-claiming #273, whose wall-type join is exact but emits nothing. ## Changes - **`docs/status.md`** — re-dated the RE-26 wall and column residuals as historical; added RE-29 (wall ends 689 → 711 of 720, bodies 336 → 351 of 360, 15 improved / 345 unchanged / 0 regressed, 9 residual ends at two true L corners; columns 176 → 256 of 256 at a worst residual of 9.4e-13 ft, `difference_box` fail-closed, `IFCPROPERTYSINGLEVALUE` 9231 → 9311) and RE-28 (the `0xffff8080` wall-type record, 360 of 360, distribution 129/127/100/4, #240 as an index artifact) with an explicit **library-side only, nothing emitted** paragraph; recorded #88's no-oracle finding and the 86-record `OST_Materials` bound; new `## Performance` section. - **`docs/user-guide.md`** — deleted the contradictory 801 of 872 paragraph; 336 → 351 of 360 plus the 256 of 256 column cut; added the #272 panel/schedule paragraph and a `### Performance` note; corrected the demo-gallery decode time. - **`README.md`** — the headline paragraph, the gaps table row and the demo-gallery line now carry the RE-27/RE-28/RE-29 state; new `### Performance on large projects`. - **`docs/contribution-map.md`** — the closed-issue list is now twelve issues, not six; the #33 / #219 row reads 853 of 872 and keeps the reference side marked `NOT MEASURED`; new rows for #238, #88, #227, #34 and #90; the closed #32 row is gone. - **`docs/support-matrix.json`** — `reviewed` to 2026-09-19; the walls and columns rows carry the RE-29 measurements and **stay `partial`**; a new `element-record-wall-type-join` row records RE-28 at `partial` with "None yet in the exported file" as its user impact; the instance-recovery and level-record rows no longer read 801 as current. - **`docs/supported-profile.md`** — IFC output and browser viewer rows; the compound-layer and family-profile bullets now name the no-oracle finding and the 9-end residual. - **`docs/ifc-compare.md`** — divergence table updated to the measured state, plus a plain statement that `catalogued_divergence_notes` in `src/ifc/compare.rs` still quotes the pre-#274 figures and still names #219 for slabs and windows. - **`docs/viewer-api.md` / `docs/viewer-build-pipeline.md`** — the #266 throughput and the `DECODE_BYTES_PER_SECOND` basis; the pre-#266 figures are kept but dated; the `build_gltf` `extras` fix and the panel / schedule contract from #272. ## Testing - N/A: docs-only PR — no Rust, viewer, workflow or test file is touched. - `docs/support-matrix.json` re-validated against `docs/schemas/support-matrix.schema.json` (required keys, `additionalProperties`, id pattern, status vocabulary, unique ids) and against the `honesty_invariants` that `tests/support_matrix.rs` enforces: `never_verified_capability_ids`, `max_status_by_capability_id`, and the COR-001 converter-grade rule. All pass; the new row is `partial`. - Every test and function name cited in the new prose was checked to exist: `the_surviving_side_of_a_true_l_corner_is_still_over_trimmed`, `core_interior_2024_column_join_cut_plan_extents`, `core_interior_2024_wall_joins_are_named_in_the_reference_list`, `core_interior_2024_wall_type_record_join`, `core_interior_2024_material_record_family`, `core_interior_2024_wall_join_trimmed_bodies`, `core_interior_2024_column_type_symbol_join`, plus `partition_type_records::{type_definition_ids, unique_type_reference}` and `element_record_column_cuts::{difference_box, column_cut_boxes}`. - `core_interior_2024_wall_join_trimmed_bodies` asserts `resolved == 360` and `trimmed == 322`, which is what the support-matrix evidence string now says. - Every relative link and repo path added resolves on disk. ## Audit-honesty checklist - [x] README / docs reflect the current state after this PR — no claims of features that are not actually shipped - [x] Resolved limitations updated: #239 (columns), #240 (the `18" Basement` slot), and the plate / window storey containment #219 tracked - [x] New limitations documented: the 9 true-L-corner ends, and #88 being unwitnessable on this corpus - [x] No emojis, no private paths, no personal email addresses - [x] N/A: no reverse-engineering finding is introduced here — the reports (RE-27, RE-28, RE-29) already shipped with their own PRs **Three claims deliberately not written:** 1. **Nothing about rooms.** `gh pr view 275` reported `OPEN` (checked twice, at the start and just before committing), so the existing space claims are untouched and `IFCSPACE` still reads "name-only, placeholder body" everywhere. 2. **The wall → `IfcWallType` join is never described as shipping in the export.** RE-28 §7 says "Library only. No emitted IFC entity, property or relation changes", and §8 says the join "is not yet a property on the emitted wall". Every mention says so explicitly. 3. **README's "419 MB of linear memory" is left alone.** That is a wasm32 figure from #256. #266 re-measured native peak RSS (490.1 MiB) and the browser decode time, but not wasm linear memory, so there is no measurement to replace it with. Also left as-is, and now flagged in `docs/ifc-compare.md` rather than silently papered over: the note constants in `src/ifc/compare.rs` still say "31 over-trimmed wall ends" and still name #219 for `IFCSLAB` and `IFCWINDOW`. Fixing those is a code change and out of scope for a docs-only PR. ## Legal and contribution hygiene - [x] I agree this work is licensable under Apache-2.0 - [x] No Autodesk proprietary source, decompiled internals, or NDA'd SDK content - [x] N/A: no new test fixtures ## Breaking changes None. ## Screenshots or output samples N/A: docs-only PR — no UI or IFC output changed. ## Related issues Refs #88, #219, #238, #239, #240, #266, #272, #273, #274. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation and support-matrix metadata only; no Rust, viewer, or export logic changes. > > **Overview** > **Docs-only refresh** so README, status, user guide, contribution map, supported profile, IFC compare notes, viewer docs, and `docs/support-matrix.json` match what landed after #266–#274 — without changing runtime behavior. > > **Capability numbers and gaps** are brought up to date: wall runs trimmed using the record **reference list** (351/360 world-exact, 9 L-corner ends still wrong), **column bodies** as prism minus named cutting walls (256/256), **storey binding** via record Level ids (853/872), and **wall→wall-type** join exact in the library but **not written to IFC** (#88 compound layers marked **no oracle** on the ReferenceView corpus). > > **Performance narrative** is added/updated everywhere it was still ~28s: partition inflate **memoized on `RevitFile`** (#266), Core Interior **~1.7s / ~490 MiB** native and **~3s** browser decode, byte-identical IFC aside from timestamps. > > **Viewer docs** now describe **glTF `extras`** for picking (#272), the typed info panel / schedule / host navigation, and **`DECODE_BYTES_PER_SECOND`** for loading hints. > > **Contribution map & matrix** list twelve closed issues, new remainder rows (#238, #88, #227, …), RE-29 evidence on wall/column rows, and a new **`element-record-wall-type-join`** row at `partial`. **`docs/ifc-compare.md`** documents the measured divergence table and explicitly notes that **`catalogued_divergence_notes` in `src/ifc/compare.rs` still lags** (separate code fix). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d5c32eb. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bound the capacity a DEFLATE member reserves before decoding, and route wasm panics to
console.error. Together these let the browser viewer open2024_Core_Interior.rvt(33.7 MB, the RE-21 to RE-26 witness file), which previously trapped withRuntimeError: unreachableabout two seconds in.Motivation
inflate_at_with_limitsreservedmin(4 x remaining input, 256 MiB)for every gzip member, andinflate_all_chunks_with_limitskeeps every member's buffer alive in its result list. A stream with dozens of members therefore reserved O(members x stream) bytes. Native allocators back untouched capacity lazily, sorvt-ifcpeaks at 427 MB RSS on that file; wasm32 linear memory commits every grown page, so the same call grew the module to 4057 MB in 139 ms and trapped at the 4 GiB ceiling. Without a panic hook the trap surfaced only asunreachable.Changes
src/compression.rs: cap the pre-decode reservation at 1 MiB (INITIAL_INFLATE_CAPACITY_BYTES) in addition to the caller's output limit;shrink_to_fitthe retained buffer. Regression testinflate_capacity_hint_does_not_scale_with_remaining_input(fails before: 32 MiB capacity for a 12-byte payload).src/wasm.rs: install astd::panic::set_hookonce, on the first byte-opening call, that reports the panic message and location throughconsole.errorvia a wasm-bindgenconsoleimport. No new dependencies; no network primitives.Testing
cargo test --lib compression::(25 passed; the new test fails before the fix)tools/check-local.sh --viewer2024_Core_Interior.rvtunder Node with the rebuilt wasm: OK after 29.4 s at 419 MB of linear memory (before:RuntimeError: unreachableafter 139 ms at 4057 MB)Revit_IFC5_Einhoven.rvtunaffected (control): 0.52 s, linear memory 20 MB (was 43 MB)Audit-honesty checklist
Legal and contribution hygiene
Breaking changes
None. Outputs are byte-identical; only the reservation strategy changed.
Related issues
Refs the viewer demo work in the follow-up PR that stages the magnetar real-project samples.
Note
Medium Risk
Touches core decompression memory behavior used across RVT parsing (wasm and native), though outputs are intended to remain byte-identical; wasm panic handling changes failure observability only.
Overview
Caps pre-decode
Vecreservation for each gzip/DEFLATE member so it no longer scales with the full stream remainder (4 × remaining), which multi-member Revit streams were multiplying across every retained chunk and blowing past wasm32’s 4 GiB linear memory ceiling. Initial capacity is now bounded byINITIAL_INFLATE_CAPACITY_BYTES(1 MiB) as well as the existing output limit; decoded buffers areshrink_to_fitwhen kept in chunk lists. A regression test asserts tiny payloads don’t reserve capacity proportional to trailing junk input.For the browser wasm bindings, the first RVT byte-opening call installs a one-time panic hook that logs
rvt-rs wasm panic: …viaconsole.errorinstead of surfacing onlyRuntimeError: unreachable.Decompressed bytes stay the same; only allocation behavior and panic diagnostics change.
Reviewed by Cursor Bugbot for commit b22eece. Configure here.