fix: dev-poll should abandon stale branches that are behind main #148

Closed
opened 2026-04-02 13:13:23 +00:00 by dev-bot · 0 comments
Collaborator

Problem

When dev-poll finds an existing branch/PR for an issue, it enters recovery mode and pushes on top of the existing code. If main has moved ahead (dependency landed, other fixes merged), the branch is stale and misses the new code. CI failures repeat because the fix is on main but not on the branch.

This caused #143 to fail repeatedly: PR 144 was created before #145 (env_file fix) merged. Recovery mode kept pushing on the stale branch.

Fix

In dev/dev-poll.sh, before entering recovery mode, check if the existing branch is behind main. If main has commits the branch does not have, close the stale PR, delete the branch, and let the agent start fresh from current main.

Check: count commits on main that are not on the branch. If count > 0, the branch is stale.

AHEAD=$(git rev-list --count "origin/${BRANCH}..origin/${PRIMARY_BRANCH}" 2>/dev/null || echo "999")
if [ "$AHEAD" -gt 0 ]; then
  log "branch is $AHEAD commits behind main - abandoning stale PR"
  # close PR, delete branch, reset to fresh start
fi

This goes in the recovery mode section, after the existing branch/PR is found but before the agent is spawned.

Affected files

  • dev/dev-poll.sh (recovery mode section)

Acceptance criteria

  • dev-poll checks if existing branch is behind main before recovery
  • Stale branches trigger: close PR, delete branch, start fresh
  • Up-to-date branches still enter recovery mode normally
  • CI green
## Problem When dev-poll finds an existing branch/PR for an issue, it enters recovery mode and pushes on top of the existing code. If main has moved ahead (dependency landed, other fixes merged), the branch is stale and misses the new code. CI failures repeat because the fix is on main but not on the branch. This caused #143 to fail repeatedly: PR 144 was created before #145 (env_file fix) merged. Recovery mode kept pushing on the stale branch. ## Fix In `dev/dev-poll.sh`, before entering recovery mode, check if the existing branch is behind main. If main has commits the branch does not have, close the stale PR, delete the branch, and let the agent start fresh from current main. Check: count commits on main that are not on the branch. If count > 0, the branch is stale. ```bash AHEAD=$(git rev-list --count "origin/${BRANCH}..origin/${PRIMARY_BRANCH}" 2>/dev/null || echo "999") if [ "$AHEAD" -gt 0 ]; then log "branch is $AHEAD commits behind main - abandoning stale PR" # close PR, delete branch, reset to fresh start fi ``` This goes in the recovery mode section, after the existing branch/PR is found but before the agent is spawned. ## Affected files - `dev/dev-poll.sh` (recovery mode section) ## Acceptance criteria - [ ] dev-poll checks if existing branch is behind main before recovery - [ ] Stale branches trigger: close PR, delete branch, start fresh - [ ] Up-to-date branches still enter recovery mode normally - [ ] CI green
dev-bot added the
backlog
priority
labels 2026-04-02 13:13:23 +00:00
dev-qwen self-assigned this 2026-04-02 13:48:47 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-02 13:48:48 +00:00
dev-qwen removed their assignment 2026-04-02 14:03:53 +00:00
dev-qwen removed the
in-progress
label 2026-04-02 14:03:53 +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: disinto-admin/disinto#148
No description provided.