The repository wallet — the last 20 spends
/owner/name/wallet lists the last 20 spends of one app, newest first, one
row each (#13298): the date (UTC), the amount in US dollars, what it paid
for (build #12 Fix the login: the run's kind and the issue or pull it
worked on), and a link to the run. Rows come from the usage ledger
(core/usage.ts), the provider's list price, not money charged. A run that
did not end well says so beside what it paid for.
- Who: whoever may read the app's spend, a writer (
canSeeOwnerFacts, as the usage API). Anyone else gets the not-found page. - Where: a link beside the statement in the app's settings → App; at the
terminal,
owner/name — Walletin the:palette while the repository is open (j/kmove). - CSV:
/owner/name/wallet.csvdownloads those same rows (time_utc,dollars,paid_for,outcome,run) through the shared formula-safe writer (actions/wallet_csv.ts: a cell starting=,+,-or@is written as text). It readsreadWallet, so the gate is the page's; anyone else gets 404. The newest 5,000 spends are listed, one row each and no commentary. When older ones were left out, the response carriesX-Wallet-Rows-Cut: 5000. The page links it; the terminal's wallet screen prints the path. It does not go throughexportRows, which reads a table of an app's own database; the ledger is the forge's. - Last 30 days: above the spends, one row per UTC day, today first, each with its dollars and a
server-rendered SVG bar (a share of the largest day; no script, no chart library). A day with no
spend reads
$0.00, never a gap. One grouped query reads the window and the total is the sum of its 30 rows (actions/wallet_days.ts);test/wallet-days.test.tsfails if a day is dropped or the total differs from an independent sum of the ledger. Days are cut at 00:00 UTC. The terminal's wallet screen heads with the same total. - Spend per month (#14458): above the last 30 days, one row per UTC month with spend, newest first,
at most 12, each with its count of spends and total dollars (
actions/wallet_months.ts, one grouped read overusage_repo (repo_id, at)). The totals cover every spend in those months, not only the 20 rows listed below, so a busy month's total is more than the rows add up to (test/wallet-months.test.tschecks it with 25 spends). The admin's cap screen in the terminal prints the same months on one line, newest first, cut at the terminal's width. - 80% of the month (#14489): with a cap set, once spend reaches 80% of it an admin reads one
sentence under the spend line,
80% of June is spent; the crew pauses at 100%.; from 100% that sentence gives way to the existing paused line, which on the page also links to the cap field, so the two never say the same thing together. Below 80%, or with no cap, nothing is added, and the home and board gain no banner. It reads the cap and spend the pause rule reads (spentWordsincore/wallet.ts);test/wallet-threshold.test.tscovers 79%, 80%, 100% and no cap. - Days left (#14680, #15980): one sentence at the head of the wallet,
At this pace the balance lasts about 9 days.(core/wallet_days_left.ts). The pace is the median of the last seven UTC days with quiet days counted as $0, so one large one-off day does not skew it. A sparse week has a median of $0, and then the week's total over seven is the pace: one $7 day is $1 a day, never $7. The month's balance under the cap over that pace is rounded down. The cap resets with the UTC month, so the count stops at the days to the reset (the month's last day counts as one): a balance that would last 50 days says 6 on the 25th. A week with no spend readsNo spend this week.; a spent-out cap readsNo days left.; a balance under a dayAt this pace the balance lasts less than a day.; spending with no capNo cap is set, so no days to count.Everyone who may read the wallet sees it. The page, the MCPdaysLeftfield (the page's sentence, character for character) and the terminal (first on theowner/name — Walletscreen's total line, so a narrow terminal cuts the rest, and on the admin's cap screen) all take it from the onedaysLeftLine. The page and that screen take the week from the 30 day rows they already read, so the line costs them no extra query. - Speed: the read walks
usage_repo (repo_id, at)for twenty rows, no scan and no sort, so it does not grow with the ledger (test/wallet.test.tscounts its statements at 10,000 rows and reads the plan). - Left out: paging beyond 20; the MCP (below) gives the summary, and
GET /api/v1/repos/:owner/:name/usagegives the recent lines as JSON.
MCP
usage with { repo, kind: "wallet" } answers the balance and the three latest spends, amounts and balance written by the page's own money and balanceWords; a reader who may not see the wallet gets the page's not-found.