Skip to content

🐛 fix: page through every closing PR reference when picking the latest merged closer - #15687

Merged
hivecommons-hive[bot] merged 9 commits into
v5from
scanner/fix-15642
Oct 30, 2026
Merged

hivecommons-hive[bot] merged 9 commits into
v5from
scanner/fix-15642

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 30, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15609 🐛 fix: select latest merged issue closer same files src/pkg/github/pr_supersession_sweep.go

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
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>
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Error after page 1 now returns a partial answer (low). Before this PR any GraphQL failure returned (_, false); now :471 and :496 return latest, found, so a failure on page 2+ hands back whatever page 1 held with found == 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 returning supersessionCloser{}, false on error as before so the sweep falls through to its other resolvers at :420+).
  2. Two changelog fragments for one change (docs): changelog.d/fixed-15687.md cites the PR number as if it were the issue, and changelog.d/fixed-supersession-closer-pagination.md says the same thing without a reference. One fragment citing #15642 would 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

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
…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>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 carries latest/found across pages, so the max-mergedAt selection from #15634 now spans every page rather than the first 10 nodes. The currentPR, !Merged and sameRepoPullURL filters are unchanged per node.
  • Fail-closed on a mid-pagination error (:485-487) is right: the caller resolveIssueClosingPR (:418-421) falls back to issueClosingCommit + ListPullRequestsWithCommit when ok is false, so a transport error degrades to the old path instead of a stale closer. TestClosedByPullRequestReferenceFailsClosedOnLaterPageError pins this.
  • newTestClient (client_test.go:20) is the existing package helper; the two new tests reuse it with an httptest GraphQL stub and exercise the after cursor.

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

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed → 050-review-pending: required-check-pending:build-and-test

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed → 050-review-pending: required-check-pending:Sign-off survives the squash

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-mergedAt selection as before, follows pageInfo.endCursor, and stops on hasNextPage=false or an empty cursor, with a 10-page cap. The existing TestClosedByPullRequestReferenceSelectsLatestMergedNode fixture has no pageInfo, so it decodes to hasNextPage=false and 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 follows pageInfo.endCursor via $after:String (nullable, nil on the first page), keeps the existing per-node filters (currentPR, unmerged, cross-repo URL via sameRepoPullURL), and the latest-mergedAt selection from #15634 now spans pages. Exit on !hasNextPage || endCursor == "" prevents a cursor loop.
  • The only caller is resolveIssueClosingPR (:417-419); on false it 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

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed → 050-review-pending: required-check-pending:build-and-test

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 at closedByReferencePageCap (10 pages × first:10). The first request sends "after": nil, which GraphQL accepts for a nullable $after:String.
  • The latest-mergedAt selection from #15634 is kept verbatim inside the page loop; currentPR, unmerged and cross-repo nodes are still skipped via sameRepoPullURL.
  • A mid-pagination error returns (zero, false) so callers fall back to the closing commit rather than a possibly stale closer; TestClosedByPullRequestReferenceFailsClosedOnLaterPageError pins that, and …PagesToLatestMergedCloser pins that a newer closer on page 2 beats ten older ones on page 1. Both use the existing newTestClient helper (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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with after set from pageInfo.endCursor, keeps the latest-mergedAt selection across pages, and breaks on !hasNextPage || endCursor == "". Nodes on later pages still go through the same currentPR / merged / sameRepoPullURL filters as before, so semantics per node are unchanged.
  • A Do error 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:28 exercises the old single-response shape with no pageInfo; the zero-value HasNextPage=false breaks 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

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 0f45f79 into v5 Oct 30, 2026
75 of 76 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15642 branch October 30, 2026 07:18
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#156872706487` sha256:fc8f4e7c2a19c32b7012b1e26bc68b7a36bab88f0ab3969f2adb6248e44b8fe7 — download from the dashboard or `hivectl review evidence #15687`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review backlog (correctness): closedByPullRequestsReferences still capped at first:10

0 participants