docs: store write credential phase 2 fixes in the design
Section 3 describes the core's scope and its two renderings; section 14 lists every repoint path and how each meets the console floor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+146
−40
docs/superpowers/specs/2026-11-25-store-write-credential-design.md+146 −40
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 f8ddf20bd..1d9bc1cc4 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 |
| @@ -226,39 +226,54 @@ write-only and prefix-scoped, and the app's key mints none. |
| ## 3. The scope: the core's session policy |
| -Built in `internal/objstore` (provider-neutral, no SDK), from the bucket |
| -in the store's record and the validated prefix. With `R` = |
| -`arn:aws:s3:::<bucket>/<prefix>*` and `W` = the three write actions: |
| +The core (`internal/objstore`, provider-neutral, no SDK) decides the scope, |
| +a `WriteScope` of the bucket in the store's record and the validated |
| +prefix, and each backend renders it into the session policy its own STS |
| +takes (phase 2 fixes, Paul's option 1 of 2026-11-25). With `R` = |
| +`arn:aws:s3:::<bucket>/<prefix>*` and `W` = the three write actions, both |
| +renderings share three statements (`WriteScope.scopeStatements`): |
| ```json |
| -{"Version": "2012-10-17", "Statement": [ |
| {"Effect": "Allow", "Action": W, "Resource": R}, |
| + <the backend's denial of every action that is not a write>, |
| {"Effect": "Deny", "Action": ["s3:*"], "NotResource": R}, |
| - {"Effect": "Deny", "Action": ["s3:Get*", "s3:Delete*", "s3:Replicate*", "s3:Restore*", "s3:Bypass*", |
| - "s3:PutObjectV*", "s3:PutObjectR*", "s3:PutObjectL*", "s3:PutObjectT*"], "Resource": "arn:aws:s3:::*"}, |
| {"Effect": "Deny", "Action": ["s3:PutObject"], "Resource": "arn:aws:s3:::*", |
| "Condition": {"Null": {"s3:RequestObjectTagKeys": "false"}}} |
| -]} |
| ``` |
| -The two scope Denies are what make the scope hold against a resource |
| -policy **(astra 1.6)**: everything outside the prefix, and every object |
| -action that is not a write, by family. The last Deny refuses any upload |
| -that carries tags at all (`x-amz-tagging`), beside the writer's Deny on |
| -the platform's own tag keys: AGENTS.md's "absence is not the property" |
| -applied to the new credential. The MinIO contract runs this exact |
| -document. |
| - |
| -Why families and no `NotAction` (found by the MinIO contract in CI, |
| -2026-11-25): MinIO's STS refuses a session policy with `NotAction`, since |
| -it cannot marshal the empty action set that leaves, and it refuses any |
| -action name it does not know, accepting a wildcard only when it matches |
| -one it does. Each family above is accepted by both engines. Three AWS |
| -object actions fit no such family and stay denied only by absence: |
| -`s3:PutObjectAcl` (store buckets are made with ACLs disabled, so S3 |
| -refuses it anyway), `s3:ObjectOwnerOverrideToBucketOwner` and |
| -`s3:InitiateReplication` (both need a replication configuration, which |
| -the store's own policy denies setting). A test pins that list. |
| +**AWS** (`awsWriteSessionPolicy`, the AWS adapter): the second statement is |
| +`{"Effect": "Deny", "NotAction": W, "Resource": "*"}`. Everything but the |
| +three writes is denied by name of what is allowed, so an S3 action AWS |
| +adds later is denied with no change here. Phase 1 denied object action |
| +families instead (below), and code review round 3 found that left |
| +`s3:ListObjectAnnotations`, `s3:PutObjectAnnotation` and |
| +`s3:UpdateObjectEncryption` open to a resource policy granting the session |
| +directly. The evaluator test (`TestAWSWriteScopeAgainstEverySDKAction`) |
| +judges this document against every S3 action the pinned SDK names, its |
| +client's operations and the actions its operation docs name, plus names |
| +it does not have yet, under such a direct grant and without one. |
| + |
| +**MinIO** (`minioWriteSessionPolicy`): MinIO's STS refuses a session policy |
| +with `NotAction` (it cannot marshal the empty action set that leaves), and |
| +refuses any action name it does not know, accepting a wildcard only when it |
| +matches one it does (found by the MinIO contract in CI, 2026-11-25). Its |
| +second statement denies the object action families MinIO accepts: |
| + |
| +```json |
| + {"Effect": "Deny", "Action": ["s3:Get*", "s3:Delete*", "s3:Replicate*", "s3:Restore*", "s3:Bypass*", |
| + "s3:PutObjectV*", "s3:PutObjectR*", "s3:PutObjectL*", "s3:PutObjectT*"], "Resource": "arn:aws:s3:::*"} |
| +``` |
| + |
| +What that leaves undenied by name is what MinIO has no action for, so a |
| +MinIO server cannot be asked for it. That is why it is MinIO's rendering |
| +and never AWS's. The MinIO contract runs this document. This build has no |
| +MinIO provisioner (§6); a future one renders with it. |
| + |
| +The scope Denies are what make the scope hold against a resource policy |
| +**(astra 1.6)**: everything outside the prefix, and every action that is |
| +not a write. The last Deny refuses any upload that carries tags at all |
| +(`x-amz-tagging`), beside the writer's Deny on the platform's own tag keys: |
| +AGENTS.md's "absence is not the property" applied to the new credential. |
| The prefix is validated before it goes near a policy: |
| @@ -313,11 +328,16 @@ seconds of steps 5 to 7. It is never logged, recorded or returned. |
| ## 6. Provider boundary |
| - **Core** (`internal/objstore/writecred.go`): the prefix and lifetime |
| - rules, the session policy, the writer's name and policy, the state |
| - object, the walks. No SDK. |
| -- **AWS adapter** (`internal/objstore/aws_writecred.go`): creating the |
| - writer, the single-use key and `GetFederationToken`. STS client from |
| + rules, the scope (`WriteScope` and the statements every rendering |
| + shares), the writer's name and policy, the state object, the walks. No |
| + SDK. |
| +- **AWS adapter** (`internal/objstore/aws_writecred.go`): AWS's rendering |
| + of the scope (`awsWriteSessionPolicy`, §3), creating the writer, the |
| + single-use key and `GetFederationToken`. STS client from |
| `internal/rootaws` (`LoadStaticConfig`, the bounded transport). |
| +- **MinIO rendering** (`internal/objstore/minio_writecred.go`, no SDK): |
| + `minioWriteSessionPolicy`, which the MinIO contract runs and a future |
| + MinIO provisioner would send. |
| - **S3-compatible stores** (a record with an `endpoint`): refused with |
| 409 `write_credentials_unsupported`, saying a write credential needs AWS |
| S3 and STS. The console also refuses to boot with both |
| @@ -329,9 +349,10 @@ seconds of steps 5 to 7. It is never logged, recorded or returned. |
| - **MinIO contract.** MinIO's STS `AssumeRole`, signed with a MinIO |
| user's key, takes a session policy and grants the intersection of the |
| user's policy and it. The CI step creates a MinIO user carrying the |
| - writer policy's shape and proves the core's session policy on a real |
| - policy engine. A future MinIO provisioner implements the same |
| - `MintSession` seam with that call. |
| + writer policy's shape and proves MinIO's rendering of the core's scope |
| + (`minioWriteSessionPolicy`, §3) on a real policy engine. A future MinIO |
| + provisioner implements the same `MintSession` seam with that call and |
| + that rendering. |
| The provisioner seam gains two methods: |
| @@ -339,9 +360,11 @@ The provisioner seam gains two methods: |
| // EnsureWriter creates the writer user under the store boundary if absent |
| // and writes its inline policy (an overwrite). |
| EnsureWriter(ctx context.Context, name, path, policy string) error |
| -// MintSession mints a temporary credential for user, narrowed by the IAM |
| -// session policy policy, lasting ttl, through a single-use key. |
| -MintSession(ctx context.Context, user, policy string, ttl time.Duration) (Session, error) |
| +// MintSession mints a temporary credential for user, narrowed to scope by |
| +// a session policy the backend renders for its own engine (§3), lasting |
| +// ttl. The AWS adapter renders awsWriteSessionPolicy and calls STS through |
| +// a single-use key. |
| +MintSession(ctx context.Context, user string, scope WriteScope, ttl time.Duration) (Session, error) |
| ``` |
| `DeleteUser` removes the writer as it removes a store user. |
| @@ -493,12 +516,15 @@ What it costs and why it is safe: |
| grant; teardown removing the writer and state; the AWS adapter against |
| stub IAM and STS clients; the doors and the CLI. |
| - Policy evaluation: a small IAM evaluator in the tests, over the |
| - boundary, the writer's policy, the session policy and a resource policy |
| - naming the session, proving a write credential cannot read, list, |
| + boundary, the writer's policy, AWS's session policy and a resource |
| + policy naming the session, proving a write credential cannot read, list, |
| delete, tag, write outside its prefix, write another store or a |
| - deployment bucket, and that a revocation cuts it off. |
| + deployment bucket, and that a revocation cuts it off. Phase 2 fixes: |
| + the same against every S3 action the pinned SDK names and names it does |
| + not have yet, under a resource policy granting the session everything, |
| + and a test of the evaluator's NotAction itself. |
| - MinIO contract (`.amadan/ci.d/30-minio-contract`): a real session from |
| - MinIO's STS narrowed by the core's session policy, against a user with |
| + MinIO's STS narrowed by MinIO's rendering of the scope, against a user with |
| the writer's policy: put and multipart under the prefix succeed; read, |
| head, list, delete, tag, put outside the prefix, put tagged and put to |
| another bucket are denied. |
| @@ -508,7 +534,9 @@ What it costs and why it is safe: |
| - 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. |
| + it does not. Phase 2 fixes: `release.PointLive` refuses the same on |
| + every path (§14), with a witness per path, a floor-read failure on each, |
| + and a guard test over the module's source. |
| ## 12. Stopped after code round 2: named-unit recovery and the floor |
| @@ -567,3 +595,81 @@ fixed and reviewed.** |
| STS refuses `NotAction`. Section 3 changes to match. |
| Both are listed in `docs/superpowers/notes/store-write-credential-followups.md`. |
| + |
| +## 14. Phase 2 fixes: one floor admission for every repoint (option A) |
| + |
| +Branch `store-write-credential-phase2-fixes`. The phase gate stays closed |
| +(`writeCredentialsReleasedPhase` is still 1); switching it on is a later |
| +change with Paul's go. |
| + |
| +**The one admission.** `release.PointLive(ctx, floor, optDir, host, acct, |
| +ver, app, ...)` is the only way a live link moves. It asks |
| +`admitConsoleFloor` first and swaps through the unexported `pointLive` |
| +only when that admits. The rule is §10's, unchanged: when the staged |
| +build's Go program is the console, the floor key exists (a one-key bounded |
| +listing; the body is never read) and the staged bytes lack the marker, |
| +nothing moves and the answer is a `*ConsoleFloorError` |
| +(`errors.Is(err, release.ErrConsoleFloor)`). A floor read that fails, or |
| +no store to read it from, refuses a console build too; any other program |
| +is admitted whatever the store says. Because every caller must hand |
| +`PointLive` a store, the compiler finds every path; the guard below finds |
| +any that writes the link itself. |
| + |
| +**Every path that can make a box run a different console build,** found by |
| +reading every caller of `PointLive` and every writer of a live link: |
| + |
| +| Path | Where | How it meets the floor | |
| +|---|---|---| |
| +| Adoption, forward | `release/adopt.go` `adoptHost` | `consoleFloorAdmits` early (skips the converge and history attempt), then `PointLive` with the pass's store | |
| +| Adoption, D1 rollback to the running build | `adopt.go`, after a failed restart | `PointLive` with the pass's store; a refusal is "could not roll the symlink back", so nothing is started | |
| +| D1 process-group rollback | `release/rollback.go` `rollbackGroup` | `PointLive` with the pass's store, per sibling | |
| +| Held stage publish, and its restore | `release/materializeheld.go` `publishHeld`, `restoreLive` | `PointLive` with the stage's store | |
| +| Named-unit recovery, stopped unit | `host/namedrecovery.go` `repair` | `PointLive` with the proof binding source's deployment store | |
| +| Named-unit recovery, active unit | `host/namedrecovery_active.go` `recover` | `release.CheckConsoleFloor` before the rollback attempt is captured, then `PointLive` | |
| +| Root rollback resume | `host/rootrollback_resume.go` `resumeRootRestart` | `rootRestartChecks.repointLive`: `PointLive` with the same source's store | |
| +| Root history rollback | `host/roothistory_recovery.go` `resumeHistoryRestart` | the same | |
| + |
| +Paths that do not repoint, checked: |
| + |
| +- A cold wake's materialize (`activator` `ensureLiveLink` → |
| + `release.MaterializeHost`) runs `PassFilter`, so it is adoption, above. |
| +- `carlos bootstrap` creates `/opt/carlos/live` and puts nothing in it. |
| +- `carlos system update` and `system apply` install the platform binary |
| + and its units, not a route's build. |
| +- The offline move landing (`movesoffline_land.go` `liveNotSealed`) reads |
| + the link and never changes it. |
| +- An isolated instance's own `live/` (`instancectl` `ensureExe`) links to |
| + the host's live link, never to a build, so it follows `PointLive`. |
| +- A restart of the build the link already names (active recovery's |
| + `before == target`, `carlos adopt -restart-only`, D1's start after an |
| + admitted rollback) runs the same build. |
| + |
| +**What a refusal leaves.** A refused forward repoint leaves the box on what |
| +it runs, as §10 says. A refused rollback leaves the writer-aware build |
| +linked and its unit down, the state a rollback that cannot repoint already |
| +reaches (`could not roll the symlink back`); the next pass asks again, and |
| +promoting a writer-aware build is the way out. A box already running a |
| +console below the floor keeps it until its next repoint: the floor governs |
| +what is pointed live, as §10 defines it. |
| + |
| +**The guard.** `TestEveryRepointPassesTheConsoleFloor` |
| +(`internal/release/consolefloor_guard_test.go`) reads every non-test Go file |
| +in the module and fails on any use of `pointLive` outside `PointLive`, and |
| +on any function that names a live link (`LiveLink`, `liveDir`, `liveLink` |
| +or a `live` path segment) and makes, renames or replaces a link |
| +(`os.Symlink`, `os.Rename`, `os.Link`, their `unix` and `syscall` forms, |
| +`instancefs.RenameBetween*`), outside `pointLive`. Today nothing else does. |
| + |
| +**Witnesses**, each with a floor and a console build from before it, a |
| +floor read that fails, and (host) a no-floor control: |
| +`TestPointLiveIsTheConsoleFloor`, `TestAdoptionForwardFloorReadFailureRefuses`, |
| +`TestBoxRefusesAPreFloorConsole`, `TestD1RollbackMeetsTheConsoleFloor`, |
| +`TestRollbackGroupMeetsTheConsoleFloor`, `TestHeldStageMeetsTheConsoleFloor` |
| +(release), and `TestNamedRepairMeetsTheConsoleFloor`, |
| +`TestNamedActiveRecoveryMeetsTheConsoleFloor`, |
| +`TestRootRollbackResumeMeetsTheConsoleFloor`, |
| +`TestRootHistoryRollbackMeetsTheConsoleFloor` (host). All of them fail |
| +with the admission disabled. |
| + |
| +**The session policy** (§3): the core's `WriteScope`, rendered by AWS with |
| +`NotAction` and by MinIO with action families. |