Repository navigation
A job's budget covers all its runs - #2353
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… caps Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cap decisions read SpentBefore plus current run spend; receipt accounting and cost retain their meanings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep raise fixture below its initial cap; let real cap checks stop completed receipts before further spending. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…spend Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The proxy must acknowledge its first replay before a retry withdraws the old worker request; later cleanup reports need no extra replay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adapt the c34 live lane to stop a paid job and Start over, reach the job-total budget with the second run below its own cap, then raise and reconcile lifetime spend with the ledger. Bound every paid request under a separate $0.30 ceiling and verify all recorded models. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Worker reports advanced the whole-job version between the page read and budget raise. Track budget revisions and compare under the item lock, preserving conflicts with other budget edits and refusing ended jobs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Return conflict instead of stale so desktop reconciliation cannot overwrite a budget changed back by another editor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Compare authoritative spending under the item lock. Preserve the incoming receipt, park the job with its job total question, and withdraw execution through the existing wire response. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deliver spending newer than an acknowledged retry before admitting paid work. Let valid person-approved Publish anyway finish its post at the cap while keeping model phases gated. Save raises on stopped jobs without attempting continuation. Also close the pre-existing pause resume race while canceled controls settle spending receipts. Resume waits for release before reviving the saved chat. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion from a stuck job A call the budget stop cancels before any reply has no cost to record, and a model that keeps ending replies without a report runs the step out of attempts, when the job asks. The check failed on both. It now accepts only a cut with no reply at or past the cap, presses try again only when the job asked and the last press made progress, asserts no priced call follows the crossing, and reports what it waited on under its own limit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wledge to finish writing Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keeps both reserve behaviours: the locked job decides thread-only, and a job at its budget takes no lease. A stopped job at its budget is held without a cap question, so the Stop stays what the job says. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Apply gained a capWait argument on this branch. This test has no budget question, so it passes false, and it keeps its earlier behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its Stop and pending reply stay, a raise doesn't resume it, and it still takes no lease. The signal retry test held its first heartbeat until the step entered, while the step's admission report waited on that same delivery loop; it now answers heartbeats until the step has entered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Measure report stalls through the real worker loop and HTTP boundary without model calls. Both report paths block lease renewals and queued signals for the request timeout. Keep timing observations assertion-free for the requested baseline. Stop before changing admission: TestBudgetAdmissionCountsUnreportedRoundSpend and TestBudgetAdmissionDrainsOlderPendingSpend require the factory answer before another executor starts, because their extra lifetime spend exists only on the factory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Serialize running-job admission and periodic reports on one reporter so spend deltas keep their acknowledgment order without blocking signals. Keep factory approval before each step and cancel admission waits on Stop. Join the reporter before cleanup and guard shared delivery state. Keep the budget-wait acknowledgment on late updates so a parked lease is not withdrawn and a completed chat is not resumed and charged again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Admission errors withdrew the runner and final reporting could release the job as backlog. Retry the saved unspent round after the drive and reporter settle, without consuming attempts, and bound the complete admission wait to 5.5 seconds. Prove automatic retry counts and spend, the full queued report/flush/admission chain, and cancellation plus report/heartbeat lease-loss accounting. Exercise both undelivered and replayed reports, late spend, receipt replay and reporter goroutine termination under the race detector. Keep the existing stall tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Retry expiry cleared the retrying guard, allowing final delivery to return a withdrawn, unspent round to backlog. Keep the lease and round while flushing reports, then resume through the existing same-round Hold path after delivery catches up. The separate retained-result recovery block remains authoritative. Prove state through work(), real report and heartbeat doors, and GET /v1/jobs. Cover answers before and after expiry, exact spend deltas, authoritative budget withdrawal, unchanged attempt limits, and joined worker/reporter shutdown. Document admission recovery and its separate result-delivery deadline. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A heartbeat can resume a parked worker while its reporter sends a cap question frozen from the old mirror. ApplyReport reopened it after the server had saved the higher cap and answered the question. After folding usage, ignore cap questions below the authoritative cap. Keep questions at exhaustion and cover both Continue and budget edits with a deterministic HTTP replay. Preserve admission and reporting paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cover equality, reports whose own cost crosses the raised cap, and reports that remain below it through the worker HTTP report seam. Verify non-cap questions and all other report contents survive the cap-question filter. Exercise a frozen leased-worker report, continuation, and the next cap stop without admitting a third paid step. Mutation checks fail for <=, filtering before addCost, removing the guard, filtering all question kinds, and dropping the whole report. Restore every mutation before the final repeated tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both sides kept in the two conflicts with #2370: the raise test's job gets the owner's tier and its earlier spend, and Doors.SignOff checks write access before the lifetime cap. The lifetime budget and late-usage tests now record the owner's tier, which #2370 requires before a job can write. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What a person saw
A job's budget only limited the current run. Start, Carry on, Rerun and Start over each began with a fresh count, so a job with a $5 budget could spend far more across its runs.
What changes
Wire
spending_limit.{spent,next_limit}andquestions[].{spent,next_limit}now mean the job's total.coststays per run.What stays the same
Stage attempt limits and step costs, pipeline intake
start.max_cost, the daily rail and Pareto model selection keep their meanings. A pipeline'sdefault_budgetsupplies the job ceiling, which now covers all runs.Limits
An older job uses only its saved total; money lost from old saved records isn't rebuilt from the ledger.
The call that crosses the cap is already paid for, so a job can end above its budget by that one call. No priced call follows it: the running step stops once the crossing is recorded. Live, at a budget set 5% above the first run's cost, that call was $0.0003 to $0.0005 when the prompt was cached and $0.003 to $0.0046 when it wasn't, which took the total to between 1.00 and 1.89 times the budget. On a $5 budget the same call is about 0.1%.
A call admitted just before the crossing is recorded is cancelled before it replies, and records no cost. On the provider's own account, 36 requests cut at 50, 100 and 200 ms were billed $0 while 3 uncut ones matched to the sixth decimal. That covers this model and its route only. A provider that bills a cut call would cost up to one unanswered call per stop, uncounted.
During a stalled report the job shows running, with its last acknowledged step and spend, no question, and no line saying why it's waiting. After the two-minute retry window the job keeps its round and lease and keeps trying to report. When the factory answers, the round resumes on its own without using an attempt, or the person gets the cap question if the job's total has reached its cap.
A heartbeat still has its own 5 s limit.
Validation
TestAppFactoryLifetimeBudget, a late receipt, unreported spend at admission, publish and merge at the cap, Publish anyway at the cap, and a raise on a stopped job.TestAPauseAndResumeReachTheRunnerand the resume path ran 30 of 30 after a race fix here.go vet,internal/factory/...,internal/manual,internal/appwireand the wholecmd/codeafpackage pass on this head.TestLiveJobTotalBudgetAcrossRerunwithdeepseek/deepseek-v4.1-flashfor every role: 10 of 10 on this head. In every run the job total, ledger and spending agree after a raise to $5.🤖 Generated with Claude Code