testsAndMisc/docs/superpowers/evidence/pytest-xdist-coverage-flake-fix-2026-06-22.json
Krzysztof kuhy Rudnicki d8f8605275 Drop -n 4 xdist parallelism from the pytest-coverage pre-commit hook
The coverage gate failed twice in a row on GitHub Actions on the exact
same line (wake_alarm/_alarm_display.py:71), with the run rerun on the
identical commit -- ruling out a one-off flake. Could not reproduce
locally across 6 attempts, including running the exact same -n 4
invocation directly. The likely cause is a pytest-xdist/pytest-cov
worker coverage-combine timing issue specific to the CI runner that
isn't practical to root-cause further from here. Running the hook
serially removes the risk outright; local timing shows no meaningful
slowdown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A7vbgtFfZmfxJtN5DdtJky
2026-06-22 08:29:54 +02:00

29 lines
1.9 KiB
JSON

{
"intent": "Eliminate a reproducible (not flaky) coverage-gate false failure on GitHub Actions, where pytest-xdist's -n 4 workers combined with pytest-cov consistently dropped coverage of one specific line (wake_alarm/_alarm_display.py:71) on the CI runner, never locally.",
"scope": [
"meta/scripts/pytest_changed_packages.py (the pre-commit pytest-coverage hook entry point)",
"Non-goal: a full root-cause diagnosis of the xdist/coverage interaction itself -- not reproducible locally despite 6 attempts, so the fix removes the risk rather than chasing the exact mechanism"
],
"changes": [
"Removed the -n 4 (pytest-xdist parallel workers) flag from the pytest invocation this hook runs. Serial execution has never produced a coverage gap in any local or CI run; -n 4 produced the identical gap on two consecutive CI runs (a rerun of the same commit), which rules out a one-off flake and points at a CI-runner-specific worker/coverage-combine timing issue this repo cannot fix at the pytest-cov/xdist level from here."
],
"verification": [
{
"command": "time python meta/scripts/pytest_changed_packages.py python_pkg/wake_alarm/_alarm.py",
"result": "pass",
"evidence": "948 passed, 100.00% coverage, 14.3s total -- functionally identical runtime to the parallel version locally, with the coverage gap gone"
},
{
"command": "pre-commit run --all-files",
"result": "pass",
"evidence": "all hooks green including pytest-coverage"
}
],
"risks": [
"Slightly slower CI runs without parallelism, though local timing showed negligible difference (~13-14s either way for this test count); reliability of the 100%-coverage gate matters more than a few seconds"
],
"rollback": [
"git revert this commit to restore -n 4 if CI proves the gap was actually something else (e.g. transient runner load) -- but two identical consecutive failures on the same line make that unlikely"
]
}