Skip to content

WASM Architecture

WASM sandboxes use a host-mediated model: the API server stays in sandboxd, while each sandbox runs inside a dedicated worker subprocess speaking IPC over a Unix socket.

sandboxd (service layer)
└─ internal/runtime/wasm.Driver
├─ pkg/wasmmod resolver (module cache)
├─ pkg/wasm/worker supervisor
└─ toolbox reverse proxy (files / exec)

Passivation writes a mem.snap directory:

  • config.json — engine metadata, clone generation, module digest
  • memory.zstd, globals.cbor, wasi-state.cbor — guest state

Durable sandboxes push the directory to AOCR at:

cluster/<cluster-id>/wasm-checkpoints/<sandbox-id>:latest

  1. Create — resolve module, start or acquire warm worker, instantiate, invoke entrypoint.
  2. Passivate — checkpoint live guest, stop worker, release admission.
  3. Rehydrate — restore from local mem.snap (pull from AOCR first when durable and missing).
  4. Failover — cluster owner calls RecreateSandbox; durable WASM pulls checkpoint then rehydrates.
VariablePurpose
SB_ENABLE_WASMMaster gate
SB_WASM_MODULES_DIRModule + checkpoint cache root
SB_WASM_CHECKPOINT_INTERVALOptional periodic boundary checkpoint
SB_WASM_DURABLE_PUSH_INTERVALRetry AOCR push for durable rows
SB_SNAPSHOT_PUSH_ENABLEDEnables AOCR push/pull credentials

See the WASM runtime health runbook for failure modes and log signatures.