plans 6a: build ledger
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+43
−0
docs/superpowers/notes/plans-6a-ledger.md+43 −0
CI cancelled — superseded by a newer push — run details
diff --git a/docs/superpowers/notes/plans-6a-ledger.md b/docs/superpowers/notes/plans-6a-ledger.md| new file mode 100644 |
| index 000000000..a17d10080 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/plans-6a-ledger.md |
| @@ -0,0 +1,43 @@ |
| +# SDD ledger — plan: docs/superpowers/plans/2026-10-25-plans-6a-checkout.md |
| +Task 0: complete (commit 9d1af95f: Calls accepted by Paul 2026-10-25; Personal bandwidth 50 GB in example catalog + spec §4.2; plans/cmd console/console plan tests pass, no test asserted the old figure) |
| +Pre-flight: T1 book -> T2 ParsePriceMap/Recognise, T3 Check, T4 billingConfig: book types consumed as plain-string currencies (map[string]map[string]int64). Plan 7 Task 1 declares `type Currency string`. Ruling: one book, string currencies per 6a's Interfaces — every 6a consumer uses strings and the export JSON is identical either way — cost if wrong: a type rename inside internal/plans. |
| +Pre-flight: T1 example book version: 6a says "example-v1", Plan 7 says "2026-10-25-draft1". Ruling: "example-v1" (6a's later tasks key prices by it; the real draft name belongs to the deployment's book file, not testdata) — cost if wrong: renaming testdata and a golden. |
| +Pre-flight: T1 refusals: Plan 7 also refuses a country under the default currency and keys the catalog lacks with named substrings. Ruling: build the union of both refusal tables, with Plan 7's error substrings — cost if wrong: none (stricter book). |
| +Pre-flight: T5 SetBillingPlan -> T6 syncSubscription: parent asks for one plan-write function for Plan 4d-1's later swap. Ruling: the write goes through one helper billingSetPlan (inside SetBillingPlan's transaction) that calls SetAccountPlan's own upsert (upsertAccountPlan, which SetAccountPlan now wraps), commented "switches to Plan 4d-1's plan-change function when it lands"; calling SetAccountPlan itself would put the source guard and the write in two transactions and let an operator write slip between them — cost if wrong: one call site to change. |
| +Pre-flight: T2 Provider.Check consumed by T7 billingReadyCheck; T6 syncSubscription consumed by T7 and T8 (close reads Provider.Subscription): signatures agree. |
| +Task 1: Ruling: Plan 7 Task 1's platform parts (PublicExport, TierMemoryMB + cgroup agreement test, cmd/pricebook-export, golden) built here per the parent's brief; schema doc committed as docs/superpowers/specs/2026-10-25-public-price-export-schema-2.md — cost if wrong: Plan 7 builder must not rebuild them. |
| +Task 1: Ruling: plans[].packs in the export are sorted by key (Plan 7 did not specify; catalog order would also be stable) — cost if wrong: a golden regen. |
| +Task 1: Ruling: book also refuses a priced pack that no paid plan offers, and a price over 100000000 minor units, with "too large" — 6a's Interfaces bound amounts 1..100000000 — cost if wrong: none. |
| +Task 1: complete (commits 9d1af95..1a77863, tests: go test ./internal/plans/ ./cmd/pricebook-export/ → ok github.com/carlosframework/platform/cmd/pricebook-export 0.005s) |
| +Task 2: Ruling: ParsePriceMap also refuses a key under the configured book's version that the book does not price (other versions stay free), so "free plan priced under a hand-made key" is tested with an example-v0 key that Recognise refuses — a mistyped current key could otherwise sit unnoticed — cost if wrong: none (stricter config). |
| +Task 2: Ruling: billingtest.Fake gained New(), Lock/Unlock and copies on read (so tests can change a subscription while a pass reads it) and counts Check in Calls — cost if wrong: none. |
| +Task 2: complete (commits 1a77863..f55016c, tests: go test ./internal/billing/... → ? github.com/carlosframework/platform/internal/billing/billingtest [no test files]) |
| +Task 3: Ruling: the fence metadata key carloku_quantity_fence became quantity_fence (no product name in code) — cost if wrong: a Stripe metadata key rename before any use. |
| +Task 3: Ruling: NewProvider also enforces the mode's rk_ prefix, an acct_ account and 1-3 non-empty webhook secrets (Task 4 checks again with variable-named errors); CheckoutSubscription maps a Stripe 404 to billing.ErrNotFound; Provider.Client() exposes the client for 6b — cost if wrong: none. |
| +Task 3: Ruling: adversarial_test's one case (timestamp centuries ahead) folded into TestParseEventKinds rather than webhook_test.go — same coverage through the adapter — cost if wrong: none. |
| +Task 3: complete (commits f55016c..097c911, tests: go test ./internal/billingstripe/ ./internal/billing/... → ? github.com/carlosframework/platform/internal/billing/billingtest [no test files]) |
| +Task 4: Ruling: NewServer refuses Billing without PlanCatalog (belt to billingConfig's CARLOS_PLAN_CATALOG error), and billingConfig checks in the order mode, catalog, key, account, webhook secrets, book, prices — so each error names the first variable at fault — cost if wrong: none. |
| +Task 4: complete (commits 097c911..9310761, tests: bash -c 'go test ./cmd/console/ -run "BillingConfig|PlanCatalog" && go test ./internal/console/ -run "NotePriceBook|ClaimSQL"' → ok github.com/carlosframework/platform/internal/console (cached)) |
| +Task 5: Ruling: (as pre-flight) billing's plan write goes through billingSetPlan (accountplans.go), the single call site to switch to Plan 4d-1's plan-change function; it runs SetAccountPlan's own upsert (upsertAccountPlan) inside SetBillingPlan's transaction rather than SetAccountPlan itself, because the store has one connection (SetMaxOpenConns(1)) and the guard must share the write's transaction — cost if wrong: one call site. |
| +Task 5: Ruling: a default row whose plan and packs already match is still written once to take source billing (the source differs), as the plan's "plan, packs or source differ" says — cost if wrong: one extra revision per account at first sync. |
| +Task 5: Ruling: SetBillingCustomer refuses a second, different customer for an account that already has one (the plan only named a customer bound elsewhere) — the customer is the purchase identity — cost if wrong: 6b needs an explicit rebind path. |
| +Task 5: complete (commits 9310761..75e53c4, tests: go test ./internal/console/ -run 'SetBillingPlan|BillingCustomer|BillingState|OpenProblem|LiveBillingAccounts|AccountPlan|ClaimSQL' → ok github.com/carlosframework/platform/internal/console 52.550s) |
| +Task 6: Ruling: a subscription the provider answers 404 for (billing.ErrNotFound) changes nothing and syncSubscription returns nil (logged), so the webhook answers 204 rather than drawing three days of retries and the pass moves on — cost if wrong: a recorded paid subscription deleted at the provider keeps the account paid until an operator acts (no problem row is opened for it). |
| +Task 6: Ruling: adopting a new subscription after the old one ended clears PaidPacks, PaidPeriodEnd and Book before applying the rules, so nothing of the old period carries over — the plan's PaidPacks rule is silent on a change of subscription — cost if wrong: none. |
| +Task 6: Ruling: unknown_customer is filed under the account the metadata names when it exists, else account 0, and logged with the metadata sqid; a customer that changed between the two reads returns an error (retried) — cost if wrong: none. |
| +Task 6: complete (commits 75e53c4..8c39739, tests: go test ./internal/console/ -run 'Decide|PackReduction|Sync|SponsoredAccountOpens' → ok github.com/carlosframework/platform/internal/console 7.775s) |
| +Task 7: Ruling: a checkout the provider answers 404 for is treated as one that made no subscription (204), not a transient error — cost if wrong: a lost checkout is still caught by the subscription events and the hourly pass. |
| +Task 7: Ruling: billingSyncPass also does nothing until billing is ready; added TestStartBillingSyncPassOffReturns and TestStartBillingSyncPassChecksThenSyncs beyond the plan's list — cost if wrong: none. |
| +Task 7: full `go test ./internal/console/ -run Claim -timeout 40m` ran (895 s): every Claim test passed except TestClaimConsoleRouteCensus, which failed only on the two Task 8 route lines added to claim-routes.txt while it ran; those lines were held out of this commit and the census re-run passes. |
| +Task 7: complete (commits 8c39739..2c7dc1a, tests: go test ./internal/console/ -run 'BillingWebhook|BillingNotReady|StaleEvent|BillingSyncPass|ClaimConsoleRouteCensus|Census|Decide|Sync' → ok github.com/carlosframework/platform/internal/console 34.989s) |
| +Task 8: Ruling: TDD order slipped — the Task 8 implementation was drafted while Task 7's 15-minute claim run held the package; it was moved aside, the Task 8 tests were run alone and watched fail (undefined billingCopyStillLive, cliBillingCopyNoProblems), then the implementation restored and the tests passed — cost if wrong: tests shaped by code already written. |
| +Task 8: Ruling: door strings beyond the plan's four (billingCopyClosed, billingCopyProviderDown, billingCopyFailed) and CLI strings (usage, flag help, -id required, closed, needs console) added in the two copy files; an unknown problem id is the stdlib 404 like the operator gate — cost if wrong: none; all went through the Luna pass. |
| +Task 8: full `go test ./internal/console/ -run Claim -timeout 40m` → ok (759 s), with both new routes in claim-routes.txt, fixtures and probes. |
| +Task 8: complete (commits 2c7dc1a..a63b67e, tests: bash -c 'go test ./internal/console/ -run "BillingProblemsDoor|CloseRefused|CloseNeeds|ClaimConsoleRouteCensus" && go test . -run BillingCLI' → ok github.com/carlosframework/platform 0.016s) |
| +Task 9: Ruling: coordinator message mid-task (Paul's prices, 2026-10-25): example catalog splits storage into disk (+10 GB per running thing) and storage (+50 GB object storage), bandwidth pack +50 GB a month; example book carries Personal 2800/2400/2200 and packs apps 1200/1000/900, disk 3600/3100/2800, storage 1200/1000/900, email 2400/2100/1900, bandwidth 4800/4100/3800, still draft; catalog version kept at 2026-10-20-v1 (test fixture; its ID changes with content); spec §4.2 and plan Calls updated — cost if wrong: fixture edits. |
| +Task 9: Ruling: Luna changed the configuration error to "console: invalid billing configuration: <variable>" (plan said "billing configuration invalid"); applied verbatim per the copy rule, test updated — cost if wrong: one string. |
| +Task 9: Ruling: problem detail strings (operator diagnostics in carlos billing problems) and log lines were left out of the Luna brief as diagnostics (Paul, 2026-10-16 copy scope) — cost if wrong: a follow-up copy pass. |
| +Task 9: Ruling: SetAccountPlan's upsert is shared as a statement constant (accountPlanUpsertSQL + accountPlanUpsertArgs) instead of an upsertAccountPlan helper, so SetAccountPlan keeps its own QueryRow and the census sees a body change, not a removed unit — cost if wrong: none. |
| +Task 9: census: 4 body units approved via census-propose (serve, Store.SetAccountPlan, NewServer, Store.migrate); 17 new units hand-written as decision census-ruling-plans-6a-units; record-write layer plans6aWriteCensusInventory (main, registerCLIRoutes, NewServer body-only). |
| +Task 9: merged origin/main c743efea (9160c4cc); full go test ./internal/console/ -run Claim -timeout 40m → ok (1154 s); census (TestPlan14RootReadCensus, TestPlan9B8RecordWriteCensus) → ok; darwin and windows go build ./... ok. |
| +Task 9: complete (commits a63b67e..9160c4c, tests: bash -c 'go test ./internal/provision/ -run "TestPlan14RootReadCensus|TestPlan9B8|Census" && go test ./internal/docsite/ ./internal/plans/ ./internal/billing/... ./internal/billingstripe/ ./cmd/console/ ./cmd/pricebook-export/ && go test . -run BillingCLI' → ok github.com/carlosframework/platform 0.020s) |