carlos / platform Public

plans 6b: Paul granted Invoices read (Call 18); round-5 findings and the round-6 brief

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 09060b4921f08adf82ebf7fab0de62a0b3b8d463 parent df01e87
3 files changed, +100 −4
  • docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md +4 −4
  • docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN-R5.md +73 −0
  • docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R6.md +23 −0

CI passed — run details

diff --git a/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md b/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md
index fb12e7d75..fe60ab702 100644
--- a/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md
+++ b/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md
@@ -91,7 +91,7 @@ Read with `stripe docs` on 2026-10-25. API v1, which is what the 6a client calls
- **The obligation survives failures.** An invoice-read failure or `ErrIncomplete` leaves it `open`, with `attempts` and `last_error` updated. A crash between saving the renewal and checking it leaves it `open`, and the pass finds it, because the trigger is the open row, not the period change.
- An obligation still `open` 7 days after the renewal opens `restore_check_stalled` for an operator.
- Detection writes nothing to the provider. The operator reduces the quantity or bills it in the Dashboard, then closes the problem.
- - It needs Invoices read on the restricted key: a **pending decision for Paul** (Call 18).
+ - It needs Invoices read on the restricted key: granted by Paul (Call 18, 2026-10-25).
- **R2. A late Checkout session** after its create was abandoned (Invariant 1's exception).
- The session's URL was never shown, so nobody can pay it. Its `expires_at` is at most an hour after the create, so it is already past or close.
- If one were ever completed anyway, the live-subscription check (Checkout) and discovery would adopt the subscription, and a second purchase is refused.
@@ -204,7 +204,7 @@ Also binding:
- a positive read settles at any time, from any path.
- **Operator:** the pass opens `operation_unresolved` for a cached 5xx (fact 5) or a window that closed with no definite outcome (fact 6). Changes on the account stay refused. Closing it needs a fresh read showing the target, or the operator's note stating what the Dashboard request log shows. A negative read alone never closes it.
- **A known pending payment never escalates.** It follows Stripe's pending-update lifecycle (fact 8).
-18. **Pending, asked of Paul by the coordinator: grant Invoices read to the restricted key** for Risk R1's detection.
+18. **Ruled 2026-10-25: Paul granted Invoices read on the restricted key** for Risk R1's detection.
- **Recommend: grant it.** Astra concurs (round 5): no complete permission-free substitute exists.
- The subscription read doesn't expose the renewal invoice's lines.
- `latest_invoice` can be replaced by a later proration invoice.
@@ -1362,7 +1362,7 @@ CLI: `carlos billing house -account <sqid> -on|-off -note "..."`, console mode o
| 1. R1 detection stops after the first renewal observation | A `billing_restore_checks` obligation per restore (subscription, period, op), written with the op. It is re-checked on every observation and selected directly by the pass, until it is proven applied in its own period, never executed, or compared against a stored renewal-invoice baseline (flagged or clear). It survives invoice-read failures, `ErrIncomplete` and restarts, and stalls to an operator after 7 days. Tests: renew, observe, delayed apply, observe; invoice-read failure; crash after sync; later proration invoice. |
| 2. orphaned `sending` rows | Invariant 8: a `sending` row seen under the hold is orphaned and adopted as `unresolved`. `recoveryEligible` is the single resend gate for ops, customer creates, Checkout creates and expiries, and the pass escalates rows that can never become eligible. Tests: crash before send, crash after send, an orphan escalating, a Checkout create crash. |
| 3. retry costs | Per-branch retry costs: operation `1 + 2N`, Checkout create `1 + N × (L(c) + 1)`, customer `1 + N`, expiry `1 + 2N`. `I(v, l)` counts invoice and line pages. Counts are asserted against a fake that pages like Stripe. |
-| Invoices read | A pending decision for Paul (Call 18), recommended with Astra's concurrence, with the fallback if refused. |
+| Invoices read | Granted by Paul (Call 18, 2026-10-25). |
---
@@ -1395,7 +1395,7 @@ The runbook goes at `docs/superpowers/plans/2026-10-XX-plans-6c-stripe-setup.md`
5. **The webhook:** `https://<console>/billing/webhook`, with `checkout.session.completed`, `customer.subscription.created`, `customer.subscription.updated`, `customer.subscription.deleted`, `invoice.paid` and `invoice.payment_failed`; API version `2025-02-24.acacia`; the secret goes to `CARLOS_STRIPE_WEBHOOK_SECRET`.
6. **Retry settings:** cancel after all retries fail.
7. **The restricted `rk_` key:**
- - granted: Checkout Sessions write (which also lists a customer's sessions), Customers write, Subscriptions write, Customer portal write, Billing portal configurations read, Prices read, Products read, Coupons read, and **Invoices read, pending Paul's decision (Call 18)** for Risk R1's detection;
+ - granted: Checkout Sessions write (which also lists a customer's sessions), Customers write, Subscriptions write, Customer portal write, Billing portal configurations read, Prices read, Products read, Coupons read, and **Invoices read (Call 18, granted 2026-10-25)** for Risk R1's detection;
- not granted: refunds, charges, events, webhook endpoints, keys, subscription schedules.
8. **Console variables** (EnvironmentFile only): `CARLOS_BILLING`, `CARLOS_PLAN_CATALOG`, `CARLOS_PRICE_BOOK`, `CARLOS_BILLING_PRICES`, `CARLOS_STRIPE_SECRET_KEY`, `CARLOS_STRIPE_ACCOUNT`, `CARLOS_STRIPE_WEBHOOK_SECRET`, `CARLOS_STRIPE_PORTAL_CONFIGURATION`, and optionally `CARLOS_STRIPE_HOUSE_COUPON`.
9. **Test-mode rehearsal on dev** (test clocks):
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN-R5.md b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN-R5.md
new file mode 100644
index 000000000..504a02303
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN-R5.md
@@ -0,0 +1,73 @@
+**Verdict: changes required** at `51a331c28cfe4cae69fbc880f0cd663525d998c6`.
+
+Two new Important findings and one Minor finding. Calls 1–17 and the acceptance of R1/R2 remain settled. This was an offline, static review; wording was not reviewed.
+
+| Round-4 finding or risk | Disposition | Plan evidence |
+|---|---|---|
+| 1. Retirement retries invalidate earlier checks | **Fixed** | Operations and intents finish before the final exhaustive subscription checks; nothing afterward writes to the provider. The fresh-auth regression test is explicit. [Task 13](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:1186). |
+| 2. Admission reconciliation removes available paid capacity | **Fixed** | Admission uses present seats first; reconciliation during admission never reduces quantities. [Task 11](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:1095). |
+| 3. Revocation omits `unresolved` | **Fixed as reported** | Revocation uses `opOutstanding`; the index must match its state set. Recovery still mishandles `sending`: new finding 2. [Invariant 7](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:65), [revocation](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:1105). |
+| 4. Checkout retries resolve a different coupon | **Fixed** | The console resolves the coupon before preparation; stored method, path, body and key are resent verbatim. An actual HTTP-body comparison across configuration changes is required. [Preparation](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:559), [test](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:977). |
+| 5. Retry budgets omit prerequisite reads | **Fixed for subscription retries; partly fixed overall** | `2R` includes a read and resend, but does not represent paginated Checkout reads or the customer exception. New finding 3. [Budget](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:227). |
+| R1. Restore first applies after renewal | **Accepted risk; detection incomplete** | The provider-time margin and skew guard constrain sends. The detector misses later observations within the same period. New finding 1. [Detection](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:747). |
+| R2. Abandoned Checkout create completes late | **Accepted residual; consistent with its stated boundary** | Abandonment follows exhaustive discovery, and the unknown session’s URL was never presented. This is explicitly an exception, not proof of non-execution. [Checkout lifecycle](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:934). |
+
+Only new findings follow.
+
+1. **Important — R1 detection stops after the first renewal observation.**
+
+ `lateRestoreCheckLocked` runs only when `sub.PeriodEnd` advances beyond `prev.PeriodEnd`, after `applyBillingRead` has saved the new period. [Task 7](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:683), [trigger](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:747).
+
+ A restore from one pack to three remains in flight across renewal. Renewal bills one. The console observes renewal **before** the restore applies, so quantities match the invoice and no problem opens. The restore then applies. Subsequent reads see three packs, but the stored period already matches: detection is skipped.
+
+ The same trigger loses retries after `ErrIncomplete` or a crash between saving the renewal and checking its invoice. The promised “next observation” no longer satisfies the condition.
+
+ Persist the outstanding verification obligation by subscription, period and restore. Recheck subsequent observations, retaining retry work across failures and restarts. Add `Renew → observe → delayed apply → observe`, invoice-read failure, and crash-after-sync tests.
+
+2. **Important — a crash leaves `sending` operations permanently outstanding without recovery or escalation.**
+
+ `BeginBillingOp` persists `sending` before transmission. However, `finishOpLocked` is specified only for `unresolved`, and the observation pass opens an operator problem only for `unresolved`. A negative read leaves other states unchanged. [Send and recovery](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:728), [observation pass](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:753).
+
+ Persist a seat operation, then crash before sending it. After restart, the provider still has the old quantity. The operation neither retries nor escalates, while `opOutstanding` correctly prevents another change, revocation and deletion indefinitely.
+
+ Define recovery for persisted `sending` rows: treat delivery as unknown, apply the same read/retry restrictions, and escalate when necessary. Test crashes before transmission and after transmission but before outcome persistence. The shared predicate currently covers exclusion more completely than recovery.
+
+3. **Minor — the revised retry budget still assumes every prerequisite read costs one request.**
+
+ Checkout creation retries discover the session through exhaustive `CustomerCheckouts`, whereas the budget charges `1 + 2R`. [Retry algorithm](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/docs/superpowers/plans/2026-10-25-plans-6b-checkout-flow.md:936).
+
+ With three pages per discovery and three retries, creation costs `1 + 3 × (3 + 1) = 13` requests, not seven. Conversely, customer creation explicitly has no prerequisite read, so three retries cost four requests. The new renewal-invoice lookup also lists invoices before listing lines, exceeding its one-request lookup allowance when invoice enumeration spans pages.
+
+ Use branch-specific retry costs and count both invoice and line pagination. Assert these cases against the adapter or a pagination-faithful fake.
+
+The customer-create read-before-resend exception is otherwise coherent: without a returned customer ID, the identical same-key request recovers the result. Prepared requests fix the coupon problem, and background passes consistently prohibit provider writes.
+
+**Invoices-read decision:** no complete permission-free substitute is established at this HEAD.
+
+The current subscription decoder does not expose `latest_invoice` or invoice lines. Expanding it is a possible optimization, but the supplied material does not establish that expansion works without Invoices read. Moreover, a later proration invoice can replace the renewal invoice as `latest_invoice`; reliable detection needs a retained renewal baseline.
+
+Signed invoice webhook payloads could provide cheaper diagnostic evidence without another API permission. However, the current adapter reduces them to subscription IDs, and the inherited policy uses events only to trigger fresh reads. Missing deliveries and incomplete embedded lines also need recovery. They are therefore not a complete drop-in replacement. [Current event handling](/home/paulca/.cache/tmp/claude-1001/plans-6b-checkout-flow/internal/billingstripe/adapter.go:113).
+
+I recommend Paul approve **Invoices read** if complete, recoverable invoice evidence remains required, after fixing detection. Permission behavior for expansion remains unverified under the no-network instruction.
+
+No tests, network calls or repository writes were made. HEAD, index and working tree remain unchanged.
+
+---
+
+**FIRST PROMPT:**
+“Follow the brief docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R5.md exactly, at the branch's current HEAD.”
+
+**WHAT:**
+Review revision 5 of the Plans 6b implementation plan.
+
+**STATUS:**
+Complete: changes required; two new Important findings and one Minor finding.
+
+**NEEDED:**
+Paul’s decision on granting Invoices read for R1 detection.
+
+**RECOMMENDED:**
+Fix durable late-restore verification, crash recovery for `sending`, and request accounting before implementation.
+
+**SESSION:**
+Safe to close. Repository unchanged; nothing started or left running.
\ No newline at end of file
diff --git a/docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R6.md b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R6.md
new file mode 100644
index 000000000..883e82bb8
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-PLANS-6B-PLAN-R6.md
@@ -0,0 +1,23 @@
+# Plan review brief, round 6: Plans 6b
+
+Round 5 reviewed 51a331c2; its findings are
+docs/superpowers/specs/CODEX-FINDINGS-PLANS-6B-PLAN-R5.md. Revision 6 is
+`git diff 51a331c2..HEAD`. Paul has granted Invoices read (Call 18).
+6a has merged to main as 7f79385 (this branch's parent content, plus
+main's claims cleanup R1/R2 since); flag anything in the plan that
+assumes a 6a name or file that differs on origin/main. Rulings, context
+and read-only rules as in rounds 1-5.
+
+Report:
+1. A disposition table for round 5's three findings.
+2. Only NEW findings, graded Critical / Important / Minor with a concrete
+ failure scenario. Check: the verification record (written with the
+ restore, rechecked on every observation and hourly, survives
+ failures and restarts, 7-day operator escalation, renewal-invoice
+ baseline stored once); `sending` converted to `unresolved` only while
+ holding the billing lock (is that inference sound for every writer,
+ including customer create and Checkout create?); recoveryEligible as
+ the single resend gate; the per-branch budget.
+3. A verdict: accept, accept with fixes, or changes required.
+
+Do not review the wording.