Repository navigation
✨ feature: enqueue eligible PRs into GitHub native merge queues - #15308
Conversation
|
Docs map: this PR adds page(s) under
A page missing from the map is one readers do not find. Please add a If the page is indexed from a subdirectory README, or is deliberately |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Conclusion: the enqueue/dequeue mechanics look right and keep the existing gates; one cost path on paused repositories is unbounded and I think needs a memo before this lands.
What I verified (read automerge_native_queue.go, native_merge_queue.go, the sweep wiring):
tryNativeQueue(automerge_native_queue.go:33-105) runs only after the lane'smergeClaimis built, pinsexpectedHeadOidto the evaluated head (:44-46,:86), re-keys the claim perREMOVED_FROM_MERGE_QUEUE_EVENTso a removal gets a fresh attempt (:66-71), and preserves the mixed-authorship merge-commit gate by reading the branch's queue method (:49-64). Good.reconcileNativeQueueGate(:109-161) nil-guardspr, so thedeferintrySweepQueuedPRis safe on early returns, and the dequeue closure re-reads provenance immediately before the write (:141-148) so a human's re-enqueue is never withdrawn. Good.NativeMergeQueueAvailable(native_merge_queue.go:28) requires App auth, which matches themerge_grouptrigger constraint the comment cites.
Finding (medium) — per-sweep API fan-out on paused/disallowed repos:
SweepQueuedAutoMerges calls reconcileInactiveNativeQueues unconditionally at automerge_sweep.go:893. For every repo that is paused or has automerge disallowed (automerge_native_queue.go:172-174) it pages GET /pulls?state=open (:177-181) and then, per open PR, reconcileNativeQueueGate with lane "inactive" reaches ReadNativeMergeQueue (:126) — one GraphQL query per PR. None of the early returns at :111-124 fire for "inactive" + "repo-paused-or-disabled". Nothing is cached between sweeps and nothing checks isMergeQueueEnabled once per repo first.
Consequence: a paused repo with 200 open PRs costs ~2 REST pages + 200 GraphQL points on every queued sweep, for as long as it stays paused — the exact state an operator chooses to stop traffic. TestNativeQueuePauseWithdrawsOwnEntry covers the behaviour but not the repeat cost.
Suggestions (either is enough): remember per repo that no App-owned entry was found and skip until the repo's pause/allow state changes; or query repository.mergeQueue(branch) once per repo and skip repos where the queue is not enabled before listing PRs.
Not a correctness bug in what it does, but it ships a standing API bill on every hive with a paused repo, so I'd fix it before merge.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Docs-currency review (read at head e8a41cf).
-
Stage-reason table not updated for the new reasons —
src/docs/labels-and-control-signals.md:487is the operator-facing reason → stage table.src/pkg/stageengine/derive_pr_classify.go:453now routes everynative-merge-queue*reason (native-merge-queued: queued (position N, STATE)and the failure reasonsnative-merge-queue-read/-enqueue/-method,src/pkg/github/automerge/automerge_native_queue.go:45,50,62,67,70,103) to100-merge-queue, but the table still lists onlymerge-queue-requiredand describes the sweeps as skipping the direct merge on a queue-only base "the same way". With App installation auth (src/pkg/github/native_merge_queue.go:28) that row is now wrong: queue-enabled bases are enqueued, andmerge-queue-requiredremains only on static-token transports. Please add thenative-merge-queue*reasons to the100-merge-queuerow (note that the enqueue failure reasons also land there) and qualify themerge-queue-requiredtext. -
New page not linked from the docs map —
src/docs/native-merge-queue.mdis a new top-level page, butsrc/docs/documentation-map.mdhas no entry (thehive-mergeentry at :76 is the natural neighbour)..github/workflows/docs-index-reminder.yml:68-116will flag this on the PR; adding the line now avoids the round-trip.
The claims in src/docs/native-merge-queue.md (App-only transport, expectedHeadOid pinning, enqueuer-scoped dequeue, MERGE-method requirement for mixed authorship) match native_merge_queue.go:28,47-73,77 and automerge_native_queue.go:49-70,129-150.
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Style/conventions review (read at e8a41cf) — no blocker; two advisory consistency notes.
-
Shared reason strings bypass
prstage.src/pkg/stageengine/prstage/reasons.go:14documents that lane reasons shared by producers and the stage classifier live there (cf.AutoMergeReasonReviewGatePrefix,AutoMergeReasonMergeQueueRequired). This PR instead definesnativeQueueReason = "native-merge-queued"locally (src/pkg/github/automerge/automerge_native_queue.go:15), emits"native-merge-queue-read"/"-enqueue"/"-method"as inline literals (lines 45, 60/65/68, 96), and the classifier matches the literal prefix"native-merge-queue"(src/pkg/stageengine/derive_pr_classify.go:453). The match works only becausenative-merge-queuehappens to be a prefix ofnative-merge-queued; a rename on either side silently drops PRs out ofstage/100-merge-queue. Suggest aprstage.AutoMergeReasonNativeQueuePrefix(+ the queued constant) aliased from both packages, as the existing reasons are. -
Transport capability split across a named and an anonymous interface.
nativeQueueTransport(automerge_native_queue.go:21-26) declares four methods, butNativeMergeQueueMethodis asserted via an inline anonymous interface atautomerge_native_queue.go:55-57, even though both the real client (src/pkg/github/native_merge_queue.go:77) and the test fake (automerge_native_queue_test.go:245) implement it. Folding it intonativeQueueTransportremoves the second type assertion and the unreachable "cannot be verified" branch. Similarly,"queued"/"inactive"are ad-hoc lane strings (automerge_native_queue.go:121,192;automerge_sweep.go:936,2509) alongside thestageLane*constants.
— hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Security review (head e8a41cf7)
1. Hive can never recognise — and therefore never withdraw — its own queue entries (high, in-scope).
src/pkg/github/automerge/automerge_native_queue.go:140-141 gates dequeue on strings.EqualFold(state.MergeQueueEntry.Enqueuer.Login, login) where login = c.transport.AppBotLogin(). AppBotLogin is the REST form "<app-slug>[bot]" (src/pkg/github/client.go:162, app.go:479), but enqueuer { login } comes from GraphQL (src/pkg/github/native_merge_queue.go:33-36), where a Bot actor's login has no [bot] suffix. Verified live against this App: REST pulls/15308 → hivecommons-hive[bot]; GraphQL author { __typename login } → {"Bot","hivecommons-hive"}. The comparison is always false, so the pre-write recheck at :157 also never passes.
Consequence: every withdrawal path in the contract (#15198 "Leave the queue when the gate breaks") is dead — hold, withdrawn approval, changes-requested, stale lgtm, paused/disabled repo (reconcileInactiveNativeQueues). Once Hive enqueues, GitHub merges regardless of a later gate break; the gate becomes one-way. The changelog and src/docs/native-merge-queue.md:23-27 claim this works. Tests can't catch it because fixtures set the same testHiveAppBotLogin string on both sides (automerge_native_queue_test.go:34,45).
Fix: compare normalised slugs (strings.TrimSuffix(x, "[bot]") on both sides, or query enqueuer { __typename login } and match Bot+slug), and change the fixture so Enqueuer.Login is the GraphQL form (hive-app) while AppBotLogin() returns hive-app[bot].
Otherwise: enqueue/dequeue both route through effects.ExecuteReconciling with c.mutation (:88,:151), expectedHeadOid is pinned to the validated head (:50,:91), static tokens are excluded (native_merge_queue.go:28), no new App permissions.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
Guard reconcileNativeQueueGate with the shared native-merge-queue prefix so read/enqueue/method error reasons do not dequeue Hive's own entry. Hive-Fix-Attempt: 3/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
… routing Hive-Fix-Attempt: 4/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
#15380) * fix: park mixed-authorship PRs on a SQUASH native queue at stage/085 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> * 🐛 fix: report queue method read failures as native-merge-queue-read A transient failure reading the native queue's merge method was reported as native-merge-queue-method, which the stage engine derives to stage/085-needs-decision with the merge-method explanation. Return the read reason instead so the PR stays at stage/100-merge-queue, and state that in the docs. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Queued lane: a blocked/behind PR on a queue-enabled base is enqueued instead of stopping at not-mergeable (and withdrawing its own entry). - Self, trusted and contributor lanes skip the behind update and the default-on current-base gate on a queue-enabled base; the merge group tests the merged result and a new head would drop the queue entry. - Withdraw the App's own entry only on an allowlist of eligibility-loss reasons (holds, approval loss, changes requested, paused/disabled, draft/closed); transient reasons keep the entry. - Match the own entry by enqueuer __typename Bot as well as slug. - Fold the 085 method-refusal note into the added- changelog fragment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
… the current-base gate explicit, cache the queue probe Addresses the three standing review findings on the native merge queue hand-off (hivecommons/hive issue 15198): - Opt-in, per repo: auto_merge.native_merge_queue.enabled (default off) plus a repos allow-list. The zero policy never probes, enqueues, withdraws or lists a paused repo's PRs, so hives without queues see no behaviour change. Settings-parity allowlist, config accessors, the runtime golden and docs are updated. - The require_current_base gate and the behind update-branch stay in force on queue bases; auto_merge.native_merge_queue.skip_current_base_gate (default false) is the explicit, documented bypass. - API cost: isMergeQueueEnabled is cached per owner/repo#base for auto_merge.native_merge_queue.probe_ttl (default 30m, failures not cached), and the per-held-PR reconcile, the queued-lane PullRequests.Get and the 10-minute paused-repo listing run only on opted-in repos. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
There was a problem hiding this comment.
Intent-alignment (delta re-review, head cb0e58fa9) — the opt-in policy, explicit gate and probe cache do what the body says; one new in-scope gap from the delta:
Default-on current-base gate now branch-updates a head Hive already has in the queue, dropping its own entry. The delta removed the queue bypass, so with skip_current_base_gate: false (the default) every lane runs the behind update (automerge_sweep.go:1912, :2412; automerge_contributor_lane.go:1383) and currentBaseGate (automerge_sweep.go:1990, :2466; automerge_contributor_lane.go:1457) before tryNativeQueue (automerge_sweep.go:2045, :2495; automerge_contributor_lane.go:1485), and neither checks IsInMergeQueue. currentBaseGate compares base..head and pushes update-branch on any behind_by > 0 (automerge_current_base.go:100-111). On an active queue every merged entry makes the remaining Hive-enqueued PRs behind, so the next sweep pushes a new head to each — which, as native-merge-queue.md itself says, drops the PR from the queue — then re-enqueues after CI. Net effect on the #15198 use case: the queue never batches and each PR re-runs full CI per upstream merge, which is the "strict up-to-date" cost the issue lists as the alternative it rejects. TestNativeQueueCurrentBaseGateIsExplicit only fixtures IsInMergeQueue: false, so the case is untested.
Concrete fix compatible with keeping the gate explicit: skip the behind update and currentBaseGate when the PR's own queue entry already exists (read IsInMergeQueue + ownNativeQueueEntry via the cached probe path), and add a table row for behind + already-queued. Advisory, no action needed: per #15198 "branches with a queue go from skip to enqueue" with no config; the delta makes it opt-in (default off) per the standing review findings — fine as a config-shape call, but the issue reporter's hive will need auto_merge.native_merge_queue.enabled: true to see any change.
— hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (correctness, delta c224c14 → cb0e58f) — no blocking findings; one advisory.
- Low / advisory — entries orphaned when the policy is switched off.
reconcileInactiveNativeQueuesreturns before any listing when!c.nativeQueuePolicy().Enabled(src/pkg/github/automerge/automerge_native_queue.go:357) and skips repos no longer in.repos(:370-372);reconcileNativeQueueGatelikewise returns early viac.nativeQueue(owner+"/"+repo) == nil(:302-304). So if an operator setsenabled: false(or drops a repo from the allow-list) while the App still has entries queued, a subsequent hold / withdrawn approval never dequeues them and GitHub merges them on its own. Docs (src/docs/native-merge-queue.md:57-58) only cover paused/automerge-disabled repos, not the policy flip. Acceptable for a default-off feature, but worth a sentence in the doc or a one-pass drain on flip.
Verified: zero policy → nativeQueue()/nativeQueueEnabled() return nil/false so every lane keeps pre-queue behaviour (:234-240, :165-168); nativeQueueSkipsCurrentBase requires both the flag and a queue (:187-189); probe failures are not cached (:178-181); cache map guarded by nativeQueueProbeMu (:108-125). Tests cover opt-in, per-repo allow-list, explicit gate, probe TTL and inactive-reconcile skipping (automerge_native_queue_test.go:459-640). CI was still pending on the merge head when read; go test is blocked on this host, so test execution was not confirmed here.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (security) — no blocking findings at 61114ba8 (head moved from b73c66f0 by a v5 merge touching no PR files; the PR's own delta since the prior review is cb0e58fa9).
Checked: tryNativeQueue runs only after each lane's existing gates and pins the evaluated head via expectedHeadOid (automerge_native_queue.go:258-262, native_merge_queue.go:58-64); dequeue is limited to the App's own Bot-typed entry and re-verified immediately before the write (automerge_native_queue.go:143-145, 330-337); all GraphQL goes through bound variables; the feature is default-off and allow-listed per repo (config.go NativeMergeQueueAutoMergeConfig, main_sweeps.go:853-856).
Low advisory, only when skip_current_base_gate: true: a positive probe is reused for probe_ttl (automerge_native_queue.go:118-126). If a base's queue is removed inside that window, nativeQueueSkipsCurrentBase still skips the current-base gate / behind update (automerge_sweep.go self/trusted lanes), then tryNativeQueue re-reads, finds no queue, returns "" and the lane falls through to a direct merge without the gate. Branch protection still applies, so impact is bounded; consider only trusting a cached positive after tryNativeQueue confirms it, or shortening the TTL for the skip path.
— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (correctness, delta since c224c14 → b73c66f) — the only substantive delta is cb0e58f (per-repo opt-in, explicit skip_current_base_gate, cached queue probe); the rest is v5 merge noise. No blocker. One advisory:
- Stale positive probe can skip the current-base gate for a direct merge (low).
nativeQueueSkipsCurrentBase(src/pkg/github/automerge/automerge_native_queue.go:186-188) trusts a cachedenabled=truefor up toprobe_ttl(30m). If the queue was removed from the base in that window,trySweepSelfAuthoredPRskips the behind update-branch andcurrentBaseGate(automerge_sweep.go:1912-1913,1990), thentryNativeQueuereads live, sees!IsMergeQueueEnabled && !IsInMergeQueueand returns"", nil(automerge_native_queue.go:235-238), so the lane falls through to a direct merge of a behind head withrequire_current_baseon. Bounded to one tick per base per queue removal and only when the operator setskip_current_base_gate; the cache self-corrects viarecordNativeQueueProbeat:234. A cheap fix is to havenativeQueueSkipsCurrentBasebypass the positive cache (or only cache negatives). Same pattern inautomerge_sweep.go:2411andautomerge_contributor_lane.go:1382.
Full test matrix passed at b73c66f (test (agent|hub|rest|dashboard|scheduler) * all success); TestNativeQueueIsOptInPerRepo, TestNativeQueueCurrentBaseGateIsExplicit, TestNativeQueueProbeIsCachedPerBase, TestInactiveQueueReconcileSkipsUnlistedRepos cover the delta. Note the PR now defaults OFF whereas #15198 described queued branches going straight from skip → enqueue; the opt-in was requested by prior review and is documented in src/docs/native-merge-queue.md, so judged acceptable.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Supersedes #15226 (adopted after CI went red and the contributor was unavailable; original commits by @thatguywob preserved).
Closes #15198
This branch starts from #15226's head
4412365d62c8as pushed by @thatguywob (forkthatguywob/hive); the original commit (now41fc37875after the rebase ontov5) and itsSigned-off-byare preserved. Follow-up commits on top (hashes are pre-rebase):bce4d0999throttle native merge queue reconciliation on paused reposd2601f0b4match the native queue enqueuer by bot slug and share queue reasons986591112keep the own native queue entry on queue error reasons8a4a2afe1docs: list real withdrawal triggers and method-failure routingba4544287park mixed-authorship PRs on aSQUASHnative queue atstage/085(🐛 fix: park mixed-authorship PRs on a SQUASH native queue at stage/085 #15380)e46ab67fcaddress the adjudicator review findings atba45442:blocked/behindPR on a queue-enabled base is enqueued instead of stopping atnot-mergeable(which also withdrew Hive's own entry).behindupdate-branch and the default-onrequire_current_basegate on a queue-enabled base; the merge group tests the merged result, and a pushed head would drop the PR from the queue. Documented insrc/docs/native-merge-queue.md.behind,not-mergeable, pending checks, moved head, API errors) keep the entry.__typename == "Bot"as well as login slug.changelog.d/added-native-merge-queue.md, and thefixed-native-queue-method-refusal.mdfragment is deleted.Table tests in
automerge_native_queue_test.gocover each behavior change.Taken over by hand
Taken over by @clubanderson's operator at his request after the hive's fixer exhausted its attempts. The branch was rebased onto
v5(the 15 automatedMerge branch 'v5'commits are gone; @thatguywob's commit and the hive's fix commits are preserved with their authorship) and one new commit,cb0e58fa9, addresses the three standing review findings:auto_merge.native_merge_queue.enabled(default off) andauto_merge.native_merge_queue.repos: [](owner/repoallow-list; empty = every watched repo once enabled).config.NativeMergeQueueAutoMergeConfigwithEnabledFor/RepoSet/EffectiveProbeTTLaccessors follows theTrustedAuthorAutoMergeConfigpattern;cmd/hive/main_sweeps.gowires it intoautomerge.Options.NativeMergeQueue. With the zero policy no lane probes, enqueues, withdraws an entry or lists a paused repo's PRs, so hives without queues see zero behaviour change (merge-queue-requiredstill parks). The settings-parity allowlist, the agent-runtime config golden andsrc/docs/native-merge-queue.md+operator-reference.mdare updated. Tests:TestNativeQueueIsOptInPerRepo,TestInactiveQueueReconcileSkipsUnlistedRepos,TestNativeMergeQueueAutoMergeConfigIsOptInPerRepo,…ParsesYAML.require_current_basestays in force on queue bases. The silent&& !queueEnabled()bypass of the current-base gate and thebehindupdate-branch in the self, trusted and contributor lanes is gone. Both gates run on a queue base exactly as on any other base unless the operator sets the new, documentedauto_merge.native_merge_queue.skip_current_base_gate: true(default false). Test:TestNativeQueueCurrentBaseGateIsExplicit(replacesTestNativeQueueSkipsCurrentBaseUpdate).isMergeQueueEnabledis cached perowner/repo#baseforauto_merge.native_merge_queue.probe_ttl(default 30m; read failures are not cached;tryNativeQueuerefreshes the cache from the read it already does). The per-held-PRreconcileNativeQueueGate, the extraPullRequests.Getin the queued prefilter and the 10-minute paused-repo PR listing all run only on opted-in repos. Test:TestNativeQueueProbeIsCachedPerBase.The changelog fragment
changelog.d/added-native-merge-queue.mdnow describes the opt-in, the explicit gate and the probe cache.