Fleet secrets key design rev 3: Astra round 1 findings A1-A6 (direct mode fails closed, sqid-resolved placement authority, unique fleet keys, one lock from key choice to commit, owner-only door, CLI and agent-restart rollout); round 2 brief
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md+101 −28docs/superpowers/specs/CODEX-FINDINGS-fleet-secrets-key-R1.md+19 −0docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key-R2.md+41 −0
CI passed — run details
Intent
<task-notification> <task-id>br9jgoa78</task-id> <tool-use-id>toolu_01HC2TjavsXX2FoLXtbomcmD</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/br9jgoa78.output</output-file> <status>completed</status> <summary>Background command "Run Astra round 1 review via codex" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bqfcu92t1</task-id> <tool-use-id>toolu_01HXEsbijAbRcBPR8r39Y49J</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/bqfcu92t1.output</output-file> <status>completed</status> <summary>Background command "Wait for Astra round 1 marker" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 25.4 g CO₂e (2,972,210 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-fleet-secrets-key, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md b/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md| index 32f7e2ba5..e49b389dd 100644 |
| --- a/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md |
| +++ b/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md |
| @@ -1,6 +1,6 @@ |
| # Fleet secrets key: secrets for apps on a customer's own boxes |
| -Status: draft rev 2, 2026-10-29 (rev 2: the builder check's answers, marked B1-B8). Discussion: amadan carlos/platform #366 |
| +Status: draft rev 3, 2026-10-29. Rev 2: the builder check (B1-B9). Rev 3: Astra round 1 (A1-A6, `CODEX-FINDINGS-fleet-secrets-key-R1.md`, all accepted). Discussion: amadan carlos/platform #366 |
| (found by rootfs Plan 4 Task 11). Branch `design-fleet-secrets-key`. |
| ## 1. Why |
| @@ -123,15 +123,29 @@ change. |
| reading a `CARLOS_SECRETS_PUBKEY=` line or a bare key, so the owner can |
| pipe `carlos secrets genkey` output through a file). The CLI parses the |
| key locally (`appconfig.ParsePublicKey`) and prints its fingerprint. |
| -- Console door: `PUT /api/cli/fleets/{fleet}/secrets-key` with |
| - `{"pubkey": "<base64>"}`. Authority: the same as `fleets add-box` (an |
| - owner of the fleet's account), because whoever sets the key decides who |
| - can read the fleet's future secrets, which is no less than minting a box |
| - token. Refuses: an unknown fleet or one of another account (same answer, |
| +- Console door: `PUT /api/cli/fleets/{account}/{fleet}/secrets-key` with |
| + `{"pubkey": "<base64>"}`, beside the existing fleet routes |
| + (`authcli.go:939`; account resolved from the path as `apicli.go:232` |
| + does), registered with the zero service-role set like them (`svcrole.Set{}`, pinned by `TestNoRoleReachesAMintFleetOrPolicyDoor`). |
| + (A5) Authority: an explicit **owner** check on the account. `fleets |
| + add-box` does not check a role today (`fleets.go:315`, `apiFleet`), so |
| + "the same as add-box" would be weaker than intended: whoever sets the |
| + key decides who can read the fleet's future secrets. (Whether add-box |
| + itself should be owner-only is a separate question, filed, not changed |
| + here.) Refuses: an unknown fleet or one of another account (same answer, |
| as `fleets.go:1107`); a key that does not parse; the deployment's own |
| - public key (fingerprint equal to `expectedSecretsFP()`), because that |
| - would mean the owner holds the deployment key or is about to be asked |
| - for it; a replacement while sealed values exist (§5.6). |
| + public key (fingerprint equal to `expectedSecretsFP()`); (A3) a key |
| + whose fingerprint is already registered on ANY other fleet, of any |
| + account; a replacement while sealed values exist (§5.6). Registering the |
| + same key again on the same fleet is a no-op success. |
| +- (A3) Why keys must be unique: the store door lets every box of a fleet |
| + read the whole account's `apps/<sqid>/**` (`storedoor.go:541`), and v2 |
| + binding does not stop a holder of the private key who supplies the |
| + original account and app (`crypto.go:245`). Two fleets sharing a key |
| + could open each other's apps' secrets. The registry enforces it with a |
| + unique index on the non-empty `secrets_key_fp`, so two concurrent |
| + registrations cannot both win. A two-fleet isolation witness (fleet B's |
| + box cannot render an app placed on fleet A) is part of the plan. |
| - Storage: three columns on the registry `fleets` table, |
| `secrets_pubkey`, `secrets_key_fp`, `secrets_key_set_at` (plus who set |
| it, as the other fleet writes record). Builder's call whether it also |
| @@ -160,14 +174,25 @@ change. |
| ### 5.2 One answer for "which key": `sealKeyFor` |
| -`func (s *Server) sealKeyFor(ctx, acct *Account, app string) (pub *ecdh.PublicKey, fp string, err error)`: |
| - |
| -1. `placement := appPlacement(reg, acct, app)`. |
| -2. `fleet/<f>`: load the fleet row; it must belong to `acct` (defence in |
| - depth; placement already guarantees it). No key registered: a typed |
| - refusal, `errFleetNoSecretsKey{fleet}`, whose message tells the owner to |
| - run `carlos fleets secrets-key <f>`. |
| -3. Not placed: the deployment key, with today's refusals when the console |
| +`func (s *Server) sealKeyFor(ctx, acctSqid, app string) (sealer, error)`: |
| + |
| +1. (A2) Resolve the account from its sqid inside the function, and refuse |
| + if it does not resolve. Callers pass the sqid, never a hand-built |
| + `Account`: `rotateWebhookBudget` builds `&Account{Sqid: ...}` with a |
| + zero `ID` (`apisystem.go:134`), and `AppPlacement` queries by `ID` and |
| + reads a missing row as "not placed" (`store.go:1929`), which would pick |
| + the deployment key for a fleet app. |
| +2. (A2) The app's row in the console store must exist; a missing row is a |
| + refusal, never "not placed". The `apps.placement` column is the |
| + authority. At console start, before the first seal, a one-time backfill |
| + writes `placement` from routes (`fleetFromRoutes`) for every app whose |
| + column is empty and whose routes say `fleet/<f>`; after that, |
| + `sealKeyFor` does not consult routes. The plan checks dev and flagship |
| + for fleet apps with an empty column after the backfill. |
| +3. `fleet/<f>`: load the fleet row; it must belong to the account. No key |
| + registered: a typed refusal, `errFleetNoSecretsKey{fleet}`, whose |
| + message tells the owner to run `carlos fleets secrets-key <f>`. |
| +4. Not placed: the deployment key, with today's refusals when the console |
| has none or it does not parse. |
| Every site in §3's seal-site list calls it instead of parsing |
| @@ -196,6 +221,33 @@ fleet-placed app. (B5) Store and mail seal inside their own packages |
| bound or not), and `objstore.GrantIn` and `mail.EnableEnvironment` take |
| that sealer instead of a bare public key; they also fill `sealed_to`. |
| +### 5.2.1 One lock from key choice to commit (A4) |
| + |
| +A PUT that chose key A must not commit after a replacement installed key |
| +B, and a placement change must not slip between a seal and its write. |
| +Every operation below runs under one console lock keyed by the account |
| +sqid, held from `sealKeyFor` through the commit of the write: |
| + |
| +- the config PUT (`apiconfig.go:483`, `Apply` / `ApplyEnvironment`) for |
| + any request carrying a sealed value; |
| +- every console seal site's seal-and-write (store, mail, relay, scan |
| + callback, plan storage, team credentials, `rotateWebhookBudget`); |
| +- key registration and replacement (§5.1, §5.6), including their "no |
| + sealed values" check; |
| +- placement changes (`placeAppTarget`, `apps create --place` onto an |
| + existing app), including §5.5's check. |
| + |
| +The check that refuses (replacement while sealed values exist, a move |
| +with stale values) reads the config under the same lock, so it sees every |
| +committed write. `release.WithAppMutation` is not this lock: it passes |
| +straight through while host claims are off. |
| + |
| +Assumption, stated so it can be checked: the console is one writer |
| +process per deployment (one `console.db`). A deployment that ever runs two |
| +console writers needs this lock moved into a shared fence first; the plan |
| +records where the assumption is made. Deterministic witnesses for both |
| +races (PUT vs replacement, PUT vs placement change) are part of the plan. |
| + |
| ### 5.3 What the CLI sends, and what the console refuses |
| - Each sealed `Var` gains `sealed_to` (the fingerprint, omitted for plain |
| @@ -211,12 +263,17 @@ that sealer instead of a bare public key; they also fill `sealed_to`. |
| - The terminal's `CARLOS_SECRETS_PUBKEY` override keeps winning in the |
| CLI; the PUT check is what stops it sealing a fleet app's secret to the |
| wrong key. |
| -- (B3, my call) Direct-bucket mode (`appconfig_cli.go:987-1000`, operators |
| - with bucket access, no console) never meets the PUT. It refuses `secrets |
| - set` for an app whose routes in the registry it already opens carry a |
| - `fleet/<f>` region, and says to use the console. G3's single point of |
| - enforcement is the console; this refusal is the one other writer's |
| - guard. |
| +- (B3, A1) Direct-bucket mode (`appconfig_cli.go:987-1000`, operators |
| + with bucket access, no console) never meets the PUT, and it cannot know |
| + an app's placement: the placement column lives in the console's |
| + database, and a laptop has no registry at all (`appconfig_cli.go:59`). |
| + So it needs evidence it can read from the bucket: direct-mode `secrets |
| + set` refuses for any account that owns a fleet (any |
| + `accounts/<acct>/fleets/*.json` owner record exists), and says to use |
| + the console. An account with no fleet cannot have a fleet-placed app, |
| + so the deployment key is right for it. A read error refuses too. G3's |
| + single point of enforcement is the console; this refusal is the one |
| + other writer's guard, and it fails closed. |
| - (B9) `scanSecretHash` hashes the whole `Var` |
| (`internal/console/scankeysync.go:16-23`), so adding `SealedTo` changes |
| what it covers: the plan keeps the hash's input as it is today (or |
| @@ -276,7 +333,8 @@ and for a fleet box it is stored under `fleets/<f>/status/boxes/`, which |
| the console already loads for the fleet page (`fleets.go:1186`). In scope: |
| a console join of those refusals into the instance rows (under the same |
| tenant check as the rollout join), and a REASON cell naming the reason and |
| -the fix (`no_key`: put the fleet's key in the box's host.env; |
| +the fix (`no_key`: put the fleet's key in the box's host.env and restart the |
| +agent; |
| `cannot_open`: set the secrets again). Console and CLI only. Platform |
| boxes' snapshots get the same join if it costs nothing extra; the builder |
| says which. |
| @@ -322,11 +380,22 @@ exclusion is needed; a guard test pins it. |
| ## 9. Rollout and Task 11 |
| -Console only. Roll order as usual (dev console, then flagship). On dev: |
| +No box code change, but not console only (A6): the new `fleets |
| +secrets-key` command and `sealed_to` need a CLI from the same release, so |
| +the release ships the CLI (tap, apt) as usual and owners update before |
| +registering. Roll order as usual (dev console, then flagship). |
| + |
| +Installing a key on a box is: write `CARLOS_SECRETS_KEY=` into |
| +`/etc/carlos/host.env`, then restart the agent (`carlos-edge.service`, |
| +and `carlos-instance-control` if it caches config). The running agent |
| +reads the key once: the guard at start (`configguard.go:99`) and both |
| +config loops exit when the key is absent (`agent.go:1531`, `:2269`). The |
| +BYO page, the docs, the `no_key` REASON text (§5.7) and the replacement |
| +procedure (§5.6) all say "then restart the agent". On dev: |
| register r10r's key (`carlos secrets genkey` on DOCS-T1 into a 0600 file, |
| the private half into box-1's host.env by one SSM command reading it from |
| -a presigned URL, never in command parameters), set shop's secrets again |
| -(§5.1's list names them), grant shop's store, check `instances list` shows |
| +a presigned URL, never in command parameters), restart box-1's agent, set shop's secrets again |
| +(§5.1's list names them) with the new CLI, grant shop's store, check `instances list` shows |
| no config refusal, and resume rootfs Plan 4 Task 11. The dev |
| store backend (approved by Paul, 2026-10-29) is configured beside it. |
| @@ -349,4 +418,8 @@ store backend (approved by Paul, 2026-10-29) is configured beside it. |
| instead (§5.7). No box change. |
| - C8. (B2) The first key's registration warns with a list instead of |
| refusing. |
| -- C9. (B3) Direct-bucket `secrets set` refuses fleet-placed apps. |
| +- C9. (B3, A1) Direct-bucket `secrets set` refuses for any account that |
| + owns a fleet. |
| +- C10. (A4) One in-process lock per account, assuming one console writer. |
| +- C11. (A5) Key registration is owner-only, stricter than `add-box` |
| + today. |
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-fleet-secrets-key-R1.md b/docs/superpowers/specs/CODEX-FINDINGS-fleet-secrets-key-R1.md| new file mode 100644 |
| index 000000000..b7e73b374 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-FINDINGS-fleet-secrets-key-R1.md |
| @@ -0,0 +1,19 @@ |
| +1. **P1 — §5.3: the direct-bucket guard cannot establish placement.** |
| + **Invariant:** fleet secrets never fall back to the deployment key. The proposed guard checks local routes, but direct mode explicitly supports laptops without a registry ([appconfig_cli.go:59](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/appconfig_cli.go:59)). Even an available registry cannot identify a fleet-placed app with zero routes; that is why console placement uses its database first ([fleets.go:523](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/fleets.go:523)). In either case, the proposed check permits sealing with the terminal’s deployment key and writing directly to the bucket. **Fix:** require authoritative placement evidence before direct sealing; refuse when it is unavailable. An empty local route list must not establish platform placement. |
| + |
| +2. **P1 — §5.2: background account objects can select the deployment key for fleet apps.** |
| + **Invariant:** key selection uses the app’s actual account and placement. `rotateWebhookBudget` constructs `&Account{Sqid: target.acct}`, leaving `ID` zero ([apisystem.go:134](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/apisystem.go:134)). The proposed helper calls `appPlacement`, which queries by `acct.ID`; a missing database row returns empty placement without error ([store.go:1929](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/store.go:1929)). For a fleet app without console-local routes, the fallback also returns empty, so callback rotation seals to the deployment key. Merely calling the helper per app does not fix this. **Fix:** resolve the canonical account from its sqid inside the selection boundary, and refuse unresolved identities. Test background callers with sqid-only accounts and fleet apps without routes. |
| + |
| +3. **P1 — §5.1: registration permits two fleets to share a key.** |
| + **Invariant:** a box outside an app’s placement cannot decrypt its secrets. Registration rejects the deployment key but does not reject another fleet’s fingerprint. If two fleets in one account register the same public key, either fleet’s boxes can fetch the other’s app config: the store door grants all `apps/<account>/` reads ([storedoor.go:541](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/edge/storedoor.go:541)). V2 binding does not prevent decryption by a private-key holder supplying the original account and app ([crypto.go:245](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/appconfig/crypto.go:245)). **Fix:** enforce unique nonempty public-key fingerprints across fleet records, atomically, while allowing idempotent registration on the same fleet. Add a two-fleet isolation witness. |
| + |
| +4. **P1 — §§5.3, 5.5–5.6: validation and key/placement changes can race.** |
| + **Invariant:** an accepted sealed write remains valid for the committed key and placement. A PUT can validate against key A, pause, then write after replacement has observed no secrets and installed key B. Both requests succeed, leaving an undecryptable value. Placement changes have the same race. Config PUT currently writes directly through `Apply`/`ApplyEnvironment` ([apiconfig.go:483](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/apiconfig.go:483)); placement’s app lock does not cover those writes ([fleets.go:692](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/fleets.go:692)). **Fix:** specify a shared serialization or fencing contract covering key selection through config commit, key replacement, placement changes, and background credential delivery. Include deterministic witnesses for both races. |
| + |
| +5. **P2 — §5.1: the API route and authority description do not match the existing fleet API.** |
| + Existing fleet routes include `{account}` ([authcli.go:939](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/authcli.go:939)), and account resolution reads that path parameter ([apicli.go:232](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/apicli.go:232)); the proposed route omits it. Also, CLI `add-box` uses `apiFleet` without an owner-role check ([fleets.go:315](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/console/fleets.go:315)). Thus “same authority” and “an owner” specify different policies. **Fix:** include `{account}` and state the intended role explicitly. If registration is owner-only, require an explicit owner check rather than copying `add-box`; retain the person-only route registration. |
| + |
| +6. **P2 — §§5.7, 9: rollout omits the CLI update and agent restart.** |
| + “Console only” is insufficient: the new command and `sealed_to` require an updated CLI. Writing the private key into `host.env` also leaves a running keyless agent unchanged. The guard reads its key once ([configguard.go:99](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/host/configguard.go:99)), and both config loops exit when the key is absent ([agent.go:1531](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/host/agent.go:1531), [agent.go:2269](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/internal/host/agent.go:2269)). **Fix:** specify CLI deployment, installation of the private key, and restart of the fleet agent before verification. Include the restart in the `no_key` remedy and replacement procedure. |
| + |
| +NOT READY |
| \ No newline at end of file |
diff --git a/docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key-R2.md b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key-R2.md| new file mode 100644 |
| index 000000000..9f3420e60 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key-R2.md |
| @@ -0,0 +1,41 @@ |
| +# Review brief: fleet secrets key design, round 2 of 3 |
| + |
| +Repo carlos/platform, branch `design-fleet-secrets-key`, commit named in your prompt. |
| +Under review: `docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md` (rev 3). |
| +Authorities: the code on this branch (main 0c39af30 plus the spec), `AGENTS.md`, and the merged rootfs spec `docs/superpowers/specs/2026-10-24-rootfs-apps-design.md`. Do not review against unmerged branches; if this work needs one, say so as a P1 and stop. |
| + |
| +You are an independent reviewer. Read the document, then the code it names, and check every claim against that code. Do not edit files. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul's ruling (2026-10-29, amadan #366): each fleet gets its own secrets key; its private half lives only on the fleet's boxes, its public half on the fleet record; the CLI and the console seal a fleet-placed app's secrets and store credential to it. Not taken: giving a fleet box the deployment key; carrying secrets as plain config. |
| +- Rootfs rulings R1 (rootfs apps only on boxes the customer owns) and R5, and AGENTS.md "Stopping rules". Report only mechanisms that fail to honour them. |
| +- The calls in §10 are the author's; challenge one only with a failure it causes. |
| + |
| +## What to check |
| + |
| +1. Tenant isolation: can any path seal a value for app X to a key that a box outside X's account, or outside X's placement, can open? Can a fleet box open anything sealed for another account? Include console background walks, team credentials, relay, scan callback, plan storage, `rotateWebhookBudget`, offline moves, and the direct-bucket CLI path. |
| +2. Fallbacks: is there any path where a fleet-placed app's value is sealed to the deployment key (a keyless fleet, an old CLI, the terminal's `CARLOS_SECRETS_PUBKEY`, a placement read that fails, the route fallback in `appPlacement`)? A silent fallback is a P1. |
| +3. `sealed_to` and the PUT check (§5.3): does refusing an absent `sealed_to` for fleet apps break any existing writer (console-side writes, team credentials, environments, `env adopt`, imports, moves)? Is the check before the first store call? |
| +4. The authority to set or replace a key (§5.1, §5.6): who can, and does it match `fleets add-box` in the code? |
| +5. §5.7's join of box `config_refusals` into instance rows: is the tenant boundary right (fleet box snapshots readable only by the fleet's account)? |
| +6. The claim of no box change (§6, §9): does a fleet box with `CARLOS_SECRETS_KEY` really run the config sync loop and the config guard over the store door, render `<host>.config.env`, and hand it to rootfs and binary instances? Name anything on the box that assumes the deployment key (fingerprint checks, `replica-home-keys`, adopt, claim paths). |
| +7. Anything missing that a planner would need, where a wrong guess would matter. |
| + |
| +## Round 2 |
| + |
| +Earlier rounds: round 1, `docs/superpowers/specs/CODEX-FINDINGS-fleet-secrets-key-R1.md` (4 P1, 2 P2; all accepted, marked A1-A6 in rev 3). The round number counts every earlier review of this design, under any file name or reviewer. |
| + |
| +First give one line per P1 and P2 from round 1: resolved, partly, or not. Carry every unresolved or partly resolved finding forward at its current severity, then add new findings. Name the invariant beside each finding (stopping rule 2). The verdict covers everything outstanding, earlier rounds included. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The census, and review of any newly changed security, root, termination or production-storage behaviour, still check the fix; see AGENTS.md, "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section, the problem, the evidence (file:line), and the fix you would make. Then one verdict line: READY, READY AFTER FIXES (no P1), or NOT READY (one or more P1). This is round 2 of at most 3; a round with no P1 ends the review. |