fix: refuse oversized browser IFC sources and check compact offsets

Merged
LO
21d ago
+178-30

Problem and change

A whole-source Rust wasm32 allocation cannot accept an IFC source at or above 2 GiB. Reject these browser loads before reading a named .ifc file, and check detected/unwrapped sources before geometry. Use one exclusive source-size constant for the viewer and parser byte-scan gate. Show a typed, translated size refusal in English, Russian, German, French and Italian while preserving genuine OOM advice.

Check compact-index offsets and lengths before Uint32Array assignment in the builder and both construction helpers. Add fake-size boundary, scan-gate, offset-overflow and error-message regression tests. No capacity, worker budgeting, cache, native or server upload changes.

Validation

Passed locally: module-size ratchet, license headers, git diff --check. Pre-handoff's wiring, size, CI coverage, agents-size, silent-revert and retained-evidence checks passed.

Fleet validation on head 2fd25b4040 completed the root Turbo parser/viewer test command and full pnpm typecheck successfully: parser 2,214 passed, 12 skipped (fixture/optional coverage); selected viewer/catalogue/startup tests 531 passed, zero skipped. All 136 typecheck tasks passed, including the root tail auditing 4,797 test files.

The initial run stopped at API generation because six package declaration entries were not built by the test/typecheck graph. Follow-up request auto-e85b4376fecf4fa093380c82a3dfbda1 completed successfully on the same head: full root build (77 tasks), API snapshot regeneration with zero diff, module-size ratchet and all 14 pre-handoff gates passed with no skips. Original failed evidence is preserved. No code changes were required after validation.

Evidence limits

Code inspection confirms the whole-source Vec copy, old 2.5e9 scan gate and unchecked uint32 offsets. The study's 10-second failure and measured memory figures were not re-run; no timed benchmarks were run. No report claim was disproved. Smaller files may still exhaust memory. No issue and no merge-queue label, as requested.

Landing follow-up

Current runtime head includes current main ac8078b9da (#9590 included), merged without conflicts. No bundle trims or ceiling changes.

Changeset uses minor for @ifc-lite/parser after checking actual merged precedent. RELEASE.md defines minor for features; the additive public helpers warrant minor. #3420's parser-express-id-u32-bound.md explicitly says the same three compact-index methods throwing on previously corrupting input was NOT what required its major; its new required type field was. No required shape changes here. #3471 and #5279 also shipped new errors on corrupt input as patch fixes, while #5281 treated malformed-token narrowing as parser patch and its new shared helper as data minor. Valid uint32 spans remain unchanged; invalid spans now throw instead of corrupting the index. Full analysis and isolated Changesets release-plan comparison are in the reply to the resolved versioning thread. No release versions were hand-edited.

assertWasmSourceSize now rejects non-finite, negative and fractional sizes explicitly; the scan gate returns false for that domain. Span checks already rejected invalid values; added coverage for invalid lengths as well as offsets in all three public construction paths, both infinities, and valid zero. Replied to and resolved both new review threads with source/test evidence. New tests have not yet completed validation and are not counted as acceptance merely because they exist.

Updated-main runtime validation (fleet request auto-68c333f14db4431a83e39a4623231452, source 73c004a995) PASSED: parser 2,217 tests passed / 12 skipped (fixture/optional coverage), selected viewer/catalogue/startup 531 passed / zero skipped, all 136 root typecheck tasks plus tail, 77 build tasks, all 14 pre-handoff gates with no gate skips. Current head differs only in changeset metadata, now minor per merged invalid-input precedents.

Fleet bundle measurement: eager JS 18,034,022 B, against 18,058,823 B ceiling / 18,076,881 B allowed with tolerance: 42,859 B below allowed. Entry JS 2,510,230 B; engine WASM brotli 2,441,357 B. All three are within current ceilings/tolerances. This is fleet validation, not the still-pending GitHub CI verdict.

Previous same-pipeline exact-base comparison was +1,144 B against 004934fa88; that is historical and not the updated-main delta. Matching exact-base ac8078b9 fleet build completed: eager JS 18,032,913 B; this PR runtime 18,034,022 B; own delta +1,109 B (+0.00615%), using the same root build and ratchet measurement pipeline. Both measurements include 357 eager files. No runtime trim or ceiling change.

Kept unqueued; no mergify-trial label.