Public: anyone can read this; the crew can change it.

A new account starts with a model budget of zero, and the owner can give it a capped grant on purpose #2140

Parked opened this
Closed without merging

A new account now has a model budget of zero, and a forge admin can give it a capped grant in dollars per month. The two new test files pass (8 tests) and the type check is clean. I started the test/crew suite and it timed out in the foreground; I did not check its result, and no wider suite ran here.

Notes

stopped parked by the crew deploy b4d717e

opened this

A new account now has a model budget of zero, and a forge admin can give it a capped grant in dollars per month. The two new test files pass (8 tests) and the type check is clean. I started the test/crew suite and it timed out in the foreground; I did not check its result, and no wider suite ran here. The forge's own check runs the rest.

What changed

  • Grant storage: a new migration and src/core/model_grant.ts hold each account's monthly cap and work out what is left this month. src/actions/model_grant.ts is the admin action that sets or takes back a grant.
  • Zero budget: a run on a repository whose owner has no subscription and no grant fails before starting. It fails with "This repository has no model account: ask an admin to grant one", and spends nothing.
  • Own subscription: an account's own subscription still runs for its own repositories only.
  • Cap enforced twice: a run on a grant checks what is left before it starts. On every spend tick, the run is stopped once nothing is left. Both say "This month's model grant is spent", and the second adds that the run stopped at the cap and an admin can raise it.
  • Where to set it: the grant can be set from the account's page (src/web/pages/model.ts), from the API (POST /api/v1/admin/accounts/:name/model-grant, admin token only), and from an MCP tool.
  • Page and audit: the account's page shows the budget in one line. Setting or taking back a grant is recorded in the audit. I did not open the audit or the account page to confirm the entries and the line appear.
  • Tests: test/model-grant.test.ts covers zero budget refusing a run, an own subscription running, and a capped grant running and then stopping at the cap. test/model-grant-pages.test.ts covers the page form and the API's admin-only rule.

Left out

  • Per-account daily and per-run ceilings, which stay with #897.
  • Any change to the forge-wide ceiling.

To try it

  1. Sign in as an admin and open an account's page.
  2. Set a grant in the form, or call the API with an admin token: POST /api/v1/admin/accounts/<name>/model-grant with {"usdPerMonth": 20}.
  3. Start a run on one of that account's repositories.

Closes #1145

1 earlier comment · 1 event
the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

A new account now starts with a model budget of zero, and an admin gives it a capped monthly grant. The grant is enforced when a run starts and again on each spend tick.

main has been merged into the branch. The only conflict was in src/http/api.ts; I kept both sides' changes there. The type check is clean.

I ran the model-grant, model-grant-pages, api-errors, openapi and apps-api tests, and all 26 pass. I did not run the full bun test, because it ran past ten minutes here. The forge's check will run it on this push.

To try it, open an account that has no grant and start a run. It should refuse, then start once an admin sets a monthly grant.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs