fix(FN-5353): reacquire fresh worktree when reuse handoff fails instead of falling back to main
Before: when reuse-task-worktree was configured but task worktree was missing/unusable, merger fell back to cwd-main, losing the task worktree isolation benefit. After: merger creates a fresh worktree for the task branch inline (using the standard git worktree add pattern with identity guard installation) and retries the reuse handoff. Only falls back to cwd-main if fresh acquisition also fails. Three new audit events track the recovery path: - merge:reuse-worktree-fresh-acquire — fresh acquisition started - merge:reuse-worktree-fresh-acquired — fresh worktree created and bound to task - merge:reuse-fallback-cwd-main — only when fresh acquisition itself fails (last resort) Behavior: - Missing/unusable task worktree → fresh worktree created, merge continues from it - Fresh acquisition fails → cwd-main fallback (last resort, fully audited) - Genuine liveness conflict (usable worktree but lease refused) → re-thrown, not masked Regression test covers the missing-worktree case: verifies fresh acquisition + handoff succeeds without any cwd-main fallback event.
This commit is contained in:
@@ -161,6 +161,8 @@ export type GitMutationType =
|
||||
| "merge:reuse-handoff-deferred-to-worktrunk"
|
||||
| "merge:reuse-fallback-cwd-main"
|
||||
| "merge:reuse-fallback-new-worktree"
|
||||
| "merge:reuse-worktree-fresh-acquire"
|
||||
| "merge:reuse-worktree-fresh-acquired"
|
||||
| "merge:audit-failure"
|
||||
| "branch:auto-reclaim"
|
||||
| "branch:auto-canonicalize-case"
|
||||
|
||||
Reference in New Issue
Block a user