Repository navigation
🐛 fix: honour requiredChecksExpected memory on the queued merge lane - #15430
Conversation
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@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
|
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Looks correct to me. Read the tree at b89a144:
trySweepQueuedPRalready consultsknownMergeRefusal(attempt)before the PUT (automerge_sweep.go:2681-2684), andknownMergeRefusalcheckschecksExpectedKnownfirst (automerge_merge_refusal.go:170). So the only thing missing on this lane was the remember half, which is exactly what the three added lines do — same shape as the review lane atautomerge_sweep.go:1951and the contributor lane atautomerge_contributor_lane.go:1437, minus theupdateBranchAndSkipbranch those lanes take (the queued lane has no branch-update path, so returningcheck-pendingdirectly is right).requiredChecksExpectedtakesmergeRefusalsMuitself viarememberMergeRefusal(automerge_merge_refusal.go:225), and the call site is outsideknownMergeRefusal's lock, so no self-deadlock.- The new test fails without the fix:
refusedMergereturns""for the 405 text, so the old code fell through to"merge-failed", err.
Couldn't run go test in this pod (blocked for agents); CI build was still in progress when I looked.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (style/conventions) — no blockers; one advisory.
- Test asserts via the lock-requiring inner helper rather than the entry point the sweep uses.
src/pkg/github/automerge/automerge_sweep_test.go:1081callsc.checksExpectedKnown(attempt, c.clock())directly. That helper is documented/used only undermergeRefusalsMu(automerge_merge_refusal.go:167-172), and the existing memory tests assert throughc.knownMergeRefusal(next)instead (automerge_merge_refusal_test.go:95,:252). Assertingc.knownMergeRefusal(attempt) == autoMergeReasonChecksExpectedwould follow the established idiom and prove the exact path the next sweep pass takes atautomerge_sweep.go:2682. Advisory only — the production change itself (automerge_sweep.go:2697-2699) mirrors the trusted-author lane (:2346-2348) and is correct.
Out of scope (pre-existing): the self-authored lane returns the literal "check-pending" at automerge_sweep.go:1953 while the other two lanes (incl. this PR) use autoMergeReasonChecksExpected.
— hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
…, not only off "blocked" checksExpectedKnown only honoured the memory while GitHub reported the head "blocked", but the queued lane only reaches the merge call for a head GitHub already calls mergeable, so the stored refusal was deleted on sight and the merge re-PUT every pass. Re-arm on a change from the stored state (as the review key does) so the memory applies on every lane. The queued-lane test now runs two passes and asserts a single merge call via knownMergeRefusal; the self-authored lane's "check-pending" literal uses the shared constant. 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>
There was a problem hiding this comment.
Correctness — delta re-review at 528ef1d (previous head b89a144)
Previous findings: automerge_sweep.go:2697 memory-unreachable → fixed (checksExpectedKnown now compares against the remembered r.state, automerge_merge_refusal.go:139); automerge_sweep_test.go:1082 → fixed (test now runs two passes against a clean head and asserts merges == 1, lines 1078-1086).
New (medium, in-scope): the queued lane can now stall a merge-ready PR for up to 30 minutes.
The memory is now keyed on the state it was refused in, and on the queued lane that state is clean (automerge_sweep.go:2681, automerge_merge_refusal.go:124). The lifecycle described in the issue and in the new doc comment (automerge_merge_refusal.go:114-116) is clean → blocked → clean: refused while GitHub still calls the head clean, blocked once the required check runs exist and are pending, clean again when they pass. But trySweepQueuedPR returns not-mergeable at automerge_sweep.go:2634-2635 (blocked → MergeableNo, pkg/github/client.go:1120) before it reaches knownMergeRefusal at :2682, so the blocked pass never invalidates the entry. On the next clean pass the head and state both match the memory again and checksExpectedKnown returns check-pending until mergeRefusalRecheck (30 min, automerge_merge_refusal.go:34) expires — for a PR GitHub would now merge. Before this delta the queued lane re-PUT and merged immediately; that is a regression in the exact scenario #15419 targets. (The same cycle can't bite the other lanes: they are refused in blocked, and the move to clean re-arms them.)
Requested change: forget the checks entry whenever the lane observes the PR in a different mergeable_state than the one remembered — e.g. a small c.forgetChecksExpectedIfStateMoved(attempt) (or just the state-compare/delete already in checksExpectedKnown) called before the not-mergeable return at :2635, and a test that drives clean (405) → blocked → clean through trySweepQueuedPR and asserts the third pass PUTs the merge. The case where the checks are created and complete between two passes is not observable and is fine to leave to the recheck window; say so in the comment.
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the three lanes and the refusal memory at head 528ef1d; this looks correct to me.
automerge_sweep.go:2681-2684already buildsattemptwithpr.GetMergeableState()and consultsknownMergeRefusalbefore the PUT, so the newrequiredChecksExpectedbranch at:2697is what was missing for the memory to ever be written on the queued lane. Returningcheck-pendingwithoutupdateBranchAndSkipis consistent with this lane — it never updates branches (a person queued the PR; the sweep only carries the merge out).automerge_merge_refusal.go:139(!= r.stateinstead of!= "blocked"):requiredChecksExpectedat:122already storedcomparableMergeableState(a.state), so the memory was being recorded and then unconditionally discarded for any non-blocked refusal. The existing table test still covers the edge I checked: a refusal remembered inblockedfollowed byunknownmaps to"", which!= "blocked"→ re-arms, same as before.- The new test at
automerge_sweep_test.go:1049fails without the:2697branch (mergeswould be 2 and reasonmerge-failed).
No findings.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the tree at 528ef1d, not just the diff. This looks correct to me.
trySweepQueuedPRalready consultsknownMergeRefusalbefore the PUT (src/pkg/github/automerge/automerge_sweep.go:2681-2684), so the memory written by the newrequiredChecksExpectedcall at:2697is actually read on the next pass — the fix is complete, not just the recording half.- The
checksExpectedKnownrelaxation (automerge_merge_refusal.go:140,!= "blocked"→!= r.state) is necessary, not incidental: the queued lane only reaches the merge call for a head GitHub already reportsclean/unstable, so ablocked-only memory would never have matched there.mergeRefusal.statewas already populated byrequiredChecksExpected(:122), so no new state is introduced. - Re-arming on
unknownis unchanged and is explicitly covered by the existingstate not yet computed re-armscase inTestRequiredChecksExpectedRemembered. - The reason returned is the same
check-pendingstring the other lanes use, which the sweep loop atautomerge_sweep.go:983-987logs as a skip rather than a failure — matches the issue's ask (#15419).
Nothing to change.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 080-awaiting-merge-admission: no activity for 30m0s: merge-train:queued-behind#15308:2/2:0/0:automerge_merge_refusal.go,automerge_sweep.go,automerge_sweep_test.go |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
The queued merge lane (
trySweepQueuedPR) did not consultrequiredChecksExpected, unlike the self-authored, trusted-author and contributor lanes. A 405 "N of M required status checks are expected" was therefore re-PUT on every pass and logged as a falsemerge-failed. It now remembers the refusal per head and returnscheck-pending, using the same helper and reason as the other lanes. Test added that fails without the change.Closes #15419
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88