Skip to content

Commit e7dd218

Browse files
fix(automations): teach PR Shepherd to resolve additive merge conflicts
Previously, the shepherd aborted on any rebase conflict and immediately labeled the PR needs-human. Most conflicts in this repo are additive (both sides added non-overlapping lines at the same insertion point). Now the shepherd attempts to resolve conflicts file-by-file, validates with lint/typecheck/test, and only escalates to needs-human when facing genuine semantic conflicts or failing checks. Co-authored-by: Ona <no-reply@ona.com>
1 parent 77e3ce4 commit e7dd218

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

.ona/automations/pr-shepherd.yaml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,37 @@ action:
8181
git checkout <branch>
8282
git rebase origin/main
8383
```
84-
b. If the rebase succeeds cleanly:
84+
b. If the rebase succeeds cleanly (no conflicts):
8585
- Run `pnpm lint && pnpm typecheck && pnpm test` to verify nothing broke.
8686
- If checks pass: `git push --force-with-lease` and leave a comment:
8787
> [shepherd:conflict] Merge conflict resolved via rebase on main.
8888
- If checks fail: `git rebase --abort`, leave a comment:
8989
> [shepherd:conflict] Rebased on main but checks fail. Needs human attention.
9090
Add label `needs-human`.
91-
c. If the rebase has conflicts:
92-
- `git rebase --abort`
93-
- Leave a comment:
94-
> [shepherd:conflict] This PR has merge conflicts that require manual resolution. Conflicting files: <list files from rebase output>
95-
- Add label `needs-human`.
91+
c. If the rebase has conflicts, ATTEMPT TO RESOLVE THEM before giving up:
92+
- List conflicting files: `git diff --name-only --diff-filter=U`
93+
- For each conflicting file, read the conflict markers and determine if the
94+
resolution is obvious:
95+
- **Additive conflicts** (both sides added new lines at the same insertion
96+
point, but the content doesn't overlap): keep both additions. This is the
97+
most common conflict type in this repo — e.g., both sides added new entries
98+
to a list, new imports, new plugin registrations, or new lines in a doc.
99+
- **Non-overlapping edits** (each side changed different parts of the same
100+
hunk): keep both changes.
101+
- **Genuine semantic conflicts** (both sides modified the same lines with
102+
incompatible intent): do NOT attempt to resolve. Abort.
103+
- Edit each conflicting file to remove conflict markers with the correct
104+
resolution. Then `git add <file>`.
105+
- After resolving all files, continue the rebase:
106+
`GIT_EDITOR=true git rebase --continue`
107+
- If additional commits also conflict, repeat the resolution process.
108+
- After the rebase completes, run `pnpm lint && pnpm typecheck && pnpm test`.
109+
- If all checks pass: `git push --force-with-lease` and leave a comment:
110+
> [shepherd:conflict] Merge conflicts resolved and rebased on main.
111+
- If checks fail OR you could not resolve a conflict (genuine semantic
112+
conflict): `git rebase --abort`, leave a comment:
113+
> [shepherd:conflict] This PR has merge conflicts that require manual resolution. Conflicting files: <list files>
114+
Add label `needs-human`.
96115
3. If a `[shepherd:conflict]` comment already exists, skip — already handled.
97116
98117
### Needs review
@@ -153,5 +172,6 @@ action:
153172
- Act on PRs updated in the last 15 minutes — give other automations time.
154173
- Create duplicate shepherd comments — always check for existing comments first.
155174
- Re-trigger more than once per PR per run.
156-
- Attempt to resolve semantic merge conflicts (overlapping changes in the same lines).
175+
- Attempt to resolve genuine semantic conflicts (both sides changed the same lines
176+
with incompatible intent). Additive and non-overlapping conflicts ARE safe to resolve.
157177
- Rebase a PR more than once — if a [shepherd:conflict] comment exists, skip it.

0 commit comments

Comments
 (0)