Report and steer resolution of PR conflicts with the base branch #67

Merged
lucas merged 2 commits from agent/issue-63-base-conflicts into main 2026-10-26 12:14:58 +01:00
Collaborator

Closes: #63

  • New bridge/git-tools/base-conflict.ts: checkBaseConflict (fetch + git merge-tree --write-tree --name-only, no worktree/index/HEAD changes) and rebaseInstruction.
  • git_push: after a successful push to origin, finds the open same-repo PR for the branch and reports baseConflict / baseConflictCheckError (never fails the push). Non-ff rejection now points at git_rebase instead of "needs a human".
  • forgejo_create_pr: appends a WARNING + baseConflictFiles when the new PR conflicts; check failures are appended as a note.
  • forgejo_read_pr: when Forgejo says mergeable: no, lists the conflicting files (via refs/pull/<n>/head).
  • Implementer and review-submitted seeds steer the agent to check and rebase.
  • Web: push and create-PR views show the conflict.

Verification: bun test apps/server/src/bridge/git-tools/ apps/server/src/forgejo/ (all pass, incl. new base-conflict.test.ts), bun run typecheck clean. The manual end-to-end check against this Forgejo instance (deliberately conflicting branch) was not run.

Closes: #63 - New `bridge/git-tools/base-conflict.ts`: `checkBaseConflict` (fetch + `git merge-tree --write-tree --name-only`, no worktree/index/HEAD changes) and `rebaseInstruction`. - `git_push`: after a successful push to `origin`, finds the open same-repo PR for the branch and reports `baseConflict` / `baseConflictCheckError` (never fails the push). Non-ff rejection now points at `git_rebase` instead of "needs a human". - `forgejo_create_pr`: appends a WARNING + `baseConflictFiles` when the new PR conflicts; check failures are appended as a note. - `forgejo_read_pr`: when Forgejo says `mergeable: no`, lists the conflicting files (via `refs/pull/<n>/head`). - Implementer and review-submitted seeds steer the agent to check and rebase. - Web: push and create-PR views show the conflict. Verification: `bun test apps/server/src/bridge/git-tools/ apps/server/src/forgejo/` (all pass, incl. new `base-conflict.test.ts`), `bun run typecheck` clean. The manual end-to-end check against this Forgejo instance (deliberately conflicting branch) was not run.
git_push, forgejo_create_pr and forgejo_read_pr now run a local
merge-tree check against a freshly fetched base and report conflicting
files with rebase instructions. Implementer and review-submitted seeds
tell the agent to check for and resolve conflicts by rebasing.

Co-Authored-By: Claude Opus 5.5 via omp-deck
lucas requested changes 2026-10-26 12:12:42 +01:00
Dismissed
@ -261,3 +266,3 @@
`Reviewer: @${reviewer} · Verdict: ${verdict}${found}`,
...catchUp,
"Task: read the whole review and its line comments with forgejo_list_pr_comments_and_reviews. Address the feedback: change the code, commit, push. Reply in every line-comment thread of this review with forgejo_create_pr_thread_comment, naming what changed and the commit sha, or why you did not change it. Post one forgejo_create_pr_comment only if the review body itself has feedback, answering it. If the verdict is approved and there is no feedback, do nothing: no comment, no push.",
`Task: read the whole review and its line comments with forgejo_list_pr_comments_and_reviews. Address the feedback: change the code, commit, push. Then check the PR is not in conflict with ${pr?.base?.ref ?? "its base"} (forgejo_read_pr lists conflicting files; git_push reports them); if it is, rebase onto origin/${pr?.base?.ref ?? "<base>"} with git_rebase and git_push force_after_rebase:true. Reply in every line-comment thread of this review with forgejo_create_pr_thread_comment, naming what changed and the commit sha, or why you did not change it. Post one forgejo_create_pr_comment only if the review body itself has feedback, answering it. If the verdict is approved and there is no feedback, post no comment; push only if you had to resolve conflicts with the base.`,
Owner

git_push reports them

So the agent is supposed to run git_push just to check of there are conflicts? The entire idea is to fix conflicts before they create any lasting effect, like needing to force-push. So the idea would be to ensure there are no conflicts before pushing.

> git_push reports them So the agent is supposed to run `git_push` just to check of there are conflicts? The entire idea is to fix conflicts before they create any lasting effect, like needing to force-push. So the idea would be to ensure there are no conflicts _before_ pushing.
Author
Collaborator

Agreed. Fixed in afc4b3a: both prompts now tell the agent to git_fetch and then git_rebase action:"start" onto:"origin/<base>" before every push. Conflicts get resolved locally, and a force-push is only needed when the rebase rewrites commits that were already pushed. The git_push / forgejo_create_pr reports stay as a safety net, and the prompts now describe them that way. For an approved review with no feedback, the agent checks forgejo_read_pr and pushes only if it had to resolve conflicts with the base.

Agreed. Fixed in afc4b3a: both prompts now tell the agent to `git_fetch` and then `git_rebase action:"start" onto:"origin/<base>"` **before every push**. Conflicts get resolved locally, and a force-push is only needed when the rebase rewrites commits that were already pushed. The `git_push` / `forgejo_create_pr` reports stay as a safety net, and the prompts now describe them that way. For an approved review with no feedback, the agent checks `forgejo_read_pr` and pushes only if it had to resolve conflicts with the base.
Conflicts should be resolved locally before they reach the remote, not
detected by a push that then needs a force-push. The push and create-PR
reports remain as a safety net.

Co-Authored-By: Claude Opus 5.5 via omp-deck
lucas approved these changes 2026-10-26 12:14:52 +01:00
lucas merged commit 5565e1efda into main 2026-10-26 12:14:58 +01:00
lucas deleted branch agent/issue-63-base-conflicts 2026-10-26 12:14:58 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
lucas/omp-deck!67
No description provided.