Skip to content

T-8CK0-one-worktree-root-for-every-op

State: planning/draft · Impact: high · Complexity: medium

Every op builds a worktree path with worktreeDir(root, basename) (lib/util/git.ts:43), but the ops choose root differently. A determined task’s worktree can be looked for in solutions/determined/.sdlc/worktrees by one op and <repo>/.sdlc/worktrees by another, so probes and the orchestrator miss worktrees that exist.

Root usedCallers
Nearest sdlc.yamltask/ops/_probe_core.ts:41-42, task/ops/probe-state.ts:202-206, services/orchestrator/ticks/work.ts:256 (gateCwd)
Git primary checkout (mainCheckoutFrom)ensure-ready-mutate.ts:1057 (and cleanupWorktree, L583), task/ops/start.ts:92, task/ops/next.ts:130, services/git/commit-to-main.ts:97, services/pr/ops/review.ts:232, services/repo/ops/checkout.ts:138, config/trust.ts:163
findRepoRoot(taskPath)preflight-permissions.ts:645-649
Relative to cwdproject/ops/_worktree-common.ts:24, gate/ops/worktree-scope.ts:108
Caller-suppliedpr/review/worktree.ts:81

One helper returns the worktree root, the git primary checkout, and every caller above uses it. No op derives a worktree path from ctx.projectRoot or the cwd.

  1. Add worktreeRoot(fromPath) beside worktreeDir in lib/util/git.ts, built on mainCheckoutFrom.
  2. Switch the nearest-sdlc.yaml callers, the probe ops and gateCwd first; they cause the misses.
  3. Switch the cwd-relative and findRepoRoot callers; check that the caller-supplied path in pr/review/worktree.ts comes from the helper.
  4. Add a test with a nested sdlc.yaml asserting probe, start, and the work tick agree on one path.
AreaNote
solutions/ontological/lib/util/git.tsThe helper
solutions/ontological/lib/model/entities/task/ops/Probe, start, next, ensure-ready callers
solutions/ontological/lib/services/Orchestrator, git, pr, repo, gate callers
  • AC-1: git grep -n worktreeDir shows every call taking its root from the helper.
  • AC-2: For a task in a nested planning root, task start, the probe ops, and the work tick’s gateCwd resolve the same worktree path.
  • AC-3: Existing worktree tests pass unchanged for single-root projects.
  • Moving existing worktrees on disk; old nested .sdlc/worktrees directories can be removed by hand.

← Back to Tasks