Repository navigation
Description
Blocked by #2854
Context
On the in-progress #2854 implementation, a Claude turn awaits its worker's runtime-state and turn-temp handle cleanup before it releases the turn's runtime-state reservation (the async cleanup continuation in packages/ui-backend-claude/src/worker-spawn.ts on the #2854 implementation branch). A separate-UID worker's last handle closes its identity broker there. If the supervisor cannot confirm that cleanup, the close rejects, the turn fails and the reservation stays charged, as the ruling on #2854 requires.
Nothing retries it afterwards. The cleanup runs once, in the worker completion's finally. finish() only awaits the same rejected completions (the finish completion join on that branch), and the turn calls it once (turn.finishWorker, packages/ui-backend-claude/src/sdk-options.ts:142). The handle itself stays retryable: a later closeAsync() asks the broker again. But no owner calls it, and nothing would then release the reservation. One runtime-state allowance stays held until the server restarts. A launch whose own cleanup is unconfirmed is retained the same way (packages/ui-backend-claude/src/worker-spawn.ts:177).
Pi retries its turn-temp close once, because two lifecycle points call the same single-flight close (promote and the prompt's finally, packages/ui-backend-pi/src/worker-session.ts).
Observed in review of the #2854 change. Not reproduced on a real host: the refusal needs a supervisor that cannot confirm cleanup.
Scope
Needs scoping. Decide whether the Claude backend should own a retry of a refused end-of-turn cleanup, and if so who triggers it (a later finish(), the next turn's admission, a periodic reconciliation) and how often.
Maintainer ruling required
Which owner retries unconfirmed Claude end-of-turn cleanup and releases retained accounting after confirmation?
- A bounded server-owned reconciliation owner retains the retryable handle and reservation, retries transient cleanup failures, and releases exactly once only after confirmation.
- A later explicit finish/admission triggers retry; define the owner and what happens when no later turn arrives.
- Keep the reservation until restart, with an explicit accepted limitation and no automatic retry.
Recommendation (not approved): Option 1, with finite attempts/backoff, shutdown ownership and observable terminal failure. No retry cadence or owner is approved yet.
Completion evidence: a maintainer comment selecting the branch and its failure/ownership semantics; then fold that ruling into checkable acceptance and the applicable decision record before adding readiness.
Out of scope
- The SDK's handle and broker close semantics (ui-sdk: a separate-UID worker's last handle release still closes its broker with a synchronous subprocess #2854).
- Pi, unless the chosen owner is shared.
Acceptance criteria
To be written once scoped. For example: after a refused end-of-turn cleanup, a later retry that the supervisor confirms releases the turn's reservation exactly once. A test shows this, and it fails without the retry.
Verification
bun run test packages/ui-backend-claude.
Contract impact
None expected. /internal types only.
Source distinction: inspected main still uses synchronous handle closes at packages/ui-backend-claude/src/worker-spawn.ts:250-258. The reported async-cleanup behavior is a review finding of open #2854, not delivered main behavior. Recheck its final implementation before selecting the retry repair.
2026-10-25 triage at main 827861e1fa71cd4a26b52f1ef0f96b849381acdf: Exposed the unresolved architecture/policy question with options, consequences and an explicitly unapproved recommendation; retain the open implementation prerequisite and distinguish branch evidence from current main. No ruling or runtime proof is invented.
Activity
schlessera commentedon Oct 25, 2026
2026-10-25 triage at main
827861e1fa71cd4a26b52f1ef0f96b849381acdf: Exposed the unresolved architecture/policy question with options, consequences and an explicitly unapproved recommendation; retain the open implementation prerequisite and distinguish branch evidence from current main. No ruling or runtime proof is invented.schlessera commentedon Oct 25, 2026
Unblocked: #2854 is closed, so
scripts/sync-project.tsis removing theblockedlabel.schlessera commentedon Oct 25, 2026
Decision (maintainer, 2026-10-25): Option 1. A bounded server-owned reconciliation owner retains the retryable handle and the reservation, retries transient cleanup failures with finite attempts and backoff, and releases the reservation exactly once, only after confirmation. It owns shutdown (stops cleanly, reports what is still held) and makes terminal failure observable (Activity/log with the held allowance). Never release on an unconfirmed close. Acceptance: a test with a supervisor that refuses N times then confirms shows the reservation held until confirmation and released exactly once; a permanently refusing supervisor ends in an observable terminal failure with the allowance still charged; shutdown during retry neither releases nor hangs; mutations for each.
schlessera commentedon Nov 3, 2026
Claiming (token
claim-2871-07e66837), branchfix/2871-claude-cleanup-retryfrom mainadf371ffab5d. Implementing the 2026-10-25 ruling (option 1): a bounded, process-owned reconciliation owner in the Claude backend that retains the refused handles and the reservation, retries with finite attempts and backoff, releases once only after confirmation, stops on shutdown without releasing, and logs terminal failure with the held allowance. Collision report on the cited files: closure-only overlaps with open drafts (#3056, #3059, #3069, #3116, #3293), no path collisions; pi files (#2918) untouched.schlessera commentedon Nov 3, 2026
Draft PR #3490 implements the 2026-10-25 ruling at head
0f7bb08c7.check:pr, a failing-first receipt and six mutations. All are in the PR body.needs: decision) covers the launch-time unconfirmed cleanup that this ruling does not cover.fix(backend-claude): retry a refused end-of-turn worker cleanup and r…