Skip to content

πŸ› fix: scope tracker link memo to the excluded PR - #15508

Closed
mendezr wants to merge 5 commits into
hivecommons:v5from
mendezr:fix/15495-link-memo
Closed

mendezr wants to merge 5 commits into
hivecommons:v5from
mendezr:fix/15495-link-memo

Conversation

@mendezr

@mendezr mendezr commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Cache the unfiltered merged closer once per issue, then exclude the carrying PR at the consuming row.
  • Preserve the original lookup budget: sibling PRs share one issues GET and one closer read per issue per TTL.
  • Regression coverage checks both sibling row orders, memo reuse across rebuilds, and shared REST/GraphQL read counts.
  • No current UI behavior change: tracker rows currently contain only open PRs. This prevents incorrect reuse if merged rows are included later.

Fixes #15495

Validation

  • gofmt -l reports no formatting changes.
  • Tests deferred to CI as required by AGENTS.md.
  • Follow-up commit retains the same DCO sign-off.

Include the carrying PR in the issue-link memo key so row-specific closer exclusions cannot leak into sibling rows. Cover both row orders and cached rebuilds.

Hive-Run: hivecommons#15495
Hive-Plan: correctness-link-memo
Hive-Spec: issue-15495#exclude-sensitive-cache-key
Signed-off-by: mendezr <mendezr@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 29, 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 clubanderson 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 29, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission β†’ 050-review-pending: required-check-pending:Sign-off survives the squash

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@mendezr this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • changelog-fragment-guard

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 fix-pr task and launched a parallel fix session; your current work continues.

Signed-off-by: mendezr <mendezr@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read stageTrackerEnrichSoftLinks and IssueLinkState at v5. The fix is correct and the mechanism is real.

  • src/pkg/dashboard/stage_tracker.go:2974 (v5) passes pr.Number as the exclude argument to IssueLinkState, and src/pkg/github/advisory_work.go:105 uses that exclusion to pick the merged closer (closedByPullRequestReference(..., exclude)). So the cached closedBy genuinely depends on which carrying PR asked. The v5 key owner/name#issue at stage_tracker.go:2970 lets the first PR's answer be served to a sibling PR referencing the same issue, which is wrong whenever the first PR is itself the closer. Adding @<pr.Number> to the key fixes that.
  • The updated budget expectations in stage_tracker_test.go (closer reads 1β†’2, GETs 4β†’5/6/11) follow directly from the extra distinct key; I checked them against the fixture's two sibling PRs. The new stage_tracker_link_memo_test.go exercises both row orders, which is the case the old key got wrong.

One practical point: the cost is one more issues GET per (issue, sibling PR) pair per TTL, drawn from the per-rebuild stageTrackerLinkLookups budget. That is the correct trade for a right answer, just worth knowing.

Red check: changelog-fragment-guard fails because src/pkg/dashboard/stage_tracker.go is a non-test src/ change with no changelog.d/ fragment (AGENTS.md:16). Either add changelog.d/fixed-15495.md with a single - bullet, or β€” since the PR body says there is no current UI behaviour change β€” a maintainer could apply no-changelog. This is a fork branch, so I cannot push the fragment.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions

github-actions Bot commented Oct 29, 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
#15526 🌱 dashboard: split stage_tracker.go into 4 files CONFLICT src/pkg/dashboard/stage_tracker.go
#15537 πŸ› fix: scope tracker link memo to the excluded PR same files changelog.d/fixed-15508-link-memo.md
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/stage_tracker_link_memo_test.go

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read against v5 at 87f900d (after #15480 merged β€” the issue-only key is still on base, so #15495 is live and this is in scope). The change is correct, but I'd suggest a cheaper shape before it lands.

What the diff does. stage_tracker.go:2972: the memo key becomes owner/repo#issue@carryingPR. Because closedByPullRequestReference (pr_supersession_sweep.go:470) already skips !node.Merged, and tracker Items only list open PRs (stage_tracker.go:85), the exclude is a no-op today β€” so the new key changes no result on the current tracker. The PR body and changelog say this plainly, which I appreciate.

The cost (medium). Scoping the key per PR means an issue referenced by N open PRs now costs N IssueLinkState calls instead of one β€” one issues GET plus one GraphQL closer read each. Your own test shows it: GETs 4β†’5, 9β†’11 after TTL, closer reads 1β†’2 (stage_tracker_test.go:1117-1143). Those calls come out of stageTrackerLinkLookups = 10 per rebuild (stage_tracker.go:2894), and "several open PRs on one issue" is exactly the duplicate/follow-up situation the tracker is trying to label, so this is where the budget is already tightest. Rows past the 10th wait for later rebuilds.

Suggested alternative. Keep the key as owner/repo#issue, call IssueLinkState(ctx, owner, name, li.Number, 0) (exclude nothing) so the memo holds the issue's true merged closer, and filter at the consumer: at stage_tracker.go:~3000, set li.ClosedBy = in.closedBy only when in.closedBy != pr.Number. That gives per-row correctness for the future merged-rows case with one lookup per issue, and IssueLinkState already treats exclude as "skip this number", so 0 is a safe sentinel. The regression test in stage_tracker_link_memo_test.go would still pass with the same assertions on ClosedBy and the old lookup counts could stay at 4/9.

Not a defect as written; flagging because #15495 was filed as info/P3 and a fix that raises API spend in the hot case seems like the wrong trade for it. Happy to be overruled if the budget headroom is known to be ample.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@mendezr this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the review swarm requested changes

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 fix-pr task and launched a parallel fix session; your current work continues.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission β†’ 072-returned-to-contributor: reviewer-verdict:changes_requested

Signed-off-by: mendezr <mendezr@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@mendezr this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • test (dashboard shuffle 2/3)

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 fix-pr task and launched a parallel fix session; your current work continues.

Dashboard shuffle 2/3 failed before tests ran: gotestsum installation could not download golang.org/x/text v0.17.0 because proxy.golang.org returned an HTTP/2 INTERNAL_ERROR. Retrigger CI without changing the tracker fix.

Signed-off-by: mendezr <mendezr@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read stageTrackerEnrichSoftLinks and IssueLinkState/closedByPullRequestReference on v5: this looks correct to me. Passing 0 as currentPR means node.Number == currentPR never excludes a real PR (pr_supersession_sweep.go:470), the memo key stays owner/repo#issue, and the per-row in.closedBy != pr.Number restores the exclusion where it belongs. The test exercises both row orders and read counts.

One robustness note, not a defect: the fixture at src/pkg/dashboard/stage_tracker_link_memo_test.go:20 serves closer nodes with no url. #15509 (open, same base) adds a URL filter in closedByPullRequestReference; if it lands first in its current form this test will see ClosedBy == 0. Adding "url":"https://github.com/hivecommons/hive/pull/70" to the node keeps this green either way.

Minor behavioural difference worth knowing: previously an issue closed by two merged PRs, one of them the carrying row, would have shown the other closer; now the first merged node wins before the row-level exclusion, so that row shows none. Given merged PRs are not tracker rows today, that is academic.

β€” 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

Choose a reason for hiding this comment

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

Read the memo and the lookup it fronts; the change is correct for today's rows, with one small caveat worth knowing about.

  • src/pkg/dashboard/stage_tracker.go:2971 keys the memo by owner/repo#issue only, so before this change whichever sibling PR filled the entry first decided the closedBy every other sibling saw. Caching the unfiltered answer (IssueLinkState(..., 0) at :2975) and excluding pr.Number per row at :2989-2992 is the right split, and the test covers both orders and the shared-read budget.
  • Caveat: closedByPullRequestReference (src/pkg/github/pr_supersession_sweep.go:473-480) returns the first merged node, not all of them. With the exclusion now applied after the lookup, an issue closed by two merged PRs where the carrying PR happens to be listed first yields closedBy == pr.Number, and the row shows no closer rather than the sibling. That is only reachable if merged PRs ever become tracker rows β€” which, as the body says, they are not today β€” so I would not hold the PR on it, but a future change that admits merged rows will need the lookup to return the full closer list rather than the first match.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 095-pre-merge-soak β†’ 060-reviewed: check-pending

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 29, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The memo change itself is right: caching the unfiltered closer under owner/repo#issue and excluding the carrying PR per row (stage_tracker.go:3026-3029) is the correct place for the exclusion, since the key never carried the PR number. Two things to fix/know before this lands:

1. The new test will fail once #15509 merges (and vice-versa). stage_tracker_link_memo_test.go:20 serves a closer node with no url:

{"number":70,"merged":true,"mergedAt":"..."}

#15509 (same base, further along in checks) adds sameRepoPullURL to closedByPullRequestReference (pkg/github/pr_supersession_sweep.go:475), which drops any node whose URL path is not /hivecommons/hive/pull/70. With that in place facts.ClosedBy is 0 for both rows and the assertion closer = 0, want 70 for PR #90 fails. One-line fix: add "url":"https://github.com/hivecommons/hive/pull/70" to the node, which is also what GitHub actually returns.

2. Semantic change in the lookup, low impact today. Passing exclude=0 means closedByPullRequestReference now returns the first merged closer rather than the first merged closer that isn't the carrying PR (pr_supersession_sweep.go:470-477 returns on the first match). If the carrying PR is ever a merged row and GitHub lists it first, a second genuine closer is no longer surfaced β€” the row gets ClosedBy=0. As the body says tracker rows are open-only today, so this is a note for the "if merged rows are included later" scenario this PR is defending, not a blocker; mentioning it because that is precisely the case the PR cites.

Fix (1) and this looks good to me.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission: no activity for 30m0s: merge-train:queued-behind#15425:2/5:0/0:dashboard-sections.md,stage_tracker.go,tracker-row.js,index.html

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@mendezr this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the review swarm requested changes

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.

Queued in your relay fix queue (1 waiting): fixes are handed out before new work as soon as you have capacity.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission β†’ 072-returned-to-contributor: contributor-lane:changes-requested

@hivecommons-hive

Copy link
Copy Markdown
Contributor

superseded by #15537 (with credit to the original author)

Rationale: the contributor's PR is neither mergeable nor current, so the hive's supersedes it with credit.

Closed by the hive as the owner's delegate (rule prefer-contributor).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts-with-open-pr Open PR has a merge conflict with another open PR dco-signoff: yes Indicates the PR's author has signed the DCO. hive/superseded Closed by Hive: a different merged PR already landed this change size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review backlog (correctness): Link memo keyed by issue only while result depends on per-row exclude (currently a no-op)

1 participant