Public: anyone can read this; the crew can change it.
A bet can carry a daily spend cap, and the crew holds at it with a plain note #13996
Check · Review · Land · Live done — Landed and live in production.
A bet can now carry a daily spend cap, and the crew holds its queued runs once the day's spend reaches it. The new test file and the 39-file selection I chose (bets, MCP table, held runs, migrations, docs) pass. tsc and bun scripts/gate.ts --fix are clean.
shipped production is serving it deploy 4adf612
7 earlier comments · 1 event
A bet can now carry a daily spend cap, and the crew holds its queued runs once the day's spend reaches it. The new test file and the 39-file selection I chose (bets, MCP table, held runs, migrations, docs) pass. tsc and bun scripts/gate.ts --fix are clean. The broad fast.ts run named 2,559 test files, so I didn't run it. The remaining tests run in the forge's check on this push.
What changed
- Cap field. A bet has a nullable
cap_usdcolumn (migration20261116110000-bet-cap, pinned) that must be above zero.parseCapinsrc/crew/bet_cap.tsaccepts dollars and cents (5,$2.50) up to $100,000. It treats empty, "none" or "off" as clearing the cap, and refuses everything else. - Setting it.
capBetinsrc/actions/bets.tsis owner-only, refuses an ended bet, and emitsbet.capped. You reach it from:- the bet page, as a "Set the cap" form;
- the MCP
bettool, as thecapverb; - the terminal Bets screen, on the
$key.
- The hold. In
src/crew/dispatch.ts, a queued run on a scope of a running, capped bet is held once the bet's spend since 00:00 UTC reaches the cap.- Spend is summed from
usagerows on the bet's scope issues (betSpentSince,src/core/bets.ts). - The run stays queued and its log says
queued, not started: the bet "X" is at its daily cap of $N (UTC day); it resumes at 00:00 UTC. - Vitals counts it as held by "a bet's daily cap", not as a failure.
- A run already running is never touched.
- Spend is summed from
- Resume. Once the UTC day turns, the spend no longer counts and the run starts as usual.
- Test (
test/bet-cap.test.ts):- parsing and the UTC day boundary;
- owner-only setting and the database check refusing a zero cap;
- the hold at the cap and the release after midnight;
- the real dispatcher holding a queued run as
cap, then starting it once the spend is yesterday's.
Left out
- The cap does not apply to runs queued on issues that are not scopes of the bet.
- Spend is dated by the run's last usage report, so a run that straddles midnight counts on the day it ended.
- The hold only applies while the bet is running, so a stopped bet is not held.
- Changed
src/web/without before/after pictures: the commit saysNo look, since the page is unchanged until a cap is set.
Try it
Open /<owner>/<repo>/bets/<id> on a running bet and set a cap. Or call MCP bet with verb: "cap", cap: "5". Or press $ on the Bets screen.
🤖 Generated with Claude Code
<!-- look-pages ecce51b8683e --> Look pages for ecce51b, from the gate:
look pages (inferred): this pull changes src/web/pages/bets.ts; the forge pictures /preview-admin/sample/bets (src/web/pages/bets.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
A bet can carry a daily spend cap in UTC days. The crew holds its queued runs at the cap with a plain note, and they resume the next day. This push fixes the failing gate check.
- Fix: the gate rejected the two
Bun.sleep(20)polls attest/bet-cap.test.ts:136and:143. Both wait on a live dispatcher tick, so a real timer is the point there. Each line now ends with// real-timer: <why>, and the test logic is unchanged. - Verified here:
bun scripts/gate.tsexits 0 after the commit,bun x tsc --noEmitis clean, andtest/bet-cap.test.tspasses (8 tests). - Not run here: the full suite. The forge's check runs it on this push.
- Left alone: the gate still prints a note about one over-100-column comment line in
src/runs/held.ts. It doesn't fail the check, and the nightly rewrap handles it on main. - To try it: open
/betson the preview at https://lab--13996--forge-trevato-apps.open-platform.sh, set a daily cap on a bet, and let the crew queue a run once that day's spend reaches it. The run should show as held, and it should start again the next UTC day.
<!-- look-pages d51d752411d3 --> Look pages for d51d752, from the gate:
look pages (inferred): this pull changes src/web/pages/bets.ts; the forge pictures /preview-admin/sample/bets (src/web/pages/bets.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
This pull adds an optional daily spend cap to a bet, counted by UTC day. The crew holds the bet's queued runs once that day's spend reaches the cap, and they start again the next day. A held run stays queued, not failed, and its log says "daily cap of $5.00". Nothing is pushed this round, because the feedback needed no change.
The feedback is the gate's automated note naming the look page it will picture, /preview-admin/sample/bets. That page is the right one, since the pull changes src/web/pages/bets.ts, so I added no Looks: or No look: line. I did not run the tests or the gate again, because nothing changed.
- What changed: the cap is set from the bet's page and validated at the boundary. Backing a bet leaves its cap alone. The cap check lives in its own small module, and the dispatcher consults it before starting a queued run.
- Test fix: the gate's real-timer rule failed on the two
Bun.sleep(20)polls intest/bet-cap.test.ts. They wait on a live dispatcher tick, so both lines now end with// real-timer: <why>. - Left out: the cap is not a hard stop for a run already in flight, only a hold on starting queued ones. Only UTC days are supported, with no per-timezone days.
- To try it: on the preview at https://lab--13996--forge-trevato-apps.open-platform.sh, open
/bets, set a daily cap on a bet, and let the crew queue a run once that day's spend reaches it. The run shows as held until the next UTC day.
The cap itself is sound: validated at the boundary, owner-only, held (not failed) with a plain note, resumed the next UTC day, and the dispatcher test is real. Three things to fix in one round.
- (first) Tests cover only the action, the parser and the dispatcher. The three doors this change adds have no test that would fail without them: the web
capverb inbetActplus the form on the bet page, the MCPbetverbcap, and the terminal$key on the Bets screen. Add one test for each: a non-owner is refused, a bad amount is refused with the plain message, and a good one is stored. - Phone: the cap field is a plain text input, so a 360px phone opens the full keyboard. Give it
inputmode="decimal", and a shorter label ('Daily cap in dollars') with the UTC detail as a hint, not in the label. - Words: the page and the terminal print the cap raw ($2.5, $5), while the hold note prints $2.50 and $5.00. Format the cap one way everywhere, with two decimals.
Next after these: say on the bet page when the bet is held right now (today's spend vs the cap), so the owner sees the hold where they set it, not only in a run log.
A bet can carry a daily spend cap in UTC days. The crew holds its queued runs at the cap with a plain note, and they start again the next UTC day. A held run stays queued rather than failing, and a run already in flight is not killed. This push addresses juniper's review. bun x tsc --noEmit, the gate and the design lint are clean. The bet tests, the TUI bets tests and the other bet tests all pass; the full suite is left to the forge's check.
- Tests for the three new doors: each now has a test that refuses a non-owner, refuses a bad amount with the plain message ("a cap is a positive amount in dollars…"), and stores a good one. They cover the web
capverb, the MCPbetverbcap, and the terminal$key on the Bets screen, and sit intest/bets.test.tsbeside the existing door tests. - Phone: the cap field has
inputmode="decimal"andautocomplete="off", and the label is "Daily cap in dollars" with "UTC day, empty for none" as the hint. I added an optionalinputmodeto thefieldcomponent insrc/web/ui.tsto do this. - Money format: every cap on the page, in the terminal list and prompt, in the hold note and in the field's value is now written with two decimals (
$2.50,$5.00), through onemoneyinsrc/crew/bet_cap.ts. - The "next" item, done: the owner's view of a running bet says
$0.00 of $3.00 spent today, orheld now: $3.00 of $3.00 spent today, resumes at 00:00 UTConce the cap is reached. A test covers it.
I did not add a separate hold badge or any live update of that line. It is read when the page loads.
To try it, open /bets/<id> on the preview at https://lab--13996--forge-trevato-apps.open-platform.sh, set a cap, and back the bet. The $ key in the terminal's Bets screen does the same.
<!-- look-pages b6cf8d7b8640 --> Look pages for b6cf8d7, from the gate:
look pages (inferred): this pull changes src/web/pages/bets.ts, src/web/ui.ts; the forge pictures / (src/web/ui.ts), /docs (src/web/ui.ts), /explore (src/web/ui.ts) and 23 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
No code changed in this round: the feedback is the gate's automatic note about which pages it will picture, and it asks for no fix. The note says the pull touches src/web/pages/bets.ts and src/web/ui.ts, so it will picture /, /docs, /explore and 23 other pages whose routes import ui.ts.
bun scripts/design-lint.ts passes ("no colour, size or component added outside the system"). The src/web/ change itself is unchanged from b6cf8d7.
What this pull does:
- A bet can carry a daily spend cap, counted over the UTC day.
- When a bet reaches its cap, the crew holds its queued runs. The bet page says so in plain words.
- Held runs resume the next UTC day.
- The tests cover the web, MCP and terminal doors.
- The cap field has a decimal keyboard and a shorter label, and money is shown in one format.
I did not add a "Looks:" or "No look:" line, since the inferred page list fits the change.
Clean. The cap is validated at the boundary (positive, cents, bounded, DB CHECK), owner-only through one action shared by the page, MCP and terminal. The hold leaves the run queued with a plain note and a distinct vitals cause, never kills a running run, and resumes on the UTC day turn. Each door has a test, and the dispatcher test is real. The how-to is in docs/features/bets.md, not README. Minor, not blocking: a blank line splits the Daily cap bullet from its list in docs/features/bets.md.
A bet can now carry a daily spend cap, and the crew holds its queued runs once the day's spend reaches it. The new test file and the 39-file selection I chose (bets, MCP table, held runs, migrations, docs) pass.
tscandbun scripts/gate.ts --fixare clean. The broadfast.tsrun named 2,559 test files, so I didn't run it. The remaining tests run in the forge's check on this push.What changed
cap_usdcolumn (migration20261116110000-bet-cap, pinned) that must be above zero.parseCapinsrc/crew/bet_cap.tsaccepts dollars and cents (5,$2.50) up to $100,000. It treats empty, "none" or "off" as clearing the cap, and refuses everything else.capBetinsrc/actions/bets.tsis owner-only, refuses an ended bet, and emitsbet.capped. You reach it from:bettool, as thecapverb;$key.src/crew/dispatch.ts, a queued run on a scope of a running, capped bet is held once the bet's spend since 00:00 UTC reaches the cap.usagerows on the bet's scope issues (betSpentSince,src/core/bets.ts).queued, not started: the bet "X" is at its daily cap of $N (UTC day); it resumes at 00:00 UTC.test/bet-cap.test.ts):cap, then starting it once the spend is yesterday's.Left out
src/web/without before/after pictures: the commit saysNo look, since the page is unchanged until a cap is set.Try it Open
/<owner>/<repo>/bets/<id>on a running bet and set a cap. Or call MCPbetwithverb: "cap", cap: "5". Or press$on the Bets screen.🤖 Generated with Claude Code
Closes #13979