carlos / platform Public

spec: store write credential rev 4, two-phase rollout

Paul's option A for Astra round 3's P1: a phase constant keeps the doors
shut in phase 1, and adopting boxes refuse a pre-floor console build once
a writer has existed. Round 3's P2s applied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c17ac2a4bea12c3a97c71517570599989a6c79ca parent 13475ba
1 file changed, +99 −82
  • docs/superpowers/specs/2026-11-25-store-write-credential-design.md +99 −82
diff --git a/docs/superpowers/specs/2026-11-25-store-write-credential-design.md b/docs/superpowers/specs/2026-11-25-store-write-credential-design.md
index 86c33336f..8bb223c52 100644
--- a/docs/superpowers/specs/2026-11-25-store-write-credential-design.md
+++ b/docs/superpowers/specs/2026-11-25-store-write-credential-design.md
@@ -1,8 +1,9 @@
# Store write credential: design
-Status: rev 3, 2026-11-25, option B (Paul, 2026-11-25). **Stopped after
-Astra design round 3 of 3 with one P1 (section 12); a fourth round needs
-Paul's go.** Asked for by Paul on 2026-11-25. Branch
+Status: rev 4, 2026-11-25: option B, with the rollback P1 of round 3
+answered by Paul's choice of a two-phase rollout (§10). No fourth design
+round (Paul did not approve one); the code review checks §10 and the round
+3 P2s explicitly. Asked for by Paul on 2026-11-25. Branch
`store-write-credential`.
Round history:
@@ -19,7 +20,9 @@ Round history:
during a rotation unless the design shows a reason (it does not, §5).
- Round 3, `docs/superpowers/reviews/REVIEW-FINDINGS-store-write-credential-design-R3.md`:
NOT READY. Every round 1 and 2 finding resolved or moot, except R2 3
- (partly). One new P1 (rollback, section 12) and two P2s.
+ (partly). One new P1, rollback to a writer-unaware console, and two P2s.
+ Paul chose a two-phase rollout enforced in code (§10, **astra 3.1**); the
+ P2s are applied in §2.3 (**astra 3.2**) and §7 (**astra 3.3**).
## 1. What and why
@@ -144,20 +147,34 @@ and the state's `revoked_before`. Three walks write it:
writes the store user's policy. That is how the storage-grace Deny
reaches the writer when storage-limit convergence flips it.
-Those walks do not share one console lock: the storage-limit and scan
-regrants hold the account lock, the private-store grant holds the walk
-lock, and the doors here hold both. So the write is
-**write-then-validate** **(astra 1.1)**:
+**The lock discipline this rests on (astra 3.2).** One console process
+per deployment, and these locks, which every caller holds:
-1. Read the record and the state object, with their etags.
-2. Write the writer's policy computed from them.
-3. Read both again. If either etag changed, go to 2 with the new values,
- at most three times; then fail the walk.
+- the mint and revoke doors: the account lock, then the store walk lock;
+- the storage-limit and scan regrants: the account lock;
+- the store grant door: the account lock, then the store walk lock;
+- the instance private-store grant: the store walk lock, and the account
+ lock when plans are on (`instanceprivatestore.go`, `plancaps.go`).
-A revocation writes the state object before the policy, so any writer
-that read the state before the revocation sees its etag change in step 3
-and writes again. Whichever write lands last was computed from the latest
-inputs.
+Every input that matters to a revocation's safety, `revoked_before`, is
+written only by the revoke door, under both locks, and every other writer
+of the writer's policy that could hold a stale copy of it takes the account
+lock. So no two writers of the writer's policy run at once except a grant
+walk without plans, which reads `revoked_before` and cannot change it.
+
+On top of that, each write is **write-then-validate**:
+
+1. Compute the policy from the record and the state object.
+2. Write it.
+3. Compute it again from fresh reads. If it differs, go to 2 with the new
+ one, at most three times, then fail the walk.
+
+This is retry assistance, not the safety proof: a validation read that
+fails, a cancelled context or an exhausted retry can leave a stale write
+last, and the walk then returns an error, so the door or the next pass
+runs it again. A revocation writes the state object before the policy, so
+a concurrent grant that read the state earlier sees the change in step 3
+and writes again.
### 2.4 Revocation
@@ -329,11 +346,17 @@ full credential.
`DeleteAccessKey`, `ListAccessKeys`, `DeleteUserPolicy`, `DeleteUser`.
The STS call is made as the writer, not the role.
-What the boundary change gives each principal under it:
-
-- **store users** (app keys): nothing new. Their inline policy, which is
- unchanged for every store, grants no STS;
-- **managed fleet users**: nothing new, for the same reason;
+What the boundary change gives each principal under it **(astra 3.3)**:
+
+- **store users** (app keys): no STS. Their inline policy, unchanged for
+ every store, grants none. But with `store_conversion` off, turning
+ `store_write_credentials` on adds `s3:AbortMultipartUpload` and
+ `s3:ListMultipartUploadParts` to the boundary, and every store user's
+ inline policy already asks for both, so existing app keys gain those two
+ calls on their own bucket. Neither reads or writes object data; this is
+ the state `store_conversion` already produces. A tofu test pins it;
+- **managed fleet users**: nothing new; their inline policies grant
+ neither STS nor the multipart calls on store buckets;
- **writers**: `GetFederationToken` for session names under
`carlos-write-`, and the write actions.
@@ -378,22 +401,59 @@ operator applies the module switch first). Without it: 503
`TestPlan14RootReadCensus` covers `internal/objstore` and the root package
(both in the root binary) and every file under `infra/`. The changed units
are the grant and teardown walks, the new files, the provisioner seam, the
-CLI and the region-host module. None adds a root read: these are console
-walks and a CLI verb. The record-write census (`routeDecls`,
+CLI, the region-host module, and `adoptHost` with the console floor
+(§10), which is the one new root read: the floor object, and a scan of the
+staged bytes D2 already reads. The record-write census (`routeDecls`,
`linkedPolicies`) takes re-pinned entries for the two new doors.
-## 10. Rollout and rollback
-
-- Roll every console forward before setting the switch.
-- Rolled back after the switch is on, an older console does not know the
- writer. Its grant walk does not converge the writer's policy, so a
- storage-grace Deny it sets does not reach write credentials until a
- current console runs again. Its teardown leaves the writer user (which
- holds no key) and the state object behind, and the state object keeps
- the app's name from being reused (the claim gate refuses a prefix that
- still holds a key) until an operator deletes both. Revocations already
- made stay in force: nothing an older console writes touches the
- writer's policy.
+## 10. Two-phase rollout and the console floor (Paul's option A)
+
+Round 3's P1: a console that does not know writers, rolled back to after a
+writer exists, purges a store without deleting its writer and leaves the
+storage-grace Deny off it. Paul ruled a two-phase rollout, enforced in
+code, so such a rollback cannot happen while a writer exists.
+
+**Phase 1 (this branch).** The console knows writers: grant, teardown,
+purge (through teardown) and storage-limit convergence (through the grant
+walk) all cover the writer user and its state object. But the doors cannot
+open: `writeCredentialsPhase = 1` in `internal/console`, and below 2 both
+doors answer 503 `write_credentials_not_released` whatever
+`CARLOS_STORE_WRITE_CREDENTIALS` says. The boot log says so when the
+variable is set.
+
+**Phase 2 (a later branch, after a phase-1 release is on every console).**
+One line: `writeCredentialsPhase = 2`.
+
+**The console floor, on the adopting box.** Two parts:
+
+- Every console build from phase 1 on carries the capability marker
+ `carlos-console-capability:store-writers.v1` in its bytes
+ (`release.ConsoleStoreWritersCapability`, logged at boot so the linker
+ keeps it). No earlier console carries it.
+- The first mint writes `control/console-floors/store-writers.json` to
+ the deployment bucket, create-only, before it writes the state object or
+ creates any writer. It is never deleted.
+
+`adoptHost` (`internal/release/adopt.go`), beside D2, refuses to point a
+route live on a build whose Go program is the console
+(`github.com/carlosframework/platform/cmd/console`, read from the staged
+bytes as D2 reads it) when the floor object exists and the staged bytes
+lack the marker. The refusal prints why and points nothing live; the next
+pass asks again. A floor read that fails also refuses for that pass. This
+is where D2 and D3 already enforce console releases, on the box, so a
+rollback by any route (a console door, a bucket-direct promote) meets it.
+
+What it costs and why it is safe:
+
+- It is a root-side read of a deployment-bucket object any region host
+ can write. A forged floor object can only make a box refuse console
+ builds that predate phase 1: a refusal, never an admission
+ (`bucket-records-are-not-a-tenancy-boundary`). Census: a new kind of
+ read in `adoptHost`, for the reviewer to approve.
+- Boxes must run a carlos binary with the gate before phase 2; the phase-2
+ release note says so.
+- Once a deployment has had a writer, it can never roll a console back
+ below phase 1. That is the floor.
## 11. Tests
@@ -418,50 +478,7 @@ walks and a CLI verb. The record-write census (`routeDecls`,
- `tofu test`: the boundary byte for byte without the switch, the
statements with it (with and without `store_conversion`), the
precondition.
-
-## 12. Stopped after round 3: rollback to a writer-unaware console
-
-Round 3 found one P1. It is not the retirement family of rounds 1 and 2,
-which option B removed; its family is "version changes must preserve
-credential retirement and storage enforcement".
-
-- **R3 1 (P1).** §10 assumed the state object outlives an older console.
- It does not: an older console's app purge tears the store down, then
- sweeps the app's whole prefix (`internal/console/ownership.go`,
- `internal/release/trash.go`), state object included, and never deletes
- the writer user. The writer and its policy then outlive the store, so
- a session minted before the rollback can write its prefix again if the
- bucket name is created or adopted again, until it expires (24 hours at
- most). Separately, an older console's storage-limit pass records
- `writes_deny_applied` after converging only the store user, so later
- passes skip the writer and it keeps uploading past the storage grace.
-- **R3 2 (P2).** Write-then-validate (§2.3) helps, but a validation read
- that fails, a cancellation or an exhausted retry can leave a stale write
- last. The safety rests on the lock discipline (mint and revoke take the
- account and walk locks; the plan-enabled private-store grant takes the
- account lock) and must say so.
-- **R3 3 (P2).** §7 understates the boundary change: with
- `store_write_credentials` on and `store_conversion` off, existing app keys
- gain `s3:AbortMultipartUpload` and `s3:ListMultipartUploadParts`, which
- their inline policy already asks for. They still gain no STS.
-
-The P1 is refused up front without cutting the feature (Astra's reading):
-no rollback to a writer-unaware console while any writer exists. The ways
-to hold that, for Paul to choose between:
-
-- **A. Two-phase rollout.** Ship a console release that knows writers
- (teardown and purge delete them, the grant walk converges them,
- `writes_deny_applied` covers them) with the switch unable to turn on.
- Allow the switch only from a later release, so every console a rollback
- can reach is writer-aware.
-- **B. A retire-before-rollback step.** An operator verb that revokes and
- deletes every writer and its state object, run before any rollback past
- this release, written into the rollback runbook. Procedural, so it holds
- only if the runbook is followed.
-- **C. Both.**
-
-Either needs a fourth design round, which stopping rule 1 reserves for
-Paul. What a fourth round would buy: a check that the chosen gate closes
-R3 1 and that the R3 2 and R3 3 fixes are right. The option B core is built
-and unit-tested on the branch, not pushed, and changes little under A or B
-here.
+- The phase gate: both doors refuse in phase 1. The floor: the first mint
+ writes it before the writer; `adoptHost` refuses a console build without
+ the marker while it exists, and admits one with it, or any build while
+ it does not.