fix(FN-5353): reacquire fresh worktree on reuse-handoff refusal

After merge:reuse-handoff-refused with no usable task worktree:
- Acquire a fresh worktree and restore the fusion/<task-id> branch
  from baseCommitSha before continuing merge
- Hard-fail only if fresh acquisition itself fails (not cwd-main fallback)
- Emit merge:reuse-worktree-fresh-acquire / merge:reuse-worktree-fresh-acquired
  audit events around the acquisition lifecycle

Replaces the incorrect cwd-main fallback (499784581) with correct
reacquire path. Updates regression test in merge-reuse-task-worktree.test.ts
to assert fresh-acquire audit trail instead of cwd-main fallback.

Refs: FN-5353
This commit is contained in:
gsxdsm
2026-05-20 10:47:35 -07:00
parent a03a5de235
commit 6d66559eb3
3 changed files with 64 additions and 108 deletions

View File

@@ -160,6 +160,7 @@ export type GitMutationType =
| "merge:reuse-handoff-released"
| "merge:reuse-handoff-deferred-to-worktrunk"
| "merge:reuse-fallback-cwd-main"
| "merge:reuse-fallback-new-worktree"
| "merge:audit-failure"
| "branch:auto-reclaim"
| "branch:auto-canonicalize-case"