Repository navigation
π fix(automerge): do not merge the base into a PR on a merge-queue-only base - #15038
Conversation
β¦ly base With auto_merge.require_current_base on, the current-base gate updated a behind head with update-branch (`base-moved`) before the sweep learned that the base only accepts merges through GitHub's merge queue, which the hive cannot use. On projectbluefin/finpilot#599 that happened three times in a day: each update moved the head off its review verdict, the PR waited 16m-1h27m for a fresh review, and then held at merge-queue-required again. The 30-minute merge-queue memory had expired between refusals, so the gate went back to updating. The gate now leaves a behind head alone when its base refused a direct merge as merge-queue-only within the last 24 hours (MergeQueueBases.HoldBaseRefresh). Each such hold also keeps Required true for another 30 minutes, so the sweep holds the PR at merge-queue-required after the review gate instead of probing the base with a direct merge of a head that does not contain it. A hold never extends the refusal itself: the direct-merge probe still runs on a head that is current, a new refusal re-arms the 24 hours, and with none the gate updates again, so a removed queue rule is picked up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
@Danathar this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Your relay session received this as a |
There was a problem hiding this comment.
Read the diff plus automerge_sweep.go at 191650f. The mechanism holds together and looks correct to me; one low-severity observation on the chosen window.
What I verified
- Ordering is right for the hold to bite:
currentBaseGateruns atautomerge_sweep.go:1823and:2379, andknownMergeRefusalat:1889/:2407β soHoldBaseRefresh(automerge_merge_queue_bases.go, new) marksheld = nowbeforeRequiredis consulted, and the behind head lands atmerge-queue-requiredinstead of being re-probed with a stale head. That is the property the long comment onHoldBaseRefreshpromises, andTestSelfAuthoredLaneNoBaseRefreshOnMergeQueueBase/TestMergeQueueBasesHoldBaseRefreshpin it. Notenow doesentry := m.seen[key]; entry.refused = nowso a fresh 405 preserves an existingheld;Requireddeletes only onrefusedβ₯ 24h, andHoldBaseRefreshnever extendsrefusedβ so a base with no new refusal does return to updating aftermergeQueueBaseRefreshHold, as the comment says.- Rule-removed path (
TestSelfAuthoredLaneMergeQueueRuleRemoved): a current head on a base with no recentheldstill probes with a direct merge and merges.
Low β a behind head that is swept every tick keeps held fresh, so a current head on the same base is never probed for up to 24h. Required returns true when now - max(refused, held) < 30m (automerge_merge_queue_bases.go, Required), and every sweep of any behind PR on that base calls HoldBaseRefresh, which resets held = now. With one long-lived behind PR open, a current head on that base is held at merge-queue-required tick after tick, so a removed queue rule is noticed only when the 24h refused expiry fires β not within 30m as the mergeQueueBaseRefreshHold comment ("when no head on that base is current to probe it") implies. Not a defect against the finpilot#599 symptom you are fixing, and strictly better than the old 30m memory for that case; just noting the comment overstates how quickly a current head gets to probe. If you want current heads to keep probing, Required could ignore held when the head being evaluated is not behind β but that is a call for you, not a blocker.
Changelog fragment and both docs tables are updated to match.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
2db8805
into
hivecommons:v6
There was a problem hiding this comment.
Read the diff against v6 with automerge_sweep.go:1800-1850 (self-authored flow) and automerge_merge_refusal.go:118-124. Looks correct to me.
- The stale-head probe the doc comment worries about cannot happen: a behind head that
currentBaseGatelets through (automerge_current_base.go, newmergeQueueBaseHoldsRefreshbranch) has just setheld = now, so when the merge attempt reachesknownMergeRefusalβmergeQueueBaseKnownβRequired,last = heldandnow.Sub(last) < mergeQueueBaseRecheckis true βmerge-queue-required, no direct merge. A current head skips the hold branch (behindBy <= 0returns first), soheldis not refreshed by it and the probe resumes once no behind head has been held for 30m β matching the body. RequiredandHoldBaseRefreshboth drop the entry at 24h fromrefused, and a hold never writesrefused, so a removed queue rule is bounded bymergeQueueBaseRefreshHoldas stated.Notepreservesheldon re-refusal (reads the existing entry before writingrefused); fine.- No
time.Sleep(added underpkg/tests.
One operational note, not a defect: while any behind PR on a merge-queue base is swept every tick, held is pinned, so a current PR on the same base is also held at merge-queue-required and never probes; the 24h cap is then the only re-probe path. That is what the body describes, just worth knowing when reading a merge-queue-required hold on a PR that is up to date.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Summary
On 2026-10-28 the hive merged
maininto projectbluefin/finpilot#599 (a mergeraptor PR in the self-authored/trusted-bot lane) three times: at 09:15, 11:13 and 15:16Z. Each was an update-branch throughcurrentBaseGate, loggedreason=base-moved.The review verdict is keyed to the exact head, so after each update the PR dropped back to
review-gate:no-review-bundleand waited for a fresh review: 16m, 31m and 1h27m.Each time it reached stage 100, the sweep logged
automerge hold reason=merge-queue-required. finpilot'smainaccepts merges only through GitHub's merge queue, which the hive cannot enqueue into. So the PR could never merge directly, and each refresh only moved it off its review. A merge queue tests base plus PR itself, so a base refresh by the hive buys nothing there.The hive already remembers such bases (
MergeQueueBases, #14068), but:currentBaseGateruns before the merge attempt and did not consult it.mergeQueueBaseRecheck) and only a real 405 re-arms it, while a hold throughknownMergeRefusalnever did. The 11:13Z update came 1h41m after the 09:31Z refusal.The rules read is not an alternative signal. finpilot's
rules/branches/mainlists nomerge_queuerule, and GraphQLmergeQueue(branch: "main")is null, so the requirement presumably comes from classic branch protection, which the App cannot read. The remembered 405 is the signal the hive has.Change
MergeQueueBasestracks holds separately. Each entry now keeps two times:refused, the last 405, andheld, the last time the base gate skipped an update on that base.HoldBaseRefresh(repo, base, now). It is true for 24h after the last refusal (mergeQueueBaseRefreshHold) and marks the base held.Requiredis true within 30 minutes of either time and drops the entry after 24h.currentBaseGate(automerge_current_base.go) returns "proceed, no update" when the head is behind and the base holds refreshes. This check sits before the update-budget check, and all three lanes go through it. The sweep then holds the PR atmerge-queue-requiredafter the review gate, as it already does for a current head.auto_merge.require_current_base.mergeable_state == behindupdate paths.operator-reference.md(therequire_current_baserow) andlabels-and-control-signals.md(themerge-queue-requiredrow).changelog.d/fixed-no-base-sync-on-merge-queue-base.md.Testing
From
src/,TZ=UTC,-count=1:go test ./pkg/github/automerge/passes, as do theMergeQueue/MergeEligibtests in./cmd/hive/.gofmtandgo vetare clean.TestCurrentBaseGateMergeQueueBaseTestSelfAuthoredLaneNoBaseRefreshOnMergeQueueBaseTestSelfAuthoredLaneMergeQueueRuleRemovedTestMergeQueueBasesHoldBaseRefreshMutation checks
Seven mutants, each restored from a backup copy, and every one fails a test:
Requiredignoring holds;Not verified, or still open
behindpath) is a separate change.Contributor checklist
changelog.d/fixed-no-base-sync-on-merge-queue-base.md.v6.src/docs/operator-reference.md,src/docs/labels-and-control-signals.md).π€ Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1