Repository navigation
Description
Out of scope
The fixture-level contention in #3628 (two in-memory apps share one domain) and #3019 (in-memory fixtures use the per-user fallback ledger). Changing the default allowance or budget for every maintenance command. The reference pool's own allocation and accounting. Provider-facing tool text beyond the refusal's code and message.
Context
One app with a file-backed database, so with its own admission domain, refuses its own first reference_source call of a turn. The cause is contention with that same turn's worker sandbox preparation for the maintenance temporary-storage budget.
- By default every maintenance command reserves the whole budget: allowance and budget are both 256 MiB (
DEFAULT_MAINTENANCE_TEMP_BYTES,packages/ui-sdk/src/server/worker-state-limits.ts:151-152). Admission refuses rather than waits when the budget is held (if (held + BigInt(limits.allowanceBytes) > BigInt(limits.budgetBytes)),packages/ui-sdk/src/server/maintenance-temp-budget.ts:236). - Turn start prepares the worker sandbox. Its scratch check runs a maintenance command (
resolveScratchMountSteps(brain, options.maintenance),packages/ui-sdk/src/server/worker-launcher.ts:967). - The reference transport runs each Git command as a maintenance command too (
const run = options.run ?? runMaintenanceWorker,packages/ui-server/src/brain/reference-transport.ts:111). - So a reference call that overlaps the turn's scratch check is refused, or the scratch check is refused and the turn's
.brain/scratch/goes read-only. - The refusal also escapes unclassified.
operaterethrows a non-invalidresolve error as is (const check = await transport.resolve,packages/ui-server/src/brain/reference-source.ts:302-305). The tool then answers the genericunavailablewith no retry guidance (function refusal(error: unknown),packages/ui-server/src/brain/reference-tools.ts:66-71), rather thanbusy.
Observed in the opt-in integrated reference cell (scripts/prove-reference-pool.ts --integrated). It was run on hosted runtime_host through a temporary probe in PR #4072 (heavy feedback run 43810765015, checkout 4e63c9983). The scripted Claude turn calls reference_source as soon as the turn starts. Its app logged both sides of the race 136 ms apart:
worker scratch area is read-only this turn: .brain/scratch/ could not be checked (Maintenance temporary storage is busy: this command needs 256 MiB, 1 maintenance reservations hold 256 MiB of the separate 256 MiB budget (held by: git). ...)
reference tool failed: Maintenance temporary storage is busy: this command needs 256 MiB, 1 maintenance reservations hold 256 MiB of the separate 256 MiB budget (held by: command). Nothing ran. ...
The tool returned {"ok":false,"code":"unavailable","message":"The reference service could not complete this request."}. Run 43794917101 failed the same way at the same step. The cell passed on a native host when it was added (#2860), so how often the two overlap depends on the host's timing. A real model usually needs longer than the scratch check before its first tool call, but nothing guarantees that.
Scope
- A reference acquisition in a turn no longer fails because of that turn's own maintenance commands. Choose one in the PR: a bounded admission wait for reference transport commands, ordering the turn's sandbox checks before its tools are offered, or a separate allowance for reference Git commands. Each must remain inside the existing budget; none may be an unbounded wait.
- A maintenance-busy refusal that still reaches the reference service becomes a classified
busyrefusal with retry guidance, never the genericunavailable.
Acceptance criteria
- A test holds the maintenance budget the way the turn's scratch check does, then issues a
reference_sourcecall in the same app. The call succeeds after the holder finishes, within a stated bound. The test fails on main for the reason quoted above. - With the budget held past that bound, the tool answers
code: "busy"with a retry message. A test proves it; on main it fails withunavailable. - The turn's scratch area stays writable when a reference call starts in the turn's first moments, proven by a test.
-
bun scripts/prove-reference-pool.ts --integratedpasses its firstreference_sourcecall on both backends on hostedruntime_host, through a probe like PR test(ui-server): qualify EDQUOT, cancellation and crash recovery under the Git workload (#3513) #4072's, with the receipt linked.
Verification
Focused bun run test for the reference source, tools and maintenance budget; bun run check:pr --base origin/main; hosted heavy feedback for the integrated cell as above. No network or provider keys.
Contract impact
Possibly additive: the reference tool's refusal code for this case changes from unavailable to the existing busy code. Assess against docs/integration-contract.md in the PR.
Blocks the backend-latency criterion of #3513.
Activity
test(scripts): keep the integrated latency instrument out until #4079 …
schlessera commentedon Nov 16, 2026
Readiness review (2026-11-16): the cited lines still hold on
mainat eb3c53a (DEFAULT_MAINTENANCE_TEMP_BYTESatworker-state-limits.ts:151-152, the refusal atmaintenance-temp-budget.ts:236, the scratch check atworker-launcher.ts:967, the transport'srunatreference-transport.ts:111,operate's resolve atreference-source.ts:302-305andrefusalatreference-tools.ts:66-71). The acceptance criteria are checkable and the scope leaves the approach to the PR within stated limits, so this isagent-ready.schlessera commentedon Nov 16, 2026
Claimed for implementation. Claim token:
claim-ec61586c. Branch:fix/4079-reference-maintenance-admission.path collisions: #4002 (reference source/tools/transport), #4072 (reference source, temporary probe)
chore(scripts): TEMPORARY hosted probe running the integrated referen…
test(ui-sdk,ui-server): place the scratch admission brain where a mai…
Revert "chore(scripts): TEMPORARY hosted probe running the integrated…
test(ui-server): qualify EDQUOT, cancellation and crash recovery unde…
test(ui-sdk): give the scratch admission test's maintenance worker a …
CONTRACT: fix(ui-server,ui-sdk): wait for a turn's own maintenance be…
schlessera commentedon Nov 16, 2026
Merged in #4080 as
c67d588c2through the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.test(ui-server): hold the integrated reference cell's latency to meas…