AI Focus

browser ephemeral vm

When an application runs generated code or untrusted scripts inside the browser, two things go wrong: an infinite loop can lock up the tab forever, and killing a crashed script leaves half-mutated data behind. This lab tests how to run code inside a strict step budget (“fuel”) and roll memory cleanly back to a known snapshot instead of restarting a full server container.

Hypothesis

Fuel-metered .wasm linear memory paired with binary OPFS checkpoints provides sub-millisecond deterministic halt and byte-exact rollback for untrusted compute scripts inside a standard browser tab.

What confirms it: Runaway loops trap via WebAssembly.RuntimeError at the exact fuel limit, and rolling back to a pre-run OPFS checkpoint leaves zero residual mutated bytes in the hex diff.

What falsifies or bounds it: Checkpoint serialization to OPFS exceeds acceptable turn latency on multi-megabyte linear memories or infinite host-import callbacks stall before fuel check increments.

Dedicated Worker running a fuel-metered Wasm kernel that traps deterministically on step-budget exhaustion, computes byte-level memory hex diffs, and restores OPFS checkpoints. Open browser ephemeral vm full screen ↗

What this lab tests

Browser Ephemeral VM (GitHub) runs a fuel-metered linear-memory .wasm binary inside a Dedicated Worker backed by OPFS binary checkpoints (vm-ckpt-*.bin), aborting deterministically via WebAssembly.RuntimeError on step-budget exhaustion and computing exact byte-level hex diffs and rollbacks.

Open questions

  • How large can WASM linear memory checkpoints grow before incremental page hashing beats full .bin snapshots in OPFS?
  • How should capability-gated host imports expose DOM or OPFS slices without leaking host heap state?

Iteration log

  • — Shipped fuel-metered .wasm Dedicated Worker kernel, OPFS checkpoint snapshots, hex diff view, and top-of-page setup code.
  • — Moved the fuel-metered Wasm VM workbench above the setup blueprint for 700px embeds, added CSP-safe DOM syntax highlighting for WAT/hex-diff/wire views, and tightened Worker CSP with no-cache static asset routing (15 passing checks).

Primitives tested: WebAssembly.Memory, Fuel Metering, OPFS Snapshots, Dedicated Worker.

This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.

More in browser containment & sandbox boundaries

Connected labs

← browser containment & sandbox boundaries · All labs