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 used | Callers |
|---|---|
Nearest sdlc.yaml | task/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 cwd | project/ops/_worktree-common.ts:24, gate/ops/worktree-scope.ts:108 |
| Caller-supplied | pr/review/worktree.ts:81 |
Proposed
Section titled “Proposed”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.
Approach
Section titled “Approach”- Add
worktreeRoot(fromPath)besideworktreeDirinlib/util/git.ts, built onmainCheckoutFrom. - Switch the nearest-
sdlc.yamlcallers, the probe ops andgateCwdfirst; they cause the misses. - Switch the cwd-relative and
findRepoRootcallers; check that the caller-supplied path inpr/review/worktree.tscomes from the helper. - Add a test with a nested
sdlc.yamlasserting probe, start, and the work tick agree on one path.
| Area | Note |
|---|---|
solutions/ontological/lib/util/git.ts | The helper |
solutions/ontological/lib/model/entities/task/ops/ | Probe, start, next, ensure-ready callers |
solutions/ontological/lib/services/ | Orchestrator, git, pr, repo, gate callers |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1:
git grep -n worktreeDirshows 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’sgateCwdresolve the same worktree path. - AC-3: Existing worktree tests pass unchanged for single-root projects.
Out of scope
Section titled “Out of scope”- Moving existing worktrees on disk; old nested
.sdlc/worktreesdirectories can be removed by hand.