Repository navigation
Description
What happened
On dev@5153b24a (and unchanged on #606's head 04f8a5ea), a leaf whose journaled cost is 0.00048 renders in the head's plan view as:
- write the file | done | 3 turns | $0.00 | id ...
#606 made a settled leaf's measured cost durable and put it in reach of this very row. The row then rounds it away, so the money #606 journals is invisible in the surface that reads it. $0.00 does not read as "very small", it reads as free — the failure this repo already wrote down twice, at internal/head/money.go:38-48 and internal/tui2/tokens/format.go:338-352 ("a model shown a rate it had been told was zero reached for a figure that was not, and wrote $20.00 a run").
Replication
Deterministic (no model). internal/head/toolbelt.go:1201-1202 reads impact.Cost from store.Impact and formats it as fmt.Sprintf(" | $%.2f", impact.Cost) under a impact.Cost > 0 guard — so any positive cost below half a cent passes the guard and prints $0.00. A store fixture with one plan node at Cost: 0.00048 driven through renderPlanWithin shows it today. The identical raw $%.2f appears twice more in the same file, at :880-881 and :1061-1062.
Field (real models). OPENROUTER_API_KEY, ~$0.01, ~2 min — the same run as #615: aforge do --db <store> on deepseek/deepseek-v4-flash with one errand that writes one file, then open aforge and read that job's plan in the head view. The leaf's journaled cost is 0.00048; the row says $0.00.
Where
renderPlanWithin (and renderPlan above it) in internal/head/toolbelt.go — search " | $%.2f", three sites. The formatter that already gets this right is moneyUSD in internal/head/money.go:49-62 (cents down to $0.01, four decimals below that, under $0.0001 at the floor). The spend surface's own form is tokens.Money / AppendMoney in internal/tui2/tokens/format.go:353-385, whose stated law is "A POSITIVE FIGURE NEVER RENDERS AS ZERO" — $0.00048 prints as $0.0005, and exact zero stays $0.00 "because zero is a fact and not a rounding".
The fix
Every money figure in internal/head goes through one shared formatter rather than a raw %.2f. moneyUSD is that formatter and it already exists in the package, so the three sites in toolbelt.go call it — a sub-cent leaf reads $0.0005, matching digit for digit what the spend surface shows for the same figure. The impact.Cost > 0 guard stays: an unpriced step still says nothing rather than $0.00.
Acceptance
- e2e: through the real door — the field run above,
aforgehead view of the plan — the leaf row shows$0.0005, the same figure the spend place shows for that node, and never$0.00. Exit 0. - e2e: control — a step costing
$1.24still renders$1.24, and a step with no priced row still renders no money segment at all. - Unit: no raw
$%.2fmoney format string is left ininternal/head(structural law over the package), andmoneyUSD(0.00048)is not"$0.00". - The manual page that covers the plan read quotes the new spelling (
internal/manual/chat/), and the change entry'sinvalidatesnames the two-decimal row people read before.
Drafted with CodeAF · reviewed and owned by the author
Activity
head: a cost that was really spent never reads $0.00 (#650)