gvisor demos: design rev 4 answering round 3
Round 3 (Astra, 77e2943c): NOT READY, 2 P1 and 2 P2. Rev 4 refuses gVisor mode until no apply journal is open and the guard executor and recovery unit are aware, makes the stop verb today's fenced /stop (gen role refused in gVisor mode), specifies the awareness marker and its reader, and maps physical limits back to tiers in the size report.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+70
−22
docs/superpowers/specs/2026-11-08-gvisor-demos-design.md+70 −22
CI cancelled — superseded by a newer push — run details
Intent
diff --git a/docs/superpowers/specs/2026-11-08-gvisor-demos-design.md b/docs/superpowers/specs/2026-11-08-gvisor-demos-design.md| index 4a8c76614..ca0d54f5a 100644 |
| --- a/docs/superpowers/specs/2026-11-08-gvisor-demos-design.md |
| +++ b/docs/superpowers/specs/2026-11-08-gvisor-demos-design.md |
| @@ -1,4 +1,4 @@ |
| -# gVisor sandbox for anonymous demos: design (2026-11-08, rev 3) |
| +# gVisor sandbox for anonymous demos: design (2026-11-08, rev 4) |
| Discussion: amadan carlos/platform #527. Spike: `~/.cache/gvisor-spike/REPORT.md` |
| and `astra-integration.md` (2026-11-07, runsc release-20261102.0, systrap, t4g). |
| @@ -9,7 +9,8 @@ round 2 (Astra, 1fab79f8, NOT READY: 3 P1, 4 P2) triggered stopping rule 2 on fo |
| repeated families. Paul ruled 2026-11-08, "A-D as recommended" (via platform-f6): |
| A exec-sandbox floor and no fence, B one root stop-uncertain verb, C no generation |
| overlap for gVisor demos, D no new exit record kind. Rev 3 applies them; see §15. |
| -This is round 3 of 3, the last without Paul's go. |
| +Round 3 (Astra, 77e2943c, NOT READY: 2 P1, 2 P2) is answered in rev 4; see §17. |
| +A round 4 needs Paul's go. |
| ## 1. What a user gets, and when |
| @@ -118,8 +119,10 @@ matches the pin is authentic wherever it was fetched from. |
| ### 6.1 Templates (embedded in `internal/host/units`) |
| -- `carlos-instance-gvisor@.service` and `carlos-instance-gvisor-gen@.service`. Demo |
| - boxes run only the main and generation roles today; every other role stays refused. |
| +- `carlos-instance-gvisor@.service`, the original (generation 0) run unit only. With |
| + overlap cut (ruling C) a gVisor demo needs no generation units: the gen role is |
| + refused in gVisor mode (round 3 P1-2), as every other role but run already is on |
| + demo boxes. |
| - `carlos-demo-build-gvisor@.service` (§9). |
| - `carlos-instance-gvisor-probe.service` (§8). |
| @@ -147,14 +150,18 @@ root runner, then pin it in the verifier); it is not copied from the native temp |
| `small` everywhere it is named (route, policy, shares, billing); one function, |
| `execsandbox.Physical(tier cgroup.Limit) cgroup.Limit`, derives the limits written |
| to and read back from systemd and the kernel (round 1 P2-7). Every writer and |
| -verifier calls it: the start path's tier lines, the parent slice write, generation |
| -drop-ins and their readback, `assertDemoUnit`, `demoSizeShown`, `demoCgroup`. |
| +verifier and reader calls it: the start path's tier lines, the parent slice write, |
| +`assertDemoUnit`, `demoSizeShown`, `demoCgroup`, and the size report |
| +(`internal/host/sizestatus.go` `readSizeInForce`, round 3 P2-4), which reads the |
| +unit name from the activator's retained handle and matches `memory.max` against |
| +`Physical(t)` for each logical tier `t` of that family, returning the logical name. |
| No generation overlap in gVisor mode (Paul's ruling C, round 2 P2-5). A gVisor demo |
| -update stops the running unit, proves it gone, then starts the new one: the agent |
| -takes its existing stop-then-start swap path whatever `CARLOS_SWAP` says, and root |
| -refuses (`EXEC-SANDBOX-OVERLAP`) any start for a host that still has an active unit |
| -or a non-empty cgroup in either family. So a parent slice only ever holds one child, |
| +update stops the running unit through `/stop` (with its fence), proves it gone, then |
| +starts the new one: the agent takes its existing stop-then-start swap path whatever |
| +`CARLOS_SWAP` says, root refuses the gen role, and root refuses |
| +(`EXEC-SANDBOX-OVERLAP`) any start for a host that still has an active unit or a |
| +non-empty cgroup in either family. So a parent slice only ever holds one child, |
| parent and child expectations are the same single physical tier, and there is no |
| overlap budget or restoration to derive. Cost: about 200 ms of 503 per demo update. Shares are |
| taken from the logical tier, never from `SharesOf(physical)`. For a gVisor demo unit |
| @@ -248,8 +255,8 @@ produced it. `unitMainExitOf` and status label exits from a gVisor unit (the |
| activator knows the family from its handle) "exit status via gVisor". Records stay |
| advisory; termination proof is unchanged. Termination proof |
| stays systemd invocation state plus an empty cgroup. `runsc delete -force` runs before |
| -start and after stop (spike gotcha 2); the generation finaliser also removes the |
| -bundle directory after the proof, before any reuse of the id. |
| +start and after stop (spike gotcha 2); root removes the bundle directory after the |
| +stop's proof, inside the same fence (below), before any reuse of the id. |
| ## 7. Root policy in gVisor mode (ruling 5, no fallback) |
| @@ -267,12 +274,21 @@ Unit identity (round 1 P2-6; Paul's ruling B, round 2 P2-4): the start response |
| carries the unit name root started (additive field); `Client.Start` returns it; the |
| activator's handle stores it, and every observe and stop on a handle uses the stored |
| name, never one rebuilt from the route. A start whose response never arrived has no |
| -handle, so its cleanup goes through one root verb, `POST /stop-uncertain?host=&role=&gen=`: |
| -root takes the existing per-unit lock for the validated (host, role, gen), derives |
| -the unit names of both families from them, stops whichever is loaded, proves each |
| -inactive with an empty cgroup, and only then answers. The agent's uncertain-start |
| -paths (`backend_exec.go` generation and original-unit cleanup) call it and never name |
| -a family. Stops and discovery recognise both families whatever |
| +handle. Its cleanup is the one root stop verb (ruling B), and that verb is today's |
| +`/stop` for the original run unit (round 3 P1-2), not a new one: it keeps the |
| +existing start fence (`legacystart.go`: every `/start` registers an attempt and |
| +re-checks its context just before submitting; `/stop` fences the host, refuses |
| +requests accepted at or before the fence by the accepted-connection watermark, |
| +cancels and joins attempts in flight, then stops). The only change: the stop step |
| +derives both families' unit names from the validated host and stops each that is |
| +loaded, then proves each inactive with an empty cgroup, and removes the bundle |
| +directory, all before the fence is released. Start, stop and bundle removal share |
| +that one per-host fence; there is no other lock. gVisor generation starts do not |
| +exist (refused), so `markGenStarting` is untouched. The agent's uncertain-start |
| +cleanup for the original unit already calls `/stop`; it never names a family. Tests: |
| +a cleanup that overtakes an accepted-but-delayed start (the start is refused and |
| +nothing runs), and a response lost after a successful gVisor start (stop finds and |
| +stops the gVisor unit). Stops and discovery recognise both families whatever |
| the configured mode, and keep working while Ready is blocked. The plan carries the |
| full inventory of dispatch points from round 1's table: main/sidecar start, gen |
| start/drop-in/stop, seed and its retry, cmd/tty, rootfs roles and probe, native |
| @@ -294,10 +310,17 @@ probes natively. Rather than fence native units, an unaware binary never runs on |
| box whose effective mode is gVisor. This is the moves/seeds floor pattern |
| (`rootmovesfloor_boot.go`, `carlos-system-recover.service`), applied to one fact: |
| -- **Aware:** a binary is sandbox-aware when its build carries the exec-sandbox |
| - protocol marker (`execsandbox.Protocol = 1`), read from the file without running |
| - it, the way `rootFloorBinary` reads a binary's supported floors. This release is |
| - the first aware build. |
| +- **Aware (round 3 P2-3):** a binary is sandbox-aware when its file carries the |
| + marker `CARLOS-EXEC-SANDBOX-PROTOCOL:` followed by a decimal protocol (1 for this |
| + release) and a newline, from a package-level `[]byte` that `main` references so the |
| + linker keeps it, also under `-s -w`. The reader opens the file once without |
| + following a symlink, requires a root-owned single-link regular file below a size |
| + cap, scans it in bounded chunks for the marker, and accepts exactly one occurrence. |
| + It is tied to the executable being judged because root reads that exact file at |
| + its fixed root-owned path (`/opt/carlos/carlos.prev`, the staged target, the guard |
| + executor) and nothing else can write there. Tests run the reader on a real |
| + stripped release-style build (`make build`, linux/arm64 and amd64) and on the last |
| + release binary, which must read as unaware. This release is the first aware build. |
| - **System apply** (this binary as updater, forward or rollback, console-driven or |
| local): when the effective mode is gVisor, it refuses a target binary that is not |
| aware before staging anything, and writes result `refused: exec-sandbox floor`. |
| @@ -313,6 +336,22 @@ box whose effective mode is gVisor. This is the moves/seeds floor pattern |
| - **Bootstrap** installs only the pointer's current binary, which is aware once this |
| release is current; a pointer below this release on a box with gvisor set fails |
| the same apply check. |
| +- **Activation baseline (round 3 P1-1).** The floor binds only code that knows about |
| + it, so root does not enter gVisor mode until all code that could take over the box |
| + is aware. Ready in gVisor mode requires, checked at every Ready: |
| + (a) no system-apply journal is open (`/opt/carlos/system/router/journal.json` |
| + absent): the first roll onto this release is driven by the old updater process, |
| + whose own in-process rollback has no floor, so gVisor waits until that roll has |
| + finished; (b) the guard executor (`/opt/carlos/system/guard/carlos`, the recovery |
| + unit's first branch) is absent or aware; (c) the installed |
| + `carlos-system-recover.service` is byte-identical to this binary's embedded copy. |
| + Otherwise Ready fails with `EXEC-SANDBOX-BASELINE` naming which, and nothing |
| + starts. `carlos.prev` may be unaware: after (a) every path that could restore it |
| + runs aware code, which refuses it. A journal opened later by this binary is an |
| + aware transaction, but Ready still refuses while it is open, so no demo starts |
| + mid-update. Dev order: roll the aware release in systemd mode, then set gvisor and |
| + restart. A fresh box whose pointer is unaware never runs an aware binary, so it |
| + never enters gVisor mode. |
| - **Below the floor:** an operator sets `CARLOS_EXEC_SANDBOX=systemd`, restarts |
| (root drains and reports systemd), then rolls back. The floor binds only while the |
| effective mode is gVisor. |
| @@ -462,3 +501,12 @@ stop-uncertain finds either family; overlap refused in gVisor mode. |
| | 6 exit attribution | P2 | exit attribution | §6.5 no new kind (ruling D) | |
| | 7 build chown | P2 | build-cache ownership | §9 exact ownership list | |
| | P3 pointer tests | P3 | doc consistency | §12 rewritten | |
| + |
| +## 17. Round 3 answers |
| + |
| +| R3 | Sev | Family | Answer | |
| +|---|---|---|---| |
| +| 1 floor not established before activation | P1 | no native fallback (activation, recovery) | §7 activation baseline: no open journal, aware guard executor, this release's recovery unit; refuse up front with `EXEC-SANDBOX-BASELINE` | |
| +| 2 stop-uncertain loses the start fence | P1 | termination proof vs future submission | §7: the stop verb is today's fenced `/stop`, family-aware; gVisor gen role refused, so no gen path | |
| +| 3 aware marker reader | P2 | capability identification | §7 marker bytes + bounded reader + stripped-build tests | |
| +| 4 size report | P2 | logical vs physical limits | §6.2 `readSizeInForce` uses `Physical` and the retained unit | |