plans 6b: round-1 findings and the round-2 brief
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+139
−0
docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN.md+112 −0docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R2.md+27 −0
CI passed — run details
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN.md b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN.md| new file mode 100644 |
| index 000000000..9defacb0b |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN.md |
| @@ -0,0 +1,112 @@ |
| +**Verdict: changes required** at `b6005e868a08765ab70185692d7905aec058d08d`. |
| + |
| +No Critical findings. Twelve Important findings and one Minor finding follow. This was a static plan review; no network calls, tests, or repository changes were made. |
| + |
| +1. **Important — the proposed calls deadlock on the billing lock.** |
| + [Task 9, line 724](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:724) calls `syncSubscription` while holding the account’s billing lock, but the existing sync acquires that lock itself. Task 10 also calls `membersChanged` under the lock, which calls the lock-taking `reconcileSeats`. A successful charge can therefore leave the request—and subsequent billing activity for that account—blocked indefinitely. |
| + |
| + Define separate locking wrappers and helpers whose callers already hold the lock. Preserve **billing → lapse → store**, and add timeout-bounded tests for changes, renewal, and invite acceptance. |
| + |
| +2. **Important — concurrent accepts can admit members without buying seats.** |
| + [Task 10, line 781](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:781) acquires the lock only when the preliminary `seatCharged` check says payment is needed. With nine members and ten paid seats, two accepts can both see a free seat and admit eleven members. Reconciliation then opens `seats_unpaid` without charging. Task 3’s member-cap check has the same count-before-write race. |
| + |
| + Serialize every admission, including free joins and rejoins. Recheck invite validity, existing membership, member count, and paid capacity inside that boundary. Restore a previously reduced subscription quantity before admitting a free rejoin; otherwise renewal can occur between admission and reconciliation. |
| + |
| +3. **Important — invitation charge authorization is not durable.** |
| + [Task 10, line 778](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:778) displays a confirmation but records no billing authorization on the invitation. An invitation issued before billing, or when a seat was free, can later charge a Business seat without the owner having confirmed that purchase. An invitation confirmed under Community can also be accepted after a switch to Business. |
| + |
| + Persist what the owner authorized and define when renewed consent is required. Add recovery for payment succeeding before membership creation fails or the process crashes; a retried or revoked invitation must not initiate another purchase. |
| + |
| +4. **Important — previous-period quantities can buy the next period’s capacity for free.** |
| + [Task 9, line 731](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:731) takes `paidHighest` from stored `PaidPacks`, despite rereading the subscription. Suppose three packs were reduced to one, renewal bills one, and its webhook is delayed. A request for three sees current quantity one but stored paid quantity three, so it restores two packs with `ProrateNone`. Task 10 has the same problem with `PaidSeats`. |
| + |
| + Reconcile the fresh subscription’s period and identity with the stored paid quantities **before** computing any update. Test delayed renewal events and replacement subscriptions for both packs and seats. |
| + |
| +5. **Important — pending payments defeat the stated double-submit guarantee.** |
| + [Task 9, line 727](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:727) does not refuse a fresh subscription with `PendingUpdate`. After a declined or action-required payment, the current item quantity remains unchanged. Submitting again therefore issues another charge-capable update with a new random key. The absolute-target no-op rule does not protect this case, and invite acceptance follows the same pattern. |
| + |
| + Define one outstanding operation per subscription, with durable identity and explicit handling of retries, payment completion, expiry, and reordered webhooks. Hiding the form on the billing page is insufficient; enforce this in the handlers and seat path. |
| + |
| +6. **Important — Checkout can create a second live subscription.** |
| + [Task 8, line 657](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:657) refuses `billingRenewing`, which is false for an active subscription with cancellation scheduled. An owner can stop renewal and then POST directly to Checkout while the existing subscription still runs. |
| + |
| + There is another route: Task 5 treats expiry of an already-completed session as success. If the first Checkout completes before its webhook is processed, a second start can “expire” that completed session and create another subscription. |
| + |
| + Refuse while any relevant subscription remains live. Expiry must distinguish **expired** from **completed**; completion requires reconciliation before another purchase is considered. |
| + |
| +7. **Important — an uncertain Checkout creation loses its retry identity.** |
| + [Task 8, line 663](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:663) replaces the intent on every start. If Stripe creates a session but its response is lost, the stored intent has an empty session. Retrying replaces it and uses a new idempotency key, leaving the original session untracked. |
| + |
| + Resume unresolved intents with the same key and exact request parameters before replacing them. Persist enough information—including book and expiry—to reconstruct that request. Test lost responses and failure to save the returned session. Explicitly integrate this with 6a’s revised discovery pass; the promise that “the hourly pass finishes” must also cover returning customers and replacement purchases. |
| + |
| +8. **Important — account deletion is not fenced against continuing billing activity.** |
| + [Task 8, line 639](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:639) adds a stored-state check before step-up, without serializing deletion against Checkout or renewal changes. Another request can resume renewal after that check. An open Checkout can also complete after deletion because no subscription was recorded when deletion was allowed. |
| + |
| + Call 15’s assurance that stopping renewal means nothing more can be charged is unsafe: it does not establish that existing payment attempts or pending purchases are settled. Define a durable retirement gate, resolve open Checkout attempts, and verify provider state under the billing lock before tombstoning the account. Purchase and renewal handlers must recheck retirement after acquiring that lock. |
| + |
| +9. **Important — `seats_unpaid` can permanently block a repaired account.** |
| + [Task 10, line 789](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:789) opens the problem but provides no resolution. If an operator removes the excess members, the problem remains. The billing page suppresses changes while problems exist, and the inherited close endpoint refuses closure while the subscription is live. |
| + |
| + Add a reason-specific resolution that checks membership and paid capacity under the billing lock. Preserve 6a’s revised `subscription_missing` closure protections rather than weakening the general close gate. |
| + |
| +10. **Important — live-counted team changes bypass the shared plan transition.** |
| + [Task 3, line 303](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:303) changes effective limits through revision bump and publication alone. Removing members from an operator-assigned team can lower running limits without starting the lapse lifecycle; adding them back bypasses immediate reconvergence. Reading the member count after removal also loses the previous effective assignment needed to detect the fall. |
| + |
| + Route these effective-limit changes through `transitionAccountPlan`, preserving the before-and-after counts and durable lapse bookkeeping. Include the CLI membership path and retry after publication failure. |
| + |
| +11. **Important — two-step restoration does not specify how to address the newly created item.** |
| + [Task 9, line 724](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:724) allows restoring a deleted pack to its paid quantity, then charging above it. For current quantity zero, paid quantity three, and target four, the first operation creates an item. The second must update **that returned item ID**. Reusing the original absence sends another add, producing a rejected or duplicate-item purchase. |
| + |
| + Carry the item identity between steps, or reread it before the second write. Add this exact case, including failure and retry between steps. |
| + |
| +12. **Important — Call 7 contradicts the stated team-plan ruling.** |
| + [Call 7, line 63](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:63) excludes disk from the multiplier and pool, although the plan’s binding ruling explicitly includes disk. Keeping 10 GB per running thing is a different product contract. Multiplying that per-thing figure would also differ from pooling it. |
| + |
| + The recommendation cannot silently supersede the ruling. Resolve the enforcement design before recording the recommendation as the agreed specification. |
| + |
| +13. **Minor — the currency flow still silently defaults some explicit values.** |
| + [Task 7, line 589](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:589) drops malformed currencies, so `currency=usd1` becomes a default selection instead of a refusal. The Buy form also always describes selectable currencies, although ended subscriptions return to Buy with a fixed account currency. |
| + |
| + Preserve an invalid-input outcome without reflecting unsafe input, and render returning purchasers’ fixed currency consistently. Test currency enforcement again inside the Checkout lock. |
| + |
| +The remaining gaps are: |
| + |
| +- **6a integration tests:** cover discovery followed by seat reconciliation; pending replacement adoption followed by payment; clearing old seat allowances when subscription identity changes; and `subscription_missing` closure racing a purchase or seat change. Task 6 must carry seats through 6a’s atomic billing/plan/lapse transaction, not recreate the earlier separate-write path. |
| +- **Payment tests:** the proposed fake only leaves items unchanged on failure. Extend it to model outstanding updates, later payment, expiration, response loss, and reordered delivery. The existing happy-path double-submit test cannot establish financial idempotency. |
| +- **Readiness tests:** the portal and house-coupon predicates are appropriately restrictive. Add the omitted wrong-mode, invalid-coupon, payment-method-update-disabled, and house-without-coupon cases. Verify that no session is created after a readiness refusal. |
| +- **Census:** derive the final units and envelopes from the completed diff, including invitation admission, membership transitions, deletion, and recovery helpers introduced by these fixes. Review every changed function in re-pinned envelopes and retain the separate record-write census gate. |
| +- **Provider neutrality:** the interface boundary is sound in outline, but `billingRenewing` embeds Stripe status strings in console policy. Expose the required lifecycle/settlement facts through `internal/billing`; keep Stripe status interpretation in the adapter. |
| + |
| +The request budget also needs correction at [Global Constraints, line 119](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:119): |
| + |
| +| Operation | Requests implied by the plan and existing code | |
| +|---|---| |
| +| Readiness | 34 Stripe reads: merchant + 24 prices + 8 products + portal; 35 with the coupon. A late failure retried each minute can approach 2,040–2,100 reads/hour. | |
| +| Checkout start | Normally 1–3 requests; an expiry failure followed by session inspection adds another. Recovery checks need their own allowance. | |
| +| Checkout return | 3 reads normally; 4 when sync must inspect another recorded subscription. | |
| +| Pack/seat change | 4–5 calls normally: initial read, one or two writes, and two sync reads. | |
| +| Renewal change | 4 calls normally. | |
| +| Hourly reconciliation | Baseline sync and discovery calls, **plus** a fresh read, possible write, and another sync for each seat drift. Persistent `seats_unpaid` drift repeats this work. | |
| +| Limits publication | Normally an S3 GET and conditional PUT, with retries on conflicts. The shared lapse transition can add inventory reads and convergence writes; it is not merely one PUT per change. | |
| + |
| +The `/upgrade` construction uses a fixed local path and existing `safeNext` protection; I found no open redirect in the specified construction. Owned-account selection is also appropriately scoped. Keep end-to-end hostile-`next` tests alongside the currency cases. |
| + |
| +--- |
| + |
| +**FIRST PROMPT:** |
| +“Follow the brief docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN.md exactly, at the branch's current HEAD.” |
| + |
| +**WHAT:** |
| +Review the 6b implementation plan before construction. |
| + |
| +**STATUS:** |
| +Complete: changes required; 12 Important and 1 Minor findings. |
| + |
| +**NEEDED:** |
| +Nothing to complete this review. |
| + |
| +**RECOMMENDED:** |
| +Revise locking, purchase recovery, and seat admission first; then review the updated plan. |
| + |
| +**SESSION:** |
| +Safe to close. Working tree and HEAD unchanged; nothing started or left running. |
| \ No newline at end of file |
diff --git a/docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R2.md b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R2.md| new file mode 100644 |
| index 000000000..2a9805224 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R2.md |
| @@ -0,0 +1,27 @@ |
| +# Plan review brief, round 2: Plans 6b |
| + |
| +Round 1 reviewed b6005e86; its findings are in |
| +docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN.md (copied from the |
| +round-1 output). Paul has since accepted all sixteen "Calls for Paul" as |
| +recommended (69b01f37); they are rulings, not to reopen. Call 7 is now |
| +the ruling for disk: not multiplied or pooled, teams keep 10 GB per |
| +running thing. |
| + |
| +Context, scope and read-only rules are as in |
| +CODEX-REVIEW-BRIEF-PLANS-6B-PLAN.md. The revision is |
| +`git diff 69b01f37..HEAD`; the plan ends with a "Revision 2 fixes" table. |
| + |
| +Report: |
| +1. A disposition table for round 1's thirteen findings and the listed |
| + gaps: fixed, partly fixed or not fixed, with plan line evidence. |
| +2. Only NEW findings the revision introduces, graded Critical / |
| + Important / Minor with a concrete failure scenario. Look hard at the |
| + new member lock and its order (member -> billing -> lapse -> store), |
| + billingHold and the *Locked split of 6a's syncSubscription, the |
| + billing_operations table (one outstanding operation, settlement on |
| + expiry and reordered webhooks, crash recovery), invite consent and |
| + the token-bound seat charge, the retirement gate, intent resumption |
| + within 23 hours, and the request budget. |
| +3. A verdict: accept, accept with fixes, or changes required. |
| + |
| +Do not review the wording. |