fix(FN-4917): correct pooled invalid worktree cleanup call

Fusion-Task-Id: FN-4917
Fusion-Task-Lineage: 1422a545-f4b5-4e1f-a347-8be2a4202f45
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 11:07:29 -07:00
committed by gsxdsm
parent 2bc76cf00f
commit 1cb952fe58

View File

@@ -11,6 +11,8 @@ import {
type WorktreePool,
classifyTaskWorktree,
isInsideWorktreesDir,
removeWorktree,
RemovalReason,
} from "./worktree-pool.js";
import {
NativeWorktreeBackend,
@@ -286,7 +288,14 @@ export async function acquireTaskWorktree(opts: AcquireTaskWorktreeOptions): Pro
await store.logEntry(task.id, `Pool returned ${pooledClassification.classification} worktree (${pooledClassification.reason}); creating fresh worktree`, undefined, runContext);
if (isInsideWorktreesDir(rootDir, worktreePath, settings)) {
try {
await backend.remove(worktreePath, { rootDir, force: true, reason: RemovalReason.PoolCleanup, taskId: task.id });
await removeWorktree({
rootDir,
worktreePath,
settings,
reason: RemovalReason.PoolPrune,
taskId: task.id,
audit,
});
} catch (removeErr) {
logger?.warn(`${task.id}: failed to remove unusable pooled worktree ${worktreePath}: ${formatError(removeErr)}`);
}