feat(wasm): opt-in wasm32 retained runtime over the SMLib Worker (M1-E1, #7955)
Refs #7955. This is M1 PR E1 of the CLI retained-mode plan. It adds the wasm32 retained runtime, which the Node CLI (PR F) and the viewer will both use, so both run the same controller and executor as native. It builds on #8180 and is independent of #8183.
What it adds. Everything below sits behind retained-browser/retained-runtime. None of it is in the shipped default engine.
- Runtime.
rust/wasm-bindings/src/retained_browser/runtime.rsimplements the executor traits for the SMLib-wasmBrowserWorker. Runtimes report onlyRuntimeFault, and every receipt is checked for domain and incarnation. - Driver operations.
boolean,affineandtessellateare added tojs/retained-driver.mjsover the existing Worker protocol (C ABI opcodes 5, 17ā19). Their lifetimes match native: a kernel refusal or resource limit keeps the worker alive and releases its handles. The runtime also checks capability bits and enforces native's 128-operation depth limit. The result mesh size is checked throughretained_wire::MeshInfobefore sealing. - Clock.
resource/budget_monotonic.rsgives a monotonic wasm clock for the product budget:BudgetStart::now()no longer usesstd::time::Instanton wasm32. A missing or regressing clock fails closed. - Frame maths.
document/retained_wire.rsholds pure frame and wire maths in the published geometry crate, with no dependency on geometry-runtime.
Default bundle. Rebuilt fresh at the same source path, it is byte-identical to main. The size ratchet passes. The one-line #[allow] added on mesh_check::closed_or_hairline silences a wasm32 Clippy warning that main already has.
Tests and CI.
- SMLib-free Rust and JS tests.
- A browser runtime test against the inert peer, run in real Chrome. It is wired into the PR lane, and its path now triggers that lane.
- A feature-gated revert-oracle witness on the mesh-size check.
- A gated parity skeleton. It skips explicitly when no engine is present, and that skip is not counted as parity evidence.
Validation.
- PC fleet,
eccb2e9ca1, before the rebase, exit 0: clippy (native and wasm32), tests, the real-Chrome runtime tests (3/3), the oracle (OBSERVED), the guards and the bundle check. - Pop fleet, after the rebase onto main (
f5547782bc): the same checks passed, with two exceptions, both resolved. The browser runtime test could not start because that host has no chromedriver; it passed on PC. The CI-path-coverage guard flagged the new test script; this head fixes it.
Reviewed independently; every finding is addressed. The geometry-runtime refactor onto retained_wire was deferred to the native side.
Not in this PR: E2 (the IfcAPI.retainedModel binding and its d.ts baseline, built on #8183's driver API) and real native/wasm parity runs.
š¤ Generated with Claude Code
Summary by CodeRabbit
- New Features
- Added browser support for retained geometry workflows, including construction, affine transformations, Boolean operations, and tessellation.
- Added checks for result size limits and operation depth, with clear errors when limits are exceeded.
- Bug Fixes
- Expected operation refusals now preserve the active worker and existing results, allowing subsequent operations to continue.
- Improved handling of invalid geometry data and cleanup failures.