plans: Astra round 2 findings on platform accounts slice 1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r2.md+23 −0
Intent
<task-notification> <task-id>a3a5de93bab7f559a</task-id> <tool-use-id>toolu_011REUeJqg5QzggbFDPsiQnQ</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>The plan is revised in place and committed as `9b4c07a2` on `design-platform-accounts`, on top of the coordinator's `e2eb3195`. Not pushed. I checked each finding's code citation before acting; all five hold, so none were declined. The plan now opens with a "Review log" section, and every change is marked "(Astra r1-N)". - **r1-1 (P1, failed create breaks idempotency and the cap): accepted.** Tasks 2, 4 and 8 now enforce one rule: one live account per (platform, ref), and a promised account uses capacity until it exists. - **Pending mint first:** customer create records a pending mint in a new `platform_pending_mints` table before touching the bucket. Pending mints count against `max_customers` and hold their ref. - **Bucket mint is retry-safe:** `MintLinkedAccount` writes the mint id into the manifest (new `platform_mint` field) and returns an existing match instead of minting again. - **Finish before anything else:** platform requests finish pending mints under the platform lock before reading refs or capacity, so a retry or a console restart lands on the same account. - **New tests:** a failed finish followed by a retry (with the cap at 1), a Put that lands but reports an error, and a restart over the same database and bucket. - **r1-2 (P1, a mint can escape the revoke): accepted.** Tasks 4, 7 and 10. - **Generation:** each grant gets a generation number that every revoke increments. Every platform-role and per-customer credential row stores the generation it was minted under, and resolution accepts a row only while that generation is current and active. - **One check, two callers:** the per-customer mint re-checks the generation, the link and the minter's own authority inside its insert transaction, using the same function resolution uses. The row sweep from the first version is gone. - **New tests:** a mint paused across revoke and re-grant (minted by a platform credential, by a person owner, and with the minter's own credential revoked during the pause). Each is refused and writes no row. - **r1-3 (P1, platform deletion races customer creation): accepted.** Tasks 8 and 9. - **Shared lock:** `deleteAccountNow` takes the platform's account lock first and holds it through the re-check, the tombstone and the row deletion. Customer create takes the same lock and re-reads the platform and its grant under it. - **Pending mints count:** they count as customers in the deletion check. - **Lock order:** on the billing path the billing hold comes first, then the account lock. I found no existing code that takes them the other way round. - **New tests:** both interleavings, create first and delete first. Neither tombstones a platform that has customers, and a create that waited on a deletion writes nothing. - **r1-4 (P1, host door writes before its safety checks): accepted, by removing the write rather than reordering checks.** Task 12. - **Why no manifest is needed:** the box-side reconcile serves records for apps with no instances manifest (`provision/reconcile.go:1628-1660` says the manifest "only governs the API door"). - **How:** the `platform-host` door writes nothing itself. It passes a default manifest in memory to the existing instance-create handler through a request-context value that only `instanceManifest` reads. That handler then runs all its own refusals and takes its own copies lock. - **New tests:** for each refusal case (control-plane app, bad channel, non-static channel head, running-things cap), the manifest stays absent, the audit rows and the serial are unchanged. Two more pin that the record serves without a manifest and that only those two places read the context value. - **Copy table:** the `audit.platform_host_enable` row is gone, since the door writes no audit row of its own. - **r1-5 (P2, second-customer test can pass without isolation): accepted.** Tasks 10 and 14 now create `site` in both customers, each through its own credential, and show each credential working in its own account first. Only then do they assert the 404s across accounts, a read and a ship write, in both directions. This was round 1 of the three allowed.</result> <usage><subagent_tokens>520573</subagent_tokens><tool_uses>28</tool_uses><duration_ms>444553</duration_ms></usage> </task-notification>
<task-notification> <task-id>brcqrk3j2</task-id> <tool-use-id>toolu_01Pqk45FsfoxgNwtdkUDqsiB</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9284fe97-c7c7-4e03-80f2-87c51eb0406d/tasks/brcqrk3j2.output</output-file> <status>completed</status> <summary>Background command "Wait for Astra round 2 to finish" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 3.74 g CO₂e (446,683 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-platform-accounts, 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/ASTRA-FINDINGS-platform-accounts-1-r2.md b/docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r2.md| new file mode 100644 |
| index 000000000..724277ca5 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r2.md |
| @@ -0,0 +1,23 @@ |
| +Reviewed `9b4c07a23ce7f791b32957237174322f4da54b41` read-only. No tests run or files changed. |
| + |
| +The revised steps address r1-1, r1-4 and r1-5. The generation check closes r1-2’s mint/revoke race; the shared lock closes r1-3’s creation/tombstone race. Those last two fixes introduce these defects: |
| + |
| +1. **P1 — Task 9: the deletion lock introduces a billing deadlock.** |
| + **Invariant:** account and billing locks must have one acquisition order. |
| + |
| + [Task 9:684](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md:684) says no existing caller takes billing while holding the account lock. But `startDomainPurchase` takes `planLock` at [domainbuy.go:131](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/domainbuy.go:131), then `holdBilling` at line 165. With plans enabled, `planLock` **is** the account lock. Deletion holds billing while calling `deleteAccountNow` ([ownership.go:139](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/ownership.go:139)); the proposed change then waits for the account lock. |
| + |
| + Reachable sequence: deletion passes its initial empty-account check and acquires billing; a concurrent app create completes; a domain purchase acquires the account lock and waits for billing; deletion waits for the account lock before reaching its second app check. Both requests remain blocked. |
| + |
| + **Fix:** enforce one lock order across retirement and deletion, or use a dedicated platform lifecycle lock shared by customer creation and platform deletion. Add a deterministic interleaving test covering domain purchase; the proposed tests cover only customer creation. |
| + |
| +2. **P2 — Tasks 4, 7: ended generations remain “live” to credential management.** |
| + **Invariant:** credential listing, rotation and name reuse must agree with authentication about ended credentials. |
| + |
| + [Task 4:391](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md:391) drops the token sweep without adapting the existing management queries. `ServicePrincipals` lists rows using only `revoked_at = 0` ([svcprincipal.go:456](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/svcprincipal.go:456)); rotation uses the same condition and preserves the generation (line 491). Minting checks the old row’s name at line 422, backed by the [unique index](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/internal/console/authstore.go:326). |
| + |
| + After revoke and re-grant, `cms` still appears live. Rotating it succeeds but returns a token that always gets 401; creating a replacement named `cms` fails as already taken. |
| + |
| + **Fix:** define management behavior for ended generations. Retain generation checks for authorization, but retire obsolete platform-role rows or explicitly handle them in listing, rotation and name reservation. Test revoke → re-grant → list/rotate/recreate with the same name. |
| + |
| +NOT READY |
| \ No newline at end of file |