Skip to content

fix(coverage): dedupe the per-test map before its row cap and cut whole tests - #4331

Merged
swati510 merged 2 commits into
mainfrom
fix/coverage-map-cap-after-dedupe
Oct 21, 2026
Merged

swati510 merged 2 commits into
mainfrom
fix/coverage-map-cap-after-dedupe

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

save_test_coverage sliced the records at the 250k cap before deduping. At the cap, later tests and files vanished in report order, a test could be cut part way and still look measured, and coverage add counted duplicates and cut rows together.

  • cap_test_map (pure) merges a repeated (test, file) pair before the cap, unioning its lines. It then keeps whole tests in a stable order (test file, then test id). The test that reaches the cap is kept whole, and every later test is left out whole.
  • Truncation stays visible. A truncated map therefore stores at least the cap's rows, so the shared map_is_truncated check keeps firing and test selection runs every test.
  • Readers. The missing-test signal and test impact now use the same truncation check as test selection. On a truncated map, a file's missing tests are unknown, never untested.
  • Write path and output. The write is one bulk delete plus batched bulk inserts. coverage add reports merged records and the tests left out.

Stacked on #4328.

Verification

  • Unit tests:
    • dedupe before the cap;
    • whole-test cuts independent of input order;
    • union merge;
    • a truncated save reading as truncated;
    • truncated-map readers returning unknown;
    • the CLI output.
  • A 250k-pair map saves in 8.7 s instead of 24.5 s (median of 3, temp SQLite).
  • tests/unit/{persistence,analysis,server/mcp} plus the coverage and impacted-tests CLI tests: 9,029 passed.
  • ruff check clean.

@repowise-bot

repowise-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🔍 2 things to check

  1. This PR introduces 2 new findings across 1 file: 1× complex method, 1× io in loop (see all)
  2. packages/core/src/repowise/core/analysis/health/coverage/discovery.py changed in 11 of the 20 commits that touched packages/cli/src/repowise/cli/commands/coverage_cmd.py and is not in this PR

⚠️ Health of changed files: 5.5 → 5.4 (-0.1; structure -0.1)
Average full file score (structure and history) of 9 changed code files, weighted by size before this PR; not the repository score.

Check Result
Coverage 95.4% of 66 changed lines covered · 3 uncovered in 2 files
Tests 3 of 3 changed code files reached by a test · which tests
Security No new findings on changed lines
Doc drift No drift in docs this PR edits
Coverage: 3 uncovered changed lines

Patch coverage 95.4% (63 of 66 changed executable lines covered)

2717897 · cobertura · 5 of 9 changed files measured, 4 out of scope

File Uncovered changed lines Covered
packages/cli/src/repowise/cli/commands/coverage_cmd.py 345-346 3 of 5
packages/core/src/repowise/core/persistence/crud/analysis/coverage_map.py 67 46 of 47

Report from this run for 2717897.

🧾 Evidence: 1 to look at, 6 not known
Item Status Evidence
Components touched ok · inferred 2 components: packages, tests
Declared owners ok · declared @RaghavChamadiya, @swati510
Suggested reviewers unknown · not known Not known: not gathered on a pull request
Tests reaching the change unknown · not known 0 of 3 changed files reached by a test; 3 not known
Contracts touched ok · measured No workspace contract touched; no breaking signature change
Consumers in other repos unknown · not known Not known: not gathered on a pull request
Decisions crossed unknown · not known Not known: decision records are read only for an AI review
Health delta look · measured Findings: 2 introduced, 0 worsened, 0 resolved
AI provenance unknown · not known Provenance: unknown, known for 0 of 2 commits; AI share withheld: coverage 0% is below 30%
Diff size rank ok · measured Larger than 52.4% of recent commits
Outcomes since merge unknown · not known Not known: a pull request is not a merged change

AI review is paused: this repository reached its monthly spending limit. Bot settings


📊 See the full report for this PR
Blast radius, every caller of the contracts it changes, and health before and after. No sign-in.
Plain markdown for agents

Settings and updates

Updated 2026-10-21 09:32 UTC, since the last push: health 5.5 to 5.4
Silence one PR with [skip repowise] in the title · Bot settings
⭐ Star Repowise · 📥 Install on another repo

@RaghavChamadiya
RaghavChamadiya force-pushed the fix/coverage-per-test-resolve branch from d1f13d4 to b727c23 Compare October 21, 2026 04:36
@RaghavChamadiya
RaghavChamadiya force-pushed the fix/coverage-map-cap-after-dedupe branch from 4bda75a to 73cd1f3 Compare October 21, 2026 04:36
@RaghavChamadiya
RaghavChamadiya force-pushed the fix/coverage-per-test-resolve branch from b727c23 to 9c91913 Compare October 21, 2026 05:31
@RaghavChamadiya
RaghavChamadiya force-pushed the fix/coverage-map-cap-after-dedupe branch from 73cd1f3 to 35864bc Compare October 21, 2026 05:31
@RaghavChamadiya
RaghavChamadiya force-pushed the fix/coverage-per-test-resolve branch from 9c91913 to c3b12e7 Compare October 21, 2026 08:56
@RaghavChamadiya
RaghavChamadiya force-pushed the fix/coverage-map-cap-after-dedupe branch from 35864bc to bff9dd8 Compare October 21, 2026 08:56
Base automatically changed from fix/coverage-per-test-resolve to main October 21, 2026 08:58
…le tests in a stable order

save_test_coverage sliced the records at the 250k cap before deduping, so
at the cap later tests and files vanished in whatever order the report
listed them, a test could be cut part way and still look measured, and the
CLI counted duplicates and cut rows together as "dropped".

cap_test_map (pure) merges a repeated (test, file) pair, lines unioned,
before the cap, then keeps whole tests in a stable order (test file, then
test id): the test that reaches the cap is kept whole and every later one
is left out whole. A truncated map therefore stores at least the cap's
rows, which is what tells test selection to run every test. The write is
one bulk delete and batched bulk inserts (a 250k-pair map: 24.5 s to
8.7 s), and coverage add reports merged records and the tests left out.
…st map is truncated

Test selection already ran every test once the map reached its row cap,
but the missing-test signal and test impact read the same map as complete:
a file whose covering tests were cut read as an untested change or a stale
test, and its gaps were reported.

map_is_truncated is now the one check (pair count at or past the cap,
which a whole-test cut guarantees) for test selection, the missing-test
signal and test impact. On a truncated map the missing-test signal files
an uncovered change or an unedited covering test as no data, and test
impact's coverage block degrades with per_test_coverage_map_truncated so
its gaps are withheld.
@RaghavChamadiya
RaghavChamadiya force-pushed the fix/coverage-map-cap-after-dedupe branch from bff9dd8 to 2717897 Compare October 21, 2026 09:32
@swati510
swati510 merged commit 7af371a into main Oct 21, 2026
10 checks passed
@swati510
swati510 deleted the fix/coverage-map-cap-after-dedupe branch October 21, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants