fix(repoanalysis): only claim test coverage for files we actually probed #87
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/test-coverage-overclaim"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
RepoHasTests was derived as
len(UntestedFiles) < len(sources), andFormat only reached that branch when UntestedFiles was empty. Files that
findUntestedFiles skips — non-code, or a language with no convention in
testFileCandidates — landed in neither the numerator nor the denominator,
so a PR touching only Terraform, Rust, or Markdown made zero HEAD probes
and still told the model "Changed files appear to have test coverage".
Split the probe into explicit tested/untested lists so unprobed files are
represented as unknown rather than tested, and drop the bullet entirely
when nothing was probed. Also reword the surviving claim: what we verify
is that a matching test file exists on the head branch, which is not the
same as the change being covered.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Automated review by pr-reviewer v0.41.3 | Safety Check | Claude Sonnet 5 | tracking id
r-67f741-269b21This is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: LGTM — Bug-fix PR is logically sound, appropriately tested, and introduces no security or stability concerns.
This is a straightforward, well-scoped fix. The change correctly addresses the described bug: previously
RepoHasTestswas inferred aslen(UntestedFiles) < len(sources), which silently treated unprobed files (non-code, or languages without a test convention) as "tested" simply because they weren't in the untested list. The fix replaces this with explicitTestedFiles/UntestedFileslists, only emitting the test-coverage claim when something was actually probed, and softens the wording to reflect that file existence isn't proof of coverage.The logic change in
probeTestFiles(formerlyfindUntestedFiles) looks correct — files skipped viaisNonCodeor lackingtestFileCandidatesnow land in neither list, which is the intended behavior. TheFormatswitch was updated to checklen(r.TestedFiles) > 0instead of the oldRepoHasTestsfield, consistent with the struct change.Tests were added for both the new "no claim when nothing probed" case and the reworded output, which is good given the bug was subtle and behavior-order dependent (silent success case).
No secrets, no unsafe injected input into HEAD requests (paths are file paths, not raw user text executed anywhere), and no breaking API changes beyond an internal struct field rename (
RepoHasTests→TestedFiles), which is safe since this is an internal type.Nothing here looks alarming or accidentally committed.