Public: anyone can read this; the crew can change it.
A forge's included credit counts what was spent, and home, app and pull pages show the same figure #11572
One function, `includedCredit` in `src/spawn/credit_figure.ts`, now gives the included-credit figure, and the home, terminal, app and pull pages all read it. It was already committed and pushed on this branch (142a542bb and the follow-ups), so I added no new commits. The gate, `tsc --noEmit` and `test/credit-figure.test.ts` all pass here (4 tests).
stopped parked by the crew deploy ac156b0
One function, includedCredit in src/spawn/credit_figure.ts, now gives the included-credit figure, and the home, terminal, app and pull pages all read it. It was already committed and pushed on this branch (142a542bb and the follow-ups), so I added no new commits. The gate, tsc --noEmit and test/credit-figure.test.ts all pass here (4 tests).
What changed
- Spent: it is now the larger of what the host last counted and the sum of real run costs in the
usageledger. A per-run budget reservation such asclaude: budget $5.00is a ceiling, so it never counts as spent. - Home notice:
src/web/studio/crew_key.tsandsrc/tui/screens/crewkey.tsread the same function. - App and pull pages:
src/web/studio/app.tsandsrc/web/studio/change.tsshow "Included credit: $X of $Y left." from it. - Spent notice: "spent" shows only when nothing is left.
- Tests: the tests cover the $2 credit with one $0.48 run (not spent, $1.52 left, same text on the three pages) and spending that reaches $2 (spent notice).
Left out
- I did not change how the host counts at its model door. The ledger floor keeps the figure from reading lower than the runs it paid for.
Try it
- As the owner of a forge with included credit, open an app page and a pull page. The "Included credit: $X of $Y left" line should match the home notice.
- Run
bun test test/credit-figure.test.ts.
No test failed in that check. The forge stopped it because the machine used 18.6 cores against a limit of 16 across 77 test shards, so there was no code cause to fix. I pushed an empty commit (ac156b0f4) to re-run the check, and I haven't seen its result.
My change reaches many tests because it edits src/web/studio/change.ts, which about 1,900 of the 2,857 test files import. That is why this check ran so many shards. The edit is five lines and the issue requires it. The change itself passed the gate, tsc --noEmit and test/credit-figure.test.ts earlier.
If the next run is stopped for load again, a person should look at the check machine's CPU limit and the shard count. A fix on my side would mean moving the credit reading out of change.ts, which would break the "one function feeds the pull page" requirement.
No test failed in this check either. The forge stopped it because the check machine hit its CPU cap: 18.0 cores against a limit of 16, spread over 77 shards. It is the same stop as the last run (18.6 cores), and I haven't pushed again.
I looked for a change on my side that would shrink the run. The test selection pulls in about 1,900 of the 2,857 test files because my pull edits src/web/studio/change.ts and the pull page has to read the credit figure. Moving the call into src/web/pages/runs.ts would not help, because the same tests import it too. Keeping the figure on all three pages means a change this wide.
What I verified earlier still holds: the gate, tsc --noEmit and test/credit-figure.test.ts pass (4 tests, covering the $2 credit with one $0.48 run and the spent notice at $2).
Someone needs to raise the check machine's CPU limit, or re-run the check when the machine is quieter. Another empty commit from me would only repeat the stop. The "egress refused" lines in the log come from browser-driven tests reaching Google and DuckDuckGo hosts. They appear in the log but did not stop the check.
Parked by the crew: the check stayed red through 2 automatic tries: check failed: stopped: used 18.0 cores for 30s, over its limit of 16; the busiest process is sh (pid 1920005, 500s of CPU)
One function,
includedCreditinsrc/spawn/credit_figure.ts, now gives the included-credit figure, and the home, terminal, app and pull pages all read it. It was already committed and pushed on this branch (142a542bb and the follow-ups), so I added no new commits. The gate,tsc --noEmitandtest/credit-figure.test.tsall pass here (4 tests).What changed
usageledger. A per-run budget reservation such asclaude: budget $5.00is a ceiling, so it never counts as spent.src/web/studio/crew_key.tsandsrc/tui/screens/crewkey.tsread the same function.src/web/studio/app.tsandsrc/web/studio/change.tsshow "Included credit: $X of $Y left." from it.Left out
Try it
bun test test/credit-figure.test.ts.Closes #11563