Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/signals/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { GittensorContributorSnapshot } from "../gittensor/api";
import { nowIso } from "../utils/json";
import { sanitizePublicComment } from "../queue-intelligence";
import { labelMatchesPattern, projectLinkedIssueMultiplierForPlannedSolve, type LinkedIssueMultiplierStatus } from "../scoring/preview";
import { hasLocalTestEvidence } from "./test-evidence";
import { hasLocalTestEvidence, isTestPath } from "./test-evidence";
import { isFailingCheckSummary } from "./local-branch";
import { isDuplicateClusterWinnerByClaim } from "./duplicate-winner";
import { PREFLIGHT_LIMITS } from "./preflight-limits";
Expand Down Expand Up @@ -2138,7 +2138,7 @@ export function buildRepoOutcomePatterns(args: {
};
for (const pr of outsideDecided) {
for (const bucket of new Set(pr.filePaths.map(pathBucket))) addToGroup("path", bucket, pr);
if (pr.filePaths.length > 0) addToGroup("test_evidence", pr.filePaths.some(isTestFile) ? "with_tests" : "without_tests", pr);
if (pr.filePaths.length > 0) addToGroup("test_evidence", pr.filePaths.some(isTestPath) ? "with_tests" : "without_tests", pr);
for (const label of pr.labels) addToGroup("label", label, pr);
const size = sizeBucket(pr);
if (size) addToGroup("size", size, pr);
Expand Down Expand Up @@ -2571,7 +2571,7 @@ export function buildPreflightResult(
findings.push(...issueQualityFindings(linkedIssues, issueQuality));
const changedFiles = input.changedFiles ?? [];
const tests = input.tests ?? [];
if (changedFiles.some((file) => isCodeFile(file)) && tests.length === 0 && !changedFiles.some((file) => isTestFile(file))) {
if (changedFiles.some((file) => isCodeFile(file)) && tests.length === 0 && !changedFiles.some((file) => isTestPath(file))) {
findings.push({
code: "missing_test_evidence",
severity: "warning",
Expand Down Expand Up @@ -2619,7 +2619,7 @@ export function buildLocalDiffPreflightResult(
issueQuality,
);
const codeFileCount = changedFiles.filter(isCodeFile).length;
const testFileCount = changedFiles.filter(isTestFile).length;
const testFileCount = changedFiles.filter(isTestPath).length;
/* v8 ignore next -- Sparse local-git adapters omit changed-line totals; aggregate local diff behavior covers the zero fallback. */
const changedLineCount = input.changedLineCount ?? 0;
const findings = [...base.findings];
Expand Down Expand Up @@ -2721,7 +2721,7 @@ export function buildPullRequestMaintainerPacket(args: {
? collisions.clusters.filter((cluster) => cluster.items.some((item) => item.type === "pull_request" && item.number === pr.number)).length
: 0;
const codeFiles = args.files.filter((file) => isCodeFile(file.path));
const testFiles = args.files.filter((file) => isTestFile(file.path));
const testFiles = args.files.filter((file) => isTestPath(file.path));
const additions = args.files.reduce((sum, file) => sum + file.additions, 0);
const deletions = args.files.reduce((sum, file) => sum + file.deletions, 0);
const approvalCount = args.reviews.filter((review) => review.state.toUpperCase() === "APPROVED").length;
Expand Down Expand Up @@ -5484,17 +5484,7 @@ function sanitizeOutcomeDimensionKey(key: string): string {
}

function isCodeFile(file: string): boolean {
return /\.(ts|tsx|js|jsx|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestFile(file);
}

function isTestFile(file: string): boolean {
return (
/(^|\/)(test|tests|spec|__tests__)\//i.test(file) ||
/(^|\/)src\/test\//i.test(file) ||
/(^|\/)[^/]+_test\.(go|py|rb)$/i.test(file) ||
/(^|\/)[^/]+_spec\.rb$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|js|jsx|py|rb|rs)$/i.test(file)
);
return /\.(ts|tsx|js|jsx|py|rb|rs|kt|scala|java|go|sql)$/i.test(file) && !isTestPath(file);
}

function riskRank(risk: CollisionCluster["risk"]): number {
Expand Down
15 changes: 15 additions & 0 deletions test/unit/signals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,21 @@ describe("world-class backend signals", () => {
expect(result.findings.map((finding) => finding.code)).toContain("missing_test_evidence");
});

it("preflight treats Cypress and snapshot paths as test evidence", () => {
const result = buildPreflightResult(
{
repoFullName: repo.fullName,
title: "Add Cypress login coverage",
body: "Fixes #7",
changedFiles: ["cypress/e2e/login.cy.ts", "src/auth.ts"],
},
repo,
issues,
pullRequests,
);
expect(result.findings.map((finding) => finding.code)).not.toContain("missing_test_evidence");
});

it("gates public comments to detected contributors and sanitizes comment text", () => {
const currentPr = pullRequests[0]!;
const priorPr: PullRequestRecord = {
Expand Down
Loading