On merge-to-main, rebase other open PRs that just lost mergeability #40
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#40
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As a maintainer, when one PR merges to
mainand breaks the mergeability of other open PRs targeting the same base, I want the webhook to dispatch the other PRs' authors to rebase automatically, so that a merge conflict on PR B doesn't leave B silently stalled with no agent touching it.Context
Forgejo fires no webhook event for "PR mergeability changed". So today:
mergeable: true.mainadvances.main—mergeableflips tofalse.synchronize, nostatus, noaction_run_*event for B. B's approval still stands, its head SHA is unchanged, CI is unchanged. The only way forward is a human closing the loop manually.If boss later attempts to merge B (e.g. from a lingering
pull_request_approveddispatch), the patchedmerge_pull_requestwill surface the conflict as an error and boss'smerge.mdskill tells it to "post a comment asking the author to rebase, exit" — but nothing then dispatches the author. B stays open with a comment no one reacts to.Acceptance criteria
New post-merge handler
pull_requestcase, whenaction=closedandmerged=true, call a new handlerhandlePostMergeRebase(repo, mergedPr)(name TBD; can live inwebhook-ci.tsafter #34 lands).base.refas the merged PR, excluding the just-merged one.mergeable.mergeable === falseand the PR author is a configured agent (has a token inconfig.agents), dispatch the author with the existingrebaseskill (same codepath asdispatchRebaseIfNotMergeable).mergeable === trueor the PR is not authored by an agent: skip silently.(repo, pr.number, pr.head.sha)tuple recently (e.g. within 10 minutes), skip. Reuse theBoundedMapfrom #35 if it's landed.Existing flow composes cleanly
pull_request action=synchronize(d)handler fires (new head SHA) → no-workflows fast path or CI fallback → reviewer re-requested.requestReviewIfFreshcomparescommit_id === sha— so the reviewer is re-asked on the new SHA and can re-approve.Logging
[webhook] post-merge: <repo>#<n> still mergeable, skippingor[webhook] post-merge: <repo>#<n> lost mergeability, dispatching rebase to <author>.Tests
handlePostMergeRebase:mergeable: trueand onemergeable: false→ exactly one rebase dispatch, to the second PR's author.mergeable: falsePR but author is not inconfig.agents→ no dispatch, log only.Out of scope
mergeable: truePRs (noise, no benefit — rebasing a mergeable PR just churns CI).develop). This issue only handles PRs that share the merged PR'sbase.ref.merge.mdto skip the "post comment, exit" behavior. The comment + exit stays; this new handler makes the comment informational rather than load-bearing.References
handlePullRequestClosed,handlePullRequestOpened,dispatchRebaseIfNotMergeable.Dependencies
#34(cleaner seams for the new handler),#35(BoundedMap for dedup).main(or whichever branch#34merges to if it lands first).