Summary
When the dev pipeline fails before the Claude subprocess successfully completes (e.g. [Errno 2] No such file or directory: 'claude', or any early subprocess/exec failure), the orchestrator leaves behind:
- A git worktree under
~/.dev-sync/worktrees/<repo>-dev-<repo>-<n>-<hash>/
- A local branch
fix/issue-<n> in the bare repo
On the next attempt for the same issue, worktree creation fails with:
git failed: Preparing worktree (new branch 'fix/issue-13')
fatal: a branch named 'fix/issue-13' already exists
...so the issue can never be retried without manual cleanup.
Repro
- Break the dispatcher (e.g. PATH doesn't include claude binary under launchd)
- Let the poller pick up a new issue → it creates worktree + branch, then fails
- Fix the dispatcher
- Retry the same issue → fails on "branch already exists"
Expected
On any failure path in run_dev_issue (dispatcher error, checkpoint FAILED, uncaught exception), the orchestrator should remove the worktree and delete the fix/issue- branch so the issue is safe to retry.
Suggested fix
Wrap the pipeline body in a try/finally (or an async context manager) that:
git worktree remove --force <worktree_path> on any failure exit
git branch -D fix/issue-<n> in the bare repo on any failure exit
- Leaves both intact on BLOCKED (user may still want to inspect / continue)
- Leaves both intact on DONE (PR may still reference the branch)
Evidence
Seen today in AInvirion/dev-sync for issues #13, #14, #15. Required manual:
BARE=~/.dev-sync/repos/AInvirion-dev-sync.git
git -C "$BARE" worktree remove --force <path>
git -C "$BARE" branch -D fix/issue-<n>
...plus clearing the issue from ~/.dev-sync/poller_state.json seen_issues before the poller would retry.
Related
Summary
When the dev pipeline fails before the Claude subprocess successfully completes (e.g.
[Errno 2] No such file or directory: 'claude', or any early subprocess/exec failure), the orchestrator leaves behind:~/.dev-sync/worktrees/<repo>-dev-<repo>-<n>-<hash>/fix/issue-<n>in the bare repoOn the next attempt for the same issue, worktree creation fails with:
...so the issue can never be retried without manual cleanup.
Repro
Expected
On any failure path in
run_dev_issue(dispatcher error, checkpoint FAILED, uncaught exception), the orchestrator should remove the worktree and delete the fix/issue- branch so the issue is safe to retry.Suggested fix
Wrap the pipeline body in a try/finally (or an async context manager) that:
git worktree remove --force <worktree_path>on any failure exitgit branch -D fix/issue-<n>in the bare repo on any failure exitEvidence
Seen today in AInvirion/dev-sync for issues #13, #14, #15. Required manual:
...plus clearing the issue from
~/.dev-sync/poller_state.jsonseen_issuesbefore the poller would retry.Related