Skip to content

sprint-master: worktree-isolation hijacks the orchestrator shell CWD, splitting sprint-tracking state #201

Description

@lwalden

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)

  1. 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.
  2. Mandate CWD pinning in the sprint-master promptSet-Location <main-repo> / cd "$(git -C <main> rev-parse --show-toplevel)" as the first step of every orchestration command after a worktree-agent spawn.
  3. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions