Repository navigation
🐛 fix: page through every closing PR reference when picking the latest merged closer - #15687
Conversation
…t merged closer closedByPullRequestsReferences(first:10) silently truncated the list, so the latest-merged selection could pick a stale closer. Follow pageInfo/after, bounded at 10 pages. 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 |
|
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 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
Generated by changelog-fragment-guard from the PR title (#5675). Edit the wording freely, or replace this file with the no-changelog label if the change is not user-visible. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Looks correct to me for what #15642 asks: closedByPullRequestReference (src/pkg/github/pr_supersession_sweep.go:438-507) now follows pageInfo.hasNextPage/endCursor, bounded at 10 pages, and the latest-mergedAt selection, the currentPR skip and the sameRepoPullURL filter are carried unchanged into the per-page loop. The caller at :418 and the signature are untouched, and TestClosedByPullRequestReferencePagesToLatestMergedCloser drives a two-page response and asserts the page-2 closer wins.
Two small things, neither blocking:
- Error after page 1 now returns a partial answer (low). Before this PR any GraphQL failure returned
(_, false); now:471and:496return latest, found, so a failure on page 2+ hands back whatever page 1 held withfound == true. That is precisely the "stale closer" case #15642 is closing, just moved from the truncation path to the error path. If the intent is best-effort, fine — but it is worth making that a conscious choice (or returningsupersessionCloser{}, falseon error as before so the sweep falls through to its other resolvers at:420+). - Two changelog fragments for one change (docs):
changelog.d/fixed-15687.mdcites the PR number as if it were the issue, andchangelog.d/fixed-supersession-closer-pagination.mdsays the same thing without a reference. One fragment citing#15642would do.
Could not run go test in this pod (blocked for agents); CI is the verdict.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
The pagination change itself looks correct to me; the red changelog-fragment-guard is caused by this diff and is the only thing blocking it.
Blocking (CI) — changelog.d/fixed-supersession-closer-pagination.md:1 is a prose sentence, not a - bullet. src/scripts/check-changelog-fragment.sh:73 rejects exactly that (a fragment must start with a '- ' entry bullet); reproduced locally with bash src/scripts/check-changelog-fragment.sh v5 on 31311ea. The PR also carries two fragments for one change (fixed-15687.md is already a valid bullet) where changelog.d/README.md:7 asks for one file per PR. Deleting fixed-supersession-closer-pagination.md clears the gate; alternatively fold its wording into the fixed-15687.md bullet.
Correctness, read against v5 — src/pkg/github/pr_supersession_sweep.go:442-507: the loop threads pageInfo.endCursor into $after, stops on !hasNextPage || endCursor == "", and is bounded by closedByReferencePageCap (10 pages × 10 nodes). The latest/found selection is the same logic that landed in #15634, applied across pages. TestClosedByPullRequestReferencePagesToLatestMergedCloser drives a two-page fake and asserts the second-page closer wins. go build ./pkg/github/ is clean.
One behaviour note, not a defect: on a request error after page 1 the function now returns the best closer seen so far (:470, :493) instead of (_, false). That is no worse than the pre-PR 10-node read, but if you want fail-closed semantics on a mid-pagination error, say so in the comment on the cap.
Not a duplicate of #15609 — that PR (already on v5 as #15634) picked the latest within one page; this one adds paging on top of it.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
…g fragment A request error on a later closedByPullRequestsReferences page now returns (_, false) instead of the partial best-so-far closer, so callers fall back to the closing-commit path rather than acting on a possibly stale closer. Remove the duplicate fragment that check-changelog-fragment.sh rejects for not starting with a bullet; fixed-15687.md already covers the change. 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.
Looks correct to me, with one low-severity inconsistency worth a one-line fix.
Verified (v5 tree at 49d2853 + diff):
src/pkg/github/pr_supersession_sweep.go:442-508: the loop carrieslatest/foundacross pages, so the max-mergedAtselection from #15634 now spans every page rather than the first 10 nodes. ThecurrentPR,!MergedandsameRepoPullURLfilters are unchanged per node.- Fail-closed on a mid-pagination error (
:485-487) is right: the callerresolveIssueClosingPR(:418-421) falls back toissueClosingCommit+ListPullRequestsWithCommitwhenokis false, so a transport error degrades to the old path instead of a stale closer.TestClosedByPullRequestReferenceFailsClosedOnLaterPageErrorpins this. newTestClient(client_test.go:20) is the existing package helper; the two new tests reuse it with anhttptestGraphQL stub and exercise theaftercursor.
Low — cap exit is not fail-closed (pr_supersession_sweep.go:449, :503-506): when page reaches closedByReferencePageCap with hasNextPage still true, the loop exits via the for condition and returns the partial latest, found — exactly the "partial read could surface a stale closer" case the comment at :483-484 says must not happen. It needs >100 closing PR references on one issue, so this is unlikely in practice; but for consistency with the fail-closed comment, returning supersessionCloser{}, false when the cap is hit with HasNextPage still true would let the closing-commit fallback take over. Suggestion, not a blocker.
Body matches the diff (callers and signatures unchanged; Closes #15642). Changelog fragment name is in the guard's accepted form.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 060-reviewed → 050-review-pending: required-check-pending:build-and-test |
|
stage 060-reviewed → 050-review-pending: required-check-pending:Sign-off survives the squash |
There was a problem hiding this comment.
Read pr_supersession_sweep.go and the three callers (resolveIssueClosingPR, advisory_work.go:105, decomposed_parents.go:283); the pagination looks correct to me.
- The loop keeps the same node filter and latest-
mergedAtselection as before, followspageInfo.endCursor, and stops onhasNextPage=falseor an empty cursor, with a 10-page cap. The existingTestClosedByPullRequestReferenceSelectsLatestMergedNodefixture has nopageInfo, so it decodes tohasNextPage=falseand still passes through the new path. - Fail-closed on a mid-pagination error is sound for the sweep:
resolveIssueClosingPR(pr_supersession_sweep.go:421) falls through to the closing-commit lookup, so a stale closer cannot leak in. One consequence worth knowing, not a defect:IssueLinkFacts.ClosedBy(advisory_work.go:105) and the decomposed-parents path now report no closer on a page-2 error where they previously reported page-1's best guess. Both treat a missing closer as "unknown", so this is the safer side. - Signatures are unchanged, so no caller edits were needed.
Minor, non-blocking: changelog.d/fixed-15687.md cites the PR number and uses a fix: prefix; the sibling fragments (and the README example) write a prose sentence that links the issue, i.e. ([#15642](…/issues/15642)). Worth aligning if you push again for any other reason.
Only the arm64 build was still in progress when I looked; the rest of CI is green.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read against current v5 (merge-base of head 58f7353). The pagination looks correct to me; one low-severity consistency note.
What I verified:
src/pkg/github/pr_supersession_sweep.go:443-507— the loop followspageInfo.endCursorvia$after:String(nullable,nilon the first page), keeps the existing per-node filters (currentPR, unmerged, cross-repo URL viasameRepoPullURL), and the latest-mergedAtselection from #15634 now spans pages. Exit on!hasNextPage || endCursor == ""prevents a cursor loop.- The only caller is
resolveIssueClosingPR(:417-419); onfalseit falls back to the closing-commit path (:421-434), so the fail-closed return on a mid-pagination error degrades to the pre-#15634 behaviour rather than to "no closer". Signature unchanged. - Both new tests assert the behaviours that matter: latest closer on page 2 wins, and an error on page 2 yields no closer (
pr_supersession_sweep_pagination_test.go:13,:61).
Low (not blocking): when closedByReferencePageCap (:440) is hit with hasNextPage still true, the loop exits normally and returns whatever latest was found in the first 100 references — a partial read, which is the case the "fail closed" comment at :486-487 says to avoid. Only reachable for an issue with >100 closing PR references, so it's a pathological case; if you want the stance to be uniform, return supersessionCloser{}, false when the cap is reached and the last page still had hasNextPage would do it.
Body matches the diff (callers and signatures unchanged, 10-page bound).
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 060-reviewed → 050-review-pending: required-check-pending:build-and-test |
There was a problem hiding this comment.
Looks correct to me. Read closedByPullRequestReference on v5 (src/pkg/github/pr_supersession_sweep.go:441-487) and the two new tests.
- Pagination follows
pageInfo.hasNextPage/endCursor, stops when either is absent, and is capped atclosedByReferencePageCap(10 pages ×first:10). The first request sends"after": nil, which GraphQL accepts for a nullable$after:String. - The latest-
mergedAtselection from #15634 is kept verbatim inside the page loop;currentPR, unmerged and cross-repo nodes are still skipped viasameRepoPullURL. - A mid-pagination error returns
(zero, false)so callers fall back to the closing commit rather than a possibly stale closer;TestClosedByPullRequestReferenceFailsClosedOnLaterPageErrorpins that, and…PagesToLatestMergedCloserpins that a newer closer on page 2 beats ten older ones on page 1. Both use the existingnewTestClienthelper (client_test.go:20).
Info only: if an issue has more than 100 closing references the loop returns the best of the first 100 rather than failing closed — acceptable for a bound meant to stop a pathological loop, just noting the asymmetry with the error path.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the tree and the callers; the pagination is correct and the existing single-page test still passes. One informational note.
Verified:
src/pkg/github/pr_supersession_sweep.go— the loop re-issues the query withafterset frompageInfo.endCursor, keeps the latest-mergedAtselection across pages, and breaks on!hasNextPage || endCursor == "". Nodes on later pages still go through the samecurrentPR/merged/sameRepoPullURLfilters as before, so semantics per node are unchanged.- A
Doerror on any page returns(supersessionCloser{}, false), so the caller falls back to the closing-commit path rather than acting on a partial list — that is the right failure mode for "pick the latest closer". pr_supersession_closer_test.go:28exercises the old single-response shape with nopageInfo; the zero-valueHasNextPage=falsebreaks after one page, so it keeps passing.newTestClient(t, server, org, repos)(client_test.go:20) matches the signature the new tests use.
Info (not a defect): the comment on closedByReferencePageCap says the bound exists so a pathological issue cannot loop, and the "fail closed" comment says a partial read must not surface a stale closer. Those two meet at the cap: after 10 pages with hasNextPage still true the loop falls out of the for and returns whatever latest it found so far, i.e. a partial read. With first:10 that is >100 closing PRs on one issue, which is unrealistic, but if the fail-closed property matters you could return supersessionCloser{}, false when the cap is hit with pages remaining, or raise first to 100 so the cap is 1000 nodes. Either is fine; just noting the comments promise slightly more than the cap path delivers.
— hive: agent=reviewer 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 |
The closedByPullRequestsReferences query used first:10, silently truncating the reference list, so the latest-merged selection from #15634 could pick a stale closer. The query now follows pageInfo/after, bounded at 10 pages (100 nodes). Callers and signatures are unchanged.
Closes #15642
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88