Skip to content

pr_gates: affected gate -- run the test files a branch can break, importers included (#6733) - #6736

Merged
squid-protocol merged 3 commits into
mainfrom
affected-gate-6733
Oct 26, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
affected-gate-6733

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #6733.

Why. A PR breaking other existing tests is the send-back cause that jumps with PR size. In the churn fix runs from 10-18 to 10-26 it went from 1.2 per 100 PRs at 1-2 hand-written files to 17.7 at 5. A PR's own tests failing stayed flat at 2-5. Workers test what they wrote, and CI finds the rest one push later.

What. New tests/tools/affected_tests.py and an affected gate in pr_gates.py, also in --fast, so churn's precheck runs it.

Selection:

  • an ast import graph over tests/ and gitgalaxy/ (about 6 s): gitgalaxy.* imports (relative ones too), bare imports of tests/tools modules and per-directory harnesses, and string constants naming a .py tool (subprocess runs)
  • the readers of changed docs, from docs_read_by_tests.txt
  • the .py files that name any other changed file: a workflow by its unique file name, a case's case.json / seed.sql by the case directory, a runtime's .java / .c source
  • a changed conftest.py selects the tests under it

Running: nearest first (distance 0 = a test the branch changed, 1 = a direct importer, ...), then cheapest by .test_durations, within --budget 300 s. Whatever is left is named as "left to CI", never skipped silently. --list prints the selection without running anything.

Replay on the 30 code-collateral churn fix runs of 10-19..25. A culprit is a test file that the fix commit changed and the fix run's report names. Of 22 culprits, 20 were in the within-budget selection, 1 was selected but over budget, and 1 was missed: #6101's test_cbsa_generated_siblings.py globs every case directory, so no static scan can see it.

I ran the gate itself on two broken heads:

Those are the tests their fixes changed, and the culprits pass on the fixed heads. (The replay copied the tool in as an untracked file, which made docs_read_by_tests.txt look stale there; that check aside, both fixed heads are green.)

It also caught its own branch. A first draft held the literals docs/ and .claude/, which made the classifier think this tool reads every doc. The gate's first run on this branch failed 10 classifier and plan tests. They're fixed here, and docs_read_by_tests.txt gains only the true .test_durations reader.

Checks: test_affected_tests.py (9 tests). pr_gates --only lint audits affected passes (affected: 219 s on this branch). Placed beside golden so it doesn't touch #6734's derived entry.

Related: #6731 / #6734 (stale derived files), #6735 (main-wide durations fix).

🤖 Generated with Claude Code

squid-protocol and others added 3 commits October 26, 2026 10:20
…mporters included (#6733)

tests/tools/affected_tests.py selects every test file whose imports reach a changed .py file (an ast scan of tests/ and
gitgalaxy/: gitgalaxy.* imports, bare tests/tools and harness imports, strings naming a .py tool), the readers of
changed docs (docs_read_by_tests.txt) and the .py files that name any other changed file (a workflow, a case's data, a
runtime source), then runs them nearest first within a 300 s budget (.test_durations) and names what it leaves to CI.
In --fast, so churn's precheck runs it. Replayed on 30 churn collateral-break fix runs of 10-19..25: 20 of the 22
culprit tests the fix reports name were in the within-budget selection, 1 over budget, 1 missed (a glob over every
case); run on #6561 and #6495's broken heads it fails on the culprit test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…3813; test_source_reads)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@squid-protocol
squid-protocol merged commit 185ffa0 into main Oct 26, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the affected-gate-6733 branch October 26, 2026 15:53
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.

pr_gates --fast: run the tests a diff can break (importers + change classifier), not just lint/audits

1 participant