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:
@@ -389,7 +389,6 @@ describe("FN-5279 reliability interactions: merge reuse task worktree", () => {
|
||||
expect(fallback?.metadata).toMatchObject({
|
||||
reason: "missing-task-worktree",
|
||||
source: "fresh",
|
||||
integrationBranch: "master",
|
||||
});
|
||||
} finally {
|
||||
await fixture.cleanup();
|
||||
|
||||
Reference in New Issue
Block a user