Skip to content

audit F38 [arch]: web::DerivedStateActor uses Arc<Mutex> not Rc<RefCell> in WASM-only code #538

@intendednull

Description

@intendednull

File: crates/web/src/state_bridge.rs:31 + Spec: docs/specs/2026-04-26-state-management-model-design.md
Severity: quality — design tension with documented WASM pattern
Obvious? no

The state-management spec lists Rc<RefCell<T>> as the canonical pattern for "WASM single-threaded interior mutability (web only)". The bridge instead uses Arc<Mutex<Option<U>>>.

The accompanying lock-ok comment (lines 23-30) justifies the lock as an actor-handler dedup cache and explicitly defers redesign to spec follow-up F2. Documented and intentional, but worth surfacing because the choice in WASM-only code contradicts the spec's stated table — a reader would want the rationale (Actor framework requires Send, hence Arc<Mutex> over Rc<RefCell>) repeated either in the spec or in the comment to close the loop.

Fix: add a one-liner to the spec's state-management table noting the actor-bridge exception, OR follow up on F2 to restructure DerivedStateActor.


Filed by /general-audit @ b901575 (2026-05-02). master: #513.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions