Repository navigation
Description
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:
- 152 files changed, +65,408 / −3,368 lines
- ~70 "Fix #…" commits authored by
jwbronon dates predating the pipeline (already on main, but as different SHAs) - 9 files of
.egg-state/artifacts for issue Makemake testchangeset-aware (only run tests affected by diff from base branch) #1973 (came in via the LKG sidecar from the divergent Makemake testchangeset-aware via grimp + sidecar LKG #2042) - The actual Improve overseer escalation/issue opening behavior #1962 feature work (5,872 lines across 41 files) buried inside
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:
- The branch already exists on the remote, AND
- The branch's tip is behind
origin/<base>(typicallymain),
…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_ALERTwarning 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_taskentry / branch creation/reuse path.- Whatever git-checkout helper the orchestrator calls when reusing an existing pipeline branch (likely a helper in
orchestrator/that doesgit fetch origin <branch>+git checkoutfor 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
- Improve overseer escalation/issue opening behavior #1962 — the pipeline that surfaced this (PR overseer: advisor-gated escalation + auto-issue filing (#1962) #2096 needed manual
git rebase origin/mainto drop the 70+ stale-variant commits and recover a clean diff). - The
.egg-state/tracking policy (intentionally checked in per.gitignorecomment) compounds the impact: stale-variant commits drag in unrelated pipelines' state files. That's a separate question worth its own conversation, but the rebase-on-resume fix substantially mitigates the contamination dimension regardless.
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
Address review: replace HEAD-ahead-of-base guard with ancestry test
Address re-review: handle fresh-worktree resume in ancestry guard
Fix #2098: rebase stale pipeline branch onto base on resume (#2102)