Skip to content

Leave untested changed sources out of Quick Feedback coverage - #9778

Merged
MaxGhenis merged 3 commits into
mainfrom
selective-coverage-narrowed
Oct 6, 2026
Merged

MaxGhenis merged 3 commits into
mainfrom
selective-coverage-narrowed

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Quick Feedback measures coverage only for changed source files whose tests actually run in that job. A changed .py file is left out of coverage when it maps to test targets and none of them are in the run, because the job deferred them or narrowed them away. Files with no mapped tests are measured as before.

Why

limit_test_paths drops a changed file's tests in two ways:

  • Narrowing: when a change maps to more than SELECTIVE_TEST_MAX_TARGETS targets or SELECTIVE_TEST_MAX_FILES test files, it runs only the directly changed tests.
  • Deferral: it always defers slow directories (gov/ssa, household, reform, microsimulation, contrib/congress) to the full suite.

run_tests still passed every changed non-test .py file to coverage run --include. The report then counted those files' formula bodies as uncovered, and Codecov scored the PR's project coverage from that report alone.

Observed:

Change

  • New SelectiveTestRunner.get_untested_sources(source_files, test_paths) returns the source files whose map_files_to_tests({file}) is non-empty and shares no target with the run.
  • run_tests drops those files from --include and lists them. When none are left, it runs without coverage, so coverage xml writes nothing, has_coverage=false skips the Codecov upload, and Codecov posts no project status. That is already what happens today for changes with no Python source and for runs deferred entirely.

The whole selector is unchanged when no targets are dropped.

Replaying the real changed-file lists through the new code, with the CI limits of 25 targets and 100 files:

PR changed .py sources targets run coverage commands
#9766 26 1 0 (all 26 left out)
#9764 15 1 0
#9769 59 2 0

Invariant

A changed source is in the coverage --include list exactly when one of these holds:

  • it maps to no test targets, or
  • at least one of its mapped targets is in the run.

Four tests in policyengine_us/tests/core/test_run_selective_tests.py:

  • a narrowed run issues no coverage command;
  • a deferred gov/ssa source drops out while the gov/irs source whose tests run stays in;
  • a source with running tests and an unmapped source both stay in, as today;
  • a direct check of get_untested_sources.

On upstream/main's selector, the first, second and fourth fail on their assertions and the third passes. Locally the file has 18 passed.

Microsimulation impact

None. The PR changes only CI test selection (policyengine_us/tests/run_selective_tests.py and its tests). No variable, parameter or dataset changes, so no model output can change. Its effect is on which changed files the Quick Feedback job counts for coverage.

axiom: n/a: CI test-selection infrastructure

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits October 3, 2026 16:34
When a change maps to too many test targets, limit_test_paths narrows
the run to the directly changed tests. run_tests still passed every
changed .py file to coverage --include, so the uploaded report counted
lines in those files that the narrowed tests never exercise. On the
reference-only PRs #9764 and #9766 that sent codecov/project to 54% and
69% while codecov/patch was 100%.

A narrowed run now skips coverage, like the existing path for changes
with no Python source. Codecov then gets no partial report and posts
no project status, matching PRs that Quick Feedback defers entirely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Narrowing is one of two ways Quick Feedback drops a changed file's
tests; deferring slow directories (gov/ssa, household, reform, ...) is
the other, and it produced the same partial report. Replace the
narrowed-scope flag with a per-file rule: a changed source is measured
unless it maps to tests and none of them are in this run. Files with
no mapped tests keep today's behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis changed the title Skip Quick Feedback coverage when the test scope is narrowed Leave untested changed sources out of Quick Feedback coverage Oct 3, 2026
@MaxGhenis
MaxGhenis merged commit a4b7b16 into main Oct 6, 2026
35 checks passed
@MaxGhenis
MaxGhenis deleted the selective-coverage-narrowed branch October 6, 2026 02:34
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Merged by the US + core hub on its merge gates. Audit:

  • Head: 31d73fac0b24b1eb3c0ab9677029ed8e91d5e6ff.
  • Independent review: ~/reviews/dead-reference-urls-2026-09-30/outputs/review-9778-hard.md approved head e905bdb4db with no blockers and one wording nit. The only commit since is a merge of main (31d73fac0b). The hub confirmed the PR's own diff is identical before and after that merge (3 files, +151/−2), and that it merges cleanly with current main.
  • CI: every check passed at this head.
  • Impact: CI test selection only, so no model output changes. The hub added that statement to the body.
  • Decisions: none.

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.

1 participant