You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
P1: Rematerialize a missing worktree from its preserved branch #1400
On origin/maine2924af, prepareThreadWorktree calls clearMissingWorktree when a recorded directory is gone. That function clears both worktreePath and branch and sets pendingWorktree. ensureWorktree then calls setupWorktree, which creates a new branch from the thread's original lead snapshot (or default start for an independent thread). If the old branch still exists, uniqueCoderBranch picks a suffixed name. The new checkout excludes commits made on the old branch.
This can follow an external git worktree remove or app GC of an archived transient worktree after its grace period. GC deliberately preserves branch refs, but the thread loses the ref needed to resume its work. #843 addressed ghost fields in cleanup, not this resume path.
Change
When a missing worktree's recorded branch still exists, rematerialize that branch at its existing tip. Keep the branch until the new checkout succeeds. If the ref is missing or cannot be checked out safely, fail with an actionable error rather than silently starting from an older snapshot. Preserve current behavior for a never-materialized pendingWorktree thread.
Check
A worker commits a file, its clean worktree directory is removed while the branch remains, and the next run recreates a checkout containing that commit on the same branch. A missing branch fails clearly; a fresh worker still starts from leadSnapshotSha; dirty/uncommitted files are not claimed recoverable.
Scope correction: gcClean also clears branch when it removes a worktree. To cover the app-GC case named above, retain the preserved branch ref as thread metadata (or an explicit resume ref) when GC reclaims the directory, then use that ref during rematerialization. clearMissingWorktree covers only directories removed outside the app. Do not infer a ref from the title or pick the latest matching branch.
Live-store audit, 2026-10-01: 42 thread records point to missing worktree directories while retaining a branch name. For 17, that branch ref still exists in the owning repo; all 17 branch tips have commits not reachable from the repo's default ref (56 commits total by rev-list default..branch). This does not prove the changes were not squash-merged, but it does show that the current clear-and-recreate path would detach 17 real branch histories from their threads on the next run. The other 25 refs were missing or could not be resolved, so those need a clear failure/recovery path rather than an assumed restart.
Behavior split for the 17 existing refs in the live audit: 6 are ordinary threads, whose current rematerialization can create a fresh branch from the default/base and omit the old commits. The other 11 are older orchestration workers with no leadSnapshotSha; after branch is cleared, resolveWorktreeStart refuses to start them at all (MISSING_START_SNAPSHOT). The ticket should restore the recorded ref for both cases. My earlier comment's 56 commits describe branch history at risk of disconnect, not 17 proven silent restarts.
Related retention consequence, filed separately as #1404: after GC clears a worker's worktreePath and branch (while leaving Git refs), runner.sweepCrew can purge a finished worker beyond its 20-worker cap because it guards only on worktreePath. Restoring an existing branch in this issue should include a durable branch/landing receipt that also prevents premature worker-thread purging; #1404 owns the retention behavior and regression.
Activity
currentbits commentedon Oct 1, 2026
Scope correction:
gcCleanalso clearsbranchwhen it removes a worktree. To cover the app-GC case named above, retain the preserved branch ref as thread metadata (or an explicit resume ref) when GC reclaims the directory, then use that ref during rematerialization.clearMissingWorktreecovers only directories removed outside the app. Do not infer a ref from the title or pick the latest matching branch.currentbits commentedon Oct 1, 2026
Live-store audit, 2026-10-01: 42 thread records point to missing worktree directories while retaining a branch name. For 17, that branch ref still exists in the owning repo; all 17 branch tips have commits not reachable from the repo's default ref (56 commits total by
rev-list default..branch). This does not prove the changes were not squash-merged, but it does show that the current clear-and-recreate path would detach 17 real branch histories from their threads on the next run. The other 25 refs were missing or could not be resolved, so those need a clear failure/recovery path rather than an assumed restart.currentbits commentedon Oct 1, 2026
Behavior split for the 17 existing refs in the live audit: 6 are ordinary threads, whose current rematerialization can create a fresh branch from the default/base and omit the old commits. The other 11 are older orchestration workers with no
leadSnapshotSha; afterbranchis cleared,resolveWorktreeStartrefuses to start them at all (MISSING_START_SNAPSHOT). The ticket should restore the recorded ref for both cases. My earlier comment's 56 commits describe branch history at risk of disconnect, not 17 proven silent restarts.currentbits commentedon Oct 1, 2026
Related retention consequence, filed separately as #1404: after GC clears a worker's
worktreePathandbranch(while leaving Git refs),runner.sweepCrewcan purge a finished worker beyond its 20-worker cap because it guards only onworktreePath. Restoring an existing branch in this issue should include a durable branch/landing receipt that also prevents premature worker-thread purging; #1404 owns the retention behavior and regression.Restore a deleted thread worktree from its preserved branch (#1622)
currentbits commentedon Oct 13, 2026
Landed from Solenta thread "P1: Rematerialize a missing worktree from its preserved bran" (PR #1622). Closed on merge.
Rematerialize a missing worktree from its preserved branch (#1400)