fix: dev-agent failure cleanup should preserve remote branch and PR for debugging #131
Labels
No labels
action
backlog
blocked
bug-report
in-progress
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
tech-debt
underspecified
vision
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#131
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Issue #115 added cleanup on CI exhausted / block: close PR, delete remote branch, clean up worktree. This fixed the stale-branch recovery-mode problem, but it also destroys all evidence needed to debug WHY the attempt failed. The PR diff, CI logs, and review comments are all lost.
This made it impossible to debug the #124 (smoke-init) failure — the branch was deleted and CI logs became inaccessible.
Fix
Change the failure path in
dev/dev-agent.shto preserve the remote state while still ensuring a fresh start on retry:On failure (CI exhausted, agent_failed, blocked):
On retry (next dev-poll pickup):
Use a unique branch name per attempt so the new attempt never collides with the old one:
Or use an incrementing suffix by counting existing branches:
This means:
fix/issue-124(no suffix)fix/issue-124-1fix/issue-124-2Each attempt creates its own PR. Failed PRs stay open with their CI logs intact. The dev-poll
pr_find_by_branchwon't match the old branch name, so no recovery mode.What stays the same
issue_blockstill marks the issue as blocked with the exit reasonAffected files
dev/dev-agent.sh— failure path: remove PR close and branch delete; change BRANCH naming to include attempt suffixdev/dev-poll.sh— may need adjustment if it searches for existing branches/PRs by issue number (ensure it doesn't pick up old failed PRs)Acceptance criteria
Additional fix: stale branch detection in dev-poll recovery mode
The unique branch naming only prevents collisions between consecutive attempts. Two more scenarios cause stale branch problems:
Fix in
dev/dev-poll.shrecovery modeBefore entering recovery mode (when an existing PR/branch is found for the issue), check if the branch is behind main:
This ensures recovery mode only activates when the branch is up-to-date with main. If main has moved ahead (new dependencies landed, other fixes merged), the old branch is abandoned and a fresh one is created.
Updated acceptance criteria