Repository navigation
Description
Problem or Motivation
The test step is at its budget and often over it. CONST_CI_TEST_BUDGET_SECONDS is 300 s, and AGENTS.md rule 5 says that a check which averages more than 5 minutes is a P0 bug.
Measured on 2026-10-27 on a 16-CPU host:
- The CI cache holds 399 passing runs. The
testcheck has a median of 243 s, a p90 of 526 s and a maximum of 1435 s. - Two full gates of the same code took 5 m 3 s and 6 m 27 s while other agents ran, against 3 m 28 s on a quiet host.
- The required CI job
Tests & Coveragehas a median of 291 s on the 4-CPU runner (ADR 0014, 2026-10-24), 9 s under the budget. - The suite has 11,282 tests in 501 files. Collecting them takes 9 s in one process, and each of the 16 workers collects them.
Coverage today: fail_under = 90 in pyproject.toml. The last full run measured 92.96% (79,166 of 85,160 lines; branch coverage is not measured).
The slowest tests are not slow because they cover much. In the latest gate, 7 of the 10 slowest tests were in tests/test_architectural_invariants.py or tests/test_test_module_independence.py: six of them took 10 to 20 s in fixture setup, and one took 11 s in its call. These tests read the repository's own files. They cover almost no line of src/. tests/support/trees.py parses each file "at most once per test process", and an xdist worker is a test process, so each of the 16 workers parses the whole tree.
The owner asked for this work on 2026-10-27. AGENTS.md rule 5 lets only the owner allow a lower threshold, so this issue is that permission for the floor of 85% and for nothing else.
Proposed Solution & Architectural Design
The work is larger than one pull request, so this issue is a parent. The first step produces the data. The sub-issues, one change and one pull request each, are filed after it.
1. Measure, and report only. One full run with --durations=0 gives the time of every test for setup, call and teardown. One run with COVERAGE_CORE=ctrace --cov-context=test (the build of the coverage index) gives the lines that each test runs. For each test, compute its seconds, the lines that only it covers, and the unique lines for each second ("coverage density"). core/coverage_index.py names three limits, so the density is a lower bound for some tests, and each candidate is read by hand:
- Per-test contexts need the
ctracecore. The defaultsysmoncore of Python 3.14 does not support them. - Lines that run during import have no context.
- Lines that run in a shared fixture or a memoized helper are credited to the first test that reaches them.
2. Lower the floor to 85% and gate the changed lines. Set fail_under = 85. The step Changed-Line Coverage of ci.yml already runs diff-cover against the base branch, and it is advisory since #850. Make it fail below 90% on the lines of a pull request. A floor of 85% is 7.96 points, about 6,780 lines, below today's figure. Alone, it lets untested code in and ends the ratchet. With the gate on changed lines, the pressure stays where the change happens. Update every statement of the floor: pyproject.toml, CONTRIBUTING.md (lines 26 and 70), docs/TESTING.md (line 157), docs/ROUTINE_TASKS.md (line 186), docs/SDLC.md (line 170), the checkbox in .github/ISSUE_TEMPLATE/feature_request.yml, and src/devops_cli/ai/knowledge_base/it_domains/tools/ruff_mypy_pytest.md. Find the others with grep -rn "90" --include=*.md.
3. Remove the slow tests of least value. Take them from the ranking of step 1, under these rules:
- Never remove an invariant test, a ratchet, a contract suite, a security test, a test that pins a scenario of an OpenSpec spec, or the only test of a module. The invariant tests rank last by density because they cover no
srcline, and they are the slowest, so a ranking by density alone would remove the rules of the repository. They are targets for step 4. - Keep the total above 85% with a margin.
- Run
devops ci mutateon the modules that the removed tests covered, before and after. A line can be covered by a test that asserts nothing, so a surviving mutant shows a loss that the line count hides. - Make each removal a commit with the seconds and the unique lines in its message.
4. Find further speed-ups. Each one becomes its own issue when the data supports it:
- One parse for all workers. Build the parsed tree once for the run and share it: a session fixture on the xdist controller, or a cache file keyed by the hash of the tree. This targets the six slow setups above.
- Worker start. Measure the start and the collection of one worker, the import cost of
devops_cli, and whether fewer workers than CPUs is faster on the runner. - Coverage cost. Time the suite with and without
--cov, withsysmonand withctrace, and the combine step ofparallel = true. - Shards. Split the suite by recorded duration across runners (
pytest-split) and combine the coverage, or give the invariants a job of their own. - Hypothesis. List the slowest property tests and check the
ciprofile. - Processes. Count the tests that start a real process (git,
uv) and the time they spend, against the fakes ofdocs/TESTING.md.
Acceptance: fail_under = 85 and the changed-line gate at 90%; every removal justified with numbers; the Tests & Coverage job median at or below 240 s (80% of the budget) on the runner; the test step of a full local run at or below 240 s on a quiet 16-CPU host.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
diff-coveris a dev dependency already (10.6.0), and CI runs it. The change uses it as the gate on changed lines and builds nothing.coverage.pydynamic contexts (--cov-context=test) give the lines of each test. The repository's coverage index already reads them.pytest --durations=0gives the time of each test.pytest-xdistis in use (--dist worksteal).pytest-splitshards by recorded duration and is a candidate for step 4.pytest-testmonselects tests by changed code. It answers a different question than the cost of the full run, and the project has its own selection for narrowed runs.mutmutis in use throughdevops ci mutate. It measures the value of a test better than a line count.- Cost of building, as an estimate: about 60,000 tokens and half a day for the measuring script of step 1, which joins two reports with the standard library. The rest is configuration and deletion.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 27, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The title prefix is perf, which maps to type/infra, and the goal is to reduce CI test time below its budget.The test step is at or over its 300 s budget and the owner explicitly requested this work on 2026-10-27.Every contributor waits on the test step, and over-budget runs block merges and waste runner time.The body states it is a parent issue with at least four sub-steps, a full measurement run, configuration edits across seven files, and test removal with mutation checks.Both items change the fail_under setting, but #2163 raises it to the measured total while the candidate lowers it to 85%.dan-petty commentedon Oct 27, 2026
Decision of the owner, 2026-10-27: the direction of this issue wins for the coverage floor. The floor goes down to 85%, and the changed lines are gated.
fail_underto the measured total. I edited ci(coverage): Enable branch coverage and upload coverage xml as artifact #2163: the rise is struck through and the title no longer names it. Its branch measurement and its coverage artifact stay.docs(openspec): plan #2163 enable branch coverage and upload xml (#2980)
docs(openspec): plan #2163 measure branches and keep the coverage xml (…
perf(ci): measure coverage and branch cost (#4163)