Skip to content

submit_task: resuming a stale pipeline branch should rebase onto main first (avoids 'cherry-picked variant' commits showing as new in the PR diff) #2098

Closed

Description

@jwbron

Summary

When submit_task resumes work on an existing pipeline branch (e.g. one left over from a previously cancelled run), it does not rebase the branch onto current main before letting agents start committing. If the branch is far behind main, every commit that has since landed on main shows up in the PR diff as a "new" change, plus any LKG-style fixtures that other unrelated pipelines committed will come along for the ride. The result is a PR that's huge and confusing to review even when the actual feature work is small.

Repro / observed event

Pipeline issue-1962 resumed branch egg/issue-1962 from commit ab146d0c8 (a prior cancelled refine, ~2 weeks old). Between that cut point and the resume, main accumulated ~70 commits including the changeset-aware test selection PR (#2042). The branch's view of #2042 was the original commit af0e7ebc7; main got the rebased re-applied version 5cd3d6400 — same content, different SHA. The pipeline merged main into the branch mid-flow, and the PR ended up with:

After a manual git rebase origin/main on the branch, the same 38 #1962-specific commits applied cleanly with warning: skipped previously applied commit … for each of the 33 cherry-picked already-on-main commits, and the PR diff dropped to 52 files / +43,281 / −42 lines (87% of which is the intentionally-tracked .egg-state/ artifacts; the actual code/docs diff is the 5,872-line slice). No merge conflicts, no lost work.

So the right thing was always rebasing first; it's just that nothing in the pipeline did that automatically.

Why this matters

submit_task is the supported way to resume a cancelled pipeline (and is what /sdlc <issue-url> uses when the branch already exists from a prior run). When the cancelled run is hours old, this is a non-issue. When it's days/weeks old — which is common, since cancelled refines often sit waiting for the operator's next attempt — every PR that comes out of the resume is contaminated with merged-to-main work that's pre-existing.

Suggested fix

When submit_task (or any path that resumes work on an existing pipeline branch) detects:

  1. The branch already exists on the remote, AND
  2. The branch's tip is behind origin/<base> (typically main),

…then either:

  • (a) automatically git rebase origin/<base> on the worktree before spawning the next phase's agents (cherry-pick-skip will drop the already-merged commits transparently — verified by the manual recovery here, no conflicts in this case), OR
  • (b) refuse to resume and surface a HITL decision asking the operator whether to rebase / start fresh / cancel, OR
  • (c) just emit an OVERSEER_ALERT warning at submit time so the operator notices before BRC starts producing commits that will be buried under noise.

Option (a) is the cleanest if rebases are conflict-free in the common case (this one was). Option (b) is the safe fallback if conflicts are frequent.

Where this likely lives

  • orchestrator/routes/pipelines.py — submit_task entry / branch creation/reuse path.
  • Whatever git-checkout helper the orchestrator calls when reusing an existing pipeline branch (likely a helper in orchestrator/ that does git fetch origin <branch> + git checkout for the worktree the agents will use).
  • The fix probably wants to gate on git rev-list --count <branch>..<base> > some threshold (e.g. > 0).

Related

Severity

p2. The pipeline does technically work — the PR was correct, just bloated. But the bloat hides the real changes from human review and makes the PR harder to land. Operators will routinely hit this any time a stale branch gets resumed.

Activity

  1. added
    p2
    on Apr 25, 2026
  2. added a commit that references this issue on Apr 26, 2026
    4830bed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions