From the 2026-07-19 complementary swarm review (read-only, complementary to #37 — assumed landing; no overlap).
P1 — money-path observability
P1 — Stripe idempotency
P1 — ledger scaling
P2 — simplify
Validation
bun test workspace; deno check all touched functions; pgTAP for any migration.
From the 2026-07-19 complementary swarm review (read-only, complementary to #37 — assumed landing; no overlap).
P1 — money-path observability
console.*inpackages/billing/src,packages/edge-shared/src,supabase/functions). Arefund_terminal_failure(money stuck) surfaces as an anonymous 500. Add structuredconsole.errorat:createStripeWebhookHandlercatch (edge-shared/src/index.ts:849-851),accountErrorResponsesites (:1026,1030), billingdatabaseError/BillingErrorthrow sites — includeevent.id,event.type,checkout_session_id, error code.recordStripeEventBestEffortswallows every insert error (billing/src/index.ts:919-931). Log swallowed errors; only treat23505as ignorable.P1 — Stripe idempotency
idempotencyKey(billing/src/index.ts:295-306) while refunds correctly use one (:647). Add a deterministic idempotency key to session creation.P1 — ledger scaling
sum(amount_cents)over the full ledger, computed twice per router request; ledger grows one row per ~2¢ call. Add a covering index / running-balance or cached-balance strategy (additive migration only, per chore: reconcile hosted Supabase migration history #35).P2 — simplify
settle/finalize/deleteCustomerstrio increateDeleteAccountHandler(edge-shared/src/index.ts:728-733).requiredEnv/createCallerSupabase/withCors) from 5 functions intoedge-shared.Validation
bun testworkspace;deno checkall touched functions; pgTAP for any migration.