docs: hub console spec rev 3 — Paul's decisions (cut 3, shape, route scan), round 2 P2s, dispositions
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+146
−83
docs/superpowers/specs/2026-11-24-hub-console-address-from-install-design.md+146 −83
diff --git a/docs/superpowers/specs/2026-11-24-hub-console-address-from-install-design.md b/docs/superpowers/specs/2026-11-24-hub-console-address-from-install-design.md| index df308b891..a96a89fdf 100644 |
| --- a/docs/superpowers/specs/2026-11-24-hub-console-address-from-install-design.md |
| +++ b/docs/superpowers/specs/2026-11-24-hub-console-address-from-install-design.md |
| @@ -1,6 +1,8 @@ |
| # The hub reaches the console through a socket root's install creates |
| -Status: draft rev 2 for design review, 2026-11-24. Branch |
| +Status: rev 3, approved by Paul 2026-11-24 (decisions in §12 and §14, |
| +dispositions in §15). The implementation plan is |
| +`docs/superpowers/plans/2026-11-24-hub-console-socket.md`. Branch |
| `console-addr-from-install`. Direction chosen by Paul on 2026-11-24: the |
| console install writes where the console is, and the hub reads it; trust |
| comes from root, never from records. The earlier `/proc` listener discovery |
| @@ -13,8 +15,8 @@ the console unit's environment. Rev 2 drops the derivation. §11 maps every |
| round-1 finding to this revision. Round 2 |
| (`CODEX-FINDINGS-hub-console-address-from-install-R2.md`) was NOT READY with |
| one P1 in the same fault family as round 1's P1-1, so review stopped under |
| -AGENTS.md stopping rule 2. §14 holds the choice for Paul. This revision is |
| -not further fixed until he chooses. |
| +AGENTS.md stopping rule 2. Paul chose the cut on 2026-11-24 (§14). Rev 3 |
| +applies it and round 2's P2s. The design review is closed. |
| ## 1. The problem |
| @@ -51,7 +53,9 @@ The console, when that directory exists and is its own, adds a second |
| listener: a unix socket at the compiled-in path |
| `/run/carlos-console/fleet.sock`, serving only the two box doors. The edge, |
| with no `CARLOS_REPLICA_CONSOLE_ADDR`, forwards box calls to that socket when |
| -it exists. No address is derived, no file is parsed, and no record is read. |
| +root's record says the console holds the directory alone and the socket |
| +exists. No address is derived and no route record is read. The platform owns |
| +every `carlos-` runtime-directory name, enforced in `internal/caps`. |
| ## 3. The trust argument |
| @@ -63,13 +67,15 @@ field may choose, redirect or disable where the fleet tokens go. |
| so only root (here, systemd acting on root-owned unit configuration) |
| creates `/run/carlos-console`. The one root writer that names it is the |
| §4 drop-in, which root writes for the unit named `console.service` and no |
| - other. No root writer renders a unit directive from app or bucket data: |
| - config delivery writes values into environment files under fixed |
| - drop-in shapes, and capability drop-ins come from code. A record cannot |
| - create a unit, name a directive or change which unit is `console.service`. |
| + other. The one root writer that renders `RuntimeDirectory=` from app data |
| + is the capability renderer (`internal/caps/render.go:168-177`, an app's |
| + `runtime_dir`); validation now refuses every `carlos-` name there |
| + (§4a), and root's record is `exclusive` only when no capability drop-in |
| + on the box still claims `carlos-console` (§4). A record cannot create a |
| + unit, name a directive or change which unit is `console.service`. |
| - **Only the console's user can place the socket.** systemd creates the |
| - directory owned by the unit's `User=` with `RuntimeDirectoryMode=0755`, so |
| - only that user or root can create, replace or remove `fleet.sock` in it. |
| + directory owned by the unit's `User=`, mode 0755 by default, so only that |
| + user or root can create, replace or remove `fleet.sock` in it. |
| - **It disappears with the console.** systemd removes the directory when the |
| unit stops (no `RuntimeDirectoryPreserve`). A stopped console leaves no |
| path for anyone to bind, so the edge's dial fails with no token sent. |
| @@ -103,32 +109,61 @@ A new step in root's adopt pass, `runAdoptUnderRootRelease` |
| (`internal/host/agent.go:5997`), beside the named-units step |
| (`agent.go:6181`): never fatal, on full and `-config-only` passes alike. |
| -1. `probeUnits` (`internal/host/unitops.go:302`) for `console.service`'s |
| - `LoadState`. |
| -2. `loaded`: ensure |
| - `/etc/systemd/system/console.service.d/70-carlos-fleet-socket.conf` holds |
| - exactly |
| +1. Read `console.service`: `systemctl show console.service -p |
| + Id,LoadState,ActiveState,RuntimeDirectory,RuntimeDirectoryMode,RuntimeDirectoryPreserve`. |
| +2. **A pending reload first.** If the store holds a `reload-pending` marker |
| + (below), run `systemctl daemon-reload`; on success remove the marker, |
| + on failure keep it and stop here with `failed`. |
| +3. `LoadState=loaded`: the drop-in |
| + `/etc/systemd/system/console.service.d/70-carlos-fleet-socket.conf` must |
| + hold exactly |
| ``` |
| [Service] |
| RuntimeDirectory=carlos-console |
| - RuntimeDirectoryMode=0755 |
| ``` |
| - root:root 0644, written with `hostfloor.Durable`; `systemctl |
| - daemon-reload` only when the bytes changed. Nothing is restarted: the |
| - directory appears at the console's next start, which is its next deploy |
| - (adoption's restart) or any operator restart. |
| -3. `not-found`: remove the drop-in if present, and daemon-reload. |
| -4. Any other state, or a failed write or reload: change nothing, and record |
| - the reason. |
| - |
| -It records its outcome (`installed`, `unchanged`, `removed`, `absent`, |
| -`failed: <reason>`) in a public root store, `/var/lib/carlos-console-fleet` |
| -(`rootstate.Open(dir, true, true)`, root 0644), the named-units status |
| -convention (`internal/host/namedunitsfetch.go:37`), for §8. |
| - |
| -`RuntimeDirectory=` accumulates across drop-ins, so a unit that already has |
| -its own runtime directory keeps it. The guard's `90-host-floor.conf` |
| -replaces only `ExecStart` and is unaffected. |
| + It sets no mode and no preservation, so a runtime directory the unit |
| + already has keeps its own settings. If the bytes differ: write the |
| + `reload-pending` marker durably, then the drop-in (root:root 0644, |
| + `hostfloor.Durable`), then daemon-reload, then remove the marker. A |
| + failure anywhere leaves the marker, so the next pass reloads whatever |
| + the bytes are (round 2, P2-2). Nothing is restarted: the directory |
| + appears at the console's next start, its next deploy or any restart. |
| +4. `LoadState=not-found`: remove the drop-in if present, under the same |
| + marker discipline. |
| +5. **Exclusivity**, decided every pass from what is on the box: |
| + `exclusive` is true only when the drop-in is on disk and applied (no |
| + marker), the unit's effective `RuntimeDirectoryPreserve` is `no` and its |
| + `RuntimeDirectoryMode` is `0755`, no capability drop-in claims |
| + `carlos-console` (`caps.RuntimeDirClaimant`, the exported form of the |
| + existing `scanClaims`, `internal/caps/converge.go:775-812`), and, when |
| + the unit is not active, `/run/carlos-console` does not exist. Anything |
| + else is `exclusive: false` with the reason (round 2, P2-3). |
| + |
| +It writes one record, `status.json`, in a public root store |
| +`/var/lib/carlos-console-fleet` (`rootstate.Open(dir, true, true)`, root |
| +0644, atomic), the named-units status convention |
| +(`internal/host/namedunitsfetch.go:37`): `{"schema":1,"outcome":…, |
| +"reason":…,"exclusive":…,"at":…}` with outcome `installed`, `unchanged`, |
| +`removed`, `absent` or `failed`. The `reload-pending` marker lives in the |
| +same store. |
| + |
| +The guard's `90-host-floor.conf` replaces only `ExecStart` and is |
| +unaffected. |
| + |
| +## 4a. The reserved prefix (Paul, 2026-11-24) |
| + |
| +The platform owns every `/run` directory whose name starts `carlos-` (today |
| +`carlos-runsc` and `carlos-console`, beside the existing reserved |
| +`carlos`). One function in `internal/caps`, `ReservedRuntimeDir(name)`, |
| +decides it, and `ValidCapabilities` calls it, so ship, adopt, converge |
| +(`converge.go:228`) and render (`render.go:152`) all refuse such a |
| +`runtime_dir`. A capability drop-in already installed with such a name |
| +stays as converge leaves any refused manifest, and §4's exclusivity check |
| +sees it. A guard test fails when any non-test Go string literal or shipped |
| +unit file in the repo spells `RuntimeDirectory` outside an allowlist: the |
| +capability renderer (through `ValidCapabilities`), root's console step, and |
| +the platform's own `carlos-runsc` units and transient unit |
| +(`internal/demobuild/gvisor.go:146`). |
| ## 5. The console's listener |
| @@ -151,8 +186,11 @@ The order is **env > socket > the old route scan**: |
| 1. `CARLOS_REPLICA_CONSOLE_ADDR` set: as today. Tito and self-hosters are |
| unchanged. |
| -2. Otherwise, on each box call, `lstat` `/run/carlos-console` (a directory, |
| - not a symlink, not group- or other-writable) and `fleet.sock` (a socket). |
| +2. Otherwise, on each box call, read root's record with |
| + `rootstate.OpenTrustedFile` and `rootstate.CheckPublicConfig` (root:root |
| + 0644, at most 4 KB, unknown fields refused) and require `exclusive`; |
| + then `lstat` `/run/carlos-console` (a directory, not a symlink, not |
| + group- or other-writable) and `fleet.sock` (a socket). |
| Present: forward through one cached reverse proxy whose transport dials |
| that unix path, with the same rewrite, version header and 502 error |
| handler as `newReplicaConsoleProxy` (`replicaconsole.go:64-89`). A failed |
| @@ -161,8 +199,8 @@ The order is **env > socket > the old route scan**: |
| 3. Absent or failing the checks: today's route scan, which on the flagship |
| answers 503 as it does now. |
| -The checks are two `lstat`s per call, cheaper than rev 1's file read, and |
| -need no restart or watcher. The edge's sandbox allows it: |
| +The checks are one small file read and two `lstat`s per call, and need no |
| +restart or watcher. The edge's sandbox allows it: |
| `RestrictAddressFamilies` includes `AF_UNIX`, and connecting to a socket on |
| the read-only view `ProtectSystem=strict` gives `/run` is permitted, since |
| the kernel's read-only check covers regular files, directories and symlinks |
| @@ -179,6 +217,8 @@ only (`sb_permission`, `fs/namei.c`). §9 step 2 confirms it on dev. |
| | Directory a symlink, writable by group or others, or socket not a socket | route scan, reason logged once | |
| | Console stops between check and dial | 502, nothing sent | |
| | Console moved to another box | directory gone on this box | |
| +| Root's record missing, not root's, malformed, or `exclusive: false` | route scan (today), reason logged once | |
| +| An app's capability drop-in still claims `carlos-console` | root records `exclusive: false`: route scan | |
| No case forwards a token to a path anyone but root or the console's user |
| could have placed, and no case produces a destination the edge would not |
| @@ -187,14 +227,19 @@ have used before this change other than the socket itself. |
| ## 8. Visibility |
| The agent adds `console_fleet` to the heartbeat beside `named_units` |
| -(`internal/status/snapshot.go:877-880`): root's drop-in outcome (§4), whether |
| -the socket is present, and which source the edge used for its last box call |
| -(`env`, `socket`, `route-scan` or `none`), taken from the edge's selection |
| -code, not recomputed. The system-status API projects it per box beside |
| -`named_units` (`internal/console/apisystemupdate.go:1093-1100`), and `carlos |
| -system status` prints it for every box that has `console.service`, healthy |
| -or not: one line with the drop-in state, socket presence and edge source. |
| -The new copy goes through the usual copy review. |
| +(`internal/status/snapshot.go:877-880`): root's record (§4: outcome, |
| +reason, `exclusive`, when), and the edge's last box call as the edge's own |
| +selection code saw it: the source it used (`env`, `socket`, `route-scan`), |
| +the result (`ok`, or the status it answered), and when. No call since the |
| +edge started reads as "no call yet", never as success (round 2, P2-6). |
| + |
| +The system-status API projects it per box beside `named_units` |
| +(`internal/console/apisystemupdate.go:1093-1100`), and `carlos system |
| +status` prints it on every box that has a console, healthy or not, as one |
| +suffix on the box's line: the source and the last call's result and age. |
| +The UX pass and copy review come before the CLI is built (plan, Task 6). |
| +To get a fresh call after a change, wait for any fleet box's next replica |
| +or seeds report; boxes report every few minutes. |
| ## 9. Rollout |
| @@ -202,34 +247,43 @@ The new copy goes through the usual copy review. |
| console, then flagship, per the README recipe. The box roll writes the |
| drop-in; the console roll restarts the console, which creates the |
| directory and binds the socket. |
| -2. Dev hub: `carlos system status` shows `drop-in installed`, `socket |
| - present`, and the edge source. Confirm box calls succeed. |
| +2. Dev hub: `carlos system status` shows the console suffix with source |
| + `socket` (dev has no env override) and a recent `ok` call. |
| 3. Flagship hub: the same, with the edge source still `env` (the interim |
| line wins). |
| 4. Remove the interim `CARLOS_REPLICA_CONSOLE_ADDR` line from the flagship |
| hub's `host.env` and restart `carlos-edge`, by the same Paul-approved |
| - route that added it. Confirm the edge source reads `socket` and the 503s |
| - stay gone. |
| + route that added it. Confirm `carlos system status` shows source `socket` |
| + and a fresh `ok` call. This is the one operator step after the release. |
| +6. The release after: delete the route scan (§12.3). |
| 5. Update the comment at `replicaconsole.go:16-26`, the self-host docs (the |
| env var stays the supported override) and the replica docs. |
| ## 10. Tests and census |
| +Caps: `ValidCapabilities` refuses `carlos-console` and every `carlos-` |
| +name, through ship, adopt, converge and render; the guard test (§4a). |
| Root step: `loaded` writes once and reloads once; unchanged bytes neither |
| -write nor reload; `not-found` removes; a failed write or reload changes |
| -nothing and records why. Edge: the precedence; every §7 row, against a real |
| -unix listener in a temp directory; a route row naming another upstream has |
| -no effect while the socket is present; a dial failure answers 502 without |
| -the request reaching anything. Console: listens only when the directory is |
| -its own and safe, serves only the two doors on the socket, keeps TCP. The |
| -shared constant is one symbol. |
| - |
| -Census: the root step (`internal/host`), the edge (`internal/edge`), the |
| -heartbeat field (`internal/status`) and the shared constant package are in |
| -the root binary's scope. Root's new actions: a `systemctl show` of one fixed |
| -unit, a write and remove of one fixed drop-in path, daemon-reload. The edge's |
| -new reads: two `lstat`s of a fixed path. Card and Codex census review on the |
| -branch, per AGENTS.md. |
| +write nor reload; a reload failure leaves the marker and the next pass |
| +reloads with the bytes unchanged; `not-found` removes; each `exclusive: |
| +false` reason (pending marker, `Preserve`, mode, a capability claim, a |
| +directory with the console inactive). Edge: the precedence; every §7 row, |
| +against a real unix listener in a temp directory; a route row naming |
| +another upstream has no effect while the socket is used; a dial failure |
| +answers 502 without the request reaching anything; the last-call record. |
| +Console: listens only when the directory is its own and safe, serves only |
| +the two doors on the socket, keeps TCP. Heartbeat to API to CLI: the field |
| +survives each hop, "no call yet" renders as such, and `TestCLIGolden`. The |
| +shared constants are one package. |
| + |
| +Census: the caps gate, the root step (`internal/host`), the edge |
| +(`internal/edge`), the heartbeat field (`internal/status`) and the shared |
| +constant package are in the root binary's scope. Root's new actions: a |
| +`systemctl show` of one fixed unit, a scan of capability drop-ins, a |
| +`lstat` of `/run/carlos-console`, a write and remove of one fixed drop-in |
| +path and of a marker in its own store, daemon-reload. The edge's new reads: |
| +root's record through the trusted open, and two `lstat`s of a fixed path. |
| +Card and Codex census review on the branch, per AGENTS.md. |
| ## 11. Round 1, finding by finding |
| @@ -249,17 +303,13 @@ branch, per AGENTS.md. |
| API to CLI projection, shown for healthy boxes too, with the edge's actual |
| source. |
| -## 12. Decisions for Paul |
| +## 12. Decisions (Paul, 2026-11-24) |
| -1. **The shape.** Paul asked for "the console's address in a root-owned file |
| - the edge reads". Rev 2 delivers that as a root-owned drop-in on the |
| - console's unit, and the "address" is a socket path systemd creates from |
| - it, because a derived TCP address failed review and cannot survive the |
| - console stopping. Confirm this reading. |
| -2. **The route scan.** Recommendation: keep it below the socket in this |
| - change, so a hub without the socket behaves as today; delete it in the |
| - next release once every platform hub reports `socket` or `env`. It is the |
| - one remaining place route data chooses where tokens go. |
| +1. **The cut** (§14): reserve the `carlos-` runtime-directory prefix for the |
| + platform, enforced in one place in `internal/caps`, with a guard test. |
| +2. **The shape:** the root-written drop-in plus the private socket counts |
| + as "the console install writes it". |
| +3. **The route scan:** kept below the socket for one release, then deleted. |
| ## 13. Not in this spec |
| @@ -283,7 +333,7 @@ cannot see `console.service`'s drop-in. While the console's directory is |
| absent, a unit-backed app with a static user can claim `carlos-console`, |
| bind `fleet.sock`, and pass both of the edge's checks. |
| -Per stopping rule 2, no third fix is written. The three cuts: |
| +Per stopping rule 2, no third fix was written. The three cuts offered: |
| 1. **Refuse the case up front.** The edge selects the socket only when root's |
| record says `console.service` holds the `carlos-console` claim alone: root |
| @@ -300,13 +350,26 @@ Per stopping rule 2, no third fix is written. The three cuts: |
| and reports an already-installed claim on it before the root step enables |
| the console drop-in; a guard test fails if any code path renders |
| `RuntimeDirectory=` without going through that function. Codex's |
| - recommendation, and mine: it is small (one prefix check beside the |
| - existing reserved list, one converge refusal, one test) and keeps the |
| - design. |
| - |
| -Outstanding P2s from round 2, to apply with whichever cut is chosen (they do |
| -not reopen the review): a durable pending-reload state for the drop-in |
| -(installed-on-disk versus applied); validating or refusing |
| -`RuntimeDirectoryPreserve` and an existing `RuntimeDirectoryMode` on the |
| -console unit; and a last-call result with timestamps in `console_fleet`, |
| -with heartbeat-to-API-to-CLI tests and a UX pass before copy review. |
| + recommendation, and mine: it is small and keeps the design. |
| + |
| +**Chosen by Paul, 2026-11-24: cut 3**, as §4a. An already-installed claim is |
| +not removed by converge (it leaves a refused manifest's drop-ins as they |
| +are, `converge.go:228-231`); root's exclusivity check (§4 step 5) is where |
| +it is refused. |
| + |
| +Round 2's P2s are applied in rev 3 (§15). |
| + |
| +## 15. Dispositions |
| + |
| +| Round | Finding | Disposition | |
| +|---|---|---| |
| +| R1 | P1-1 root-rendered env files carry bucket data | Resolved in rev 2: nothing reads the console's environment | |
| +| R1 | P1-2 version path is not provenance | Declined (§3, §11); R2 agreed the decline holds | |
| +| R1 | P1-3 env derivation misses inputs | Resolved in rev 2: no derivation | |
| +| R1 | P2-4 argv is not executable identity | Resolved in rev 2: no `ExecStart` check | |
| +| R1 | P2-5 record observed before config changes | Resolved in rev 2: the edge observes per call | |
| +| R1 | P2-6 remote verification incomplete | Partly in rev 2; finished in rev 3 (R2 P2-4 below) | |
| +| R2 | P1 an app can claim `carlos-console` through `runtime_dir` | Stopping rule 2; Paul chose cut 3 (§14): §4a, plus `exclusive` in §4 | |
| +| R2 | P2-2 failed reloads have no recovery | Applied: the `reload-pending` marker (§4 steps 2-4) | |
| +| R2 | P2-3 preservation and mode not established | Applied: the drop-in sets neither; `exclusive` requires `Preserve=no` and mode 0755 (§4 step 5) | |
| +| R2 | P2-4 rollout not verifiable remotely | Applied: last call's source, result and time; "no call yet"; API and CLI tests; UX pass before copy (§8) | |