Skip to content

The merge gate brings the base in itself and names the approval it waits on - #783

Merged
nambok merged 1 commit into
mainfrom
fm/coderhelm-merge-gate-keeps-current
Nov 19, 2026
Merged

nambok merged 1 commit into
mainfrom
fm/coderhelm-merge-gate-keeps-current

Conversation

@nambok

@nambok nambok commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A person approved someone's PR and the auto-merge gate armed. Three seconds later it found the PR conflicting with main and stopped (updating:false): the gate only brought the base in on CoderHelm's own PRs with a run. After a person pushed the conflict resolution and CoderHelm approved the new head, the gate stopped again "waiting on approvals": it counted only approvals of the head commit, though GitHub still counted the person's approval of the earlier one. It waited on a review event that never came and told nobody. The person had to dismiss their approval and approve again.

Root causes (on main):

  • services/worker/src/passes/await_merge.rs:1540: let updating = msg.self_authored && .... A person's PR never got the base merge; the gate stopped.
  • services/worker/src/passes/await_merge.rs:313: v.approvals.human_key_at_head(). Only approvals of the exact head counted, ignoring GitHub's own required-review rule.
  • services/worker/src/passes/await_merge.rs:1301-1310: WaitForPeople returned Next::Stop. Only a webhook could wake it, and the status comment was posted only on labelled PRs.

Changes

  • The gate keeps the branch current on anyone's PR (needs_base, keep_current, bring_base_in). When GitHub reports the PR dirty or behind, the gate merges the base in as soon as it is armed. This happens before approvals are read, so where the rules dismiss approvals on push, the update lands before a person approves. It also runs when GitHub declines the merge for that reason. It runs once per head (claim_base_update) and uses the runs' conflict resolution (pr::resolve_conflicts). It compares the PR's own change before and after with the reviewer's comparison (review_scope::same_own_change), records the base merge, and queues CoderHelm's review of the new head itself, whether or not the PR carries the review label (review_pr::review_after_base_merge). That is a push's review keyed head#<sha> like the gateway's, so a labelled PR is reviewed once, and it takes the carry-forward path from A carried approval carries the review it rests on, and that review stays in sight #781: when the PR's own change is the one approved, the earlier approval is carried with the review it rests on. The gate never waits on a review it caused. It then arms itself on the new head. There the review carries the approval or reviews what moved, CI runs, and the keys are read again. On CoderHelm's own PR with a run, the run's conflict round still does it. Only a conflict it can't resolve, or a fork it can't push to, is reported, once, with the files, on the PR and in the team's channel.
  • The person key follows GitHub (person_key). It reads the PR's reviewDecision: APPROVED keeps a person's approval of an earlier commit, and REVIEW_REQUIRED or CHANGES_REQUESTED is never outvoted. When the branch has no required-review rule, an approval of an earlier commit counts when the PR's own change is unchanged since it.
  • A wait on a person names what is missing (missing_person_line). It names a dismissed approval and the commit that dismissed it (including CoderHelm's own base merge). It also names the branch's required count, read from classic protection and rulesets (review_rules), with a note that CoderHelm's approval doesn't count toward it, plus an approval of an earlier commit and who was asked. That line is the record's detail on the run page, goes in the PR's one status comment (edited in place, now also on unlabelled PRs when a person's approval is involved), and goes once per commit to the team's channel (tell_team).
  • Waiting on people re-reads on a timer (recheck_people): every 15 minutes for a day, bound to the chain. A missed webhook can't strand the PR, and the CI window restarts when the keys are in.
  • GitHubClient::branch_protection and pr_review_decision (a GraphQL read). Approvals gains approved_on and dismissed.
  • Incident mx_gate_keeps_the_branch_current (doc and replay test).

Verification

…its on

A person's PR armed the gate, conflicted with main, and the gate stopped:
the base merge only ran for CoderHelm's own PRs. After a person pushed the
resolution, the gate counted only approvals of the head and waited on a
review event that never came, saying nothing.

- A PR behind or conflicting with its base gets the base merged in by the
  gate as soon as it is armed, on anyone's PR, once per head, through the
  runs' conflict resolution; the own-change comparison the reviewer uses
  decides whether the approval carries. The gate queues CoderHelm's
  review of the new head itself, labelled PR or not (a push's review, so
  the earlier approval carries with its review), and arms on the new head.
  Only an unresolvable conflict or a fork is reported, once, with the files.
- The person key follows GitHub's reviewDecision; with no rule, an earlier
  approval counts when the PR's own change is unchanged since.
- A wait on a person names what is missing (a dismissed approval and the
  commit that dismissed it, the required count, who was asked) on the run
  page, the status comment and once in the team's channel.
- Waiting on people re-reads every 15 minutes for a day.
@nambok
nambok force-pushed the fm/coderhelm-merge-gate-keeps-current branch from 70d3150 to 53dbdde Compare November 18, 2026 23:00
@nambok
nambok merged commit d44c7de into main Nov 19, 2026
10 checks passed
@nambok
nambok deleted the fm/coderhelm-merge-gate-keeps-current branch November 19, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant