Keeping credit usage reliable
Problem
Credits represent paid product usage, so the frontend cannot be the authority on whether an account has enough balance to perform an action.
Cause
A balance held in browser state is client-owned — it can be edited, replayed, or simply out of date by the time a credit-consuming request lands.
Fix
Credit state is persisted in the database and expressed as transactions rather than as a single mutable balance, with server-side validation around the operations that spend credits.
Why this fix
A ledger makes every grant and consumption traceable, which is what free-trial provisioning and non-expiring purchased credits both need. A disputed balance can be reconciled against a list of transactions; it cannot be reconciled against one number.

