Summary
Harden worktree management: cleanup orphans on startup, detect lock files, check merge conflicts before PR.
Current State
src/integrations/git/worktrees.ts handles creation
- Config has
orphan_worktree_cleanup_on_startup but needs robust implementation
- No lock detection or proactive conflict checking
Plan
cleanupOrphanWorktrees() — scan worktrees_dir, remove untracked in DB
detectWorktreeLock(repoPath) — check .git/worktrees/*/locked
checkMergeConflicts(repoPath, target) — git merge-tree dry-run
- Call on daemon startup, before provisioning, and before PR
- Emit new event types
Files
src/integrations/git/worktrees.ts
src/core/pipeline.ts
src/harness/events.ts
Summary
Harden worktree management: cleanup orphans on startup, detect lock files, check merge conflicts before PR.
Current State
src/integrations/git/worktrees.tshandles creationorphan_worktree_cleanup_on_startupbut needs robust implementationPlan
cleanupOrphanWorktrees()— scan worktrees_dir, remove untracked in DBdetectWorktreeLock(repoPath)— check.git/worktrees/*/lockedcheckMergeConflicts(repoPath, target)—git merge-treedry-runFiles
src/integrations/git/worktrees.tssrc/core/pipeline.tssrc/harness/events.ts