From 9cf52e3cc9ab9a4ff13b29a4961ceaca8b61108d Mon Sep 17 00:00:00 2001 From: xfodev Date: Sun, 19 Jul 2026 03:39:55 -0700 Subject: [PATCH] fix(ranker): only flag default-goal-spec use when every ranked repo lacks one (#7226) --- .../loopover-miner/lib/opportunity-ranker.js | 6 +++++- test/unit/miner-opportunity-ranker.test.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/loopover-miner/lib/opportunity-ranker.js b/packages/loopover-miner/lib/opportunity-ranker.js index 8b9b8e75ef..993504207c 100644 --- a/packages/loopover-miner/lib/opportunity-ranker.js +++ b/packages/loopover-miner/lib/opportunity-ranker.js @@ -91,7 +91,11 @@ function rankedUsesDefaultGoalSpec(ranked, options = {}) { const goalSpecsByRepo = buildGoalSpecsByRepo(options); const specRepos = Object.keys(goalSpecsByRepo); if (ranked.length === 0) return specRepos.length === 0; - return ranked.some((issue) => { + // The "ranked with the built-in default goal spec (no per-tenant .loopover-miner.yml supplied)" note is only + // truthful when the WHOLE batch fell back to the default -- so require EVERY ranked repo to lack a supplied spec, + // not just any one of them (#7226). With `.some`, a single spec-less repo made a mixed batch (where other repos + // genuinely had a spec supplied and applied) print the blanket note as if none did. + return ranked.every((issue) => { const target = issue.repoFullName.trim().toLowerCase(); return !specRepos.some((repo) => repo.trim().toLowerCase() === target); }); diff --git a/test/unit/miner-opportunity-ranker.test.ts b/test/unit/miner-opportunity-ranker.test.ts index dcf1ead4b7..72bf5eb0da 100644 --- a/test/unit/miner-opportunity-ranker.test.ts +++ b/test/unit/miner-opportunity-ranker.test.ts @@ -106,6 +106,24 @@ describe("rankCandidateIssues (#2302 follow-up)", () => { expect(summary.usedDefaultGoalSpec).toBe(false); }); + it("does not report a blanket default-goal-spec note when only SOME ranked repos lack a spec (#7226)", () => { + const summary = rankCandidateIssuesWithSummary( + [ + rawIssue({ repo: "widgets", repoFullName: "acme/widgets", issueNumber: 1 }), + rawIssue({ repo: "gadgets", repoFullName: "acme/gadgets", issueNumber: 2 }), + ], + { + nowMs: NOW, + // Only acme/widgets has a per-tenant spec supplied+applied; acme/gadgets falls back to the default. + goalSpecContentByRepo: { "acme/widgets": "minerEnabled: true\npreferredLabels: [help wanted]\n" }, + }, + ); + // Both repos are ranked and one genuinely used a supplied spec, so the batch is NOT "all default" — + // the blanket "no per-tenant .loopover-miner.yml supplied" note must NOT fire. Before #7226 this was `true`. + expect(summary.issues).toHaveLength(2); + expect(summary.usedDefaultGoalSpec).toBe(false); + }); + it("raises dupRisk when repo-level contention inputs are provided", () => { const calm = rankCandidateIssues([rawIssue()], { nowMs: NOW, highRiskDuplicateClusters: 0, openPullRequests: 4 }); const busy = rankCandidateIssues([rawIssue()], { nowMs: NOW, highRiskDuplicateClusters: 4, openPullRequests: 4 });