bug: dev-agent does not clean up branch/worktree on CI exhausted or block #115

Closed
opened 2026-04-01 13:58:05 +00:00 by dev-bot · 0 comments
Collaborator

Problem

When pr_walk_to_merge fails (CI exhausted, review rejected, agent error), dev-agent.sh marks the issue as blocked but does NOT:

  • Clean up the local worktree (worktree_cleanup)
  • Delete the remote branch on Forgejo
  • Close the failed PR

The success path correctly calls worktree_cleanup "$WORKTREE" and removes temp files. The failure path skips all of this.

Impact

When the issue is later relabeled to backlog for a retry, dev-poll.sh finds the old fix/issue-<N> branch on Forgejo, enters recovery mode, and pushes on top of the same broken code. The agent never gets a clean slate.

This caused PR #106 and PR #111 to repeat the same CI failure on issue #90.

Fix

In the failure path of dev-agent.sh (after issue_block):

  1. Close the PR if one exists: pr_close "$PR_NUMBER" or via Forgejo API
  2. Delete the remote branch: git push "$FORGE_REMOTE" --delete "$BRANCH"
  3. Clean up the local worktree: worktree_cleanup "$WORKTREE"
  4. Remove temp files: rm -f "$SID_FILE" "$IMPL_SUMMARY_FILE"

This ensures the next attempt starts from a fresh branch off main.

Affected files

  • dev/dev-agent.sh — failure path after pr_walk_to_merge fails

Acceptance criteria

  • On CI exhausted: PR closed, remote branch deleted, worktree cleaned up
  • On agent_failed/blocked: same cleanup
  • Next retry creates a fresh branch (no recovery mode)
  • Success path unchanged
  • CI green
## Problem When `pr_walk_to_merge` fails (CI exhausted, review rejected, agent error), `dev-agent.sh` marks the issue as blocked but does NOT: - Clean up the local worktree (`worktree_cleanup`) - Delete the remote branch on Forgejo - Close the failed PR The success path correctly calls `worktree_cleanup "$WORKTREE"` and removes temp files. The failure path skips all of this. ## Impact When the issue is later relabeled to `backlog` for a retry, `dev-poll.sh` finds the old `fix/issue-<N>` branch on Forgejo, enters recovery mode, and pushes on top of the same broken code. The agent never gets a clean slate. This caused PR #106 and PR #111 to repeat the same CI failure on issue #90. ## Fix In the failure path of `dev-agent.sh` (after `issue_block`): 1. Close the PR if one exists: `pr_close "$PR_NUMBER"` or via Forgejo API 2. Delete the remote branch: `git push "$FORGE_REMOTE" --delete "$BRANCH"` 3. Clean up the local worktree: `worktree_cleanup "$WORKTREE"` 4. Remove temp files: `rm -f "$SID_FILE" "$IMPL_SUMMARY_FILE"` This ensures the next attempt starts from a fresh branch off main. ## Affected files - `dev/dev-agent.sh` — failure path after `pr_walk_to_merge` fails ## Acceptance criteria - [ ] On CI exhausted: PR closed, remote branch deleted, worktree cleaned up - [ ] On agent_failed/blocked: same cleanup - [ ] Next retry creates a fresh branch (no recovery mode) - [ ] Success path unchanged - [ ] CI green
dev-bot added the
backlog
label 2026-04-01 13:58:05 +00:00
dev-qwen self-assigned this 2026-04-01 15:11:49 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-01 15:11:49 +00:00
dev-qwen removed their assignment 2026-04-01 15:23:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: johba/disinto#115
No description provided.