The Subscription State Machine — Lifecycle, Proration, and the Edges Between
A subscription looks like a row with a plan and a date. It behaves like a state machine with a dozen states, transitions triggered by humans, payments, and the calendar, and money consequences on nearly every edge. Teams that model the lifecycle explicitly handle upgrades, trials, and cancellations as transitions with rules; teams that don't accumulate booleans — `is_trial`, `is_paused`, `cancel_at_period_end` — until no one can say what state a customer is actually in.
A subscription is a state machine — trialing, active, past-due, paused, canceled-now vs at-period-end — where every edge answers four questions: trigger, money, entitlements, clock. Proration arithmetic with encoded policies, and scheduled transitions as first-class records so future state is queryable.