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

/forges shows each sent forge's crew spend today against its starter budget, carried by its heartbeat #5884

opened this

Merged 38d 0h ago, live in production

Each row on /forges now shows the child's crew spend today against its cap, and MCP forges returns both numbers for each child. The type check and the tests covering this change pass. My full bun test run hit the 10-minute limit and I didn't wait for it, so only the forge's own check on this push has run it all.

Notes

opened this

Each row on /forges now shows the child's crew spend today against its cap, and MCP forges returns both numbers for each child. The type check and the tests covering this change pass. My full bun test run hit the 10-minute limit and I didn't wait for it, so only the forge's own check on this push has run it all.

  • Heartbeat: the child's beat (src/spawn/heartbeat.ts) carries spendTodayUsd and ceilingUsd.
    • Spend is the crew's cost today since 00:00 UTC, from the usage ledger.
    • The ceiling is the child's locked starter-key budget, or null if it has none. The issue didn't say what the "forge cap" is, so I read it as the starter budget, as the title does.
    • A bad value drops that field and the beat is kept: spend must be a finite number from 0 to 1,000,000, and the ceiling null or 0.01 to 1,000,000.
  • Row words: src/web/pages/forges.ts shows $3.20 of $10 today. From 80% it is attention-toned, and at 100% it reads $10.00 of $10 today · ceiling reached. A child with spend but no cap reads $4.00 today. A child that hasn't reported spend shows nothing new. The words come from spendWords in src/spawn/clients.ts.
  • MCP: forges returns spendTodayUsd and ceilingUsd on each child, null when unsaid.
  • Tests: test/forges-spend.test.ts covers a beat with spend, one without, and negative or non-numeric values. It also covers the row's words at 50%, 85% and 100%, and a child reporting its own spend and budget. I added the two new keys to the expected key list in test/family-heartbeat.test.ts and to the row fixture in test/tui-forges.test.ts.

Not done:

  • /family and the terminal don't show spend yet.
  • No per-agent breakdown.

Description wording: the byte cap in test/mcp-size.test.ts was already nearly full, so the MCP forges description now lists the fields without "last activity". That field is still returned.

Try it: open /forges as admin; children running this build report spend on their next beat, within 10 minutes of starting.

Closes #5866

3 earlier comments
commented

Each row on /forges now shows the child's crew spend today against its cap, and MCP forges returns both numbers for each child. The type check and the tests covering this change pass. My full bun test run hit the 10-minute limit and I didn't wait for it, so only the forge's own check on this push has run it all.

  • Heartbeat: the child's beat (src/spawn/heartbeat.ts) carries spendTodayUsd and ceilingUsd.
    • Spend is the crew's cost today since 00:00 UTC, from the usage ledger.
    • The ceiling is the child's locked starter-key budget, or null if it has none. The issue didn't say what the "forge cap" is, so I read it as the starter budget, as the title does.
    • A bad value drops that field and the beat is kept: spend must be a finite number from 0 to 1,000,000, and the ceiling null or 0.01 to 1,000,000.
  • Row words: src/web/pages/forges.ts shows $3.20 of $10 today. From 80% it is attention-toned, and at 100% it reads $10.00 of $10 today · ceiling reached. A child with spend but no cap reads $4.00 today. A child that hasn't reported spend shows nothing new. The words come from spendWords in src/spawn/clients.ts.
  • MCP: forges returns spendTodayUsd and ceilingUsd on each child, null when unsaid.
  • Tests: test/forges-spend.test.ts covers a beat with spend, one without, and negative or non-numeric values. It also covers the row's words at 50%, 85% and 100%, and a child reporting its own spend and budget. I added the two new keys to the expected key list in test/family-heartbeat.test.ts and to the row fixture in test/tui-forges.test.ts.

Not done:

  • /family and the terminal don't show spend yet.
  • No per-agent breakdown.

Description wording: the byte cap in test/mcp-size.test.ts was already nearly full, so the MCP forges description now lists the fields without "last activity". That field is still returned.

Try it: open /forges as admin; children running this build report spend on their next beat, within 10 minutes of starting.

commented

Each forge's crew spend today against its starter budget now shows on /forges, in the terminal's "Forges you sent" card, and in MCP forges, carried by the child's heartbeat. The type check, design lint and the touched tests pass (forges-spend, tui-forges, mcp-size, family-heartbeat). I didn't run the full suite; the forge runs it on the push.

What changed this round, all from the review:

  • Terminal: forgeLines in src/tui/screens/forges.ts appends spendWords(r)?.words, so the card says $10.00 of $10 today · ceiling reached. test/tui-forges.test.ts checks that case, a mid-spend row, and a row with no spend.
  • README: the paragraph on "Forges you sent" now says both the page and the terminal carry spend, as the child last reported it.
  • Page and MCP: the last test in test/family-heartbeat.test.ts stores a signed beat at $8.50 of $10. It expects data-spend="warn" and $8.50 of $10 today in the admin's GET /forges. It also expects MCP forges to return spendTodayUsd: 8.5 and ceilingUsd: 10 for that child. It fails if spendNote or the clientRows wiring is dropped.
  • spendReport: test/forges-spend.test.ts now records a $3.204 usage line for a run and asserts spendTodayUsd is 3.2, so it reads the real ledger.

Not done: spend still isn't on /family or in the terminal's family screen.

The MCP forges description stays short, with "last activity" dropped, because test/mcp-size.test.ts has almost no byte headroom; the field is still returned.

To try it, open /forges as admin: a child shows spend once its next beat arrives, within 10 minutes of starting.

commented

I changed the cap as the review asked; I haven't run the full bun test or checked a live preview. The type check and the tests I touched pass (forges-spend, family-heartbeat, tui-forges).

  • The cap: the heartbeat now sends spendTodayUsd and ceilingUsd from the daily brake, not the lifetime starter budget.
    • spendTodayUsd is spentTodayEverywhere(app.db, now), the figure that pauses a crew at the ceiling.
    • ceilingUsd is app.config.crewCeilingUsd, or null when the forge sets none or sets zero.
    • On /forges, ceiling reached now means the same thing as the pause.
  • Cost: the whole spend breakdown that ran on every beat is replaced by one query.
  • Tests: the spendReport test now sets crewCeilingUsd: 10 and puts $3.204 on an agent run, then expects spendTodayUsd to be 3.2. A forge with no ceiling gives a null ceilingUsd.
  • README and comments: both say "the daily ceiling that pauses it" instead of "starter budget".
  • Old beats: a beat sent before this push carries the old cap until the child redeploys. It reports the new figure on its next beat after that.
  • Follow-up: I did not open one for the starter key's lifetime budget (spent_usd of budget_usd). It needs its own words, not "today".
commented

I merged main into this branch and pushed it. Types are clean and the 190 tests in the heartbeat, forges and spawn suites pass. I didn't run the whole suite, since the forge's check does that.

main added a "next step" line to each child's heartbeat (claimed, everyday, lastTellAt). That collided with this pull's spendTodayUsd and ceilingUsd fields in four files, and I kept both sides:

  • src/spawn/heartbeat.ts: Beat carries both sets of fields, and the optional-field list names all of them. The beat body spreads spendReport(app) and progress(app).
  • src/spawn/clients.ts: ClientRow has spendTodayUsd, ceilingUsd and nextStep. I dropped the duplicate lastHeard import the merge left behind.
  • src/tui/screens/forges.ts: each forge line reads for … · claim state · running · next step · spend.
  • test/tui-forges.test.ts: the default test row has the fields from both sides.

No test was changed.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs