Problem
When the sprint-master orchestrator spawns a subagent_type agent with isolation: "worktree", the orchestrator's own persistent shell working directory is silently moved into the agent worktree (e.g. .claude/worktrees/agent-<id>). Subsequent CWD-relative tooling then writes to the wrong place:
sprint-metrics.sh / sprint-update.sh operate on ./SPRINT.md and ./.sprint-metrics.json relative to CWD → they edit the worktree copies.
- Absolute-path file edits (the orchestrator's
Edit/Write of SPRINT.md, .quality-review-result.json) correctly hit the main repo.
Result: sprint state is split across two trees mid-sprint — the metrics file appears "missing" (it's in the worktree), phase/row updates land in different copies, and the orchestrator must stop and reconcile.
Evidence (dungeon-game Sprint 13, 2026-06-22)
First worktree-isolated executor moved the orchestrator CWD to .claude/worktrees/agent-a574…; sprint-metrics.sh init S13 had created .sprint-metrics.json in the main repo, but later item-start/review-findings ran from the worktree CWD and wrote a second metrics file there. Diagnosed via git rev-parse --show-toplevel / Get-Location showing CWD = worktree. Reconciled by hand; cost ~2 orchestration turns.
Impact
- Recurring metrics init/loss (previously flagged S10 #?, S12 retro) — this is the proximate root cause, not a separate bug.
- Per-item durations become recording-time approximations.
- Risk of phase-guard reading the wrong
SPRINT.md.
Recommended fix (any one)
- Make the sprint scripts repo-root-anchored — accept an explicit
--repo-root arg (or resolve via git rev-parse --show-toplevel internally) instead of CWD-relative ./SPRINT.md.
- Mandate CWD pinning in the sprint-master prompt —
Set-Location <main-repo> / cd "$(git -C <main> rev-parse --show-toplevel)" as the first step of every orchestration command after a worktree-agent spawn.
- Investigate whether the harness should leave the parent shell CWD untouched when a child runs in an isolated worktree.
Related: #200 (plugin bin PATH not reaching subagent shells — same "shell environment differs from where the orchestrator thinks it is" class).
Problem
When the sprint-master orchestrator spawns a
subagent_typeagent withisolation: "worktree", the orchestrator's own persistent shell working directory is silently moved into the agent worktree (e.g..claude/worktrees/agent-<id>). Subsequent CWD-relative tooling then writes to the wrong place:sprint-metrics.sh/sprint-update.shoperate on./SPRINT.mdand./.sprint-metrics.jsonrelative to CWD → they edit the worktree copies.Edit/WriteofSPRINT.md,.quality-review-result.json) correctly hit the main repo.Result: sprint state is split across two trees mid-sprint — the metrics file appears "missing" (it's in the worktree), phase/row updates land in different copies, and the orchestrator must stop and reconcile.
Evidence (dungeon-game Sprint 13, 2026-06-22)
First worktree-isolated executor moved the orchestrator CWD to
.claude/worktrees/agent-a574…;sprint-metrics.sh init S13had created.sprint-metrics.jsonin the main repo, but lateritem-start/review-findingsran from the worktree CWD and wrote a second metrics file there. Diagnosed viagit rev-parse --show-toplevel/Get-Locationshowing CWD = worktree. Reconciled by hand; cost ~2 orchestration turns.Impact
SPRINT.md.Recommended fix (any one)
--repo-rootarg (or resolve viagit rev-parse --show-toplevelinternally) instead of CWD-relative./SPRINT.md.Set-Location <main-repo>/cd "$(git -C <main> rev-parse --show-toplevel)"as the first step of every orchestration command after a worktree-agent spawn.Related: #200 (plugin bin PATH not reaching subagent shells — same "shell environment differs from where the orchestrator thinks it is" class).