Clean no-change worktrees at terminal completion #33

Closed
opened 2026-10-27 13:34:40 +00:00 by sam · 0 comments
Owner

BuildNoChanges transitions directly to merged without a PR, bypassing the only production worktree cleanup path and leaking a full clone.

Confirmed still present on main. closeNoChangesIssue (internal/domain/workflow/steps.go:67-77) sets Outcome{Status: store.StatusMerged} directly, with no worktree removal. The only two production callers of worktree.Manager.Cleanup are internal/daemon/daemon.go:769 and :788, both inside the PR-state polling loop that transitions out of StatusPROpen. A task that reaches merged without ever opening a PR never enters that loop, so its clone is never removed.

Steps to Reproduce

  1. Dispatch a task whose builder stage completes with StatusPassed but produces no diff, so implement.go:166 sets tc.BuildNoChanges = true.
  2. Let StageCommitPush run: it takes the BuildNoChanges branch, closes the issue, and sets the outcome to merged.
  3. Observe the task row reaches merged with no PR number, so the daemon's PRState polling loop never sees it.
  4. Inspect the workspace root: <work_dir>/<base64(owner)>/<base64(repo)>/issue-<n>/ still contains the full clone.
  5. Repeat for further no-change tasks and watch the directory count grow unbounded — nothing else removes them.

Acceptance Criteria

Both direct and container no-change completion remove the identity-correct worktree while parked worktrees remain available; lifecycle regression tests cover the terminal path.

Acceptance criteria

Both direct and container no-change completion remove the identity-correct worktree while parked worktrees remain available; lifecycle regression tests cover the terminal path.

Close reason

Closed


Imported from beads archie-core-1ysw.7 · GitHub #598 · type bug · priority P2 · created 2026-08-22 · closed 2026-08-24

BuildNoChanges transitions directly to merged without a PR, bypassing the only production worktree cleanup path and leaking a full clone. Confirmed still present on main. `closeNoChangesIssue` (internal/domain/workflow/steps.go:67-77) sets `Outcome{Status: store.StatusMerged}` directly, with no worktree removal. The only two production callers of `worktree.Manager.Cleanup` are internal/daemon/daemon.go:769 and :788, both inside the PR-state polling loop that transitions out of `StatusPROpen`. A task that reaches `merged` without ever opening a PR never enters that loop, so its clone is never removed. ## Steps to Reproduce 1. Dispatch a task whose builder stage completes with `StatusPassed` but produces no diff, so `implement.go:166` sets `tc.BuildNoChanges = true`. 2. Let `StageCommitPush` run: it takes the `BuildNoChanges` branch, closes the issue, and sets the outcome to `merged`. 3. Observe the task row reaches `merged` with no PR number, so the daemon's `PRState` polling loop never sees it. 4. Inspect the workspace root: `<work_dir>/<base64(owner)>/<base64(repo)>/issue-<n>/` still contains the full clone. 5. Repeat for further no-change tasks and watch the directory count grow unbounded — nothing else removes them. ## Acceptance Criteria Both direct and container no-change completion remove the identity-correct worktree while parked worktrees remain available; lifecycle regression tests cover the terminal path. ### Acceptance criteria Both direct and container no-change completion remove the identity-correct worktree while parked worktrees remain available; lifecycle regression tests cover the terminal path. ### Close reason Closed --- _Imported from beads `archie-core-1ysw.7` · GitHub #598 · type bug · priority P2 · created 2026-08-22 · closed 2026-08-24_
sam added the mediumbug labels 2026-10-27 13:34:40 +00:00
sam self-assigned this 2026-10-27 13:34:40 +00:00
sam closed this issue 2026-10-27 13:34:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#33