carlos / platform Public

Billing dashboard 1: controller rulings open

On branch billing-dash-1-data

Rulings made during the build of billing dashboard plan 1 (SDD ledger, kept here because the ledger is deleted at the end):

Ruling: 1. Task 8 (copy deck) is drafted and sent to copy review right after Task 1 is dispatched, not after Task 7 — Paul's review runs in parallel with the build; the deck only needs the plan's slot list — if wrong: deck may need a second short review if Tasks 1-7 change a slot. Ruling: 2. Task 3 changes WEBHOOKEVENTS and its test only; the WEBHOOKPROBLEM wording line lands in Task 9 with the approved copy — plan text already says the line waits for Task 8 — if wrong: none, one line moves between commits. Ruling: 3. Task 7 creates internal/console/billingmoneytest.go (checkGateInvariant + gate tests) though the Files list names only billingrevenuetest.go — the Interfaces section names that file explicitly — if wrong: file name only. Ruling: 4. Every task gets an Astra task review (controller brief), not only Tasks 1, 3, 5 as the plan's Global Constraints say — the brief is Paul's later instruction and every task touches billing (AGENTS.md rule 3) — if wrong: extra review cost. Ruling: 5. Discounts apply in listed order to the running subtotal (percent of what is left, then floor 0), not each to the gross as the plan's Step 3 reads — Stripe stacks discounts sequentially and the spec defines ARR as what the next year will charge after discounts — if wrong: mixed-discount subscriptions (rare) off by the ordering difference. Ruling: 6. A once discount still attached to the subscription makes the yearly amount unknown (AnnualKnown false), instead of being skipped as spent — Stripe removes a once discount after it is consumed, so one still attached will hit the next invoice, which may or may not be the renewal; refusing (amounts reason) beats a silently wrong ARR — if wrong (Stripe keeps consumed once discounts attached): every subscription created with a once promo shows ARR "not available yet" until fixed; visible, not wrong. Ruling: 7. Task 8 gets no Astra review: it is a copy deck Paul approved unchanged (review il22ckkydvo2n7onrbwviz3sfq); the code that applies it is reviewed in Task 9 — if wrong: none. Ruling: 8. SettledShare clamps to int64 bounds when the true answer does not fit (only possible when part > whole) — keeps the plan's signature; never reached by tax or refund shares — if wrong: absurd inputs give a clamped number instead of an error. Ruling: 9. AccountCreated's lower bound (GET /v1/account created) is accepted for the backfill start on a direct (non-Connect) account; a missing created is refused as an error (implementer's choice), so the money pass fails visibly instead of backfilling from a wrong date — if wrong: backfill misses charges older than created; the reconcile still records anything later. Ruling: 10 (superseded by 12). A refund or reversal matching a domain purchase by payment intent keeps its own Reason (refund debit other / reversed) while taking the purchase's account and Detail; only the charge gets Reason domain — a refund labelled 'domain' would lose 'reversed' and the kind column already says refund — if wrong: payments list shows a domain refund's reason as other instead of domain. Ruling: 11. Refund tax inheritance needs the charge row first; recordCharge (Task 5) always records the charge before its refunds, the only path refunds arrive by — if wrong: none on that path. Ruling: 12. Replaces 10: a refund debit matched by a domain purchase gets Reason domain (plan rule 1); only a reversal keeps 'reversed'. Purchase-price tax derivation applies to charges only; refunds/reversals inherit the charge's tax share — Astra r1 showed the derivation breaks partial-reversal symmetry — if wrong: reason label only. Ruling: 13 (superseded by 15). A charge movement whose charge read is not found / not captured / other mode is skipped and the cursor moves past it (brief's nil) — balance movements are per-mode and only exist for captured charges, so these cases are anomalies, logged — if wrong: such a movement is never recorded; it shows as a gap between Stripe and the payments list. Ruling: 14. Payment webhooks answer 503 while the key lacks the new read permissions (brief) — Paul adds the permissions before the roll; subscription/checkout events are unaffected — if wrong: Stripe retries payment events until it gives up; the reconcile still records them. Ruling: 15. Replaces 13: the reconcile verifies every charge/refund/refund-failure movement in a window was recorded before advancing the cursor or the reconciled time; a missing one fails the run (except movements of a charge skipped as the other mode, logged). The webhook keeps nil on not-found/uncaptured — the plan's own invariant ('the cursor never passes a movement that was not recorded') outranks its step text — if wrong: an anomalous Stripe charge blocks the reconcile and the money figures read 'not available yet' until someone looks; visible, not wrong. Ruling: 16. Option A: the adapter exposes two neutral facts on billing.Subscription, Billable bool (provider status active or pastdue: running and charging) and RenewalFailing bool (pastdue), stored as billingaccounts columns billable, `renewalfailing` (INTEGER NOT NULL DEFAULT 0) set by decideBilling on fresh reads beside the other provider facts; payingNow/Attention read them. Rows not yet re-read have FactsReadAt 0, so inFacts refuses figures until the first sync — keeps the provider-neutral guard intact (plan Global Constraint) — if wrong: two extra columns. Ruling: 17. Accept implementer's choices: billingFact.Subscribed (ended subscriptions get no account row); the snapshot gate also declares the account rows' currencies; arrTotals.Paying counts the paying group only (house/ours excluded, matching the groups line) — if wrong: paying count differs by house accounts with a payment. Ruling: 18. Subscribed (who gets a daily account row) = billingaccounts.live (provider may still charge), not entitlement state — spec: one row per account with a subscription — if wrong: extra rows for live-unpaid subscriptions. Ruling: 19. arrTotals.Unknown counts every paying non-exempt account with Annual -1, cancelling included; one definition for the live gate and the snapshot — plan text excluded cancelling, which let account rows hold unknown amounts under a 'complete' day — if wrong: a cancelling account with an unknown amount refuses ARR (with the amounts reason) though it is not in ARR. Ruling: 20. formatMinor prints zero-decimal currencies (Stripe's zero-decimal ISO list) without decimals; every other currency at two — spec sells only usd/eur/gbp but payments carry whatever Stripe charged — if wrong: a three-decimal currency would print off by 10x (Stripe doesn't settle charges in those for this account). Ruling: 21. Converted ARR and MRR carry the estimate label: BDC-6 reworded (copy review udf3zvfpk3xj3tlmj43qusluku, awaiting Paul) and appended to MRR too when converted; all-eur totals get no clause — spec §2 anti-goal 'converted ARR is labelled as an estimate' — if wrong: one clause. Ruling: 22. BDC-37 moves after the 'If any of them is wrong' paragraph in docs/site/plans.md (words unchanged; the record's placement note updated) — right after the table it read as a startup check — if wrong: placement only. Ruling: 23. One completeness set (factsRequired: non-exempt, live subscription) for StaleFacts and Unknown, used by the live gate and the snapshot, with a stored-state guard test — Task 7 r1 and final r1 are the same fault family (AGENTS.md rule 2: enforce in one place + guard) — if wrong: a trialing account with a stale read refuses ARR (visible). Ruling: 24. paymentfailurerefund is a failed delayed payment: new MovementPaymentFailure + ReasonPaymentFailed, recorded from the charge's own failurebalancetransaction — Stripe docs (Astra) — if wrong: bank-debit failures mislabelled; Carloku takes cards only today. Ruling: 25. Backfill starts at a fixed floor 2010-01-01 UTC; AccountCreated removed from the provider — /v1/account created is connection time, not a safe lower bound — if wrong: ~200 extra list calls once. Ruling: 26. The payments door declares inPayments (refuses with the payments reason when the reconcile is not current) and carries testmode; the CLI prints BDC-16 and BDC-13+BDC-18 verbatim — global constraint 'every money figure passes moneyReady' — if wrong: payments hidden during a reconcile outage (Stripe dashboard still has them). Ruling: 27. FeePayment carries Currency, Amount (signed) and Reason other — fee rows printed blank columns — if wrong: none. Ruling: 28. Parked: BDC-36 says 'settled in euros' while the CLI prints the settlement currency; true for both deployments; wording on the follow-up list for the next copy review — if wrong: a self-hoster settling in USD reads 'euros' in the docs. Ruling: 29. Parked: a stored row with billable 1 and live 0 counts as paying but is outside factsRequired — Stripe never produces it (active/past_due are always live); no second fix wave per the process — if wrong: such a row could count in ARR with stale facts. Ruling: 30. BDC-20 ("a paying account's yearly amount is not known yet") now also fires for a live trial with an unknown amount; wording joins BDC-36 on the follow-up copy list — if wrong: the reason text is slightly narrow.