docs: gVisor flagship plan rev 2.1 (Astra round 2 P2s)
Component-wise purge with a fixed fd budget, alert joined onto registered fleet boxes plus a sandbox-intent field, root hook stderr to the journal, slice 4 in the runbook order, cgroup memory.peak as the F3 acceptance, honest interim coverage for F5. No P1 in round 2; P2s applied without another round.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+40
−21
docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md+40 −21
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| index 89d4b38c8..6a77d2b51 100644 |
| --- a/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md |
| +++ b/docs/superpowers/plans/2026-11-16-gvisor-flagship-demos.md |
| @@ -1,4 +1,4 @@ |
| -# gVisor on flagship demo boxes: plan (rev 2) |
| +# gVisor on flagship demo boxes: plan (rev 2.1) |
| **Goal:** flagship demo boxes run anonymous demo code under gVisor (runsc), not the native systemd sandbox. A demo box that isn't explicitly configured for one or the other admits no demos. |
| @@ -8,7 +8,7 @@ |
| **Evidence:** a Fable 5.2 audit of the gVisor path at 3793aa49 (2026-11-16; summary on discussion #1096; findings F1 to F10). It found no path from the payload to root, other tenants or platform state. |
| -**Review history:** round 1 (Astra) was NOT READY, with 4 P1s and 6 P2s, in `~/.cache/sec-review-20261116/reviews/G-R1-astra.md` on docs-t1. Rev 2 answers each finding; the dispositions are at the end. Round limit is three: stop at the first round with no P1. If round 3 still finds a P1, cut scope and take it to Paul. |
| +**Review history:** round 1 (Astra) was NOT READY, with 4 P1s and 6 P2s; rev 2 answered them. Round 2 (Astra) found no P1 and 7 P2s; rev 2.1 applies those P2s without another round (AGENTS.md stopping rule 1). Both findings files are in `~/.cache/sec-review-20261116/reviews/` on docs-t1 (G-R1-astra.md and G-R2-astra.md). |
| **Scope:** demo boxes only. Shared pools are a separate, later plan: they need networked egress under gVisor and a cost ruling. |
| @@ -37,17 +37,20 @@ Both apply today under the native sandbox, so this slice ships first and protect |
| - Admit one output transfer at a time, behind a process-wide semaphore of 1 held from read through response write; other finished builds wait their turn. |
| - Raise the control service's `MemoryMax` to a measured figure covering one transfer (about 32 MiB raw, about 43 MiB base64, plus encoder buffers) on top of today's baseline. 192M is the starting estimate; the measured peak sets the final value. |
| - Keep the size, ELF-segment and digest checks unchanged. |
| - - The output dir's cleanup stays where it is (`worker.go`), after the response is written. |
| - - **Tests:** a 32 MiB output, run through validation and response encoding, measures peak heap (`runtime.ReadMemStats` HeapInuse high-water, sampled) under the new cap. Four concurrent finished builds serialise and all succeed. The unit-text test pins the new `MemoryMax`. |
| + - Cleanup: today `Worker.Build` runs its deferred output-dir cleanup before returning, and `handleDemoBuild` encodes afterwards from the in-memory bytes (`worker.go:272`, `demo_build.go:167-174`). Keep that ordering, since the response holds the bytes. Streaming from the file would need an explicit change of who owns the file and when it is cleaned up, which this slice does not make. |
| + - **Acceptance:** |
| + - The authority is the whole control service under its proposed cgroup cap on the dev demo box. Run builds at the supported concurrency (4 slots, at least one 32 MiB output) and record the cgroup's `memory.peak` and `memory.events` oom/oom_kill counts. Pass: peak under `MemoryMax`, zero OOM events. |
| + - Unit tests: four concurrent finished builds serialise and all succeed, and the unit-text test pins the new `MemoryMax`. |
| + - Heap sampling is a diagnostic only. |
| - **Why not stream the binary to the agent (fd passing):** it changes the client/upload contract across root and the agent, for a box class that runs only demos. It can be a follow-up if build concurrency grows. |
| 2. **F6: purge fails on deep or huge trees.** |
| - **Problem:** `internal/instancefs/dirs_linux.go` `removeAt` refuses depth > 64 and calls `Readdirnames(-1)`. |
| - - **Fix:** an iterative removal that holds at most 2 open directory descriptors. |
| - - It keeps a stack of name components, not fds, and re-resolves each directory from the purge root with `openat2(RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS|RESOLVE_NO_MAGICLINKS)`. That is quadratic in depth, which is accepted. |
| + - **Fix:** an iterative removal with a fixed budget of at most 3 live directory descriptors, temporary ones included. |
| + - It keeps a stack of name components, not fds. To reach a directory it walks from the purge root ONE COMPONENT AT A TIME: `openat2(parentfd, name, RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS|RESOLVE_NO_MAGICLINKS)`, then closes the parent. No joined pathname is ever passed to the kernel, so total path length (beyond PATH_MAX) does not matter. The walk is quadratic in depth, which is accepted. |
| - It reads entries in batches of 256. |
| - - Path storage is bounded at 4096 components. Past that, purge reports "too deep" and leaves the tree for an operator. A tree of 4096 levels × 255-byte names cannot be built under the guest's limits anyway. |
| + - The name stack is bounded at 65,536 components (at most about 16 MiB of names). Past that, purge refuses with "too deep", leaves the tree, and marks the demo for operator recovery (`carlos` box verb, documented in the runbook). This is a reachable refusal, accepted; the guest has no directory-depth limit. |
| - **Tests:** |
| - - a 1,000-deep tree purges with `RLIMIT_NOFILE` set to 16; |
| + - a tree whose total path is over 64 KiB (long 255-byte names), and a 10,000-deep tree, both purge with `RLIMIT_NOFILE` set to 16; |
| - a 100k-entry directory purges with bounded memory; |
| - a directory swapped for a symlink between batches is not followed; |
| - an interrupted purge (error injected mid-walk) resumes and completes on retry. |
| @@ -65,8 +68,13 @@ The census applies (`internal/demobuild`, `internal/instancefs`, `internal/insta |
| - Before slice 2 rolls to flagship, set `CARLOS_EXEC_SANDBOX=systemd` explicitly in the flagship demo box's host.env through the producer, with a backup copy kept. That makes the slice-2 roll a no-op for the mode. |
| - The roll then changes nothing until slice 4 flips that one line. Dev's demo box already says `gvisor`. |
| 3. **Alert.** |
| - - **Source:** each demo fleet's box reports at `fleets/<fleet>/status/boxes/`, with the fleet taken from the console's `CARLOS_DEMO_FLEET` (authoritative membership), read explicitly by a new alert signal. |
| - - **Fires** when the effective sandbox isn't `gvisor` on a demo box whose intended mode is `gvisor`. Intent is recorded in the console's demo settings when slice 4 flips; until then the rule is armed but expects `systemd`. |
| + - **Expected boxes:** enumerate the demo fleet's non-detached boxes through `registry.ListFleetBoxes` (`internal/registry/fleets.go:685`), with the fleet from the console's `CARLOS_DEMO_FLEET`. Then join each box's report from `fleets/<fleet>/status/boxes/` onto those identities. A registered box with no report, an aged-out or deleted report, or a failed registry or listing read raises the alert as "unknown". |
| + - **Intent:** |
| + - Add a `sandbox_intent` column to demo settings (`internal/console/demo_store.go`; an additive migration, default `systemd`). |
| + - It changes only through an ops-owner CLI/API door with step-up: `carlos demo sandbox-intent gvisor|systemd`, audited. |
| + - Slice 4 sets it to `gvisor` when it flips. |
| + - **Fires** when a box's effective sandbox differs from the intent. |
| + - **Review gates:** the alert's text, and any sandbox field shown in the console, go through the UX pass and copy review before merge (AGENTS.md). |
| - **Also fires** when the report is absent, unreadable or older than 3 heartbeat intervals, when gVisor reports blocked (not Ready), and when the mode is unset. |
| - **Detached boxes** and a deliberate rollback, recorded by setting intent back to `systemd`, are quiet. |
| - "Quiet" never counts as success: slice 4's witness also requires a fresh positive report. |
| @@ -89,8 +97,9 @@ The census applies (`internal/demobuild`, `internal/instancefs`, `internal/insta |
| 2. **F9: separate the streams.** |
| - **Problem:** pinned runsc passes its own stderr through to the guest, so `StandardError=journal` would also take the app's stderr away. |
| - **Fix:** route runsc's own diagnostics with runsc's `--debug-log`/`--log` flags to a root-owned file or the journal. Keep guest stdout and stderr on the existing log socket. |
| + - **Root hooks:** the `carlos instance-exit` hook and every runsc lifecycle command the unit runs (`gvisorCommands`: run, kill, delete and the probe) never inherit tenant-facing stderr. Each writes its diagnostics to the journal, through `systemd-cat` in the command line or the binary logging to the journal directly. Pick whichever needs no new unit privilege. |
| - Cap the listener (`internal/activator/loglistener.go`) before BOTH sinks: the tenant sink, which already has 1 MiB/minute and a ring (`internal/applog/sink.go`), and agent stdout, which today is uncapped. Bytes over the cap are still drained, and counted in a "dropped" line. |
| - - **Tests:** guest stdout and stderr both still reach the tenant log; a runsc error doesn't; a flood is drained and reported as dropped. |
| + - **Tests:** guest stdout and stderr both still reach the tenant log; a runsc error doesn't, and neither does a forced `instance-exit` failure; a flood is drained and reported as dropped. |
| Slice 3 is required before shared pools. For the demo flip, Paul decides at slice 4 whether it is required or waived. |
| @@ -105,16 +114,22 @@ Slice 3 is required before shared pools. For the demo flip, Paul decides at slic |
| - a roll that changes the runsc pin; |
| - a rollback from gVisor to systemd. |
| -**Steps:** in the window, with Paul's go and the version from 8a3d302, run the runbook's flagship-equivalent checks verbatim (runbook §"Prepare the release and approval" through §"Rollback", lines ~85-110), with the box name substituted. These include: |
| -- privileged acceptance on the current commit; |
| -- the five installed member hashes; |
| -- the Ready/probe result; |
| -- instance sandbox status; |
| -- full starter build and `Worker.Initialize`; |
| -- a fresh `X-Carlos-Version` receipt; |
| -- `/proc/net/dev` read INSIDE the guest, showing loopback only. |
| +**Steps,** in the window, with Paul's go and the version from 8a3d302, in the runbook's order with the box name substituted: |
| +1. **Before the change:** approval recorded; the five runsc assets readable through the box's own store access; privileged acceptance on the current commit; baseline. Then native Ready and drain. |
| +2. **The change:** flip host.env `systemd` to `gvisor` through the producer, keeping a backup copy, then the coordinated restart of control and the agent. |
| +3. **After the change, the gVisor witnesses:** |
| + - the Ready/probe result; |
| + - the five installed member hashes; |
| + - instance sandbox status; |
| + - full starter build and `Worker.Initialize`; |
| + - a disposable demo created, updated, woken and claimed; |
| + - a fresh `X-Carlos-Version` receipt; |
| + - `/proc/net/dev` read INSIDE the guest, showing loopback only; |
| + - a fresh positive report of effective `gvisor`. |
| -Then flip host.env `systemd` to `gvisor` through the producer, record the intent in the console's demo settings, restart control and the agent, and check for a fresh positive sandbox report. |
| + Only then set the console's sandbox intent to `gvisor`. |
| + |
| +Rollback is a conditional procedure, not part of the initial run (below). |
| **Witness demos are disposable:** create, update, wake and claim a throwaway demo. Its claim and deletion are not undone by a rollback, so never use a real visitor's demo. Record the account, region, resources and cleanup in the roll log. |
| @@ -124,7 +139,11 @@ Then flip host.env `systemd` to `gvisor` through the producer, record the intent |
| - **Why not a scan:** the round-1 review showed a scanned cap cannot stop exhaustion. Unlinked open files and fast writes outrun it, and stopping outside the activator's fences is unsafe (`internal/instancectl/hardening.go:539`). |
| - **What a real fix needs:** an enforced boundary. That means a per-demo or aggregate demo filesystem with reserved backing space, inode limits, mount, recovery and purge handling, survival across hibernation, readability during claim export, and native/gVisor parity. That is a design, not a plan task. |
| -- **Interim (no new code):** the flagship demo box runs only demos, so exhaustion is a demo-service outage on that box. The existing early disk alert (box staging disk) covers it. File the design as a follow-up on #1096. |
| +- **Interim (no new code), and what it actually covers:** the flagship demo box runs only demos, so exhaustion is a demo-service outage on that box, not another tenant's. |
| + - The existing early disk alert (`internal/host/probes.go` `readDiskFrac`) measures free blocks on `/data` only. |
| + - Before relying on it, confirm that the flagship demo box's alert delivery is configured, and record the evidence on #1096. |
| + - **Accepted, uncovered:** `/run` tmpfs exhaustion and inode exhaustion can take the demo service down with no warning. That outage is accepted until the F5 design lands. |
| + - File the design as a follow-up on #1096. |
| ## Not in this plan |