carlos / platform Public

Fleet secrets key design rev 2 (builder check B1-B9) and the Astra round 1 brief

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev f5339c05af1e6d51ed95c322bd362feb251c5ba8 parent bb2d9e3
2 files changed, +119 −21
  • docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md +84 −21
  • docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key.md +35 −0

CI passed — run details

Intent

Human

<task-notification> <task-id>aaefc5dfa5041ec11</task-id> <tool-use-id>toolu_01CxGqCiYompmMm5VjpNm4Bh</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/aaefc5dfa5041ec11.output</output-file> <status>completed</status> <summary>Agent "Builder check fleet key spec" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I found two gaps that need answers before planning, plus two smaller points. The code also settles both "builder to confirm" items, so those are given as answers. **Questions, most important first** 1. **Per-box "holds key" (G4, §5.1) needs a box change. Is that acceptable?** Fleet boxes publish no key fingerprint anywhere. - `secrets_key_fp` is only written into the edges file (`control/edges/&lt;box&gt;.json`). That loop exits on fleet boxes: `internal/host/edgesfile.go:1012-1014`, via `shouldSkipPublisherElection` (`internal/host/agent.go:4085`, which checks `CARLOS_FLEET`). - The store door would refuse that write anyway (`internal/edge/storedoor.go:644-679`). - The fleet box's status snapshot, which the console already reads under `fleets/&lt;f&gt;/` (`internal/console/fleets.go:1186`), has no fingerprint field (`internal/status/snapshot.go`). So `holds key` / `other key` can only be shown if fleet boxes start publishing the fingerprint, for example in their status snapshot. That breaks §6's "no box change" and §9's "console only". It adds a release floor and a box roll before Task 11. It also changes Task 11's own check ("`fleets ls` says `holds key`"). The alternative is to show only `unknown` per box in v1, or to infer from config refusals, which only gives negative evidence. I need to know which. 2. **What happens to values already sealed to the deployment key on a fleet-placed app when the first key is registered?** §1 says shop already has `SECRET_KEY_BASE` set, so it is sealed to the deployment key with no `sealed_to`. Any store, mail or relay credential minted earlier is in the same state. - §5.6 only blocks *replacing* a key. §5.3 only checks new writes. So after the first registration these values stay put, and the box refuses them with `cannot_open`. - That is exactly the "found when an instance starts" failure G5 rules out, and Task 11 would hit it. Should the first registration be refused, listing the vars to unset and rotate? Should it warn? Or should the plan include a one-time sweep? Each choice is a different task. 3. **Is direct-bucket `carlos secrets set` in scope?** The no-console path (`appconfig_cli.go:987-1000`) seals to the terminal's `CARLOS_SECRETS_PUBKEY`, uses the operator's `CONSOLE_SECRETS_ENVELOPE_V2`, and writes to the bucket directly. It never passes the PUT check. It also cannot see placement, which lives in the console store and the route fallback. - If it is in scope, it needs its own refusal, probably by reading the routes' `fleet/&lt;f&gt;` region from the registry it already opens. - If it is out of scope, G3's "enforced in one place" should say so, and the guard test can't cover it. 4. **Is the hostname history active on dev and flagship?** `placeAppTarget` refuses every `apps place` once hosts mode is active or invalidated (`internal/console/fleets.go:627-639`). If it is active, §5.5's `apps place` rule can't be reached there. The only live path is then `apps create --place` adopting an app whose bucket objects already exist (`adoptingExistingApp`, `internal/console/server.go`). - That path writes placement *after* creating the app row, and best-effort (`server.go:5131-5139`). So §5.5's refusal must run before `createClaimAppRow`, not where placement is written. - This decides how much of §5.5 gets built and tested now. **Settled from the code** - **§5.7 (does the refusal reason reach `carlos instances list`?): no, for any box, fleet or platform.** Only `internal/host` and `internal/status` touch `ConfigRefusals`. Nothing in `internal/console` or the CLI reads `config_refusals`. The REASON column is built only from rollout and update-settings reasons (`instances_cli.go:651-657`). - The data does exist: a fleet box's snapshot carries `Metrics.ConfigRefusals` (`internal/status/snapshot.go:663-672`), stored under `fleets/&lt;f&gt;/status/boxes/`, which the console already loads for the fleet page (`internal/console/fleets.go:1186`). - So this is in scope as a console join plus a CLI cell, with no box change. - **§6 (can fleet boxes enter the platform candidate sets?): no.** All four sites (`boxchoice.go:141`, `regioncandidates.go:197`, `apiinstancemove_offline.go:435`, `apiinstances.go:1735`) read the edges snapshot from `control/edges/` (`internal/console/instancesplacement.go:88`). Fleet boxes never write there, for the same reasons as question 1. No exclusion is needed. **Notes for the plan (not questions)** - **Forcing v2 for fleet keys:** "fleet-key envelopes are always v2" can't be done at the console call sites alone. Store and mail seal inside `internal/objstore/walk.go:898` and `internal/mail/walk.go:985`. They call `appconfig.Seal`, which follows the deployment-wide switch (`internal/appconfig/crypto.go:155-163`). The plan has to thread a bound-or-not choice, or a sealer, through `objstore.GrantIn` and `mail.EnableEnvironment`. Those packages also need to fill `sealed_to`. - **Seal-site list:** §3's list misses `apisystem.go:92` (`rotateWebhookBudget`). It sweeps every app with one key, so it needs the per-app treatment §5.2 describes. - **Hash shape:** `scanSecretHash` hashes the whole `Var` (`internal/console/scankeysync.go:16-23`), so adding `SealedTo` changes what that hash covers. - **Config GET on a keyless fleet:** it should leave out `secrets_pubkey` rather than refuse. The same GET serves `env` and `secrets list` (`internal/console/apiconfig.go:240-276`).</result> <usage><subagent_tokens>122068</subagent_tokens><tool_uses>49</tool_uses><duration_ms>380117</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>burmq9g1r</task-id> <tool-use-id>toolu_01JWhdXARV1DGzZYSGsn5m5d</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/burmq9g1r.output</output-file> <status>completed</status> <summary>Background command "Wait for builder check to finish" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 27.8 g CO₂e (3,216,270 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 8d36df816..32f7e2ba5 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 1, 2026-10-29. Discussion: amadan carlos/platform #366
+Status: draft rev 2, 2026-10-29 (rev 2: the builder check's answers, marked B1-B8). Discussion: amadan carlos/platform #366
(found by rootfs Plan 4 Task 11). Branch `design-fleet-secrets-key`.
## 1. Why
@@ -39,8 +39,8 @@ Goals:
- G3. Nothing sealed for a fleet-placed app is ever sealed to the
deployment key, and nothing for any other app is ever sealed to a fleet
key. Enforced in one place, checked by a guard test.
-- G4. The owner can see, per fleet, whether a key is registered and which
- boxes hold it.
+- G4. The owner can see, per fleet, whether a key is registered, and per
+ instance, when a box refused its config and why (B1, B6).
- G5. A mismatch is refused when it is written, not found when an instance
starts.
@@ -137,11 +137,26 @@ change.
it, as the other fleet writes record). Builder's call whether it also
goes on the bucket `FleetOwner` record; nothing on a box needs it.
- Shown: `carlos fleets ls` gains the key's short fingerprint per fleet
- (`-` when none), and per box whether the box's published
- `secrets_key_fp` matches (`holds key`, `no key`, `other key`, `unknown`
- for a box that has published nothing yet). The fleet's console page
- shows the same. The BYO page's host.env block gains the
- `CARLOS_SECRETS_KEY=` line with one sentence on where it comes from.
+ (`-` when none), and the fleet's console page shows it. The BYO page's
+ host.env block gains the `CARLOS_SECRETS_KEY=` line with one sentence
+ on where it comes from.
+- (B1, my call) No per-box "holds key" column in v1. Fleet boxes publish
+ no key fingerprint anywhere: `secrets_key_fp` is written only into
+ `control/edges/<box>.json`, whose loop exits on fleet boxes
+ (`internal/host/edgesfile.go:1012-1014`, `shouldSkipPublisherElection`
+ at `agent.go:4085`), and the store door would refuse the write
+ (`storedoor.go:644-679`). Showing it needs a box change, a release floor
+ and a roll, which this design otherwise avoids. A box that cannot open
+ its config is shown instead through §5.7. A positive per-box fingerprint
+ (in the fleet box's status snapshot) is a follow-up for the next box
+ change.
+- (B2, my call) Registering the FIRST key does not refuse, but its answer
+ lists every app placed on the fleet that has sealed values not sealed to
+ the new key (no `sealed_to`, or another one), with the fix: set those
+ secrets again, and `carlos store rotate` / `mail rotate` / `relay rotate`
+ for credentials the console minted. Those values never opened on a fleet
+ box, so nothing that works today stops working; the list is what makes
+ G5 hold for them. `carlos fleets ls` repeats the count until it is zero.
### 5.2 One answer for "which key": `sealKeyFor`
@@ -156,7 +171,13 @@ change.
has none or it does not parse.
Every site in §3's seal-site list calls it instead of parsing
-`s.cfg.SecretsPub`, and so does the config GET's `secrets_pubkey`. A guard
+`s.cfg.SecretsPub`, and so do the config GET's `secrets_pubkey` and
+`rotateWebhookBudget` (`apisystem.go:92`, B7), which today sweeps every
+app with the one key and must take each app's key in turn. On a keyless
+fleet the config GET omits `secrets_pubkey` rather than refusing, because
+the same GET serves `env` and `secrets list` (`apiconfig.go:240-276`); the
+CLI's existing "no key here" path then refuses `secrets set` and the
+console's PUT names the fix (B8). A guard
test (go/ast, like the rootfs Plan 2 guard) fails if any file in
`internal/console` other than the one holding `sealKeyFor` reads
`cfg.SecretsPub` to seal; `expectedSecretsFP` stays for the platform
@@ -168,7 +189,12 @@ deployment key as a fallback.
Fleet-key envelopes are always v2 (bound), whatever the deployment switch
says, so a fleet box opens an envelope only while rendering the app it was
sealed for. The config GET therefore always sends `secrets_account` for a
-fleet-placed app.
+fleet-placed app. (B5) Store and mail seal inside their own packages
+(`internal/objstore/walk.go:898`, `internal/mail/walk.go:985`) through
+`appconfig.Seal`, which follows the deployment switch
+(`crypto.go:155-163`). So `sealKeyFor` returns a sealer (key, fingerprint,
+bound or not), and `objstore.GrantIn` and `mail.EnableEnvironment` take
+that sealer instead of a bare public key; they also fill `sealed_to`.
### 5.3 What the CLI sends, and what the console refuses
@@ -185,6 +211,17 @@ fleet-placed app.
- 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.
+- (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
+ accepts one re-delivery of the scan callback secret per app) and says
+ which.
- Refusals run before the first store call, as the PUT's existing ones do.
### 5.4 Store, mail and relay credentials
@@ -197,6 +234,14 @@ cannot be delivered is the state that code exists to prevent).
### 5.5 Moves
+(B4) `placeAppTarget` already refuses every move once the hostname
+history is active (`fleets.go:627-639`), which it is on dev and flagship,
+so there the only live path is `apps create --place` adopting an app whose
+bucket objects already exist (`adoptingExistingApp`, `server.go`). That
+door writes placement after creating the app row, best effort
+(`server.go:5131-5139`), so the check below runs before
+`createClaimAppRow`. One helper serves both doors.
+
`carlos apps place` (and `apps create --place` onto an app name that has
config) refuses when the app has any sealed value, in any bundle or
environment, whose `sealed_to` differs from the target's key or is absent.
@@ -215,15 +260,26 @@ replacing the key, setting them again and rotating minted credentials; the
docs say so. Detaching a box (`fleets detach-box`) already stops it reading
the deployment store, which is what an exposed box needs first.
-### 5.7 Instance create and ship
+### 5.7 Instance create and ship, and showing a refusal
No new refusal at `instances create` beyond §5.3 and §5.4: an app with no
sealed values on a keyless fleet works today and keeps working. An app
-whose sealed values a fleet box cannot open is still refused by the box's
-config guard, and its reason (`no_key`, `cannot_open`) reaches `carlos
-instances list` through the box's status snapshot, as now. Builder to
-confirm that path shows the reason for a fleet box; if it does not, that
-is in scope.
+whose sealed values a box cannot open is still refused by the box's config
+guard.
+
+(B6) Today that refusal reaches no one but the box's journal: nothing in
+`internal/console` or the CLI reads `config_refusals`, and the REASON
+column is built only from rollout and update-settings reasons
+(`instances_cli.go:651-657`). The data is there: a box's status snapshot
+carries `Metrics.ConfigRefusals` (`internal/status/snapshot.go:663-672`),
+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;
+`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.
## 6. Boxes
@@ -237,9 +293,10 @@ envelope sealed to the deployment key. The rootfs path reads
The platform-region box checks that compare a box's `secrets_key_fp` with
`expectedSecretsFP()` (`boxchoice.go:141`, `regioncandidates.go:197`,
-`apiinstancemove_offline.go:435`, `apiinstances.go:1735`) must not count a
-fleet box as a keyless or wrong-key platform box. Builder to confirm fleet
-boxes never enter those candidate sets; if one can, exclude it there.
+`apiinstancemove_offline.go:435`, `apiinstances.go:1735`) never see a
+fleet box: all four read the edges snapshot under `control/edges/`
+(`instancesplacement.go:88`), which fleet boxes never write (B1). No
+exclusion is needed; a guard test pins it.
## 7. Copy, docs, census, cost
@@ -268,8 +325,9 @@ boxes never enter those candidate sets; if one can, exclude it there.
Console only. Roll order as usual (dev console, then flagship). 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), check `fleets ls` says
-`holds key`, set shop's secrets, and resume rootfs Plan 4 Task 11. The dev
+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
+no config refusal, and resume rootfs Plan 4 Task 11. The dev
store backend (approved by Paul, 2026-10-29) is configured beside it.
## 10. Calls made without Paul (check these)
@@ -287,3 +345,8 @@ store backend (approved by Paul, 2026-10-29) is configured beside it.
writer's own app if a client lies about it.
- C6. Keyless fleet in a background walk: skip and retry, never fall back
to the deployment key.
+- C7. (B1) No per-box key column in v1; refusals shown per instance
+ 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.
diff --git a/docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key.md b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key.md
new file mode 100644
index 000000000..efa9c69c9
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-fleet-secrets-key.md
@@ -0,0 +1,35 @@
+# Review brief: fleet secrets key design, round 1 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 2).
+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.
+
+## 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 1 of at most 3; a round with no P1 ends the review.