Live NAS (v0.14.0): after pr_reviewer correctly pr_fail'd task d3dab0fc to
needs_revision, the revision_coordination dispatcher tried to spawn be-pm and
re-attach its per-task worktree. git worktree add failed FATAL:
'feature/backend/fb836f80--03f80432--d3dab0fc' is already checked out at
'/data/workspaces/guard-core-saas-backend/backend/be-pm'
releasing the claim to pending and re-dispatching into the same collision
every tick — be-pm never spawned.
F123 invariant: the clone root parks on the default branch (or detached);
the task branch lives in the worktree. The clone root had drifted onto the
task branch (a pre-F123 leftover / a missed checkout path), so worktree add
refused. ensure_worktree + ensure_worktree_for_resume now restore the
invariant before the add: if the clone root's HEAD is the task branch, move
it back to the default branch (read from origin/HEAD); if that is
unresolvable or the checkout is blocked, detach HEAD at the same commit —
either frees the branch ref for the worktree. The clone root never carries
task work under F123, so nothing is lost; the branch ref (and pushed work)
survives unchanged.
TDD: 3 new tests (default-branch restore, detach fallback, self_heal recovery)
+ 36-test worktree regression green; ruff/mypy clean.