Repository navigation
✨ feature: enqueue eligible PRs into GitHub native merge queues - #15226
thatguywob wants to merge 1 commit into
Conversation
Use the App installation transport to detect and enqueue native merge queues after the existing automerge gates, pinning the validated head. Reconcile Hive-owned queue entries when gates break and report queue position/state without recording enqueue as a completed merge. Co-authored-by: jeefy <1394552+jeefy@users.noreply.github.com> Hive-Run: hivecommons#15198 Hive-Plan: native-merge-queue Hive-Spec: issue-15198#proposed-solution Signed-off-by: thatguywob <thatguywob@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 |
|
@thatguywob is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply. |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the hive App may enqueue into GitHub native merge queues on its own behalf (a new merge path, #15198), and whether the own-entry withdrawal described below must be narrowed to non-transient reasons before it lands.
Read the new automerge_native_queue.go, the four lane insertion points in automerge_sweep.go / automerge_contributor_lane.go, and the gates that run before them on v5. The enqueue side is careful: expectedHeadOid pinning, enqueuer-provenance re-read immediately before any dequeue, no merged audit on enqueue, and the after_removal timeline cycle so the journal does not suppress a legitimate re-enqueue. CI is green.
One finding I could verify, with a dependency I could not — src/pkg/github/automerge/automerge_native_queue.go:107-160 (reconcileNativeQueueGate) and the hooks that call it:
- In
trySweepQueuedPRit is installed as adeferthat fires with whateverreasonOutthe function returns (automerge_sweep.gohunk at 2506); the self/trusted/contributor lanes call it from theirstage(...)closures on every non-empty reason. The only reasons it skips are thenative-merge-queuedprefix and four routing reasons (lines 112-115). Everything else —not-mergeable, soak, review gate,head-changed-since-eval, etc. — withdraws the App's own queue entry. - The
not-mergeablegate runs beforetryNativeQueuein the queued lane (automerge_sweep.go:2598-2600onv5), andmergeableFromStatemapsblocked→MergeableNo(src/pkg/github/client.go:1108). - So the question everything turns on: what does GitHub report as REST
mergeable_statefor a PR the App has just enqueued? If it isblockedwhile the entry awaits its merge group (GitHub's community discussion #73849 says it is; I could not confirm it against a live queue from here), the sweep after enqueue returnsnot-mergeable, the deferred gate seesEnqueuer.Login == AppBotLoginand dequeues it, the removal event opens a newafter_removalcycle, and the following sweep enqueues again — an enqueue/dequeue flap in which the PR never reaches the front of the queue. The PR body says "Already queued PRs are left alone"; the code does that only while every earlier gate keeps returning empty. - The new tests do not reach this path: every fixture with
IsInMergeQueue: true(automerge_native_queue_test.gohunk ~535) is paired with RESTmergeable_state: "clean"(test hunks 469, 498), so ablocked-while-queued PR is never exercised.
Suggested narrowing, if the owner wants this in: skip withdrawal when state.IsInMergeQueue && state.HeadRefOid == pr.GetHead().GetSHA() and the reason is not-mergeable (or, more simply, treat only an explicit allow-list of eligibility reasons — label removed, held, draft, closed, untrusted merger, self-merge ban, head changed — as grounds to dequeue), plus one test with mergeable_state: "blocked" and the App as enqueuer asserting zero dequeues.
Routing: this is a fork PR (comment only) that adds a new merge path exercised under the App identity, which is merge-policy rather than a code nit, so I am leaving the decision to the owner rather than judging it alone. No other defects found; security and docs (src/docs/native-merge-queue.md) look in order.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @4412365, 57/57 checks green, DCO yes, soak 0s of 30m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
There was a problem hiding this comment.
The enqueue path itself reads correctly to me; the pause/disabled cleanup loop as written is a per-minute full-repo scan on every sub-L6 hive, which I think needs a design change before this lands.
What I verified (tree at merge-base db3be8d, PR head 4412365):
tryNativeQueueruns after each lane's existing gates and beforeknownMergeRefusalin all four lanes (automerge_sweep.go:1883,:2282,:2638;automerge_contributor_lane.go:1396). The claim keys it reads —expect_sha,method_reason— are exactly whatmergeClaimForwrites atautomerge_merge_commit.go:140-142. Head pinning viaexpectedHeadOid, mixed-authorshipMERGEcheck, and the removal-event cycle key all match the body.- Dequeue provenance re-check immediately before the write (
automerge_native_queue.go:136-147) and the enqueuer-login match are what the body claims.TestNativeQueueGateWithdrawsOnlyHiveEntries/TestNativeQueueDequeueHonorsBoundaryAndLaneOwnershipcover it. ClassifyStageprefix match onnative-merge-queue(derive_pr_classify.go:453) routes both thenative-merge-queued: queued (position N, S)reason and thenative-merge-queue-{read,enqueue,method}failure reasons tostage/100-merge-queue. Whether a failure reason should land on stage 100 rather than a refusal stage is a judgement call for the author; flagging, not asserting.
Finding (high) — reconcileInactiveNativeQueues scans every open PR in every "inactive" repo once a minute, and below L6 every repo is inactive.
automerge_sweep.go:893calls it unconditionally at the top ofSweepQueuedAutoMerges, whichrunAutoMergeSweepIfDueruns everyautoMergeSweepInterval = time.Minute(main.go:9243) with no ACMM gate (main.go:9358-9369).automerge_native_queue.go:172skips a repo only ifactive[display] && c.repoAutoMergeAllowed(display).repoAutoMergeAllowed→cfg.RepoAutoMergeEnabled, which is fail-closed: returnsfalsefor every repo when ACMM < L6 (src/pkg/config/repo_policy.go:517-520).- So on any hive below L6 with App auth, every repo falls through to
:178PullRequests.List(state=open, 100/page)over all pages, and:184→reconcileNativeQueueGate("inactive", …)→:129one GraphQLReadNativeMergeQueueper open PR. Thelane != "inactive"carve-out at:116deliberately disables the author-ownership short-circuit, so nothing filters the set. - Consequence: for this repo alone (~hundreds of open PRs) that is several REST list pages plus hundreds of GraphQL node queries per minute, forever, to look for App-owned queue entries that a sub-L6 hive can never have created (it never reaches
tryNativeQueuebecause the lanes bail on automerge-disabled repos first). At L6 the same cost applies to every repo an owner has switched off.ShedLowPriorityTickatmain.go:9368guards only entry to the sweep; the loop has no budget check of its own. - Suggested shape: remember which PRs this engine actually enqueued (the effect journal already has
operation=enqueueclaims) and dequeue from that set, or at minimum skip repos whereIsMergeQueueEnabledwas never observed true and run the inactive pass on a much longer interval. A cleanup for the rare "operator paused mid-queue" case should not cost a full scan per minute.
Low — the new REST calls are untagged. automerge_native_queue.go:178 and automerge_sweep.go:931 call PullRequests.List/Get with the bare ctx; every other REST call in this sweep wraps it in hgithub.WithRESTCaller(ctx, "hive:automerge_sweep") so /api/gh-rate-limits can attribute the load (restnegativecache.go:28-30). Given the volume above, this is the one call site you most want attributed. Also :931 adds a PullRequests.Get per prefiltered label-queued issue — the prefilter used to be free; now each held/exempt-label skip costs a REST read plus a GraphQL read.
Open question (not asserting a defect): a PR can be evaluated by more than one lane (e.g. a trusted-author PR that also carries the automerge label is seen by both the queued and trusted lanes). The gate's ownership guards cover self-authored vs. others and untrusted-author-role, but I did not find a guard preventing lane A from dequeuing an entry lane B enqueued when their gate sets differ (e.g. queued lane's label-approval gate vs. trusted lane's review gate). If the gates are identical in practice this is moot; if not, the entry could flap enqueue/dequeue each minute.
Body matches the diff throughout; the paused/disabled cleanup is described exactly as implemented, so this is a cost/design concern, not a mismatch. Fork PR, so I can't push — recommend the author rework the inactive pass before a maintainer spends time on the rest. I have not approved or changed anything.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
@thatguywob this PR is back in your court ( Review asks:
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 |
PRs targeting a GitHub native merge queue currently stop at
merge-queue-requiredeven after Hive approves the merge. The four automerge sweep lanes now detect the target queue and enqueue the validated head with GraphQLexpectedHeadOidthrough the App installation transport.The existing eligibility gates stay in place. Already queued PRs are left alone; rejected candidates are dequeued only when their entry belongs to this Hive App, with provenance checked again immediately before the write. Paused and automerge-disabled repositories receive the same cleanup. All writes use the existing mutation boundary. Queue removal events distinguish subsequent enqueue attempts in the effect journal, and uncertain writes reconcile against GitHub's current queue state.
Queue position/state is reported in the sweep reason and mapped to stage 100. Enqueueing emits no completed-merge audit or issue closure. Static-token clients retain their existing behavior. Mixed-authorship PRs that require a merge commit verify that the queue uses
MERGEbefore enqueueing.Validation: added regression coverage for all four lanes, pinned heads, idempotency, re-enqueue after removal, gate withdrawal, human/other-App ownership, paused repositories, mutation-boundary denials, GraphQL failures and stage classification.
gofmt -landgit diff --checkare clean. Tests were not run locally perAGENTS.md; CI owns test execution.Operator details and workflow requirements are documented in
src/docs/native-merge-queue.md. Automatic diagnosis of workflows missingmerge_groupremains the optional follow-up described in the issue. Withdrawal is periodic/event-driven and can race GitHub's eventual merge; it never bypasses a write denial.Closes #15198
— hive: backend=codex
🐝 Hive Agent:
contributor| SHA:4412365d6