feat(sandbox): the box as a bundle — packages/sandbox, the ubuntu user, the boot runner, the env push and header-rule credentials
PRs 2–5 of plans/20260913-sandbox-implementation-checklist.md, on top of the P0 measurement (#7527). Decisions in plans/20260913-sandbox-layout-decisions.md.
What a box is now
packages/sandboxproduces it: an image (OS, toolchain, desktop packages, theubuntuuser withNOPASSWD:SETENVsudo) and a content-addressed bundle the box installs and updates itself from at boot —rootfs/mirrored at absolute paths, hashed assets fetched fromcdn.superset.sh/sandbox/<sha><suffix>(Chrome, fonts, themes, wallpapers, the host-service runtime), six versioned steps run through a fail-open runner.build.tsderives every version and the bundle sha deterministically;--publishrefuses a bundle whose assets the bucket lacks.superset-boot(root, started throughsudo --preserve-env=HOST_SERVICE_SECRETby the control plane on every create and wake): clears/run/superset, installs the pinned bundle if the hash differs, runs the three passes, starts host-service asubuntuwith the secret in its env and nothing else, then the desktop (Xvnc+ websockify on 6080) and the checkout. Every phase is a dotted stamp in/var/log/superset/boot.log, whichhealth.checkreports.- The control plane writes one identity file (
/etc/superset/sandbox.conf), creates every sandbox with an empty env, pushes the environment's variables into host-service after boot (sandbox.setEnvironment, replace-all, in memory), and turns every outbound credential — GitHub installation token included — into a firewall header rule re-applied on every wake and keepalive. Nothing secret lands on disk; the box holds placeholders. - host-service runs the repository's
starthook once the env and the checkout are in; environments gainbundle_shaandhooksoverrides (migration 0116); the desktop pane connects to the desktop port through the gate with its own ticket, and the VNC route in host-service is gone. - Release: rewrites the host-service asset from the checkout, publishes the bundle, builds the internal golden with the environment's
setuphook, probes a fork (host, gate, firewall, desktop stream, a stop and a wake) and writes the rows only after that passes.
Evidence
boot-twice.ts(CI on every sandbox PR): 24/24 — second boot installs nothing, fetches nothing, skips every step; host-service ready in ~4 s in Docker; a broken runtime still brings the desktop up and names itself in the log.runner-check.ts(CI): the runner's sidecars, verify-and-refuse, sentinel, disable-after-three, upstream-still-runs and retry-on-new-version.real-sandbox.tsagainst the dev project: host-service on the pinned bundle asubuntu, no brokered credential in its environ, checkout onmain, Xfce + dock up,RFB 003.008overwss://…:6080/websockify, wake in 11.9 s with every step skipped. The box-side boot is ~2 s; the rest is the platform's resume.- Docs:
docs/cloud-sandbox-mismatches.md,-considerations.md,-acceptance.md§11,packages/sandbox/README.md.
Traps found on the way, all recorded in the mismatches doc: the platform's sudo: true drops the command env; the checkout replaced the cwd every child had inherited; biome reformatting rootfs JSON moved bundle hashes.
https://claude.ai/code/session_01FK6rLzBEUiHHXZWNmpQ2BP
Summary by cubic
Replaces scripts/sandbox with packages/sandbox: a box is now an image plus a content-addressed bundle it installs and updates itself from at boot. Credentials no longer enter the box; the control plane turns every outbound credential into a firewall header rule and pushes the environment's variables into host-service in memory after boot.
Boot and runtime
superset-bootruns as root on every create and wake throughsudo --preserve-env(the platform'ssudo: truedrops the command env), with the identity and host secret in the boot command's env; it installs the pinned bundle only when its hash differs, then starts host-service as theubuntuuser.- A wake now boots in one call; a create, whose box is already booting, only waits and pushes the environment instead of re-running the wake.
- Every status write goes through one guarded
transitionCloudWorkspace; a delete during provisioning wins and tears the box down, and a readiness timeout keeps the box for diagnosis. - The desktop pane connects to websockify on its own published port with its own gate ticket; the dev gate gives every workspace and port a
*.localhostsubdomain so the two tickets keep distinct origins, and host-service's VNC route is gone. - The visible Chrome runs from its own profile directory (Chrome 136+ refuses remote debugging on the default one), and the login profile turns off the agent CLIs' self-updater.
- The desktop init starts the session bus before the session and writes its address where login shells source it, so a GUI app launched from a terminal joins the session.
- host-service runs the repository's
starthook once env and checkout are in, and reports boot stamps, the bundle, and ready flags on its health route. - Migration 0116 adds
bundle_shaandhooksoverrides to environments.
Release and CI
- Release rebuilds the host-service runtime asset and the internal golden, probes a fork (host, gate, firewall, desktop stream, stop and wake), then writes rows only after the probe passes.
- The probe reads the dev stack's port from the environment's env file, and a golden's logs are stripped before its snapshot.
- CI boots the image twice on every sandbox PR, asserting a second boot installs nothing, fetches nothing, and skips every step.
- The cloud-sandbox docs record the real-box and desktop-pane evidence, add the v2 layout's stage table beside the P0 baseline, and note that runner-input changes ship with the image since the boot runner is already on the box.