AI Focus

live .wat-to-.wasm compiler & equivalence gate

Generating compact WebAssembly Text (.wat) directly from prompts raises practical questions: token cost, trusting unreviewed stack instructions via automated checks, compile latency versus the JS JIT, and strict host-import DOM boundaries. This lab compiles .wat to .wasm live in the browser and enforces an automated Wasm(x) === JS(x) equivalence gate.

Hypothesis

Compiling compact WebAssembly Text (.wat) directly to .wasm at runtime gated by an automated Wasm(x) === JS(x) equivalence oracle makes unreviewed stack instructions safer to execute while eliminating external compiler toolchains.

What confirms it: Editable and synthesized .wat modules compile live to valid binary .wasm, fail closed whenever the equivalence gate detects a mismatch against JS test vectors, and clearly expose where DOM host-import marshaling erases pure CPU compute wins.

What falsifies or bounds it: Cold .wat-to-.wasm parsing + equivalence vector generation costs more wall-clock time or tokens than running direct JavaScript on DOM-heavy workloads.

Zero-dependency on-the-fly .wat-to-.wasm compiler (browser + Cloudflare Worker), parameterized Spec-to-WAT synthesizer, automated Wasm(x)===JS(x) equivalence gate, Cold-vs-Warm speed race, and DOM host-import stage. Open live .wat-to-.wasm compiler & equivalence gate full screen ↗

What this lab tests

If an AI model emits compact WebAssembly Text (.wat) instead of JavaScript, can an automated equivalence gate verify outputs before anyone has to read stack instructions, and when does compiling .wat on the fly beat the browser’s JS JIT?

Live .wat-to-.wasm Compiler & Equivalence Gate (GitHub) compiles raw .wat S-expressions into binary .wasm on the fly in both the browser and a Cloudflare Worker (POST /api/compile-wat), synthesizes new modules directly from parameter specs (sum-squares, xor-checksum, threshold-count, collatz-steps), checks Wasm(x) === JS(x) across curated test vectors (/wasm/preset/primes.wat, /wasm/preset/primes.wasm), races Cold compile+run vs. Warm Wasm vs. Warm JS loops, and demonstrates why DOM updates require explicit host capability imports (dom.paint_bar).

Open questions

  • Which numerical/parsing tasks cross the Cold compile+run breakeven cleanly inside a Cloudflare Worker and browser tab?
  • Can automated equivalence testing synthesize property-based counterexamples rather than fixed static test vectors?

Iteration log

  • — Built zero-dependency .wat S-expression compiler (client + worker), Spec-to-WAT synthesizer, JS oracle gate, Cold/Warm race, and DOM host-import stage.
  • — Reordered workbench above setup docs, enforced a fail-closed equivalence gate with one-click bug injection, added CSP-safe WAT/JS/JSON DOM syntax highlighting, hardened 700px embed responsiveness, and routed static assets through the Worker with Cache-Control: no-cache.

Primitives tested: WebAssembly Text (.wat), Live S-Expression Compiler, Equivalence Test Gate, Host-Import DOM Bridge, Declarative Shadow DOM, Invoker Commands.

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

More in local compute, .wat compilation & on-device inference

Connected labs

← local compute, .wat compilation & on-device inference · All labs