plans: Astra round 3 findings on platform accounts slice 1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r3.md+21 −0
Intent
<task-notification> <task-id>a3a5de93bab7f559a</task-id> <tool-use-id>toolu_01Gh2TMmNxWoCg5KQeA3Qwty</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9284fe97-c7c7-4e03-80f2-87c51eb0406d/tasks/a3a5de93bab7f559a.output</output-file> <status>completed</status> <summary>Agent "Draft slice 1 plan" 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>Both round 2 findings are fixed in the plan and committed as `a63af377` on top of your findings commit `f33cb87d`. Not pushed. I checked each finding's citations against the code before accepting it. - **r2-1 (P1, billing deadlock): accepted, but I recorded a different lock order from your steer.** - **Fix:** customer creation (including finishing pending mints) and account deletion now share a dedicated platform lifecycle lock, `lockPlatformLifecycle`, which nothing else takes. `handleDeleteAccount` takes it right after the typed-name check, before the billing hold, and `deleteAccountNow` takes no account lock any more. Customer delete uses the same lock, and the slice 2 hand-off says claims must take it too. - **Why the order differs:** you gave "lifecycle, then billing, then account/plan". The code takes those last two the other way round: `startDomainPurchase` takes the account/plan lock (`domainbuy.go:131`), then the billing hold (`:165`). So the plan writes the order as **lifecycle → account/plan → billing** in the lock comments, the constraints and the Review log. Deletion fits either way, because it takes lifecycle, then billing, and never the account lock. - **Tests:** `TestDeletionAndDomainPurchaseDoNotDeadlock` reproduces Astra's sequence with no sleeps: 1. A deletion is paused while holding the lifecycle lock and the billing hold. 2. A domain purchase is seen holding the account lock and waiting on billing. 3. The deletion is released and finishes without ever waiting on the account lock. 4. The purchase then gets the billing hold and is refused because the account is gone. Every wait is guarded so a deadlock fails the test instead of hanging it, and the whole sequence runs 20 times. To observe the lock states, `holdBilling` and `lockAccount` emit events through the existing lock-event hook, `lifetimeLockHook`. A second test, `TestLockOrderLifecycleAccountBilling`, checks the order across customer create, deletion with billing on and off, domain purchase, and app create. - **r2-2 (P2, ended credentials still look live): accepted as you steered.** - **Fix:** the generation check stays the authorization rule, so a mint in flight across a revoke is still refused. `RevokePlatformGrant` now also marks every platform-role and per-customer credential row of that platform revoked, in the same transaction that ends the generation. Listing, rotation and name reuse then agree with authentication. - **Tests:** `TestRevokedPlatformCredentialIsGoneFromManagement` runs revoke, re-grant, then list (`cms` is absent), rotate (404, no token issued), and create a new credential named `cms` (201). The new token works under the new generation and the old one still gets 401. The revoke test in Task 4 now checks that exactly the platform's three rows are marked revoked. Round 3 is the last allowed review round.</result> <usage><subagent_tokens>543105</subagent_tokens><tool_uses>8</tool_uses><duration_ms>142425</duration_ms></usage> </task-notification>
<task-notification> <task-id>bjc8udxc4</task-id> <tool-use-id>toolu_01C7kqw7xMgDgVxBcZgLDM7W</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9284fe97-c7c7-4e03-80f2-87c51eb0406d/tasks/bjc8udxc4.output</output-file> <status>completed</status> <summary>Background command "Wait for Astra round 3 to finish" completed (exit code 0)</summary> </task-notification>
diff --git a/docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r3.md b/docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r3.md| new file mode 100644 |
| index 000000000..5402c2573 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r3.md |
| @@ -0,0 +1,21 @@ |
| +Reviewed `a63af377e49f811d7bf2a16732b4135e63114c7b` read-only. No tests run or files changed. |
| + |
| +The planned fixes address r1-1’s failed mint, r1-2’s stale authority, r1-3’s platform/customer race, r1-4’s premature manifest write, r1-5’s isolation witness, and r2-2’s credential management. R2-1 removes the billing lock inversion but introduces the first finding below. |
| + |
| +1. **P1 — Task 9: changing the customer-deletion lock allows app creation during retirement.** |
| + **Invariant:** an account cannot be tombstoned while a concurrent create adds an app. |
| + |
| + [Task 9:698](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md:698) replaces the customer’s account lock with the lifecycle lock. App creation still takes only `planLock` ([apicli.go:555](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/apicli.go:555)), which is the account lock with plans enabled. |
| + |
| + Pause customer deletion after `AppCount == 0`; complete an app create using its Publish credential; resume deletion. The manifest is tombstoned, then `DeleteUnclaimedCustomer` refuses because the app exists. On restart, [materialize.go:125](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/materialize.go:125) reaps the account, including its app rows ([store.go:1903](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/store.go:1903)). The previous account lock prevented this interleaving with plans enabled. |
| + |
| + **Fix:** enforce retirement versus app creation through one shared exclusion, with account liveness rechecked before creation writes. Preserve lifecycle → account → billing ordering. Add deterministic witnesses for both interleavings, with and without a plan catalog. |
| + |
| +2. **P2 — Task 9: the billing-deadlock witness cannot reach its pause point.** |
| + **Invariant:** a regression test must exercise the conflicting lock acquisitions. |
| + |
| + [The proposed test:730](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md:730) starts with an account holding an app, then waits for `deleteBeforeTombstone`. Browser deletion checks `deletionRefused` before acquiring billing ([ownership.go:136](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/ownership.go:136)); its app check immediately refuses ([ownership.go:167](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/ownership.go:167)). The test times out without exercising the lock order. |
| + |
| + **Fix:** start empty, pause deletion after acquiring billing but before its second app check, then create the app and start the purchase. Resume deletion and assert it refuses without tombstoning, releases billing, and lets the purchase finish. Place the pause before the former account-lock acquisition so restoring the faulty implementation makes the witness fail. |
| + |
| +NOT READY |
| \ No newline at end of file |