You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3e272a3
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(github): Fix merge conflicts only on pull requests people work on (#3383)
Each `pull_request.merge_conflict` event starts a full agent turn. Today
every push to the default branch checks every open Junior PR, and each
fix pushes a new head SHA, so the next push to main can fire the event
again. On busy repos, abandoned PRs got fixed over and over until their
14-day Watch expired.
The plugin now decides whether to publish the event. For PRs Junior
opened:
- **Drafts** never get the event. This applies to every PR, including
ones Junior didn't open.
- **Active PRs** (a person pushed, reviewed, or commented in the last 2
days, or the PR opened in that time) still get it, but at most once a
day and 3 times in total.
- **Approved PRs** would be ready to merge except for the conflict, so
they get the fix right away: no 2-day window and no daily wait, only the
3-fix limit. The "ready to merge" notice already requires a `clean`
merge state, so it doesn't show until after the fix.
- **Idle PRs, or PRs past the cap**, get no event and no agent turn.
Instead, the plugin adds a review desk notice to the conversation that
asked for the PR. The notice closes when the conflict is gone or the PR
closes.
- **PRs with 3 idle days that aren't approved** get nothing.
PRs that Junior didn't open (ones a person watches with `watchEvents`)
keep the current behavior, except drafts.
There is no new state. For each conflicted Junior PR, the plugin reads
its history from GitHub with one GraphQL query
(`PULL_REQUEST_CONFLICT_HISTORY`):
- `reviewDecision` gives approval on both the webhook path and the
heartbeat path.
- Commits, reviews, comments, and force pushes by a `User` count as
activity. The PR's `createdAt` counts too.
- Merge commits and force pushes by a bot count as earlier fixes. The
latest one sets the daily wait.
- The event key already names the head commit, so a recheck of the same
commit, or a webhook and the heartbeat at the same time, deliver one
fix.
- An open notice with the same dedupe key only gets new content, so
repeat checks add no second notice.
Other changes:
- Plugin heartbeats now get `reviewItems`, like plugin routes. That is
how the heartbeat conflict check adds and closes the notice without an
agent turn.
- The heartbeat GraphQL search now also reads `isDraft` and `title`.
- `merge-conflicts.test.ts` went over the 1,000-line limit. The daily
reconcile tests moved to `pull-request-reconcile.test.ts`, and the
shared webhook and heartbeat harness moved to `tests/plugin-harness.ts`.
Open tradeoffs:
- A dismissed notice can come back on a later check while the conflict
stays and the PR is still in the notice window. Without state, the
plugin can't see the dismissal.
- Force pushes by Junior for other reasons, such as a restack, also
count as fixes, so the cap can come early on stacked PRs.
- History reads the last 100 timeline items, so older activity or fixes
on a very long PR are not counted.
- Junior marks its own draft ready when checks pass, but a conflicted PR
gets no new checks. A draft that gets a conflict after Junior's last
push stays a draft until a person acts.
- `reviewDecision` is null when a repo doesn't require reviews, so on
those repos an approval doesn't change anything.
- A PR that is only `behind` its base, with no conflict, still gets
neither a fix nor the ready notice.
<!-- junior-request-attribution:start -->
via @BYK, @dcramer.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0CHB3YHES2%3A1794587008.216409 -->
--
[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0CHB3YHES2%3A1794587008.216409)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0CHB3YHES2%3A1794587008.216409/?project=4510944073809921)
<!-- junior-session-footer:end -->
---------
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Burak Yigit Kaya <[email protected]>
Co-authored-by: David Cramer <[email protected]>
Copy file name to clipboardExpand all lines: packages/junior-github/skills/github-code/SPEC.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Guide evidence-first GitHub repository work from inspection through a reviewable
11
11
- Treat shallow clones as inspection checkouts; deepen before history work; never force-push around missing ancestry.
12
12
- Install dependencies with the lockfile frozen mode before verification when needed.
13
13
- Finish every code change with a pushed PR, without asking, unless the user opts out or asked for investigation only. Open it as a draft unless the requester asks for a ready PR: opening a PR ready asks its code owners at once, and only the draft Watch checks the changed files against CODEOWNERS. An open scope question goes in the PR body, not in a stop. The Watch of a draft marks it ready when its required checks pass and no decision is open, so open decisions of a draft go in its PR body. A draft whose changed files have CODEOWNERS owners, or whose repo's root AGENTS.md asks for draft PRs or for a person to mark them ready, stays a draft unless the requester said to mark it ready, and Junior tells the requester that it waits for their review.
14
-
- After each push to a branch with an open PR, check mergeability. Resolve conflicts without asking, by merging the PR base branch (usually the default branch). Never rebase for this, except in a stack: a stack merges only with a linear history, so stacked PRs restack with `gh stack`. GitHub sends no event for a new conflict, and conflicted PRs get no new checks. The plugin publishes `pull_request.merge_conflict` for a watched PR only when another webhook event arrives for it, so the post-push check stays.
14
+
- After each push to a branch with an open PR, check mergeability. Resolve conflicts without asking, by merging the PR base branch (usually the default branch). Never rebase for this, except in a stack: a stack merges only with a linear history, so stacked PRs restack with `gh stack`. GitHub sends no event for a new conflict, and conflicted PRs get no new checks. The plugin publishes `pull_request.merge_conflict` for a watched PR only when another webhook event arrives for it, and for a Junior PR only while people work on it and never for a draft, so the post-push check stays.
15
15
- Write conventional PR titles and short plain-English bodies; keep check results out of the PR body.
16
16
- Report exact validation and permission failures.
17
17
- For 5xx, timeout, and connection failures, and for stalled or unexplained check failures, check GitHub status with `github_getStatus` (or the incidents on a `pull_request.checks.failed` event) before diagnosing. Report a matching incident as the likely cause; with no match, do not blame an outage.
0 commit comments