* refactor(worktree): drop unused flat-layout worktrees/ path
Every worktree creation now routes through the task-dir layout
(~/.kandev/tasks/{title}_{suffix}/{repo}/); the legacy flat layout
under ~/.kandev/worktrees/ has been unreachable since the subtasks
PR populated TaskDirName/RepoName unconditionally. Removes the dead
Config.BasePath, Manager.createWorktree, and the flat reconciler.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(worktree): remove unused Reconcile, add guard regression test
Address PR review feedback:
- Reconcile (and reconcileTasksDir / isOrphanedTaskDir) had no callers
anywhere in the tree after the flat-layout removal. Deleted rather than
left dangling; if startup orphan cleanup is wired up later it can return
alongside its actual call site. Also moots the stale doc comment that
CodeRabbit flagged.
- Add TestCreate_MissingTaskDirFields_ReturnsErrTaskDirRequired covering
the three permutations (missing RepoName, missing TaskDirName, both
missing) so a regression in the ErrTaskDirRequired guard surfaces in
CI rather than silently.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* fix(worktree): bound git ref-inspection with context timeout
branchExists and currentBranch spawned raw exec.Command with no context
and no timeout, and both were called while Manager.Create held the
per-repo mutex. A hung git subprocess (credential helper, stuck filter,
filesystem stall) kept the lock in Manager.repoLocks forever, blocking
every subsequent task on the same repository until the backend was
restarted.
Route both helpers through newNonInteractiveGitCmd with a new
defaultGitInspectTimeout (10s) so ctx cancellation and bounded
deadlines propagate to the subprocess. Also log lock-hold duration on
release for future diagnosis.
* fix(worktree): address review feedback on inspect-timeout change
- branchExists/currentBranch now log the ctx error when the bound fires,
so a hung git surfaces in logs instead of only as a misleading "branch
not found" (CodeRabbit).
- inspectTimeout is a Manager field (defaults to defaultGitInspectTimeout)
so tests can shrink it; added an isolation test that verifies the
internal bound fires even when the caller ctx has no deadline (Claude).
- Route setUpstreamIfExists through newNonInteractiveGitCmd so it also
gets non-interactive env + WaitDelay while repoLock is held (Claude).
- Simplify TestCreate_HangingRevParseReleasesRepoLock: drop redundant
sync.WaitGroup and extract hangOnRevParseScript constant shared by all
four tests (CodeRabbit).