Skip to main content

Module budget

Module budget 

Source
Expand description

Budget family — Postgres impl.

RFC-v0.7 Wave 4f. Implements EngineBackend::report_usage against the Wave 3b schema (0002_budget.sql): ff_budget_policy, ff_budget_usage, ff_budget_usage_dedup.

Isolation per v0.7 migration-master §Q11: READ COMMITTED + row-level FOR UPDATE on ff_budget_usage and FOR SHARE on ff_budget_policy — NOT SERIALIZABLE. Worker-A Tier A: trivial single-key atomic increment per dimension.

Idempotency per RFC-012 §R7.2.3: the caller-supplied UsageDimensions::dedup_key is used as the key for an INSERT … ON CONFLICT DO NOTHING; on conflict the cached outcome_json row is returned verbatim (replay).

update_budget_policy is NOT on the EngineBackend trait today (only report_usage is). Wave 4f therefore ships only report_usage_impl; definitional writes land via a test-only helper (upsert_policy_for_test) that the integration suite seeds through directly.