Skip to content

Commit f034f00

Browse files
feat(enrichment): add changed-line coverage-delta analyzer
Adds a coverageDelta REES analyzer that flags added lines a PR introduces which the repo's own latest successful CI coverage report records as executed zero times, parsed from the head commit's GitHub Actions coverage artifact (lcov / Istanbul coverage-final.json / Cobertura XML) and intersected with the patch's added lines. Additive and fail-safe: any missing token, absent artifact, unparseable report, or fetch error yields no finding rather than a false one. Self-contained in review-enrichment/. Closes #1516
1 parent a151d8a commit f034f00

10 files changed

Lines changed: 769 additions & 1 deletion

File tree

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ GITTENSORY_REVIEW_ENRICHMENT=false
7070
# pendingReviewRequests,testRatio,migrationSafety,looseRange,terminology,todoMarker,magicNumber
7171
# conflictMarker,debugLeftover,sizeSmell,floatingPromise,deepNesting,errorSwallow,unsafeAny,a11y
7272
# i18n,unusedExport,exhaustiveness,flakyTest,commitLint,apiBreak,deprecatedDep,revertRecurrence
73+
# coverageDelta
7374
#
7475
# Profile defaults:
7576
# fast: dependency,dependencyDiff,lockfileDrift,secret,license,installScript,heavyDependency
@@ -84,14 +85,15 @@ GITTENSORY_REVIEW_ENRICHMENT=false
8485
# commitHygiene,pendingReviewRequests,testRatio,migrationSafety,looseRange,terminology
8586
# todoMarker,magicNumber,conflictMarker,debugLeftover,sizeSmell,floatingPromise,deepNesting
8687
# errorSwallow,unsafeAny,a11y,i18n,unusedExport,exhaustiveness,flakyTest,commitLint,apiBreak
87-
# deprecatedDep,revertRecurrence
88+
# deprecatedDep,revertRecurrence,coverageDelta
8889
# deep: dependency,dependencyDiff,lockfileDrift,secret,license,installScript,heavyDependency
8990
# hardcodedUrl,actionPin,eol,redos,provenance,codeowners,secretLog,assetWeight,typosquat
9091
# commitSignature,iacMisconfig,nativeBuild,history,docCommentDrift,duplication,churnHotspot
9192
# blameLink,approvalIntegrity,ciCheckSignals,undocumentedExport,staleBranch,commitHygiene
9293
# pendingReviewRequests,testRatio,migrationSafety,looseRange,terminology,todoMarker,magicNumber
9394
# conflictMarker,debugLeftover,sizeSmell,floatingPromise,deepNesting,errorSwallow,unsafeAny,a11y
9495
# i18n,unusedExport,exhaustiveness,flakyTest,commitLint,apiBreak,deprecatedDep,revertRecurrence
96+
# coverageDelta
9597
# END GENERATED REES ANALYZERS
9698

9799
# Submitter-reputation spend control (internal-only): downgrades new/burst/low-rep

apps/gittensory-ui/src/lib/rees-analyzers.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,32 @@ export const REES_ANALYZERS = [
12951295
"Conservative: only a message-confirmed revert commit whose removed range overlaps an added range is reported (one finding per file); line-range overlap is a heuristic across history, and lockfiles/generated/binary paths are skipped. Fail-safe on missing token/invalid slug/fetch error or an aborted signal.",
12961296
},
12971297
},
1298+
{
1299+
name: "coverageDelta",
1300+
title: "Coverage gaps on changed lines",
1301+
category: "quality",
1302+
cost: "github-heavy",
1303+
defaultEnabled: true,
1304+
profiles: ["balanced", "deep"],
1305+
requires: ["files", "github-token", "head-sha"],
1306+
limits: {
1307+
maxRunsProbed: 5,
1308+
maxFilesReported: 15,
1309+
maxLinesPerFile: 20,
1310+
},
1311+
docs: {
1312+
summary:
1313+
"Flags added lines in a PR that the project's own latest successful CI coverage report records as never executed — measured test gaps on exactly the touched lines, not a guess about whether tests look present.",
1314+
looksAt:
1315+
"The PR's added new-file line numbers, intersected with the zero-hit lines parsed from the coverage artifact (lcov, Istanbul coverage-final.json, or Cobertura XML) of the head commit's most recent successful workflow run.",
1316+
reports:
1317+
"Each changed file and the specific added line numbers with no test coverage — never file contents.",
1318+
network:
1319+
"Calls the GitHub Actions runs and artifacts APIs and downloads one coverage artifact zip, each bounded by fixed fanout and byte caps. Requires GitHub token forwarding.",
1320+
notes:
1321+
"Conservative and fail-safe: only an added line the report explicitly marks zero-hit is flagged, so a missing token, absent artifact, unparseable report, or fetch error yields no finding rather than a false one. Bounded by run, file, and line caps.",
1322+
},
1323+
},
12981324
] as const satisfies readonly ReesAnalyzerDoc[];
12991325

13001326
export const REES_ANALYZER_NAMES = REES_ANALYZERS.map((analyzer) => analyzer.name);

review-enrichment/analyzer-metadata.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,34 @@
14551455
"network": "Calls the GitHub commits API per probed file and the single-commit API per revert commit, both bounded by fixed fanout caps. Requires GitHub token forwarding for private repos.",
14561456
"notes": "Conservative: only a message-confirmed revert commit whose removed range overlaps an added range is reported (one finding per file); line-range overlap is a heuristic across history, and lockfiles/generated/binary paths are skipped. Fail-safe on missing token/invalid slug/fetch error or an aborted signal."
14571457
}
1458+
},
1459+
{
1460+
"name": "coverageDelta",
1461+
"title": "Coverage gaps on changed lines",
1462+
"category": "quality",
1463+
"cost": "github-heavy",
1464+
"defaultEnabled": true,
1465+
"profiles": [
1466+
"balanced",
1467+
"deep"
1468+
],
1469+
"requires": [
1470+
"files",
1471+
"github-token",
1472+
"head-sha"
1473+
],
1474+
"limits": {
1475+
"maxRunsProbed": 5,
1476+
"maxFilesReported": 15,
1477+
"maxLinesPerFile": 20
1478+
},
1479+
"docs": {
1480+
"summary": "Flags added lines in a PR that the project's own latest successful CI coverage report records as never executed — measured test gaps on exactly the touched lines, not a guess about whether tests look present.",
1481+
"looksAt": "The PR's added new-file line numbers, intersected with the zero-hit lines parsed from the coverage artifact (lcov, Istanbul coverage-final.json, or Cobertura XML) of the head commit's most recent successful workflow run.",
1482+
"reports": "Each changed file and the specific added line numbers with no test coverage — never file contents.",
1483+
"network": "Calls the GitHub Actions runs and artifacts APIs and downloads one coverage artifact zip, each bounded by fixed fanout and byte caps. Requires GitHub token forwarding.",
1484+
"notes": "Conservative and fail-safe: only an added line the report explicitly marks zero-hit is flagged, so a missing token, absent artifact, unparseable report, or fetch error yields no finding rather than a false one. Bounded by run, file, and line caps."
1485+
}
14581486
}
14591487
]
14601488
}

0 commit comments

Comments
 (0)