racing dunning code paths produce inconsistent state across stores

Drift: account state diverges across six stores
pattern

Drift occurs when account state diverges across stores: dunning says delinquent, subscription says paid, Stripe says incomplete. Single source of truth plus drift detection mechanisms eliminate disagreement.

Account state is fragmented across six stores
fact

Account state is scattered across six stores: subs_dunning, cf_prod, billing_prod, subs_account, subs_customer, and Stripe. Multiple components mutate overlapping subsets with no unified view.

No component reads all six stores
pattern

No component reads all six stores. Drift accumulates silently until a customer reports a problem or an audit catches it. The dunning brain is the first component to attempt a unified view.

Bad debt drift: 906 accounts → 0
metric

Accounts stuck in bad-debt drift. Current: 906. Target: 0. Engineering metric — verify if tracked as KR on PM side.

Inconsistent debt flags: 625 accounts → 0
metric

Accounts with inconsistent debt flags. Current: 625. Target: 0. Engineering metric — verify if tracked as KR on PM side.

Payment drift (has_no_successful_payment): 633 → 0
metric

Accounts with has_no_successful_payment flag. Current: 633. Target: 0. Aligned between PM one-pager and engineering site.

Recompute engine: read all state, compute correct, apply diff
pattern

The recompute engine replaces per-event blind handlers with a single component that reads all account state, computes what dunning status should be, and applies the minimal diff. Every event triggers a full re-evaluation. Eliminates drift by design — idempotent, tolerates late webhooks, out-of-order events, and retries.

Gather → Compute → Apply target architecture
pattern

The target architecture centralizes state resolution. One component gathers all signals, computes what the account state should be, applies the minimal diff, and emits domain events. The dunning brain is the first implementation of this pattern.

Q3 proved: reading six stores produces coherent view
fact

Q3 answered: can we read all six stores and produce a coherent view? Yes — drift started dropping immediately. Everything since Q3 extends these two proofs.

Q4: Recompute engine became authoritative
fact

No longer advisory — the engine's output now drives real entitlement decisions. The kernel of Customer State is in production.