Repository navigation
Description
Problem
Headless run, 2026-09-01, dev 05b9953 (aforge do, deepseek-v4-flash pinned). A leaf hit its token grant mid-sh with a red build (undefined: logf at turn 20; an earlier blind edit had swallowed a test function's opening line), got its 4 landing turns, stopped with ⏳ ran out of tokens — 33 turns (cost: 178086 of 176834) — and 2 seconds later the node was ✓ done, summary = its own last line: "All 722 tests pass. Let me verify the dry-run tests specifically:". The two sibling tasks then briefed on truncated work and opened with "everything is already in place". The turn the ✓ bought away — actually running the binary — is exactly where the run's fatal bug (the blocker discarded at construction) would have surfaced. Same shape in #267's run; the two issues are one law in two organs.
Where it lives
- The journal is honest:
leaf_exhaustedis recorded, andinternal/store/leafrun.go's header says status is the scheduler's decision. The decision point iscmd/aforge/chat.go(~:1322): onleafRanOutOfRoom,revision.JudgeRemainderis asked, andremainder.Doneoverwrites the verdict toVerdictVerifiedSuccess— the else arm (splice a continuation viaReplanOverrunAs) never runs. Journal proof: the first exhaustion took the splice arm (plan_graph → subtree_spliced → job_growth → leaf_resumed); the second has none of those — justleaf_exhausted→ one 10k-token judge call →node_completed, 2s apart. - The judge is shown almost nothing:
internal/revision/judge.go(~:2149) sends the brief + the leaf's final text — not the transcript (which held the red build), not the diff, not the verification reading, not even that the leaf was cut off; the prompt actively says "exhaustion is not evidence of incompleteness".JudgeRemainderhas zero tests. - The fact cannot cross the seam anyway:
resident.ExecResult(internal/resident/runner.go~:33) carries summary, money, turns — and no budget/exhaustion field.runOneseeserr == niland callsgraph.Complete. Mid-graph nodes get no delivery gate (shouldGate= root children only), so the judge was the only check. - Metering defect on the same path:
outcome.Meter.Reachedis frozen at grant time and never updated across the landing turns — every ⏳ line and every storedleaf_exhausted.reachedunder-reports by ~12–14% (recomputed from the run's own usage rows: 172,791 actual vs 152,090 reported; 199,131 vs 178,086). - Verified pre-existing: the branch is byte-identical before one worker: swe and bare go, and the choice surface goes with them — chat and do always run linear #227 (the deleted worker-menu argument aside). The grant itself is not undersized — context sat at ~45k tokens, 92–99% cache hit, 33 turns bought; the spend went to blind-edit repair and four cold prefixes at replan.
The law
A leaf that ran out has no account. Its work is evidence for the next attempt, never a result. Only a leaf that itself reported done, inside its budget, settles a node ✓. Exhaustion is a measured fact; doneness is a claim; a measured fact is never overturned by an unmeasured claim (the same law as #267).
The fix
- Budget crosses the seam:
resident.ExecResultcarries the exhaustion kind + meter;runOneroutes it through the requeue rule it already applies on the error arm — nevergraph.Complete. chat.go's remainder arm is demoted:JudgeRemaindermay size the remainder, never manufacture a ✓.remainder.Doneon a cut leaf still splices a continuation with the stated remainder "verify" — one cheap leaf when the judge was right, the missing turn when it was wrong. Loops are already bounded (MaxOverrunRounds = 3).- Feed the judge what it judges: the exhaustion record, the last N banked turns, the workspace diff, the verification reading.
- Meter: recompute
Reachedat land time. - Surfaces: a ⏳ line is followed by ↻ or by "carried over", never by ✓ on the same node with no splice between.
Replication and acceptance (functional, required)
Harness exists: the runaway scripted completer in internal/exec (a leaf that tool-calls every turn, billing tuned to cross the grant) + cmd/aforge's scripted brain with the judge scripted to answer {"done": true} — the adversarial-but-observed case.
- The node is not done; no
node_completedwithout an intervening splice. (Red today.) leaf_exhausted.reachedequals the final spend, not the grant-time reading. (Red today.)- Either the splice triple exists or the node is released pending with attempt+1 — and the next brief carries the continuation headers and the stated remainder.
- Exit 2, never 0; the stream shows ⏳ then ↻, and never
✓ <task>between them. - Seam unit:
Outcome{Stop: budget}→ExecResultcarries it andrunOnedoes not complete.
Dependencies
Same law as #267 (settlement side); independent code. #133 is the same law in the shaper (cite as precedent). Meter drift is adjacent to #161 but mechanically distinct (usage blocks all arrived; the frozen field is local).
Drafted with CodeAF · reviewed and owned by the author
Activity
santoshkumarradha commentedon Sep 1, 2026
Live evidence, 2026-09-01: a balanced-crew headless
dorun at dev 32fd51c (glm-5.3-flash hands / glm-5.3 brain, $1.45, 52m, 14 nodes, exit 2) was given THIS issue as its brief — and reproduced it ~8 times while working on it. Textbook signature from the stream:⏳ runner.go edits — it was still working when it ran out of its tokens — 9 turns in (cost: 381163 of 302008)at 18m56s, then✓ runner.go edits (linear)at 18m58s — two seconds, no splice between. Every worker cut mid-edit was marked ✓, successors briefed on truncated work and re-litigated the same four sites; roughly ten leaves' grants went to that re-work. The delivery gate then refused correctly (no #267 acquittal shape) — its refusal independently named the unverified claims. The run's attempted fix is not usable (the new ExecResult budget fields were never populated at the construction site — dead code — and its test file never compiled), but the shape of the failed attempt is itself confirmation of the issue's premise: nothing that runs after the ✓ can recover the cut work.exhaustion: a leaf that ran out has no account
exhaustion: a leaf that ran out has no account
exhaustion: a leaf that ran out has no account (#291)
santoshkumarradha commentedon Sep 2, 2026
Post-merge evidence from a same-task/same-model re-bench on dev 805b615 (caddy-analyzer#78, deepseek-v4-flash pinned):
The fix holds. All three exhausted leaves carried a resume before completion (
leaf_exhausted→ growth →leaf_resumed→node_completedin the journal; 4leaf_resumedevents vs 1 pre-fix), and zero ⏳→✓ with nothing between (pre-fix: 1 of 2 was a free ✓).One number to look at: the ⏳ lines now report
284719 of 150000,234065 of 168586,223156 of 152322— 137–190 % overruns, where both pre-fix lines said ~101 %. Consistent withMeter.Reachednow being read at land rather than at the last write, but the magnitude is far beyond the 12–14 % under-report this PR's message predicted. Either leaves genuinely overrun their meter by that much before landing (a budget-enforcement question), or the landed figure double-counts. Worth a look; not re-opening this issue for it.