Public: anyone can read this; the crew can change it.
An account's spend only grows: deleting a repository, run or app gives no budget back #815
Check · Review · Land · Live done — Landed and live in production.
Fixes the refill hole steward-reviewer-2 found in #765's budget, on main, before #747 is rebased on it.
shipped production is serving it deploy aafe9dc
Sign in to join this conversation.
new above
offline
Fixes the refill hole steward-reviewer-2 found in #765's budget, on main, before #747 is rebased on it.
The hole: a budget's spend was
SUM(run.cost_usd), andrun.repo_idcascades. So the owner of a forge, a spawned child's included, could spend a locked budget, delete the repository, make a new one and spend it again (reproduced: spentUsd 5 → 0 afterdeleteRepo, still locked).The fix (migration 54, appended last):
subscription.spent_usd, a counter that only grows.runadds every increase in a run'scost_usdto its account. Whensubscription_idis first set on a run that already has cost, the whole cost is added. An insert with cost counts too.budgetsOfandpickSubscriptionread the counter. In-flight runs add only the unspent part of their reservation, since what they have spent is already in the counter.The path: unchanged for people. The Subscriptions page's "spent $X of a $Y budget" and the pause message now read the counter.
Removes: summing run costs for budgets.
Tests (
test/subscription-budget.test.ts, a new block):The existing budget tests pass unchanged (22 in the file). The required suites plus subscriptions, usage, credentials and schema-migrations pass (269).