From 881f1fb96f3d0fdef67a2278adff6bdb1ac52806 Mon Sep 17 00:00:00 2001 From: mendezr Date: Thu, 29 Oct 2026 19:57:10 +0000 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=90=9B=20fix:=20scope=20tracker=20lin?= =?UTF-8?q?k=20memo=20to=20the=20excluded=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/hive#15495 Hive-Plan: correctness-link-memo Hive-Spec: issue-15495#exclude-sensitive-cache-key Signed-off-by: mendezr --- src/pkg/dashboard/stage_tracker.go | 8 ++- .../dashboard/stage_tracker_link_memo_test.go | 56 +++++++++++++++++++ src/pkg/dashboard/stage_tracker_test.go | 14 ++--- 3 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 src/pkg/dashboard/stage_tracker_link_memo_test.go diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index fa4948ce73..5758c076b3 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -2895,7 +2895,8 @@ type stageTrackerLinkInfo struct { at time.Time } -// stageTrackerLinkMemo memoises link lookups keyed by owner/repo#number. +// stageTrackerLinkMemo memoises link lookups keyed by owner/repo#issue@excludedPR. +// The excluded carrying PR affects which merged closer the lookup returns. type stageTrackerLinkMemo struct { mu sync.Mutex m map[string]stageTrackerLinkInfo @@ -2938,7 +2939,8 @@ func (in stageTrackerLinkInfo) ttl() time.Duration { // stageTrackerEnrichSoftLinks gives the links no listed issue or closing // reference titled (soft refs / title / mention links, and closing keywords // hive read from the PR text) a title and state, from one issues GET per -// distinct same-repo number, memoised across rebuilds (stageTrackerLinkMemo). +// distinct same-repo number and excluded carrying PR, memoised across rebuilds +// (stageTrackerLinkMemo). // A closed issue also gets its stateReason and the merged PR that closed it // (ClosedBy, from GitHub's closedByPullRequestsReferences), so a follow-up // PR opened against an issue an earlier merge already delivered reads @@ -2967,7 +2969,7 @@ func (s *Server) stageTrackerEnrichSoftLinks(items []StageTrackerItem, qualify f kept := pr.LinkedIssues[:0] for _, li := range pr.LinkedIssues { if !li.Listed && li.Title == "" && li.State == "" { - key := owner + "/" + name + "#" + strconv.Itoa(li.Number) + key := owner + "/" + name + "#" + strconv.Itoa(li.Number) + "@" + strconv.Itoa(pr.Number) in, hit := s.stageTrackerLinks.get(key, now) if !hit && lookups < stageTrackerLinkLookups && ctx.Err() == nil { lookups++ diff --git a/src/pkg/dashboard/stage_tracker_link_memo_test.go b/src/pkg/dashboard/stage_tracker_link_memo_test.go new file mode 100644 index 0000000000..5d4f4ca3d9 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_link_memo_test.go @@ -0,0 +1,56 @@ +package dashboard + +import ( + "fmt" + "net/http" + "net/http/httptest" + "strings" + "sync/atomic" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" +) + +func TestStageTrackerLinkMemoSeparatesExcludedPRs(t *testing.T) { + var closerReads atomic.Int32 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/graphql") { + closerReads.Add(1) + fmt.Fprint(w, `{"data":{"repository":{"issue":{"closedByPullRequestsReferences":{"nodes":[{"number":70,"merged":true,"mergedAt":"2026-10-27T12:00:00Z"}]}}}}}`) + return + } + fmt.Fprint(w, `{"number":76,"title":"Delivered issue","state":"closed","state_reason":"completed"}`) + })) + defer ts.Close() + s := newTestServer() + s.deps = &Dependencies{GHClient: github.NewClientForTest(ts.URL, "hivecommons", []string{"hive"}, s.logger)} + qualify := func(string) string { return "hivecommons/hive" } + now := time.Date(2026, 10, 27, 18, 0, 0, 0, time.UTC) + + // Merged PRs are not tracker rows today. Exercise both row orders so a + // future inclusion cannot let a row's exclusion poison its sibling's memo. + for _, order := range [][]int{{70, 90}, {90, 70}} { + s.stageTrackerLinks = stageTrackerLinkMemo{} + before := closerReads.Load() + for rebuild := 0; rebuild < 2; rebuild++ { + var items []StageTrackerItem + for _, number := range order { + items = append(items, StageTrackerItem{Repo: "hive", Number: number, Kind: "pr", LinkedIssues: []StageTrackerLinkedIssue{{Number: 76}}}) + } + s.stageTrackerEnrichSoftLinks(items, qualify, now.Add(time.Duration(rebuild)*time.Minute)) + for _, item := range items { + want := 70 + if item.Number == 70 { + want = 0 + } + if got := item.LinkedIssues[0].ClosedBy; got != want { + t.Fatalf("order %v rebuild %d PR #%d: closer = %d, want %d", order, rebuild, item.Number, got, want) + } + } + } + if got := closerReads.Load() - before; got != 2 { + t.Fatalf("order %v: closer reads = %d, want 2 with rebuild memoised", order, got) + } + } +} diff --git a/src/pkg/dashboard/stage_tracker_test.go b/src/pkg/dashboard/stage_tracker_test.go index 924895903a..1a5560cc5e 100644 --- a/src/pkg/dashboard/stage_tracker_test.go +++ b/src/pkg/dashboard/stage_tracker_test.go @@ -1114,8 +1114,8 @@ func TestStageTrackerEnrichSoftLinks(t *testing.T) { if got := items[1].LinkedIssues[0]; got.Title != "Runner stalls" || got.State != "closed" || got.ClosedBy != 14570 { t.Fatalf("second PR's refs link = %+v, want closed by #14570 (never the open #14590)", got) } - if n := closerReads.Load(); n != 1 { - t.Fatalf("closer reads = %d, want 1 (closed issues only, memoised)", n) + if n := closerReads.Load(); n != 2 { + t.Fatalf("closer reads = %d, want 2 (one per excluded carrying PR)", n) } if got := links[1]; got.Number != 14578 || got.Title != "" || got.State != "" { t.Fatalf("failed lookup = %+v, want untouched", got) @@ -1123,23 +1123,23 @@ func TestStageTrackerEnrichSoftLinks(t *testing.T) { if got := links[2]; got.Number != 14567 || got.Title != "Titled" || got.State != "closed" { t.Fatalf("closing link = %+v, want unchanged", got) } - if n := gets.Load(); n != 4 { - t.Fatalf("issues GETs = %d, want 4 (one per distinct number)", n) + if n := gets.Load(); n != 5 { + t.Fatalf("issues GETs = %d, want 5 (one per distinct number and excluded PR)", n) } // A rebuild after a status publish reuses the memo, the failed lookup // included, until its retry window lapses. items = build() s.stageTrackerEnrichSoftLinks(items, qualify, now.Add(time.Minute)) - if n := gets.Load(); n != 4 || len(items[0].LinkedIssues) != 3 || items[0].LinkedIssues[0].Title != "Runner stalls" { + if n := gets.Load(); n != 5 || len(items[0].LinkedIssues) != 3 || items[0].LinkedIssues[0].Title != "Runner stalls" { t.Fatalf("rebuild: GETs = %d, links = %+v, want memoised", n, items[0].LinkedIssues) } s.stageTrackerEnrichSoftLinks(build(), qualify, now.Add(stageTrackerLinkRetry)) - if n := gets.Load(); n != 5 { + if n := gets.Load(); n != 6 { t.Fatalf("issues GETs = %d, want only the failed lookup retried", n) } s.stageTrackerEnrichSoftLinks(build(), qualify, now.Add(stageTrackerLinkTTL)) - if n := gets.Load(); n != 9 { + if n := gets.Load(); n != 11 { t.Fatalf("issues GETs = %d, want every lookup refreshed after the TTL", n) } From 98730f11c4fa0ea5d61b9f514f50f7ac6821cfc8 Mon Sep 17 00:00:00 2001 From: mendezr Date: Thu, 29 Oct 2026 20:10:15 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9D=20docs:=20add=20tracker=20link?= =?UTF-8?q?=20memo=20changelog=20fragment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mendezr --- changelog.d/fixed-15508-link-memo.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/fixed-15508-link-memo.md diff --git a/changelog.d/fixed-15508-link-memo.md b/changelog.d/fixed-15508-link-memo.md new file mode 100644 index 0000000000..b5c9731d12 --- /dev/null +++ b/changelog.d/fixed-15508-link-memo.md @@ -0,0 +1 @@ +- Scope the dashboard tracker’s issue-link cache to the carrying PR so sibling rows cannot reuse a closer selected with a different PR excluded. This defensively preserves correct links if merged PR rows are included; current open-only tracker behavior is unchanged ([#15495](https://github.com/hivecommons/hive/issues/15495)). From 0ed63b0b5e3e24876dcd956224591dc16c597734 Mon Sep 17 00:00:00 2001 From: mendezr Date: Thu, 29 Oct 2026 20:17:26 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=90=9B=20fix:=20share=20tracker=20iss?= =?UTF-8?q?ue=20lookups=20and=20filter=20closers=20per=20row?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mendezr --- changelog.d/fixed-15508-link-memo.md | 2 +- src/pkg/dashboard/stage_tracker.go | 17 ++++++++++------- .../dashboard/stage_tracker_link_memo_test.go | 14 +++++++++----- src/pkg/dashboard/stage_tracker_test.go | 14 +++++++------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/changelog.d/fixed-15508-link-memo.md b/changelog.d/fixed-15508-link-memo.md index b5c9731d12..e91cd0b2ee 100644 --- a/changelog.d/fixed-15508-link-memo.md +++ b/changelog.d/fixed-15508-link-memo.md @@ -1 +1 @@ -- Scope the dashboard tracker’s issue-link cache to the carrying PR so sibling rows cannot reuse a closer selected with a different PR excluded. This defensively preserves correct links if merged PR rows are included; current open-only tracker behavior is unchanged ([#15495](https://github.com/hivecommons/hive/issues/15495)). +- Cache the dashboard tracker’s unfiltered issue closer once per issue and exclude the carrying PR per row, preserving correct sibling links without extra lookups. This defensively preserves correct links if merged PR rows are included; current open-only tracker behavior is unchanged ([#15495](https://github.com/hivecommons/hive/issues/15495)). diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 5758c076b3..96f6caa4dd 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -2895,8 +2895,8 @@ type stageTrackerLinkInfo struct { at time.Time } -// stageTrackerLinkMemo memoises link lookups keyed by owner/repo#issue@excludedPR. -// The excluded carrying PR affects which merged closer the lookup returns. +// stageTrackerLinkMemo memoises link lookups keyed by owner/repo#issue. +// The cached closer is unfiltered; each carrying PR excludes itself below. type stageTrackerLinkMemo struct { mu sync.Mutex m map[string]stageTrackerLinkInfo @@ -2939,8 +2939,7 @@ func (in stageTrackerLinkInfo) ttl() time.Duration { // stageTrackerEnrichSoftLinks gives the links no listed issue or closing // reference titled (soft refs / title / mention links, and closing keywords // hive read from the PR text) a title and state, from one issues GET per -// distinct same-repo number and excluded carrying PR, memoised across rebuilds -// (stageTrackerLinkMemo). +// distinct same-repo number, memoised across rebuilds (stageTrackerLinkMemo). // A closed issue also gets its stateReason and the merged PR that closed it // (ClosedBy, from GitHub's closedByPullRequestsReferences), so a follow-up // PR opened against an issue an earlier merge already delivered reads @@ -2969,11 +2968,11 @@ func (s *Server) stageTrackerEnrichSoftLinks(items []StageTrackerItem, qualify f kept := pr.LinkedIssues[:0] for _, li := range pr.LinkedIssues { if !li.Listed && li.Title == "" && li.State == "" { - key := owner + "/" + name + "#" + strconv.Itoa(li.Number) + "@" + strconv.Itoa(pr.Number) + key := owner + "/" + name + "#" + strconv.Itoa(li.Number) in, hit := s.stageTrackerLinks.get(key, now) if !hit && lookups < stageTrackerLinkLookups && ctx.Err() == nil { lookups++ - facts, err := s.deps.GHClient.IssueLinkState(ctx, owner, name, li.Number, pr.Number) + facts, err := s.deps.GHClient.IssueLinkState(ctx, owner, name, li.Number, 0) in = stageTrackerLinkInfo{title: facts.Title, state: facts.State, stateReason: facts.StateReason, closedBy: facts.ClosedBy, pr: facts.IsPR, ok: err == nil} // Running out of this rebuild's budget says nothing // about the issue: leave it for the next rebuild. @@ -2987,7 +2986,11 @@ func (s *Server) stageTrackerEnrichSoftLinks(items []StageTrackerItem, qualify f if in.ok { li.Title, li.State = in.title, in.state if in.state == "closed" { - li.StateReason, li.ClosedBy = in.stateReason, in.closedBy + li.StateReason, li.ClosedBy = in.stateReason, 0 + // Exclude the carrying PR per row, not in the shared lookup. + if in.closedBy != pr.Number { + li.ClosedBy = in.closedBy + } } } } diff --git a/src/pkg/dashboard/stage_tracker_link_memo_test.go b/src/pkg/dashboard/stage_tracker_link_memo_test.go index 5d4f4ca3d9..3fb081faf0 100644 --- a/src/pkg/dashboard/stage_tracker_link_memo_test.go +++ b/src/pkg/dashboard/stage_tracker_link_memo_test.go @@ -12,14 +12,15 @@ import ( "github.com/hivecommons/hive/pkg/github" ) -func TestStageTrackerLinkMemoSeparatesExcludedPRs(t *testing.T) { - var closerReads atomic.Int32 +func TestStageTrackerLinkMemoSharesLookupAndExcludesCarryingPR(t *testing.T) { + var gets, closerReads atomic.Int32 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/graphql") { closerReads.Add(1) fmt.Fprint(w, `{"data":{"repository":{"issue":{"closedByPullRequestsReferences":{"nodes":[{"number":70,"merged":true,"mergedAt":"2026-10-27T12:00:00Z"}]}}}}}`) return } + gets.Add(1) fmt.Fprint(w, `{"number":76,"title":"Delivered issue","state":"closed","state_reason":"completed"}`) })) defer ts.Close() @@ -32,7 +33,7 @@ func TestStageTrackerLinkMemoSeparatesExcludedPRs(t *testing.T) { // future inclusion cannot let a row's exclusion poison its sibling's memo. for _, order := range [][]int{{70, 90}, {90, 70}} { s.stageTrackerLinks = stageTrackerLinkMemo{} - before := closerReads.Load() + beforeGets, before := gets.Load(), closerReads.Load() for rebuild := 0; rebuild < 2; rebuild++ { var items []StageTrackerItem for _, number := range order { @@ -49,8 +50,11 @@ func TestStageTrackerLinkMemoSeparatesExcludedPRs(t *testing.T) { } } } - if got := closerReads.Load() - before; got != 2 { - t.Fatalf("order %v: closer reads = %d, want 2 with rebuild memoised", order, got) + if got := gets.Load() - beforeGets; got != 1 { + t.Fatalf("order %v: issues GETs = %d, want 1 shared across siblings and rebuilds", order, got) + } + if got := closerReads.Load() - before; got != 1 { + t.Fatalf("order %v: closer reads = %d, want 1 shared across siblings and rebuilds", order, got) } } } diff --git a/src/pkg/dashboard/stage_tracker_test.go b/src/pkg/dashboard/stage_tracker_test.go index 1a5560cc5e..924895903a 100644 --- a/src/pkg/dashboard/stage_tracker_test.go +++ b/src/pkg/dashboard/stage_tracker_test.go @@ -1114,8 +1114,8 @@ func TestStageTrackerEnrichSoftLinks(t *testing.T) { if got := items[1].LinkedIssues[0]; got.Title != "Runner stalls" || got.State != "closed" || got.ClosedBy != 14570 { t.Fatalf("second PR's refs link = %+v, want closed by #14570 (never the open #14590)", got) } - if n := closerReads.Load(); n != 2 { - t.Fatalf("closer reads = %d, want 2 (one per excluded carrying PR)", n) + if n := closerReads.Load(); n != 1 { + t.Fatalf("closer reads = %d, want 1 (closed issues only, memoised)", n) } if got := links[1]; got.Number != 14578 || got.Title != "" || got.State != "" { t.Fatalf("failed lookup = %+v, want untouched", got) @@ -1123,23 +1123,23 @@ func TestStageTrackerEnrichSoftLinks(t *testing.T) { if got := links[2]; got.Number != 14567 || got.Title != "Titled" || got.State != "closed" { t.Fatalf("closing link = %+v, want unchanged", got) } - if n := gets.Load(); n != 5 { - t.Fatalf("issues GETs = %d, want 5 (one per distinct number and excluded PR)", n) + if n := gets.Load(); n != 4 { + t.Fatalf("issues GETs = %d, want 4 (one per distinct number)", n) } // A rebuild after a status publish reuses the memo, the failed lookup // included, until its retry window lapses. items = build() s.stageTrackerEnrichSoftLinks(items, qualify, now.Add(time.Minute)) - if n := gets.Load(); n != 5 || len(items[0].LinkedIssues) != 3 || items[0].LinkedIssues[0].Title != "Runner stalls" { + if n := gets.Load(); n != 4 || len(items[0].LinkedIssues) != 3 || items[0].LinkedIssues[0].Title != "Runner stalls" { t.Fatalf("rebuild: GETs = %d, links = %+v, want memoised", n, items[0].LinkedIssues) } s.stageTrackerEnrichSoftLinks(build(), qualify, now.Add(stageTrackerLinkRetry)) - if n := gets.Load(); n != 6 { + if n := gets.Load(); n != 5 { t.Fatalf("issues GETs = %d, want only the failed lookup retried", n) } s.stageTrackerEnrichSoftLinks(build(), qualify, now.Add(stageTrackerLinkTTL)) - if n := gets.Load(); n != 11 { + if n := gets.Load(); n != 9 { t.Fatalf("issues GETs = %d, want every lookup refreshed after the TTL", n) } From 2c12c9c1710fa8d5e6ae25c7c608549641cc46b0 Mon Sep 17 00:00:00 2001 From: mendezr Date: Thu, 29 Oct 2026 20:23:43 +0000 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=8C=B1=20chore:=20retry=20CI=20after?= =?UTF-8?q?=20transient=20Go=20proxy=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From af15cace66eb1cca7b00d30c630a643dc9435fdd Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 18:52:47 -0400 Subject: [PATCH 5/5] test(dashboard): give link-memo closer fixture a same-repo PR url The closedByPullRequestsReferences filter from #15509 drops nodes whose url is not /owner/repo/pull/N, so the url-less fixture node would make ClosedBy resolve to 0 once v5 is merged. Add the matching url. 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> --- src/pkg/dashboard/stage_tracker_link_memo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/dashboard/stage_tracker_link_memo_test.go b/src/pkg/dashboard/stage_tracker_link_memo_test.go index 3fb081faf0..20b763a9b0 100644 --- a/src/pkg/dashboard/stage_tracker_link_memo_test.go +++ b/src/pkg/dashboard/stage_tracker_link_memo_test.go @@ -17,7 +17,7 @@ func TestStageTrackerLinkMemoSharesLookupAndExcludesCarryingPR(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/graphql") { closerReads.Add(1) - fmt.Fprint(w, `{"data":{"repository":{"issue":{"closedByPullRequestsReferences":{"nodes":[{"number":70,"merged":true,"mergedAt":"2026-10-27T12:00:00Z"}]}}}}}`) + fmt.Fprint(w, `{"data":{"repository":{"issue":{"closedByPullRequestsReferences":{"nodes":[{"number":70,"url":"https://github.com/hivecommons/hive/pull/70","merged":true,"mergedAt":"2026-10-27T12:00:00Z"}]}}}}}`) return } gets.Add(1)