Repository navigation
Description
What happened
On PR #53 (Dependabot styled-components 5→6), a human posted /fs-fix at 09:27:41 UTC. Fix run 42790902168 (agents@v0.54.0 / 87a43fc) checked out PR head 2c12b99 and produced two good commits addressing all four review findings (tests 39/39, lint/prettier clean).
At 09:28:18 another PR merged to main; Dependabot then rebased its branch and force-pushed 1710475 at 09:30:15. The agent noticed mid-run that its checkout was stale but cannot fetch inside the sandbox, so it proceeded (and split source vs. dependency-file changes into separate commits to ease replay).
In scripts/post-fix.sh, the fetch showed + 2c12b99...1710475 (forced update). None of the skip arms applied (no agent merge/rebase-onto-target; origin/ not an ancestor of HEAD), so it fell through to the default git rebase "origin/${BRANCH}" (~line 3440 in the v0.54.0 build). Because the remote was rewritten, the merge-base is the old main commit, so git replayed three commits (Rebasing (1/3)): Dependabot's superseded 2c12b99 plus the agent's two. 2c12b99 conflicted with its own rebased copy 1710475 in package.json/package-lock.json (error: could not apply 2c12b99...). post-fix aborted and posted "Post-fix script failed — Push rejected", although no push was attempted. The agent's work ($1.46) was discarded, and the PR was merged minutes later without the fixes.
What could go better
High confidence on the mechanism: the log shows the forced update, Rebasing (1/3) and the conflict on the stale PR commit, and the code path is a plain git rebase origin/$BRANCH with no handling for a rewritten remote. PRE_AGENT_HEAD (=2c12b99) is already available in post-fix and identifies exactly where the agent's commits start, so replaying PRE_AGENT_HEAD..HEAD onto the new remote tip would have attempted only the agent's 2 commits.
Uncertainty: I cannot prove the agent's commits would have applied cleanly onto 1710475. The new base also bumped typescript in package.json/lockfile, and the agent's second commit removed @types/styled-components from the same files, so a genuine (smaller) conflict was possible. Even then, the failure would be a real conflict on agent changes rather than a guaranteed self-conflict of the bot's own commit.
This is likely common on Dependabot/Renovate PRs, which rebase themselves whenever the base moves; on PR #43 in this repo Dependabot force-pushed 13 s after /fs-fix (the fix only survived because it started after the push). It also applies to humans force-pushing a rebased agent branch. Secondary: the PR comment category "Push rejected" is misleading when the failure was in the pre-push rebase.
Proposed change
In scripts/post-fix.src.sh (built into scripts/post-fix.sh), in the pre-push reconcile block just before the default git rebase "origin/${BRANCH}":
- Detect a rewritten remote:
PRE_AGENT_HEADis set,origin/${BRANCH}!=PRE_AGENT_HEAD, and! git merge-base --is-ancestor "${PRE_AGENT_HEAD}" "origin/${BRANCH}"(the commit the agent built on is no longer on the remote branch). - In that case, and only when
PRE_AGENT_HEADis an ancestor ofHEADand every commit inPRE_AGENT_HEAD..HEADis agent-authored (reuse the existing identity checks used for history-rewrite authorization), rungit rebase --onto "origin/${BRANCH}" "${PRE_AGENT_HEAD}" HEADso only the agent's commits are replayed onto the rewritten tip. LogRemote PR branch was rewritten during the run (PRE_AGENT_HEAD no longer on origin/<branch>) — replaying only agent commits. - If that replay conflicts, abort and post a distinct failure category/message (e.g.
branch-rewritten-conflict: "The PR branch was force-pushed to while the fix agent was running and the agent's changes conflict with it; re-run /fs-fix") instead of the generic "Push rejected". - Keep all existing arms (post-fix.sh: skip the pre-push rebase-replay when origin/<branch> is already an ancestor of HEAD, not just after an explicit agent rebase #1323 ancestor skip, agent merge/rebase-onto-target preservation, human-commit preservation) ordered before this arm; do not touch the GitLab reconstruction path except where it already falls through.
Cross-reference agents#1797 (concurrent forward advance with an agent merge), which is the sibling case; this proposal covers the remote-rewrite case and has an observed reproduction.
Validation criteria
- Add a post-fix test fixture: base B1 → PR commit C1; agent commits A1, A2 on C1; remote force-pushed to C1' (C1 rebased onto B2, with a lockfile change in B2 not touching A1/A2 hunks). Expected: post-fix publishes C1' + A1' + A2' with no conflict, and logs the new rewritten-remote message. A variant where A2 genuinely conflicts with C1' must fail with the new category, not "Push rejected".
- Existing post-fix tests for post-fix.sh: skip the pre-push rebase-replay when origin/<branch> is already an ancestor of HEAD, not just after an explicit agent rebase #1323/fix(#1323): skip pre-push replay when origin/branch is an ancestor #1793 (ancestor skip), merge/rebase-onto-target preservation and human-commit preservation keep passing.
- In production: over the next 30 days, no fix run on a Dependabot/Renovate PR fails with
could not apply <original PR commit sha>in the post-fix log after a bot force-push.
Related issues checked
Searched: "rebase --onto" repo:fullsend-ai/agents (open+closed); "PRE_AGENT_HEAD rebase" repo:fullsend-ai/agents; "post-fix force-pushed" / "force-push during fix" / "stale PR commit replay" / "remote rewritten" repo:fullsend-ai/agents; "post-fix rebase conflict" across fullsend-ai/fullsend, fullsend-ai/agents, shairevivo/react-shopping-cart; "Could not rebase local" / "concurrent push fix agent" / "dependabot force push fix" across the three repos
Considered: #1797, #1323, #409, #342, #1930, fullsend-ai/fullsend#7564, fullsend-ai/fullsend#2731, fullsend-ai/fullsend#3938
#1797 (open): hypothetical forward-advance race that drops an agent merge; does not cover a rewritten remote or propose --onto replay — this is an observed sibling case and refines it. #1323 (closed, fixed via PR #1793): ancestor-skip only; does not fire when the remote is rewritten. #409: fetch before force-with-lease retry, not rebase strategy. #342: preserving human commits on agent force-push (opposite direction). #1930: same bot-rebase pattern but re-review scope. fullsend#7564: dispatch-time skip when a human recently pushed; not about replay of a rewritten bot commit. fullsend#2731/#3938: avoid pushing to Renovate branches / later bot overwrite; different remedy and timing.
Generated by retro agent from fullsend-ai/react-shopping-cart#53
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity