Merge pull request 'chore(agents): add auto-rebase on conflict to PR reviewer pool supervisor' (#1411) from improvement/pr-reviewer-auto-rebase-on-conflict into master
CI / benchmark-publish (push) Waiting to run
CI / lint (push) Successful in 32s
CI / typecheck (push) Successful in 52s
CI / quality (push) Successful in 34s
CI / security (push) Successful in 1m5s
CI / benchmark-regression (push) Waiting to run
CI / build (push) Successful in 18s
CI / helm (push) Successful in 23s
CI / unit_tests (push) Successful in 7m4s
CI / e2e_tests (push) Successful in 17m34s
CI / integration_tests (push) Successful in 22m50s
CI / coverage (push) Successful in 10m4s
CI / docker (push) Successful in 21s
CI / status-check (push) Successful in 1s

This commit was merged in pull request #1411.
This commit is contained in:
2026-04-05 09:01:17 +00:00
committed by Forgejo
+69 -9
View File
@@ -416,15 +416,32 @@ LOOP FOREVER:
last_status: result.merge_status
}
elif result.merge_status == "conflict":
post comment on PR #pr_number:
"Merge conflict detected. The implementing agent
needs to rebase this branch onto latest master.
# Merge conflict — attempt rebase before giving up.
# The implementing agent has already exited, so nobody
# else will rebase this branch.
rebase_success = attempt_rebase(pr_number)
if rebase_success:
pending_merge[pr_number] = {
attempts: pending_merge.get(pr_number, {}).get(attempts, 0) + 1,
last_status: "rebased_retrying"
}
post comment on PR #pr_number:
"Merge conflict detected. Reviewer pool rebased
the branch onto latest master. Re-attempting merge.
---
**Automated by CleverAgents Bot**
Supervisor: PR Review | Agent: ca-continuous-pr-reviewer"
reviewed_prs.add(pr_number)
pending_merge.pop(pr_number, None)
---
**Automated by CleverAgents Bot**
Supervisor: PR Review | Agent: ca-continuous-pr-reviewer"
else:
post comment on PR #pr_number:
"Merge conflict detected. Automatic rebase failed
(conflicts too complex). Manual rebase required.
---
**Automated by CleverAgents Bot**
Supervisor: PR Review | Agent: ca-continuous-pr-reviewer"
reviewed_prs.add(pr_number)
pending_merge.pop(pr_number, None)
elif result.decision == "changes_requested":
reviewed_prs.add(pr_number)
pending_merge.pop(pr_number, None)
@@ -549,7 +566,7 @@ The pool supervisor tracks PRs across their full merge lifecycle:
| `ci_pending` | CI still running, merge not yet attempted | Retry next cycle. |
| `ci_failing` | CI failed, fix attempted | Retry next cycle (ca-pr-checker may fix it). |
| `merge_failed` | Merge API call failed | Retry next cycle indefinitely. Post diagnostic every 10 attempts. |
| `conflict` | Merge conflicts exist | Post comment, stop retrying. Implementor must rebase. |
| `conflict` | Merge conflicts exist | Attempt auto-rebase; if it fails, post comment and stop. |
| `changes_requested` | Code review found issues | Wait for implementor to push fixes. Re-review on SHA change. |
| `awaiting_human` | `needs feedback` label | Stop. Human must merge. |
@@ -559,6 +576,49 @@ they choose, but the system never gives up autonomously.
---
## Auto-Rebase on Conflict
When a reviewer reports `merge_status: "conflict"`, the pool supervisor
attempts to rebase the PR branch onto the latest master before giving up.
The implementing agent has already exited after PR creation, so nobody else
will perform this rebase.
```
def attempt_rebase(pr_number):
pr = fetch PR #pr_number via Forgejo API
branch = pr.head.ref
cd "$CLONE_DIR"
git fetch origin
git checkout <branch>
git rebase origin/master
if rebase succeeds (exit code 0):
git push origin <branch> --force-with-lease
if push succeeds:
return True
else:
git rebase --abort # safety
return False
else:
git rebase --abort
return False
```
**Key rules for auto-rebase:**
- Use `--force-with-lease` (not `--force`) to avoid overwriting concurrent
pushes from other agents.
- If the rebase produces conflicts that cannot be auto-resolved, abort
immediately — do not attempt manual conflict resolution.
- After a successful rebase + push, the PR's head SHA changes. Add the PR
back to `pending_merge` so the next cycle re-dispatches a reviewer to
attempt the merge.
- Limit rebase attempts to **3 per PR**. If three consecutive rebases fail,
post a comment and stop retrying (the conflicts are too complex for
auto-resolution).
---
## Bot Signature (Required on ALL Forgejo Content)
Every comment, issue body, PR description, and review you post to Forgejo