Expand description
Budget family — Postgres impl.
RFC-v0.7 Wave 4f. Ships EngineBackend::report_usage against
the Wave 3b schema (0002_budget.sql): ff_budget_policy,
ff_budget_usage, ff_budget_usage_dedup.
RFC-020 Wave 9 Standalone-1 (Revision 6). Extends this module
with the 5 budget/quota admin methods — create_budget,
reset_budget, create_quota_policy, get_budget_status,
report_usage_admin — writing against 0012 (ff_quota_policy +
window + admitted set) and 0013 (additive breach / scope / reset
columns on ff_budget_policy). report_usage_impl is narrowly
extended to maintain the new breach counters per §4.4.6 and to
hold the policy row under FOR NO KEY UPDATE (replacing the
previous FOR SHARE — reviewer-finding deadlock fix on the
breach-UPDATE path).
Isolation per v0.7 migration-master §Q11: READ COMMITTED + row-
level locking on report_usage_impl (hot path). reset_budget
runs SERIALIZABLE to match Valkey’s Lua atomicity — the zero-all
pattern must not interleave with a concurrent report_usage
mid-flight.
Idempotency per RFC-012 §R7.2.3: the caller-supplied dedup_key
keys an INSERT ... ON CONFLICT DO NOTHING; on conflict the cached
outcome_json row is returned verbatim (replay).