feat(FN-4948): complete Step 2 — wire identity guard into worktree provisioning

Fusion-Task-Id: FN-4948
Fusion-Task-Lineage: dc622643-4c3e-4217-9219-a6a6e5424427
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 13:26:41 -07:00
committed by gsxdsm
parent f42a149fe3
commit 487dfcc10c
10 changed files with 67 additions and 35 deletions

View File

@@ -8,7 +8,7 @@ import {
RemovalReason,
} from "../worktree-backend.js";
const { execMock, accessMock, existsSyncMock, parseIndexLockPathMock, classifyStaleLockMock, tryRemoveStaleLockMock } = vi.hoisted(() => {
const { execMock, accessMock, existsSyncMock, parseIndexLockPathMock, classifyStaleLockMock, tryRemoveStaleLockMock, installGuardMock } = vi.hoisted(() => {
const mock = vi.fn();
(mock as any)[Symbol.for("nodejs.util.promisify.custom")] = mock;
return {
@@ -18,6 +18,7 @@ const { execMock, accessMock, existsSyncMock, parseIndexLockPathMock, classifySt
parseIndexLockPathMock: vi.fn(),
classifyStaleLockMock: vi.fn(),
tryRemoveStaleLockMock: vi.fn(),
installGuardMock: vi.fn(),
};
});
@@ -27,6 +28,9 @@ vi.mock("node:fs/promises", () => ({ access: accessMock }));
vi.mock("../branch-conflicts.js", () => ({
inspectBranchConflict: vi.fn().mockResolvedValue({ kind: "stale" }),
}));
vi.mock("../worktree-hooks.js", () => ({
installTaskWorktreeIdentityGuard: installGuardMock,
}));
vi.mock("../worktree-stale-lock.js", () => ({
StaleWorktreeIndexLockError: class StaleWorktreeIndexLockError extends Error {
lockPath: string;
@@ -54,6 +58,8 @@ beforeEach(() => {
parseIndexLockPathMock.mockReset();
classifyStaleLockMock.mockReset();
tryRemoveStaleLockMock.mockReset();
installGuardMock.mockReset();
installGuardMock.mockResolvedValue(undefined);
parseIndexLockPathMock.mockReturnValue(null);
classifyStaleLockMock.mockResolvedValue({ kind: "fresh", reason: "fresh" });
tryRemoveStaleLockMock.mockResolvedValue({ removed: true });
@@ -77,6 +83,7 @@ describe("NativeWorktreeBackend", () => {
'git worktree add -b "fusion/fn-1" "/repo/.worktrees/fn-1" "main"',
expect.objectContaining({ cwd: "/repo", timeout: 120000, maxBuffer: 10485760 }),
);
expect(installGuardMock).toHaveBeenCalledWith({ worktreePath: "/repo/.worktrees/fn-1", taskId: "FN-1" });
});
it("retries with suffix and resolves", async () => {