Skip to content

ui-server: keep retrying a managed worktree's failed checkpoint release after its turn ends #3825

Closed

Description

@schlessera

Context

Found while reviewing #3815's PR. #3815 makes a checkpoint release that fails while turns run keep retrying until it succeeds. A managed worktree's capture has the same give-up shape, but at turn end, and #3815's acceptance criteria do not cover it:

  • dropWorktrees (packages/ui-server/src/brain/turn-journal.ts:214-220) removes the worktree from the map and calls capture.close(), swallowing any error. The comment reads "A checkpoint this cannot release stays a held lease; startup recovery releases it."
  • close() clears the observer's new retry timer (packages/ui-server/src/brain/native-journal-observer.ts:514), so a failed release of a superseded checkpoint is attempted once and never again until the host restarts.
  • Because the worktree has left the map, the retained charge no longer appears in cleanupStatus(), so the owner cannot see it.

Scenario: a turn holding a managed worktree supersedes a checkpoint whose delete fails (a transient storage error). The turn ends, and the checkpoint stays retained on the reference pool until restart, with nothing retrying it and nothing showing it.

This breaks rule 3 (recover automatically) and rule 5 (diagnosable) of the proportionate-containment rule.

The same review also found three untested guards in #3815's change. A mutation removing each one leaves every test green:

  • The observer's close() clearing retryTimer (native-journal-observer.ts:514). The timer callback (:315-320) does not check closed, so without the clear it would call releaseNext on a closed manager 30 s after shutdown.
  • The compute host's slow cadence retryAt (packages/ui-server/src/brain/compute-host.ts:594-605). Without it, a permanently failing job is visited on every driver pass, every 2 s on a busy host.
  • The compute host's re-entry guard if (busy) return busy (compute-host.ts:583).

Scope

  • At turn end, hand a worktree capture's still-failing releases to an owner that keeps retrying at a low frequency until they succeed or the host shuts down. Keep the bytes charged until then.
  • Keep such retained releases visible in cleanupStatus() and /api/status until they resolve.
  • Add tests for the three guards above.

Out of scope

  • Releasing a retained checkpoint before its delete is confirmed.
  • Startup recovery, which stays as it is.
  • Changing budget limits.

Acceptance criteria

  • A worktree turn ends while its superseded checkpoint's release fails. The release is retried without a restart; once it succeeds the bytes are released, and until then cleanupStatus() reports it. A test shows this, fails on the current tree, and has a mutation receipt removing the handoff.
  • Shutdown cancels those retries without releasing the charge.
  • Tests fail when each of the three guards above is removed (observer close clears the timer, compute retryAt, compute re-entry guard). Mutation receipts are recorded in the PR.

Verification

Extend packages/ui-server/tests/native-journal-observer.test.ts and the compute-host tests with deterministic doubles. Run bun run check:pr --base origin/main.

Contract impact

None expected. cleanupStatus already reports retained checkpoint cleanup.

Part of #3813.

Blocked by #3815

2026-11-10 readiness review: updated the dropWorktrees citation against fresh main after #3816 merged. #3815 is delivered by #3823; scope and acceptance criteria are unchanged.

Activity

  1. added this to the 0.45.0 milestone on Nov 10, 2026
  2. added
    type: fix
    area: ui-server
    priority: p2
    agent-ready
    blocked
    on Nov 10, 2026
  3. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #3815 is closed, so scripts/sync-project.ts is removing the blocked label.

  4. removed
    blocked
    on Nov 10, 2026
  5. self-assigned this
    on Nov 10, 2026
  6. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Claiming #3825 as implementation worker checkpoint-3825-c446, branch fix/3825-worktree-checkpoint-retry, from fresh origin/main a75d54a. #3815 is closed and #3823 is merged. The cited drop/close/driver guards are present; acceptance criteria are ready. Collision scan reports a direct turn-journal.ts overlap with #3622 and shared proof closure with other open PRs; edits will stay scoped. Will provide full local proof and a ready PR for milestone 0.45.0; coordinator owns confirmation and merge.

  7. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Implementation handoff: ready PR #3837, head 974de9a4ab50cad9afd51a4252e280febf0986e5, milestone 0.45.0.

    All three acceptance criteria pass locally: ended-turn cleanup retains status visibility and charges until successful retry; shutdown cancels retries and drains active attempts without forgetting uncertain leases; mutations detect removal of the observer timer clear, compute slow cadence and compute re-entry guard. The PR records eight mutation receipts in total and the failing-first regression.

    Full ui-server proof: 5,657 pass, 0 fail, 0 skip, all 454 files exactly once. Both backend provider-history guards passed (33 tests). Strict typechecking and check:pr passed on the rebased head, with its receipt in the PR body. The body preserves the earlier full-suite SHA and documents the CI-only base advancement and unchanged package/test-runner inputs.

    Claim checkpoint-3825-c446 is released for the coordinator's review, candidate confirmation and merge. No integrate.ts confirm or merge was run. No implementation acceptance criterion is left open.

  8. removed their assignment
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-serverpriority: p2type: fix

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions