carlos / platform Public

Fleet secrets key implementation plan (tasks 0-12) and its Astra round 1 brief

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev a7d4e2176d7d94002f11075849f6128e1a4f7429 parent 32a82a0
2 files changed, +296 −0
  • docs/superpowers/plans/2026-10-29-fleet-secrets-key.md +262 −0
  • docs/superpowers/plans/CODEX-REVIEW-BRIEF-fleet-secrets-key-plan.md +34 −0

CI passed — run details

Intent

Attributed to this commit: 39.8 g CO₂e (4,008,397 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/plans/2026-10-29-fleet-secrets-key.md b/docs/superpowers/plans/2026-10-29-fleet-secrets-key.md
new file mode 100644
index 000000000..a8dd75ae2
--- /dev/null
+++ b/docs/superpowers/plans/2026-10-29-fleet-secrets-key.md
@@ -0,0 +1,262 @@
+# Fleet secrets key Implementation Plan
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Each customer fleet gets its own secrets key, so apps placed on a fleet receive their secrets and console-minted credentials without the box holding the deployment key.
+
+**Architecture:** The owner registers a fleet's public key with the console; the registry and the fleet's bucket owner record hold its fingerprint. One console function, `sealKeyFor`, returns an `appconfig.Sealer` (key, fingerprint, binding) for every seal of an app's config, and a go/ast guard pins that no other console code builds one. Sealed vars carry `sealed_to`; the console refuses a mismatch where it can see one. Boxes do not change.
+
+**Tech Stack:** Go (console, CLI, registry SQLite, release.Store), ECDH-P256 envelopes (`internal/appconfig`).
+
+**Spec:** `docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md` (APPROVED rev 5). Read §2.1 first: I1 (confidentiality) is the hard invariant; I2 (a value sealed to a key the app's boxes hold) is best effort, and its misses surface through §5.7.
+
+## Global Constraints
+
+- I1: the only keys anything seals to are the deployment key and keys from `sealKeyFor`, which returns the deployment key or the key of a fleet owned by the app's account. Fleet key fingerprints are unique across all fleets.
+- Fleet-key envelopes are always v2 (`appconfig.SealBound`), whatever `CONSOLE_SECRETS_ENVELOPE_V2` says.
+- No box (`internal/host`, `internal/activator`, `internal/instancectl`) code change. No new bucket polling. No cloud API.
+- Key registration route: `PUT /api/cli/fleets/{account}/{fleet}/secrets-key`, `svcrole.Set{}`, owner-only via `apiOwnerAccountFor` (`apiservices.go:127`).
+- Copy: every user-facing string is a row of `docs/superpowers/plans/2026-10-29-fleet-secrets-key-copy.md`, approved before it is written, gated by `approved_fleet_secrets_copy_test.go` (pattern: `approved_rootfs_copy_test.go`). No em dashes anywhere. Neutral names only in tests and docs (app `shop`, account `bab`, fleets `home` and `away`, hosts under `example.com`).
+- Tests: run only touched packages with `-run`, under `nice -n 19`; never `make test`. Leave `GOCACHE` at its default. Socket tests use `TMPDIR=/tmp/g` with the sandbox off. Before each commit: `go build ./... && go vet <pkgs> && gofmt -l <files>` empty, then `GOOS=darwin go build ./... && GOOS=windows go build ./... && GOOS=linux GOARCH=arm64 go build ./...`.
+- Every new test is shown failing, then passing. Security tests (I1, owner-only, uniqueness, the guard) also show the mutation that makes them fail.
+- Console behaviour is tested through the real HTTP fixture (`rawReq`, `postJSON`, `instanceFixture`, `fleetFixture`), not by calling helpers with hand-built inputs.
+- Lock order is account, then app, then hostname (`applocks.go`). The account lock is `s.lockAccount(sqid)` (`applocks.go:55`).
+- One commit per task, ending `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
+
+## Review Focus
+
+- An older CLI (no `sealed_to`) setting a secret on a fleet-placed app: refused with "upgrade the CLI", not stored (Task 5).
+- A terminal with `CARLOS_SECRETS_PUBKEY` set to the deployment key, sealing for a fleet-placed app: the PUT refuses (Task 5).
+- A fleet whose apps hold values sealed before its key existed: registration lists them, and `instances list` shows `cannot_open` with the fix after the box restarts (Tasks 3, 9).
+- The same public key registered on a second fleet, same or other account: refused; the same key on the same fleet again: no-op success (Task 3).
+- A console-minted credential (store grant, mail enable) for an app on a keyless fleet: refused before the first backend call, and a background walk skips it, never sealing to the deployment key (Task 6).
+
+## Plan rulings (deviations from the spec text, with cost if wrong)
+
+- R-1. Spec §5.2 step 2 asks for a placement backfill that finishes before the first seal. Under §2.1 an empty placement for a fleet app seals to the deployment key, which keeps I1 and is an I2 miss. So `sealKeyFor` uses `appPlacement` (store column, then routes) and the backfill runs in the existing startup goroutine beside `RunFleetOwnerBackfill` (`cmd/console/main.go:657-666`), not blocking. Cost if wrong: a fleet app placed before the column existed, with no routes, gets one deployment-key seal that its box refuses and `instances list` shows.
+- R-2. The §5.2.1 lock is `s.lockAccount(acct.Sqid)`, already used for temporary-app caps. No new lock type.
+- R-3. `ConfigRefusal` names only a host (`snapshot.go:305`), so the §5.7 join shows a refusal only on an instance row the caller already sees, matched by host. A refusal for a host the caller does not own is never shown.
+
+---
+
+### Task 0: Copy deck
+
+**Files:**
+- Create: `docs/superpowers/plans/2026-10-29-fleet-secrets-key-copy.md`
+- Create: `approved_fleet_secrets_copy_test.go`
+
+**Interfaces:**
+- Produces: row ids `FSK-C01`... referenced by every later task; the gate's `fleetSecretsCopyBuilt` list, which each later task extends in the commit that writes a row.
+
+- [ ] **Step 1: Write the deck** with one row per string, columns as `2026-10-28-console-budget-copy.md` (id, file, text, status `draft`). Rows: the `fleets secrets-key` help line in `fleetsUsage` and its output (registered, fingerprint, the stale-apps list and its fix line, already registered no-op); the door's refusals (unknown fleet, unparseable key, the deployment's own key, key used by another fleet, replacement while sealed values exist naming the apps, not an owner); `fleets ls`'s `SECRETS KEY` column header and `-`; `secrets fingerprint` help and output; the config GET-less refusal (`errFleetNoSecretsKey`: run `carlos fleets secrets-key <f>`); the PUT refusals (missing `sealed_to` on a fleet app: upgrade the CLI; wrong key: unset `CARLOS_SECRETS_PUBKEY` in the terminal; not v2); the store/mail/relay keyless-fleet refusal; the placement refusal listing vars and the order that works; the two direct-mode refusals; the REASON cells for `no_key`, `cannot_open`, and the capped report; the BYO page line; the docs paragraphs (Task 10). Draft text from the spec's sections verbatim where it gives words.
+- [ ] **Step 2: Write `approved_fleet_secrets_copy_test.go`** by copying `approved_rootfs_copy_test.go`'s four tests with this deck's path, its id prefix `FSK-C` and an empty `fleetSecretsCopyBuilt`.
+- [ ] **Step 3: Run** `nice -n 19 go test . -run 'TestFleetSecretsCopy' -count=1`. Expected: PASS (deck complete, no em dashes, nothing built yet).
+- [ ] **Step 4: Copy review.** The controller sends the deck through copy review (a Luna pass by delegation is acceptable for a deck this size). Rows come back `approved` with their final text. No later task writes a row until it is approved.
+- [ ] **Step 5: Commit** the deck and the gate.
+
+### Task 1: `appconfig.Sealer` and `Var.SealedTo`
+
+**Files:**
+- Create: `internal/appconfig/sealer.go`, `internal/appconfig/sealer_test.go`
+- Modify: `internal/appconfig/appconfig.go:160` (Var), `internal/appconfig/store.go:345` (`SetSecret`), `appconfig_cli.go:312` (`saveSecrets`), `internal/console/scankeysync.go:16` (`scanSecretHash`)
+
+**Interfaces:**
+- Produces:
+ - `type Var struct { Kind string; Value string; Envelope string; SealedTo string \`json:"sealed_to,omitempty"\` }`
+ - `type Sealer struct` (unexported fields: pub, fp, binding, bound)
+ - `func NewSealer(pub *ecdh.PublicKey, b Binding, bound bool) Sealer`
+ - `func (s Sealer) Fingerprint() string` (`KeyFingerprint(pub)`)
+ - `func (s Sealer) Binding() Binding`
+ - `func (s Sealer) Bound() bool`
+ - `func (s Sealer) Seal(b Binding, plaintext []byte) (Var, error)`: refuses `ErrSealerBinding` when `b != s.Binding()`; seals with `SealBound` when bound, else `SealUnbound`; returns `Var{Kind: "secret", Envelope: env, SealedTo: s.Fingerprint()}`.
+ - `var ErrSealerBinding = errors.New(...)`
+ - `func SetSecret(ctx context.Context, s release.Store, acct, app string, sealed map[string]Var) error` (was `map[string]string`)
+
+- [ ] **Step 1: Write failing tests** `TestSealerSealsToItsKeyAndRecordsTheFingerprint` (opens with the matching private key and the binding; `SealedTo == KeyFingerprint(pub)`), `TestSealerRefusesAnotherBinding` (`Seal(Binding{"bab","other"}, ...)` returns `ErrSealerBinding`), `TestSealerBoundIgnoresTheDeploymentSwitch` (with `SetBoundSealing(false)`, a bound sealer's envelope starts `CSB2` after base64 decode), `TestScanSecretHashIgnoresSealedTo` (two Vars differing only in `SealedTo` hash equal).
+- [ ] **Step 2: Run** `nice -n 19 go test ./internal/appconfig/ ./internal/console/ -run 'TestSealer|TestScanSecretHashIgnoresSealedTo' -count=1`. Expected: FAIL (undefined `NewSealer`, `SealedTo`).
+- [ ] **Step 3: Implement** the Sealer, the field, `SetSecret`'s new map type (callers `saveSecrets` and any other), and `scanSecretHash` hashing the Var with `SealedTo` cleared so callback secrets are not re-delivered.
+- [ ] **Step 4: Run** the same command plus `nice -n 19 go test . ./internal/appconfig/ -count=1 -run 'Secret|Config'`. Expected: PASS.
+- [ ] **Step 5: Commit.**
+
+### Task 2: Registry columns for a fleet's key
+
+**Files:**
+- Modify: `internal/registry/fleets.go` (Fleet :28-33, `migrateFleets` :102, SELECTs :217 and :241), `internal/registry/remote_dispatch.go` (:178-198 and request/response fields), `internal/console/view.go:526-539` (`consoleRegistry`)
+- Test: `internal/registry/fleets_secrets_key_test.go`
+
+**Interfaces:**
+- Produces:
+ - `Fleet` gains `SecretsPub string`, `SecretsKeyFP string`, `SecretsKeySetAt int64`, `SecretsKeySetBy string`.
+ - Columns `secrets_pubkey`, `secrets_key_fp`, `secrets_key_set_at`, `secrets_key_set_by` (ALTER ... ADD COLUMN with `"duplicate column"` ignored, as :128), and `CREATE UNIQUE INDEX IF NOT EXISTS fleets_secrets_key_fp ON fleets (secrets_key_fp) WHERE secrets_key_fp != ''` (pattern `registry.go:892`).
+ - `func (r *Registry) SetFleetSecretsKey(name, pub, fp, by string, at int64) error`, returning `ErrFleetKeyInUse` on the unique index's constraint error; a remote case `"SetFleetSecretsKey"` in `dispatchRemote`.
+ - `consoleRegistry` gains `SetFleetSecretsKey(name, pub, fp, by string, at int64) error`.
+
+- [ ] **Step 1: Write failing tests** `TestFleetSecretsKeyRoundTrips` (set, `GetFleet` and `ListFleets` return all four fields), `TestFleetSecretsKeyIsUniqueAcrossFleets` (fleet `home` of `bab` and fleet `away` of another account: the second set of the same fp returns `ErrFleetKeyInUse`; the same fp on `home` again succeeds), `TestFleetSecretsKeyOverRemote` (the remote registry fixture used by the other fleet remote tests).
+- [ ] **Step 2: Run** `nice -n 19 go test ./internal/registry/ -run 'TestFleetSecretsKey' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement** the columns, index, method, remote case and interface method.
+- [ ] **Step 4: Run** the same, plus `-run 'Fleet'` over `./internal/registry/`. Expected: PASS. Show the mutation: drop the index, `TestFleetSecretsKeyIsUniqueAcrossFleets` fails.
+- [ ] **Step 5: Commit.**
+
+### Task 3: The registration door, the bucket record, and what Paul sees
+
+**Files:**
+- Create: `internal/console/fleetsecretskey.go`, `internal/console/fleetsecretskey_test.go`
+- Modify: `internal/release/release.go:181` (FleetOwner), `internal/console/fleetowner.go`, `internal/hostops/fleetowner_classifier.go:27`, `internal/console/authcli.go:937-942`, `internal/console/fleets.go:50-63,278` (list view), `internal/console/svcroutes_test.go:160-165`, `internal/console/claim_invariant_fixtures_test.go:1370`, `internal/console/claim_invariant_probes_nonapp_test.go:632`, `internal/console/templates/fleet_byo.html`, the fleet page template (fingerprint line)
+
+**Interfaces:**
+- Consumes: Task 2's `SetFleetSecretsKey`, `ErrFleetKeyInUse`; Task 1's `Var.SealedTo`.
+- Produces:
+ - `FleetOwner` gains `SecretsKeyFP string \`json:"secrets_key_fp,omitempty"\``.
+ - `func (s *Server) recordFleetKeyFP(ctx context.Context, f registry.Fleet, fp string) error`: creates the owner record if missing, else updates it with If-Match on its etag; the classifier admits exactly this update (same fleet and account, only `secrets_key_fp` changed) and the new field under its strict decode.
+ - `func (s *Server) handleAPIFleetSecretsKey(w, r)` for `PUT /api/cli/fleets/{account}/{fleet}/secrets-key`, body `{"pubkey": "<base64>"}`, answer `{"fleet", "fingerprint", "stale": [{"app", "vars": [...], "minted": [...]}]}`.
+ - `func (s *Server) fleetSealedValues(ctx context.Context, acct *Account, fleet, fp string) ([]staleApp, error)`: for every app placed on the fleet, the sealed vars (all bundles and environments) whose `SealedTo != fp`, split into user-set and console-minted (store, mail, relay names).
+ - `fleetView` gains `SecretsKeyFP string \`json:"secrets_key_fp,omitempty"\`` and `StaleSecrets int \`json:"stale_secrets,omitempty"\``.
+
+Order inside the handler, every refusal before the first write: `apiOwnerAccountFor`; `apiFleet` (unknown or another account: 404); parse (`appconfig.ParsePublicKey`); fp equal to `s.expectedSecretsFP()`: refuse; fleet already has a different fp and `fleetSealedValues(..., oldFP)` lists any app with a value sealed to the old key: refuse naming the apps (§5.6); same fp as already set: 200 no-op; take `s.lockAccount(acct.Sqid)`; `recordFleetKeyFP`; `SetFleetSecretsKey` (`ErrFleetKeyInUse`: 409 with the copy row); compute `stale` against the new fp (§5.1 B2).
+
+- [ ] **Step 1: Write failing tests** through the HTTP fixture: `TestFleetSecretsKeyOwnerOnly` (a non-owner member: 403; mutation: drop the owner check), `TestFleetSecretsKeyRefusals` (unknown fleet and another account's fleet answer the same 404; bad base64; the deployment's own key; a key registered on another account's fleet: 409), `TestFleetSecretsKeyIdempotent`, `TestFleetSecretsKeyWritesTheOwnerRecordFirst` (a store that fails the owner-record Put: the registry row has no key; a missing owner record is created), `TestFleetSecretsKeyListsStaleValues` (an app `shop` placed on `home` with a secret without `sealed_to`: listed), `TestFleetSecretsKeyReplacementRefusedWhileSealed`, `TestFleetListShowsKeyFingerprint`, `TestFleetOwnerClassifierAdmitsTheKeyUpdate` and `...RefusesOtherChanges` (in `internal/hostops`).
+- [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ ./internal/hostops/ -run 'TestFleetSecretsKey|TestFleetListShowsKeyFingerprint|TestFleetOwnerClassifier' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement** the handler, the record write, the classifier change, the route (plus the three route-list tests), the list fields, and the BYO and fleet page lines (approved rows only, ids added to `fleetSecretsCopyBuilt`).
+- [ ] **Step 4: Run** the same, plus `TestNoRoleReachesAMintFleetOrPolicyDoor` and the claim invariant tests by name, and `go test . -run 'TestFleetSecretsCopy'`. Expected: PASS.
+- [ ] **Step 5: Commit.**
+
+### Task 4: The CLI commands
+
+**Files:**
+- Modify: `fleets.go` (`fleetsUsage` :29, `RunFleets` :93, `runFleetsList` :353), `apimode.go` (:4896-4970: `apiFleetView` gains the two fields; new `setFleetSecretsKey`), `appconfig_cli.go` (`RunSecrets` :805, `secretsUsage` :780)
+- Test: `fleets_secrets_key_cli_test.go`
+
+**Interfaces:**
+- Consumes: Task 3's door and answer shape.
+- Produces:
+ - `carlos fleets secrets-key <fleet> <pubkey>` and `--file <path>` (accepts a `CARLOS_SECRETS_PUBKEY=` line or a bare key); parses locally first and prints the fingerprint, then the `stale` list.
+ - `func setFleetSecretsKey(ctx context.Context, a apiAcct, fleet, pub string) (fleetKeyAnswer, error)`
+ - `fleets ls` header `FLEET\tBUCKET\tSECRETS KEY\tBOX\tSTATUS\tTAGS`, key shown as the first 12 hex characters after `sha256:` or `-`.
+ - `carlos secrets fingerprint [--file <path>]` (default `/etc/carlos/host.env`): reads `CARLOS_SECRETS_KEY`, prints `KeyFingerprint` of its public half, never the key; no console call.
+
+- [ ] **Step 1: Write failing tests** against a test console: `TestFleetsSecretsKeyCLI` (bare key and `--file` with genkey's output both register; fingerprint printed), `TestFleetsLsShowsSecretsKey`, `TestSecretsFingerprintReadsHostEnv` (a temp host.env; output equals `KeyFingerprint`; output never contains the private key).
+- [ ] **Step 2: Run** `nice -n 19 go test . -run 'TestFleetsSecretsKeyCLI|TestFleetsLsShowsSecretsKey|TestSecretsFingerprint' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement.**
+- [ ] **Step 4: Run** the same plus the copy gate. Expected: PASS.
+- [ ] **Step 5: Commit.**
+
+### Task 5: `sealKeyFor`, the config GET and PUT, and the CLI's `sealed_to`
+
+**Files:**
+- Create: `internal/console/sealkey.go`, `internal/console/sealkey_test.go`
+- Modify: `internal/console/apiconfig.go` (GET :264-276, PUT :302-492), `appconfig_cli.go` (`secretsPubKeyAPI` :855, `sealSecretAPI` :897, `runSecretsSet` API branch :968-981), `apimode.go:2883` (`apiConfig`)
+
+**Interfaces:**
+- Consumes: Task 1's `Sealer`; Task 2's fleet fields.
+- Produces:
+ - `func (s *Server) sealKeyFor(ctx context.Context, acctSqid, app string) (appconfig.Sealer, error)`: resolves the account by sqid (refuse unknown), requires the app's console store row (refuse `errUnknownApp`), `appPlacement`; `fleet/<f>`: the fleet row must have `Account == acct.Sqid`, its `SecretsPub` parsed, `NewSealer(pub, Binding{sqid, app}, true)`, or `errFleetNoSecretsKey{Fleet}`; otherwise the deployment key with `NewSealer(pub, b, appconfig.BoundSealing())` and today's refusals when it is missing or unparseable.
+ - `type errFleetNoSecretsKey struct{ Fleet string }` with the approved copy row as its message.
+ - The GET: `secrets_pubkey` and `secrets_account` from `sealKeyFor` (fleet: always `secrets_account`); on `errFleetNoSecretsKey` both are omitted (B8).
+ - The PUT, for each secret in `Set`, with `SealedTo` added to the request struct: under `s.lockAccount(acct.Sqid)` from `sealKeyFor` through `Apply`/`ApplyEnvironment`; fleet app: `SealedTo` must equal the sealer's fingerprint and the envelope must be v2, else 400 naming the var and the fix; platform app: absent accepted, present and different refused. The stored Var keeps `SealedTo`.
+ - CLI: `secretsPubKeyAPI` also returns the fingerprint; the API branch sends `SealedTo` per var.
+ - (R-1) `func (s *Server) backfillAppPlacements(ctx context.Context) error`: for every app row whose `placement` is empty and whose routes say `fleet/<f>` (`fleetFromRoutes`), `SetAppPlacementContext`; started from the same goroutine as `RunFleetOwnerBackfill` (`cmd/console/main.go:657-666`), logging failures, never blocking a seal.
+
+- [ ] **Step 1: Write failing tests** through the fixture: `TestSealKeyForFleetApp` (fleet key, bound), `TestSealKeyForPlatformApp`, `TestSealKeyForKeylessFleetRefuses` (never the deployment key), `TestSealKeyForSqidOnlyAccount` (a sqid that resolves to a fleet app gets the fleet key; an unknown sqid refuses), `TestSealKeyForOtherAccountsFleetRefuses` (a placement row naming another account's fleet: refused, I1), `TestConfigGetServesTheFleetKey`, `TestConfigGetOmitsKeyOnKeylessFleet`, `TestConfigPutRefusesMissingSealedToOnFleetApp`, `TestConfigPutRefusesWrongKeyOnFleetApp`, `TestConfigPutRefusesV1OnFleetApp`, `TestConfigPutAcceptsOldCLIOnPlatformApp`, `TestConfigPutRacesReplacement` (deterministic: a hook between the check and `Apply` that tries a key replacement; the replacement waits on the account lock and then refuses because the value is sealed). `TestBackfillAppPlacementsFromRoutes`. CLI: `TestSecretsSetSendsSealedTo`.
+- [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ . -run 'TestSealKeyFor|TestConfigGet|TestConfigPut|TestSecretsSetSendsSealedTo' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement.** The race hook is a test-only function variable in `apiconfig.go`, nil in production.
+- [ ] **Step 4: Run** the same plus `-run 'Config|Secret'` over `./internal/console/`. Expected: PASS. Mutation: make `sealKeyFor` fall back to the deployment key on `errFleetNoSecretsKey`; `TestSealKeyForKeylessFleetRefuses` fails.
+- [ ] **Step 5: Commit.**
+
+### Task 6: Console-minted credentials and the guard
+
+**Files:**
+- Modify: `internal/objstore/walk.go` (`writeEnv` :868, `Grant` :916, `GrantIn` :923, `GrantInFor` :929, `Rotate` :936, `RotateIn` :957), `internal/mail/walk.go` (`writeSMTPEnvIn` :957, `Enable` :2031, `Rotate` :2066), `internal/mail/walk_environment.go:198`, `internal/console/apistore.go` (`storeSealKey` :687 and callers :792, :878), `apistore_provision.go:36`, `apiscan.go` (:333, :461, :552, :692), `instanceprivatestore.go:389`, `apisystem.go` (:73, `rotateWebhookBudget` :92-140), `apimail.go` (`mailSealKey` :151, callers :1278, :1379), `relayops.go:576-591`, `relayenv.go:46-73`, `scankeysync.go:37-55`, `planstorage.go:72-109`, `teamcreds.go:46-64`
+- Create: `internal/console/sealkey_guard_test.go`
+
+**Interfaces:**
+- Consumes: Task 5's `sealKeyFor`; Task 1's `Sealer`.
+- Produces:
+ - Every `sealPub *ecdh.PublicKey` parameter in `objstore` and `mail` becomes `seal appconfig.Sealer`; they call `seal.Seal(appconfig.Binding{acct, app}, ...)` and store the returned Var (with `SealedTo`).
+ - `storeSealKey` and `mailSealKey` become `func (s *Server) storeSealKey(w http.ResponseWriter, r *http.Request, acct *Account, app string) (appconfig.Sealer, bool)` (and the mail twin), answering the approved keyless-fleet refusal before any backend call.
+ - `rotateWebhookBudget(ctx)` and `convergeCallbackKey(ctx, acct *Account, app string)` take no key; each app's sealer comes from `sealKeyFor(ctx, target.acct, target.app)`. Background walks (plan storage, team credentials, webhook rotation) skip an app whose `sealKeyFor` fails, with a log line, and retry next pass.
+ - Every seal-and-write runs under `s.lockAccount(sqid)`, taken before any app lock already held on that path.
+- Guard (`TestOnlySealKeyForBuildsSealers`): a go/ast walk of every non-test `.go` file in the module (pattern `internal/console/teamcreds_test.go`) collecting calls to `appconfig.Seal`, `appconfig.SealBound`, `appconfig.SealUnbound`, `appconfig.NewSealer` and `archive.Seal`. Allowlist, by enclosing function: `appconfig.(Sealer).Seal`; `console.(*Server).sealKeyFor`; `main.sealSecretAPI`; `main.runSecretsSet` (direct mode, after Task 8's checks); `archive.Seal` and its callers `buildArchive` and `offlineArchive` in `internal/host` (platform moves, deployment key; fleet instances are not moved). Any other call fails the test naming file:line. Negative fixtures as testdata packages: a new site with an arbitrary key, a second seal inside `sealkey.go`, a sealer for `bab/shop` used on `bab/other` (fails at runtime with `ErrSealerBinding`).
+
+- [ ] **Step 1: Write failing tests**: `TestOnlySealKeyForBuildsSealers` with its three negative fixtures; `TestStoreGrantOnKeylessFleetRefusesBeforeBackend` (the fake provisioner records no call); `TestStoreGrantOnFleetSealsToTheFleetKey` (the delivered Var opens with the fleet private key and has `SealedTo`); `TestMailEnableOnFleetSealsToTheFleetKey`; `TestRelayApplyOnFleet`; `TestWebhookRotateUsesEachAppsKey` (two apps, one platform and one fleet, sqid-only targets); `TestPlanStorageSkipsKeylessFleet`.
+- [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ ./internal/objstore/ ./internal/mail/ -run 'TestOnlySealKeyForBuildsSealers|TestStoreGrantOn|TestMailEnableOnFleet|TestRelayApplyOnFleet|TestWebhookRotateUsesEachAppsKey|TestPlanStorageSkipsKeylessFleet' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement**, approved rows only.
+- [ ] **Step 4: Run** the same, plus `-run 'Store|Mail|Relay|Scan|Webhook|Plan|Team'` over the three packages. Expected: PASS. Mutation: add `appconfig.SealBound` to `apimail.go`; the guard fails naming it.
+- [ ] **Step 5: Commit.**
+
+### Task 7: Moves and `env fork`
+
+**Files:**
+- Modify: `internal/console/fleets.go` (`placeAppTarget` :623-807), `internal/console/server.go` (`claimAppWith` :4999-5139), `internal/console/apienv.go:263-301`
+- Test: `internal/console/fleetsecrets_moves_test.go`
+
+**Interfaces:**
+- Consumes: Task 5's `sealKeyFor`; Task 3's `fleetSealedValues` logic, generalised as `func (s *Server) staleForTarget(ctx context.Context, acct *Account, app, target string) ([]string, error)` (sealed vars in any bundle or environment whose `SealedTo` is absent or not the target's key fingerprint; target `""` is the deployment key).
+- Produces: `placeAppTarget` refuses with the approved row when `staleForTarget` is non-empty, after the rootfs/seed/HA refusals and before `SetAppPlacementContext`, under `s.lockAccount`; `claimAppWith` runs the same check before `createClaimAppRow` (:5107) when `adoptingExistingApp` and placement is non-empty; `handleAPIEnvironmentFork` takes `s.lockAccount(acct.Sqid)` before `s.lockApp`.
+
+- [ ] **Step 1: Write failing tests**: `TestPlaceRefusesStaleSealedValues` (platform app `shop` with a deployment-key secret placed onto `home`: refused, names the var; placement unchanged), `TestPlaceAllowsAppWithNoSecrets`, `TestCreatePlaceAdoptingRefusesBeforeTheRow` (no app row written), `TestForkWaitsForTheAccountLock` (deterministic: fork holds; a replacement started after it blocks until it ends).
+- [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ -run 'TestPlaceRefusesStale|TestPlaceAllowsAppWithNoSecrets|TestCreatePlaceAdopting|TestForkWaitsForTheAccountLock' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement.** Hostname-history-active deployments already refuse `apps place` first (`fleets.go:637`); the new check sits after it.
+- [ ] **Step 4: Run** the same plus `-run 'Place|Fork'`. Expected: PASS.
+- [ ] **Step 5: Commit.**
+
+### Task 8: Direct-bucket mode
+
+**Files:**
+- Modify: `appconfig_cli.go` (`runSecretsSet` direct branch :987-1006)
+- Create: `appconfig_cli_fleet_test.go`
+
+**Interfaces:**
+- Consumes: Task 3's `FleetOwner.SecretsKeyFP`.
+- Produces: `func directSealRefusal(ctx context.Context, st release.Store, acct string, pub *ecdh.PublicKey) error`: lists `accounts/` (pattern `internal/provision/reconcile.go:2631`), keeps keys of shape `accounts/<a>/fleets/<f>.json`, refuses (approved rows) if any has `a == acct`, or if any record's `secrets_key_fp == KeyFingerprint(pub)`, or if the list or a read fails. Called before sealing; direct mode then seals with `NewSealer(pub, b, secretsEnvelopeV2Env())` and saves Vars with `SealedTo`.
+
+- [ ] **Step 1: Write failing tests** with a `DirStore`: `TestDirectSecretsSetRefusesAnAccountWithAFleet`, `TestDirectSecretsSetRefusesAnotherFleetsKey` (account B's fleet record carries the fp of the terminal key; target account A has no fleet: refused, I1), `TestDirectSecretsSetRefusesOnListError`, `TestDirectSecretsSetPlatformAppStillWorks`.
+- [ ] **Step 2: Run** `nice -n 19 go test . -run 'TestDirectSecretsSet' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement.**
+- [ ] **Step 4: Run** the same plus Task 6's guard. Expected: PASS. Mutation: skip the fp comparison; `TestDirectSecretsSetRefusesAnotherFleetsKey` fails.
+- [ ] **Step 5: Commit.**
+
+### Task 9: Refusals on `instances list`
+
+**Files:**
+- Modify: `internal/console/apiinstances.go` (`boxJoin` :502, `platformBoxJoin` :711, `loadRolloutJoin` :749-967, `instanceListRecord` :151-214), `apimode.go:3319` (`apiInstanceRecord`), `instances_cli.go:594-657` (`reasonCell`)
+- Test: `internal/console/instances_config_refusals_test.go`, `instances_cli_refusals_test.go`
+
+**Interfaces:**
+- Produces:
+ - `boxJoin` gains `refusals map[string]status.ConfigRefusal` (by host) and `capped map[string]bool` (box label to "total > len(list)"), filled from both platform and fleet snapshots already loaded by the join.
+ - `instanceListRecord` gains `ConfigRefusal *configRefusalView \`json:"config_refusal,omitempty"\`` (`Reason`, `Since`, `Count`) and `RefusalsCapped bool \`json:"refusals_capped,omitempty"\``, set only on the caller's own row whose host matches (R-3), and `RefusalsCapped` only when the row's box reported a capped list without that host.
+ - `reasonCell` prints the approved rows: `no_key` (put the fleet's key in host.env and restart the agent), `cannot_open` (check `carlos secrets fingerprint` against `carlos fleets ls`; if they match, set the listed secrets again and rotate minted credentials), other reasons by word, and the capped row.
+
+- [ ] **Step 1: Write failing tests**: `TestInstanceListShowsFleetBoxRefusal`, `TestInstanceListShowsPlatformBoxRefusal`, `TestInstanceListNeverShowsAnotherTenantsRefusal` (a refusal for a host of account `other` on the same box: absent from `bab`'s list; mutation: drop the host match), `TestInstanceListShowsCappedReport` (101 refusals, `total` 101, list 100, the missing host's row carries `refusals_capped`), CLI `TestReasonCellConfigRefusals`.
+- [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ . -run 'TestInstanceListShows|TestInstanceListNever|TestReasonCellConfigRefusals' -count=1`. Expected: FAIL.
+- [ ] **Step 3: Implement.**
+- [ ] **Step 4: Run** the same plus `-run 'InstanceList|Rollout|Workers'`. Expected: PASS.
+- [ ] **Step 5: Commit.**
+
+### Task 10: Box witnesses, docs
+
+**Files:**
+- Create: `internal/host/fleet_secrets_key_test.go`
+- Modify: `docs/site/fleets.md` (or the fleets page the BYO guide links), `docs/site/rootfs.md`, `docs/site/rails.md` (the secrets step for a fleet app), the `carlos secrets` reference page
+
+**Interfaces:**
+- Consumes: Task 1's `Sealer`.
+
+- [ ] **Step 1: Write the witnesses** (no box code change): `TestFleetBoxRendersFleetKeyConfig` (agent in fleet mode over a store-door fixture, `CARLOS_REGION=fleet/home`, `CARLOS_SECRETS_KEY` = the fleet key: a v2 envelope sealed to the fleet key renders into `<host>.config.env`; `CanProvideConfig` is nil), `TestFleetBoxRefusesDeploymentKeyConfig` (same box, envelope sealed to another key: `ReasonCannotOpen`), `TestFleetBoxCannotRenderAnotherFleetsApp` (fleet `away`'s box, an app of `home`: refused). They are expected to pass at once; show each failing first by sealing to the wrong key in the fixture. Also `TestFleetBoxWritesNoEdgesFile` (§6: the platform candidate sets read only `control/edges/`; a fleet-mode agent's publisher loop exits, `edgesfile.go:1012-1014`), unless an existing test already pins it, in which case cite that test in the commit message.
+- [ ] **Step 2: Run** `TMPDIR=/tmp/g nice -n 19 go test ./internal/host/ -run 'TestFleetBox' -count=1` (sandbox off). Expected: PASS.
+- [ ] **Step 3: Write the docs** from approved rows: registering a key (genkey on the first box, KEY in every box's host.env, restart the agent, `fleets secrets-key`), the stale list and how to clear it, `secrets fingerprint`, replacement (§5.6), and the rails guide's secrets step for a fleet app.
+- [ ] **Step 4: Run** the copy gates (`go test . -run 'Copy|Applied|Built'`) and any docs drift test (`-run Rails`). Expected: PASS.
+- [ ] **Step 5: Commit.**
+
+### Task 11: Census, whole-branch review, merge
+
+- [ ] **Step 1:** `make census-card`; write CLAIMS; `make census-propose NAME=fleet-secrets-key CLAIMS=<file>`; brief Astra from `REVIEW-BRIEF-TEMPLATE.md` for the census and the whole branch (one review, budget three rounds, stopping rules apply; I1 and the guard are the focus).
+- [ ] **Step 2:** Push, CI green on the tip, record the census verdict on #280.
+- [ ] **Step 3:** Paul's merge go, then `amadan branch merge carlos/platform <branch> -squash -expect <tip>`.
+
+### Task 12: Live on dev, then rootfs Task 11
+
+- [ ] **Step 1:** A release containing the merge (release session), rolled to dev: boxes, then the dev console; the CLI on DOCS-T1 updated.
+- [ ] **Step 2:** `carlos secrets genkey` on DOCS-T1 into a 0600 file under the run's scratch; KEY onto r10r box-1's host.env by one SSM command fetching it from a presigned URL (never in command parameters); restart `carlos-edge`; `carlos secrets fingerprint` on the box equals the PUBKEY's.
+- [ ] **Step 3:** `carlos fleets secrets-key r10r <pubkey>`; the answer lists `shop` (`SECRET_KEY_BASE`, `SHOP_CRASH_TOKEN`); set them again; `carlos store apply` and the operator grant for `shop`; `instances list` shows no config refusal and v1's release runs.
+- [ ] **Step 4:** Resume rootfs Plan 4 Task 11 from Step 2 (`task-11-brief.md`), public checks from the box (no sophie route row; Paul 2026-10-29).
diff --git a/docs/superpowers/plans/CODEX-REVIEW-BRIEF-fleet-secrets-key-plan.md b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-fleet-secrets-key-plan.md
new file mode 100644
index 000000000..b6060fb99
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-fleet-secrets-key-plan.md
@@ -0,0 +1,34 @@
+# Review brief: fleet secrets key implementation plan, round 1 of 3
+
+Repo carlos/platform, branch `design-fleet-secrets-key`, commit named in your prompt.
+Under review: `docs/superpowers/plans/2026-10-29-fleet-secrets-key.md`.
+Authorities: the APPROVED spec `docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md` (rev 5, Paul 2026-10-29; its §2.1 invariants bind), the code on this branch (main 0c39af30), `AGENTS.md`. Do not edit files.
+
+You are an independent reviewer. Read the plan and the spec, then the code each task names, and check every file:line, signature and name against the code.
+
+## Fixed: do not re-argue
+
+- The spec, approved after three Astra rounds (findings `docs/superpowers/specs/CODEX-FINDINGS-fleet-secrets-key-R1.md`, `-R2.md`, `-R3.md`). Review the plan against it, not the design itself.
+- Spec §2.1: I1 confidentiality is hard; I2 availability is best effort. Further direct-mode, copy-path or race findings against I2 alone are not findings.
+- The plan's rulings R-1 to R-3; challenge one only with an I1 failure or a would-not-work failure.
+
+## What to check
+
+1. Every spec requirement has a task, and no task builds something the spec does not ask for.
+2. I1 in the plan: does Task 6's guard (`TestOnlySealKeyForBuildsSealers`) and its allowlist really catch every seal path in the code today (list any `appconfig.Seal*`, `archive.Seal` or key-parsing site the plan misses), and can Task 5's `sealKeyFor` ever return a key for a fleet not owned by the app's account?
+3. Signatures and interfaces: do later tasks use exactly what earlier tasks produce? Would any changed signature (objstore, mail, `SetSecret`, `storeSealKey`, `convergeCallbackKey`, `rotateWebhookBudget`) break a caller the plan does not list?
+4. Task 3's bucket owner record update and the hostops classifier change: is it safe, and is the order (record before registry) right for direct mode (Task 8)?
+5. Lock order (account before app) on every path Tasks 5-7 put under `lockAccount`: any path that already holds an app or hostname lock first?
+6. Tests: does each named test prove what its task claims, through production wiring (AGENTS.md "Rules this repo has paid for")?
+
+## Severity
+
+- **P1**: unsafe (an I1 break), would not compile, a test fails, or it would not work. Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review.
+- **P3**: clarity or polish. Follow-up list.
+
+A P1 states its failure scenario and the evidence (file:line). Name the invariant beside each finding. Do not raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3, each with task, problem, evidence (file:line) and fix. Then one verdict line: READY, READY AFTER FIXES (no P1), or NOT READY. A round with no P1 ends the review.