Repository navigation
Description
Context
Three guards keep an uncertain charge, which is correct, but stop reconciling after a fixed number of attempts. The charge then stays until a restart, and it reduces capacity or budget for every session. Verified on main 4b8db90de:
- Claude worker cleanup: after
CLEANUP_RETRY_ATTEMPTSfailed closes, the reconciler logs "stay charged until the server restarts" and stops retrying (packages/ui-backend-claude/src/cleanup-reconciler.ts:78-90). The reservation sits in the process-wide worker-state ledger shared by both backends (packages/ui-sdk/src/server/worker-state-budget.ts:1,:80). Enough stranded allowances block admission for every session. - Superseded checkpoint release: the observation that replaced the old checkpoint has already committed, yet a failed release of the old one calls
releaseFailed. That stops every active turn and refuses earlier-requested admissions (packages/ui-server/src/brain/turn-journal.ts:175-190). The release only reclaims space. It retries at backlog pressure, so it is not sticky, but every running turn dies. A plausible trigger is a btrfs delete failing when the carrier is low on space. - Hosted compute polling: after
maxFailuresfailed visits, the driver stops tracking the job while its reservation keeps counting toward turn, session and day budgets until a restart reattaches it (packages/ui-server/src/brain/compute-host.ts:592-601). The budget checks then refuse chats (packages/ui-server/src/brain/turn-budgets.ts:161,:177).
The pi backend has a related path. An initialization failure claims cleanup, attempts closeTurnTemp() once, and registers no retry owner (packages/ui-backend-pi/src/worker-session.ts:171, packages/ui-backend-pi/src/worker-launch.ts:301-319). This was asserted by an audit and not traced end to end; confirm it before changing it.
Out of scope
- Releasing any charge before cleanup or settlement is positively confirmed.
- Changing budget limits or the worker-state ledger's sizing.
Scope
- Claude cleanup and the pi path: keep a low-frequency reconciliation owner indefinitely, with capped backoff and no terminal give-up. Release the reservation exactly once, on a confirmed close.
- Checkpoint release: a failed release of a superseded checkpoint keeps its charge and retries. It does not stop active turns. Backpressure applies only when the retained-checkpoint bound actually blocks the next safe observation.
- Compute: keep reconciling a job slowly after the foreground failure limit, independent of new turn admission. Settle or release when it is observed.
- Each give-up or backoff state is visible to the owner, with its cause (see ui-server: a latched safety recorder keeps no cause, mislabels errors as capacity, and has no recovery path #3810's pattern).
Acceptance criteria
- A Claude cleanup refused more than
CLEANUP_RETRY_ATTEMPTStimes is still retried, and its allowance is released once a close succeeds. No restart. Test fails on the current tree. - A forced failure releasing a superseded checkpoint leaves active turns running and their records complete. The release is retried and its bytes stay charged until it succeeds. Tested.
- A compute job whose visits fail more than
maxFailurestimes is visited again later and settles its reservation when its state becomes readable, with no restart. Tested. - The pi initialization-failure cleanup either has a retry owner or is shown, with a citation, to need none.
- Mutation receipts for each: restore the terminal give-up and watch the named test fail.
Verification
Unit tests in packages/ui-backend-claude/tests, packages/ui-server/tests and packages/ui-backend-pi/tests; bun run check:pr --base origin/main.
Contract impact
None expected. Owner-visible status fields, if added, are additive.
Activity
schlessera commentedon Nov 10, 2026
Claiming #3815 for implementation and verification under #3813. Claim token: runtime-reconcile-3815-a513d326. Branch:
fix/reconcile-uncertain-workers.Verified the cited cleanup, checkpoint, compute and Pi paths against current source. Pi initialization cleanup does lack a retry owner. The parallel #3816 work may touch
turn-journal.ts; this change will stay confined to superseded checkpoint releases and their admission/hold coupling. Charges remain reserved until cleanup or settlement is confirmed.schlessera commentedon Nov 10, 2026
Implementation is preserved in #3823 at
44065742c5304b8f3babcf3ebfd5134621ddb68b, targeting milestone 0.45.0. Local preflight, TypeScript, focused runtime tests and the recorded failing-first mutations passed. The latest exact-head contract check passed; no reviews are outstanding.Confirmation exhausted its bounded admission attempts because #3822 currently owns the integration reservation. No selected candidate CI or merge was started for #3823; it remains draft. This is an integration handoff, not a missing implementation criterion. Once the reservation clears, fetch/rebase current main, reconcile documented status/journal overlaps, refresh preflight for any changed candidate, then run
bun scripts/integrate.ts confirm 3823 --issues schlessera/brain-kit#3815and verify the squash and automatic main proof.Releasing claim
runtime-reconcile-3815-a513d326while leaving the branch and PR available for the coordinating task. Separate pre-supervision Pi cleanup is recorded in #3821.CONTRACT: keep reconciling uncertain runtime charges (#3823)