Public: anyone can read this; the crew can change it.
Spend 1: a monthly budget per cloud account, one notice at 80% and one at 100% #18121
Merged 16h 53m ago, live in production
An admin can now set a monthly dollar budget on each cloud account. They are told once at 80% and once at 100% of the month's projected spend, and nothing is stopped. I ran bun x tsc --noEmit, the gate and the touched suites, and they pass.
-
Reviews
Changes requested — before the latest pushThe budget does what the issue asks and I found no security finding: the web route, the MCP verb and the terminal screen all go through
setBudget, which checks admin. The route is marked admin insrc/http/marks/settings.json. Unknown spend is never shown as $0, and the notice rows are claimed with INSERT OR IGNORE. I read the code and the tests. I opened the preview:/answered 200 (first request 5.3 s, a cold start);/infraand/settings/cloudredirect a guest to sign-in, so I saw no budget picture and judged those pages from the code. The diff I was given was cut off insidesrc/web/pages/cloud.ts, so I read the rest of that file in the working tree.Two things to fix in one round:
- MCP cap disagrees with the action.
src/http/mcp/tools/cloud_account.tskeepsdollarsatmaximum: 100000, butsetBudgetand the web form accept up toMAX_BUDGET_DOLLARS(1,000,000). An agent cannot set a budget between $100,001 and $1,000,000 that the page accepts. Pick one cap. The simplest fix is to lowerMAX_BUDGET_DOLLARSinsrc/cloud/budget.tsto 100000 and setmaxon the web input to 100000. Alternatively, raise the schema maximum, keeping the property description under the 60-byte limit. - Stray unrelated edit. In
src/actions/cloud_ceiling.tsthe lineconst PLACE = /^...becameconst PLACE =/^.... Restore the space.
Small and optional: on /settings/cloud and /infra the same
standingWordsline appears for every account, including "no budget set; spend unknown: ...". Consider showing it only when a budget is set or the spend is known (principle 1, nothing says itself twice).The boxes below are all met by this head.
ApprovedBoth earlier asks are met: one cap of 100,000 on the page, the action and the MCP schema, and the stray space in PLACE is back. Only those three lines changed since my last review, and I found nothing new. Admin-only action, route marked admin, audience classified, notices claimed by row so each fires once, unknown is never $0, nothing is stopped, terminal screen and docs/features how-to are present. Non-blocking: standingWords prints 'no budget set; spend unknown' for accounts with no budget; fine to change on all three doors in a later pull.
- MCP cap disagrees with the action.
-
Checks
shipped production is serving it deploy f698c54
-
History
- Budget cap is one number, $100000, on the page, the action and the MCP verb; restore a space in PLACE (#18101) d660f5e
- Merge main into the cloud budgets pull (#18101) 29c607a
- Access 4: one view of every grant, and a page that says who may do what (#18062) 5ba07c8
- Access 2: one `may(principal, action, resource)`, with the repository checks behind it first (#18065) 7d48ce1
- Apps without a login 2: a tiny model in the browser fills the app's spec, and the compiler catches every failure (#18117) 4147a37
- Games: a new pin for the forge's proxy plugin replaces the old jar, in PLUGINS and on disk, and the page says which one loaded (#18111) da9e15f
- Healer: a server still starting, its log moving, is not started again (#18053) d918642
- Rewrap long comments (gate --fix) (#18101) 67f4dc7
- Game box: refuse a wake or a mod install the box has no memory for (#18057) 7fe508f
- Cloud budgets: shorten the dollars description, list the budgets screen in the palette roster test (#18101) 3fa1716
- Games survival step 1: a survival performance set (lithium, scalablelux, noisium, chunky) planned as one locked install (#18099) b838dce
- Games survival step 2b: read FabricExporter Prometheus metrics at check-in so TPS and tick time show on the games page (#18116) 0d92810
- Full suite red: 2 files in check run 01m8zwjzbrpcdryvgey8kqdeak (#18124) 643723c
- Classify cloud.budget and cloud.budget_notice as admin-only events (#18101) 4f35db1
- Apps without a login 1: a sentence becomes an app in the tab forge, with no model (#18080) 4aa5b50
- A git CDN: a repository's packs served from object storage by short-lived links (#18066) 78329a7
- Spend 1: a terminal screen and how-to for cloud budgets (#18101) 3b9ebd6
- Spend 1: a monthly budget per cloud account, one notice at 80% and one at 100% (#18101) b8bf282
- Access 4a: one read-only view over every grant table, and a gate test that none is missing (#18118) 11a1727
- Traces 1b: GET /api/v1/traces lists traces newest first, gated as the run's log is (#18077) 5467059
4 earlier comments · 1 event
An admin can now set a monthly dollar budget on each cloud account. They are told once at 80% and once at 100% of the month's projected spend, and nothing is stopped. I ran bun x tsc --noEmit, the gate and the touched suites, and they pass. I didn't run the whole suite or try it on a preview.
What changed
- Setting it: "Set budget" sits beside the ceiling on Cloud accounts (
/settings/cloud). The same action backs a newset_budgetverb on thecloud_accountMCP tool and a new "Cloud budgets" terminal screen. It takes whole dollars from 1, an empty value clears it, and only an admin may set it. - Spend measure:
- For DigitalOcean, Hetzner and OVHcloud it is the forge's list-price estimate of what it made.
- For AWS and Azure it is the vendor's billed spend so far this month, projected by days (billed × days in month ÷ days elapsed).
- Every figure says whether it is billed or an estimate, and as of when.
- Unknown, never $0: a bill never read, a bill that failed to read, prices never read, a machine or database with no price, or a cloud whose cost the forge doesn't read all show "spend unknown: why". The first figure on /infra for a cloud the forge makes machines on reads "unknown" in those cases too.
- Notices: the new hourly
cloud-budgetduty writes one row per account, month and percent (80 or 100) to a newcloud_budget_noticetable, then raises an event. The notifier tells each admin who has set a notification URL from that row. A second reading in the month, or a restart, sends nothing. A reading that jumps past 100% sends only the 100% notice, and 80% is never sent after 100%. A new month starts again. - Where it shows: /infra shows the budget line under each account's figure. Any account with a budget is listed there, whatever its cloud. The terminal Infrastructure line carries the same words.
- Marks and docs:
/settings/cloud/budgetis marked admin insrc/http/marks/settings.json. The how-to isdocs/features/cloud-budget.md.
Tests
test/cloud-budget.test.ts crosses 80% and 100% for both billed (AWS) and estimated (DigitalOcean) accounts, with exactly one notice at each. It also covers a second reading, a restart through the notifier, a month rollover, and unknown versus $0. test/tui-budgets.test.ts covers the terminal screen. I changed one existing expectation in test/infra-page.test.ts: the meter now carries makes and budget, so it uses toMatchObject.
What I chose not to do
- Delivery: the notice is claimed when it is detected, not when it is delivered. If a restart lands between claiming and the push, or the push fails, that notice is lost rather than sent twice. The cause is the double-notice risk you named.
- Billed numbers: there is no billed number for DigitalOcean, Hetzner or OVHcloud, because the forge reads none for them. Those accounts always show the forge's estimate.
- Gate note:
scripts/gate.tsprints similarity notes (setBudgetagainstsetCeiling, and the like). They are not refusals. I left the budget code parallel to the ceiling code on purpose.
To try
As an admin, open /settings/cloud, set a budget on an account, then open /infra to see the line under that account's figure. In the terminal, open the palette, pick "Cloud budgets" and press b.
Reused: accountReads, accountCents, priced and readTimes for the readings, the notifier's ask-line path, setCeiling's action shape, and promptScreen for the terminal prompt.
I fixed the failing audience-coverage test and pushed it. cloud.budget and cloud.budget_notice were new event kinds that nobody had classified, so the scan failed. Both are now listed in src/core/event_audience.ts next to cloud.ceiling.
This pull adds a monthly budget per cloud account, with one notice at 80% and one at 100% of it. Changing a budget and the notices are spend configuration, so both kinds are admin-only. Readers and guests never see them.
Locally, test/event-audience-coverage.test.ts passes (5 tests) and bun x tsc --noEmit is clean. I did not run the full suite; the forge's check runs it on this push.
The gate printed notes (long comment lines, near-duplicate functions such as setBudget and setCeiling) but no failure. I left them alone and did not run --fix.
To try it, open the cloud accounts page or the budgets screen in the terminal, set a budget on an account, and check that the event appears only in the admin feed.
This push fixes the three failing checks. I ran the two test files that held them (test/palette-roster.test.ts and test/mcp-size.test.ts) and both pass. I did not run the full suite. Before the push, tsc --noEmit printed nothing and bun scripts/gate.ts --fix ran.
- MCP size test: the
dollarsproperty on thecloud_accounttool had a 70-byte description, over the 60-byte limit. I shortened it to "set_ceiling; set_budget (omit to clear it)." insrc/http/mcp/tools/cloud_account.ts. - Palette roster tests: the new "Cloud budgets" screen now shows up in the site-admin roster. I added the entry to the expected lists in
test/palette-roster.test.ts, one for the person roster and one for the agent roster. The tests were out of date, not the code. - Gate:
--fixrewrapped long comments insrc/tui/screens/budgets.tsandtest/tui-budgets.test.ts. I committed that as a separate commit and pushed it. I re-rantest/tui-budgets.test.tsafter that commit and it passes.
I left the gate's "one implementation?" similarity notes alone. They ask whether a few near-duplicate functions should be merged, and they don't block the push.
To try it, open the Cloud budgets screen as a site admin.
🤖 Generated with Claude Code
I merged main into the branch and pushed it. The only conflict was src/generated/screens.ts. I took main's version and re-ran bun scripts/own-source.ts to regenerate it, so it now lists both main's screens and the cloud budgets screen.
I ran tsc --noEmit and four test files: test/own-source.test.ts, test/palette-roster.test.ts, test/mcp-size.test.ts and test/tui-budgets.test.ts. All 32 tests pass. I did not run the full suite, so the forge's check on this push is the first full run of the merged branch.
bun scripts/gate.ts --fix changed nothing. The gate's note about long comment lines is in files from main, not this pull. I left them alone, since the nightly rewrap handles them on main.
🤖 Generated with Claude Code
Both requested fixes are in and pushed.
- One cap.
MAX_BUDGET_DOLLARSinsrc/cloud/budget.tsis now 100,000. Themaxon the web input insrc/web/pages/cloud.tsis also 100000. The MCP schema already said 100000, so the page,setBudgetand the MCP tool now agree. The commit saysDirection: one cap for a monthly budget so an agent and the page agree (#18101). - Stray edit.
const PLACE = /^…insrc/actions/cloud_ceiling.tshas its space back.
Not done: I left the optional standingWords change alone. Hiding "no budget set; spend unknown: …" on /settings/cloud and /infra would make those two pages differ from the terminal screens, which show the same line. That would break the "terminal shows what the page shows" rule. I'd rather change all three together in a separate pull.
Checks:
bun x tsc --noEmitis clean.- The budget tests pass (23), including
test/subscription-budget.test.ts, which checks that $1,000,000 is refused. bun scripts/gate.tsexits 0. It only prints similarity hints and a note about long comments in files this pull doesn't touch.- I did not run the full suite.
An admin can now set a monthly dollar budget on each cloud account. They are told once at 80% and once at 100% of the month's projected spend, and nothing is stopped. I ran
bun x tsc --noEmit, the gate and the touched suites, and they pass. I didn't run the whole suite or try it on a preview.What changed
/settings/cloud). The same action backs a newset_budgetverb on thecloud_accountMCP tool and a new "Cloud budgets" terminal screen. It takes whole dollars from 1, an empty value clears it, and only an admin may set it.cloud-budgetduty writes one row per account, month and percent (80 or 100) to a newcloud_budget_noticetable, then raises an event. The notifier tells each admin who has set a notification URL from that row. A second reading in the month, or a restart, sends nothing. A reading that jumps past 100% sends only the 100% notice, and 80% is never sent after 100%. A new month starts again./settings/cloud/budgetis marked admin insrc/http/marks/settings.json. The how-to isdocs/features/cloud-budget.md.Tests
test/cloud-budget.test.tscrosses 80% and 100% for both billed (AWS) and estimated (DigitalOcean) accounts, with exactly one notice at each. It also covers a second reading, a restart through the notifier, a month rollover, and unknown versus $0.test/tui-budgets.test.tscovers the terminal screen. I changed one existing expectation intest/infra-page.test.ts: the meter now carriesmakesandbudget, so it usestoMatchObject.What I chose not to do
scripts/gate.tsprints similarity notes (setBudgetagainstsetCeiling, and the like). They are not refusals. I left the budget code parallel to the ceiling code on purpose.To try
As an admin, open
/settings/cloud, set a budget on an account, then open/infrato see the line under that account's figure. In the terminal, open the palette, pick "Cloud budgets" and pressb.Reused:
accountReads,accountCents,pricedandreadTimesfor the readings, the notifier's ask-line path,setCeiling's action shape, andpromptScreenfor the terminal prompt.Closes #18101