feat(FN-2621): guard execution for non-git project directories

- Add isGitRepository utility in worktree-pool using git rev-parse checks
- Fail fast in TaskExecutor with actionable non-git errors before worktree creation starts
- Classify not-a-git-repository worktree add failures as non-retryable in recovery flows
- Warn from in-process runtime startup when the working directory is not a Git repository
- Expand executor and worktree-pool tests to cover non-git, missing-dir, and conflict-classification paths
This commit is contained in:
Fusion
2026-04-26 22:20:17 -07:00
committed by gsxdsm
parent da97ba667f
commit 6d2cf27410
5 changed files with 191 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ import type {
import { isEphemeralAgent } from "@fusion/core";
import { Scheduler } from "../scheduler.js";
import { TaskExecutor, type TaskExecutorOptions } from "../executor.js";
import { WorktreePool } from "../worktree-pool.js";
import { WorktreePool, isGitRepository } from "../worktree-pool.js";
import { AgentSemaphore } from "../concurrency.js";
import { HeartbeatMonitor, HeartbeatTriggerScheduler, type WakeContext } from "../agent-heartbeat.js";
import { RoutineRunner, type RoutineRunnerOptions } from "../routine-runner.js";
@@ -197,6 +197,14 @@ export class InProcessRuntime
runtimeLog.warn(`reapOrphanWorktrees failed (continuing): ${msg}`);
}
if (!(await isGitRepository(this.config.workingDirectory))) {
runtimeLog.warn(
`Project directory "${this.config.workingDirectory}" is not a Git repository. ` +
`Task execution will fail until a Git repository is initialized. ` +
`Run 'git init' in the project directory to enable worktree-based task execution.`,
);
}
this.worktreePool = new WorktreePool();
// Rehydrate pool from disk state (idle worktrees)