From 9fb7217ffd75a74d3978160ba73305b8e336cf43 Mon Sep 17 00:00:00 2001 From: joaovictor91123 Date: Sun, 26 Jul 2026 06:42:48 -0700 Subject: [PATCH] fix(services): warn when contributor evidence-graph outcomes are capped Match the repos/labels/paths pattern so callers see when outcome relationships are truncated at CONTRIBUTOR_EVIDENCE_GRAPH_MAX_OUTCOMES. Closes #8887 --- src/services/contributor-evidence-graph.ts | 1 + test/unit/contributor-evidence-graph.test.ts | 25 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/services/contributor-evidence-graph.ts b/src/services/contributor-evidence-graph.ts index 44db6b209f..7ea7ea3a38 100644 --- a/src/services/contributor-evidence-graph.ts +++ b/src/services/contributor-evidence-graph.ts @@ -270,6 +270,7 @@ export function buildContributorEvidenceGraph(args: ContributorEvidenceGraphInpu ...(reposCapped ? [`Evidence graph repo relationships capped at ${CONTRIBUTOR_EVIDENCE_GRAPH_MAX_REPOS}.`] : []), ...(labels.length < allLabels.length ? [`Evidence graph label relationships capped at ${CONTRIBUTOR_EVIDENCE_GRAPH_MAX_LABELS}.`] : []), ...(paths.length < allPaths.length ? [`Evidence graph path relationships capped at ${CONTRIBUTOR_EVIDENCE_GRAPH_MAX_PATHS}.`] : []), + ...(outcomes.length < allOutcomes.length ? [`Evidence graph outcome relationships capped at ${CONTRIBUTOR_EVIDENCE_GRAPH_MAX_OUTCOMES}.`] : []), ]; const sources = buildSources(generatedAt, args.profile, args.gittensorSnapshot, repoNodes, labels, paths, outcomes); diff --git a/test/unit/contributor-evidence-graph.test.ts b/test/unit/contributor-evidence-graph.test.ts index 10c3f96abe..130b6d6845 100644 --- a/test/unit/contributor-evidence-graph.test.ts +++ b/test/unit/contributor-evidence-graph.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest"; import { buildContributorEvidenceGraph, CONTRIBUTOR_EVIDENCE_GRAPH_MAX_LABELS, + CONTRIBUTOR_EVIDENCE_GRAPH_MAX_OUTCOMES, CONTRIBUTOR_EVIDENCE_GRAPH_MAX_PATHS, CONTRIBUTOR_EVIDENCE_GRAPH_MAX_REPOS, evidenceGraphTouchedRepoFullNames, @@ -475,6 +476,30 @@ describe("contributor evidence graph", () => { ); }); + it("warns when outcome relationships exceed the max-outcomes cap (#8887)", () => { + const repoFullName = "owner/outcomes-cap"; + // Multiple outcome rows for one included repo — buildOutcomeEdges does not dedupe by repo, so the + // outcomes slice can exceed MAX_OUTCOMES even when repos stay under MAX_REPOS. + const manyOutcomes = Array.from({ length: CONTRIBUTOR_EVIDENCE_GRAPH_MAX_OUTCOMES + 1 }, (_, index) => + outcome(repoFullName, { pullRequests: index + 1, openPullRequests: 1, lane: index % 2 === 0 ? "direct_pr" : "issue_linked" }), + ); + const graph = buildContributorEvidenceGraph({ + login: "dev", + generatedAt: GENERATED_AT, + profile: profile({ + registeredRepoActivity: { pullRequests: 1, mergedPullRequests: 0, issues: 0, reposTouched: [repoFullName], dominantLabels: [] }, + }), + outcomeHistory: history(manyOutcomes), + roleContexts: [role(repoFullName)], + repositories: [repo(repoFullName)], + pullRequests: [pr(repoFullName, 1)], + pullRequestFiles: [], + }); + + expect(graph.outcomes).toHaveLength(CONTRIBUTOR_EVIDENCE_GRAPH_MAX_OUTCOMES); + expect(graph.warnings).toEqual(expect.arrayContaining([expect.stringContaining("outcome relationships capped")])); + }); + it("selects only registered touched repos for bounded path-cache loading", () => { expect( evidenceGraphTouchedRepoFullNames({