docs: plan for gVisor on flagship demo boxes
Four slices: demo-box hardening that applies today (F3 streaming validate, F6 purge, F5 disk bound), auto=gVisor on demo boxes plus an alert and pinned argv (F2, F7), host-side runsc containment and log volume (F4, F9), then the flagship flip as an operation. Based on a Fable 5.2 audit of the gVisor path at 3793aa49 (discussion 1096).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+92
−0
docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md+92 −0
CI passed — run details
diff --git a/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md b/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md| new file mode 100644 |
| index 000000000..09837cfff |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md |
| @@ -0,0 +1,92 @@ |
| +# gVisor on flagship demo boxes: plan |
| + |
| +**Goal:** flagship demo boxes run anonymous demo code under gVisor (runsc), not the native systemd sandbox, and a new or replaced demo box cannot come up without it. |
| + |
| +**Why now:** flagship demos have been live since 2026-11-11 under the native sandbox. gVisor was built for exactly this workload and has run on the dev demo box since 2026-11-11 (v0.34.47, witness PASS). Paul agreed on 2026-11-16 that we should have a plan. |
| + |
| +**Authorities (merged on main):** `docs/superpowers/specs/2026-11-08-gvisor-demos-design.md` (rev 5.5; §4.1 is the `auto` sequencing this plan completes), `docs/superpowers/runbooks/gvisor-demos.md` (dev rollout; the flagship section added here reuses its steps), `docs/superpowers/plans/2026-11-08-gvisor-demos.md`. |
| + |
| +**Evidence:** a Fable 5.2 audit of the gVisor path at 3793aa49 (2026-11-16; summary on discussion #1096). It found no path from the payload to root, other tenants or platform state. Its findings are labelled F1 to F10 below. |
| + |
| +**Scope:** demo boxes only. Shared pools are a separate, later plan: they need networked egress under gVisor and a cost ruling. The round limit is three reviews, stopping at the first round with no P1. |
| + |
| +## Facts settled |
| + |
| +- **Architecture (F1):** `carlos-flagship-demo-box-1` is t4g.small, arm64 (checked 2026-11-16, profile keymail). That matches the only witnessed architecture, so the amd64 witness is not a blocker. Keep it on the list for any future amd64 demo box. |
| +- **Flagship demo box count:** one today. |
| + |
| +## Slice 1: demo-box hardening that matters TODAY (native and gVisor alike) |
| + |
| +These hold under the current native sandbox, so they ship first, whatever happens to gVisor. Anonymous traffic can trigger all three on flagship now. |
| + |
| +1. **F3: build output validated by streaming.** |
| + - **Problem:** `internal/demobuild/runner.go` `ValidateOutput` reads up to 32 MiB with `io.ReadAll` inside `carlos-instance-control` (`MemoryMax=64M`, up to 4 build slots). A source that links to about 32 MiB can OOM-kill the root control service. |
| + - **Fix:** run `elf.NewFile` over the open file (`ReaderAt`), and hash with `io.Copy` into sha256. Never hold the whole output in memory. |
| + - **Test:** a 32 MiB output validates with heap growth well under the cap; this is a benchmark-style assertion on `testing.AllocsPerRun`, or a bounded-reader fake. |
| +2. **F6: purge works on any tree.** |
| + - **Problem:** `internal/instancefs/dirs_linux.go` `removeAt` refuses depth > 64 and calls `Readdirnames(-1)`. |
| + - **Fix:** iterative, descriptor-relative removal with batched `Readdirnames(256)` and no depth refusal. |
| + - **Test:** a 200-deep tree and a 100k-entry directory purge completely, with bounded memory. |
| +3. **F5: per-demo disk bound.** |
| + - **Problem:** demo data and run dirs have no size bound. One demo can fill `/data` (the root volume) or `/run`. |
| + - **Fix:** a scanned cap is the smallest. The instance-control service measures a demo's data and run dirs at stop, and on a timer while running. Over a fixed cap (demo tier: 256 MiB data, 32 MiB run), it stops the demo and refuses wakes until the purge. |
| + - **Alternative, needs a ruling:** a per-demo loop-mounted filesystem. It's stronger but heavier; Astra or Paul decides. |
| + - **Test:** a demo writing past the cap is stopped and its wake refused with the existing over-limit response. |
| + |
| +Census applies (`internal/demobuild`, `internal/instancefs` and `internal/instancectl` are root-binary code). It ships in the next release with the usual dev-first roll. |
| + |
| +## Slice 2: make gVisor the demo-box default (F2) and pin the argv (F7) |
| + |
| +1. **F2, the default.** |
| + - **Problem:** gVisor mode is a host.env line per box, and `auto` resolves to systemd everywhere (`internal/execsandbox/mode.go`, `AutoDemoGVisor = false`). A replacement demo box comes up native, and every "never fall back" check passes. |
| + - **Fix:** finish design §4.1. `auto` resolves to gVisor when the box is a demo box (the existing `demoBox` signal), and explicit `systemd` is the only opt-out. |
| + - **Tests:** `Parse`/`Resolve` table tests, with `auto` plus demo box giving gvisor, and `auto` plus a non-demo box giving systemd. |
| +2. **F2, the alert.** Add an alert when any demo box's sandbox status reports effective `systemd`. It goes through the existing fleet alerts engine (`internal/console` alerts), with no new channel. |
| +3. **F7, the pinned argv.** Add `--platform=systrap` and an explicit `--directfs=` value to the one argv constructor (`internal/execsandbox/command.go`), and to the `systemctl show` assertion, so a runsc lock bump can't change either silently. |
| + |
| +Census applies. This is a dormant default with a switch-on date: it switches on at the slice 4 window (AGENTS.md stopping rule 5). |
| + |
| +## Slice 3: host-side runsc containment (F4) and log volume (F9) |
| + |
| +1. **F4, host-side containment.** |
| + - **Problem:** `carlos-instance-gvisor@.service` runs runsc as root, with full capabilities and the host network. Its only backstop is `ProtectSystem=strict`. |
| + - **Fix:** measure on the dev demo box (the root runner) the smallest set runsc needs, then pin these in the unit and its unit-text test: |
| + - `CapabilityBoundingSet=` (that set); |
| + - `IPAddressDeny=any`; |
| + - `InaccessiblePaths=/etc/carlos`, plus any other root secrets path the audit names; |
| + - `NoNewPrivileges=yes`, if runsc tolerates it. |
| + - **Witness:** the dev runbook witness passes under the pinned unit. |
| +2. **F9, log volume.** |
| + - **Problem:** runsc and root hook stderr go into the tenant-visible log through a plain `io.Copy` with a line cap. |
| + - **Fix:** send runsc's own stderr to the journal, not the tenant log, and add a bytes-per-minute cap to the listener's tee, using the edge log pipeline's limits if they exist. |
| + |
| +Slice 3 is required before shared pools. For demo boxes it's recommended before the flip; if it slips, Paul decides whether the flip waits. |
| + |
| +## Slice 4: flagship flip (an operation, not code) |
| + |
| +**Preconditions:** |
| +- slices 1 and 2 are released and rolled to flagship; |
| +- slice 3 is released, or waived by Paul; |
| +- the runbook's dev witnesses not yet run are done on dev: |
| + - the claim finished by a person under gVisor (deferred since 11-09); |
| + - two concurrent builds and two concurrent demos; |
| + - a roll that changes the runsc pin; |
| + - a rollback from gVisor to systemd. |
| + |
| +**Steps** (one #421 window, Paul's go, version from 8a3d302): |
| +1. Runbook steps 1 to 3 on `carlos-flagship-demo-box-1`: |
| + - an aware release adopted, no update journal, guard files absent, and the recover unit matching; |
| + - each of the five runsc objects readable through the box's own store access. |
| +2. With slice 2 released, `auto` already resolves to gVisor. Remove any explicit `CARLOS_EXEC_SANDBOX=systemd` from host.env, keeping a backup copy. Restart control and the agent. |
| +3. Witness: |
| + - create a demo, update it (data kept), wake it from hibernation, finish a claim, take it down; |
| + - check `/proc/net/dev` shows loopback only; |
| + - check the sandbox status reports effective gvisor; |
| + - check the new alert is quiet. |
| +4. **Rollback:** set `CARLOS_EXEC_SANDBOX=systemd` in host.env, restart control and the agent, and the alert fires as expected. Write it down in the runbook before the window. |
| + |
| +## Not in this plan |
| + |
| +- Shared pools under gVisor. |
| +- F8 (guest `noexec` parity) and F10 (fail-closed 503s during rolls). Both go on a follow-up list on #1096. |
| +- The amd64 witness, which is only needed if an amd64 demo box is ever added. |