Repository navigation
Description
What happened
The coverage audit of 2026-10-24 (per-test contexts of a full run at f4d7066) found 86 test files that cover no line of src/ that another file does not also cover. 18 of them test the review and the scanners. For several, one other file covers 84-100% of the same lines. Line coverage alone cannot show that a file is redundant, because a file can cover a line and still assert something that no other file asserts. Mutation testing can show it: a file that kills no mutant that the rest of the suite leaves alive adds no check.
| File | Tests | Lines covered beyond the import baseline |
|---|---|---|
tests/ai/review/test_cited_code.py |
2 | 1716, 99% in tests/test_review_group_analysis.py |
tests/commands/test_review.py |
2 | 802, 100% in tests/test_review_adjudication.py |
tests/commands/test_review_removed_options.py |
1 | 8 |
tests/test_custom_personas.py |
3 | 21 |
tests/test_review_advisory_backing.py |
1 | 280 |
tests/test_review_deduplication.py |
4 | 377, 92% in tests/test_review_pipeline.py |
tests/test_review_defects_comments.py |
1 | 171 |
tests/test_review_defenses_and_verification.py |
7 | 631, 84% in tests/test_review_tool_runs.py |
tests/test_review_history.py |
6 | 1815, 98% in tests/test_review_group_analysis.py |
tests/test_review_location_paths.py |
5 | 153 |
tests/test_review_loop_hardening.py |
5 | 162 |
tests/test_review_regression_harness.py |
2 | 603, 94% in tests/test_review_finding_losses.py |
tests/test_review_taxonomy_and_severity.py |
7 | 163 |
tests/test_review_verification.py |
8 | 1300, 85% in tests/test_review_runner.py |
tests/test_structural_positional_oracles.py |
3 | 127 |
tests/test_security_kubelinter.py |
8 | 538, 88% in tests/test_security_sarif.py |
tests/test_security_tflint.py |
3 | 896, 92% in tests/test_security_kubeconform.py |
tests/security/test_sarif_fuzzing.py |
5 | 240 |
What should happen
Mutation runs decide, file by file, whether a file adds a check. A file that kills no mutant of its own is deleted, or its one distinct case moves into the file that covers the same lines. A file that kills a mutant of its own stays, and the pull request names the mutant.
Evidence
.data/agent/scratch/audit-coverage/unique-lines-nobaseline.jsonandsubsumption.jsonof the 2026-10-24 coverage audit (contexts of a fullpytest --cov-context=testrun at f4d7066).- Every file in the table exists at b170358.
uv run devops ci mutate --help: mutmut over the givensrc/files; the first run copies the tree and runs the suite once.
Key questions
- How is a mutant "of its own" found? (proposed) For each file, mutate the functions whose lines the file covers, once with the whole suite and once with the file left out (mutmut's
pytest_add_cli_args_test_selection,--ignore=<file>). A mutant that survives only when the file is left out is the file's own.
Acceptance criteria
- The pull request gives, for each file in the table, the mutants it killed with the whole suite and the mutants that survive without it.
- Each file with no mutant of its own is deleted, or its distinct case moves into the file that covers its lines. The line coverage and
fail_understay as they are or rise. - No contract suite, invariant test or test of a security guard is deleted by this item.
-
uv run devops cipasses, and theTests & Coveragejob takes no longer than before.
Related: #1328 owns the move of the ai/review tests onto fakes; a file this item deletes leaves that work. The 86 files also hold invariant and helper tests, which other issues of the same audit own.
Source: #1328
Alternatives check of 2026-11-06: not-applicable.
Class: test, no search.
Tool: none found.
Proposed design
Problem statement
The coverage audit of 2026-10-24 lists 18 review and scanner test files that cover no line of src/ that another file does not cover. Line coverage cannot show that a file adds no check. Mutation runs must show, file by file, whether a file kills a mutant that the rest of the suite leaves alive. The first mutation stats run does not finish today. The test-selection list names paths that no longer exist, and also_copy lacks openspec. Tests that need git tracking fail from mutants/, because that tree has no git checkout. The change repairs the run first and then reads its report.
Acceptance criteria
Requirement: Mutation copy list holds the OpenSpec tree
[tool.mutmut].also_copy in pyproject.toml MUST hold openspec, so a test that reads the OpenSpec tree runs from mutants/.
Scenario: the copy list
- WHEN a test reads
also_copyfrompyproject.toml - THEN
openspecis one of its entries.
Requirement: Mutation test selection names only paths that exist
Every path in [tool.mutmut].pytest_add_cli_args_test_selection MUST exist in the checkout, so pytest ignores or deselects the test that it names.
Scenario: a stale selection path
- WHEN a test resolves each
--ignoreand--deselectpath of the list against the repository root - THEN each path names a file or a test that exists.
Requirement: Tests that cannot run from mutants are deselected
The selection list MUST deselect each test that fails from mutants/ because it needs git tracking or reaches a host path without a fake, and a comment MUST give the reason.
Scenario: a git-dependent test
- WHEN the stats run starts from
mutants/with no git checkout - THEN no test fails with the message 'host path reached without a fake' and the stats run ends with no failed test.
Requirement: The first mutation stats run completes
uv run devops ci mutate MUST finish its first stats run from mutants/ and report its survivors.
Scenario: a clean mutation run
- WHEN a person runs
uv run devops ci mutate src/devops_cli/ai/review/cited_code.pywith nomutants/directory - THEN the command exits 0 and its report lists the surviving mutants.
Requirement: The change records the mutants of each file
The design.md of the change MUST hold one row for each of the 18 files, with the mutants that it kills and the mutants that survive without it.
Scenario: the record of the runs
- WHEN a reader counts the rows of the mutation table in the
design.mdof the change - THEN the table holds one row for each of the 18 files of the issue.
Requirement: A file with no mutant of its own leaves the suite
A file that kills no mutant that the rest of the suite leaves alive MUST leave tests/, or its one distinct case MUST move into the file that covers its lines, unless it holds a contract, an invariant or a security-guard test.
Scenario: a redundant file
- WHEN the table marks a file as killing no mutant of its own
- THEN the file is absent from
tests/, or its row names the contract, invariant or security-guard test that keeps it.
Requirement: A file with a mutant of its own stays
A file that kills a mutant that the rest of the suite leaves alive MUST stay in tests/, and its row MUST name that mutant.
Scenario: a file with its own mutant
- WHEN the table names a mutant that only one file kills
- THEN that file is present in
tests/.
Requirement: No contract, invariant or security-guard test is deleted
The change MUST NOT delete a contract suite, an invariant test or a test of a security guard.
Scenario: a guard with no mutant of its own
- WHEN the table marks
tests/security/test_sarif_fuzzing.pyas killing no mutant of its own - THEN the file stays in
tests/and its row names the guard that it holds.
Requirement: The coverage floor holds
fail_under MUST stay at 85, and the covered lines of src/ MUST NOT fall below their count at the base commit.
Scenario: the coverage report
- WHEN
uv run devops ciruns the suite and the coverage report - THEN the report passes
fail_underand its covered line count is at least the base count.
Requirement: The required check passes in its old time
uv run devops ci MUST pass, and the Tests & Coverage job MUST NOT run longer than it ran at the base commit.
Scenario: the required check
- WHEN the pull request runs
Tests & Coverage - THEN the job succeeds and its duration is not greater than the base duration.
Existing Tool Considered
mutmut 3.8.0 is the open, maintained mutation tool that covers the need. It is pinned in the dev group of pyproject.toml and run by uv run devops ci mutate. It generates mutants over src/ and reports survivors. It lacks a per-file attribution of killed mutants, so the change runs it twice for each file, with PYTEST_ADDOPTS=--ignore=<file> in the second run. The alternatives check gave not-applicable for the class test and found no tool. The change writes no mutation code. It repairs the settings of the run and reads its report.
Key questions
- How does the change find the mutants that only one test file kills?: Run mutmut over the
src/functions whose lines the file covers, once with the full suite and once withPYTEST_ADDOPTS=--ignore=<file>. A mutant that survives only in the second run is the file's own. (best practice) [sources: pyproject.toml, openspec/changes/2162-mutation-runs-decide-which-of-the/design.md]- Chosen: Second run with PYTEST_ADDOPTS. The variable is not part of the mutmut config fingerprint, so cached test stats stay valid.
- Rejected: Edit the selection list in pyproject.toml for each file. mutmut hashes that list, so each edit forces a new serial run of the whole suite.
- Rejected: Read the line coverage subsumption alone. A covered line cannot show that a file misses an assertion that another file makes.
- Do the paths in the mutation test-selection list exist today?: No. The list names
tests/test_architectural_invariants.py, and the module now lives attests/invariants/test_architectural_invariants.py. Pytest ignores a missing path, so the module still runs frommutants/and fails. [sources: pyproject.toml, tests/invariants/test_architectural_invariants.py] - What repairs the first stats run, which fails on tests that touch git?: Name the current paths in
pytest_add_cli_args_test_selection, addopenspectoalso_copy, and deselect each test that fails frommutants/for lack of git tracking or a host-path fake, with a comment that gives the reason. The reply on the issue namestests/ai/mcp/test_mcp_roadmap_tools.pyandtests/ai/agents/test_embedding_config_retention.pyas failing tests. (best practice) [sources: pyproject.toml, tests/invariants/test_change_folders.py]- Chosen: Update the selection paths and the copy list, and deselect the failing tests. The pyproject.toml comment already states this rule for tests that rely on git tracking. The run then completes and keeps the mutation tree small.
- Rejected: Copy the whole checkout into mutants/. The tree is 475 MB, and the copy would still hold no git tracking.
- Rejected: Make the failing tests skip when a tree is absent. A skip inside the test hides a broken mutation run.
- Does a file with no mutant of its own lose its one distinct case?: No. Move that case into the file that covers the same lines, then delete the file. Keep the whole file when it holds a contract, an invariant or a security-guard test. (best practice) [sources: docs/adr/0007-tests-double-only-process-edges.md]
- Chosen: Move the one distinct case, then delete the file. The suite keeps the assertion and loses the duplicate.
- Rejected: Delete the file with every case. The suite loses an assertion that no other file makes.
- Rejected: Keep the file. The file adds no mutant kill and keeps its run time cost.
- Which rule wins when a security or contract test kills no mutant of its own?: The protection rule wins. The file stays, and its row names the test and the requirement that it guards. (best practice) [sources: openspec/specs/scanner-adapters/spec.md, tests/security/test_sarif_fuzzing.py, docs/adr/0004-ci-is-the-authoritative-gate.md]
- Chosen: The protection rule wins. The acceptance criteria of the issue forbid the deletion of a guard test.
- Rejected: The mutation result wins. The project would lose a guard that a spec requires.
- Where does the change record the mutation evidence?: In the
design.mdof the change, as one row for each file, with the mutants that it kills and the mutants that survive without it. (best practice) [sources: CONTEXT.md]- Chosen: The design.md of the change. The change folder is the record of the item and stays on the default branch.
- Rejected: The pull request body. The squash merge keeps no searchable record of it.
- Rejected: A new report file under docs/. It adds an artifact that no reader maintains.
- Does the coverage floor change?: No.
fail_understays at 85, and the covered lines ofsrc/do not fall. (best practice) [sources: pyproject.toml, CONTRIBUTING.md]- Chosen: Keep the floor and the covered lines. The gate stays as strict as before the cleanup.
- Rejected: Lower fail_under to admit the deletions. It weakens the gate that ADR 0004 makes authoritative.
Fit
Needs splitting into 7 items:
- test(ci): make the mutation run complete its first stats run, with the current test-selection paths, the
openspeccopy entry and the deselected git-dependent tests - test(review): mutation cleanup of cited code, review command, and removed options
- test(review): mutation cleanup of custom personas, advisory backing, and deduplication
- test(review): mutation cleanup of defect comments, defenses, and history
- test(review): mutation cleanup of location paths, loop hardening, and regression harness
- test(review): mutation cleanup of taxonomy, verification, and structural oracles
- test(security): mutation cleanup of kubelinter, tflint, and SARIF fuzzing
Suspected block
None.
Dependencies
None.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 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 candidate proposes changes to test behavior using mutation runs.This change improves test quality and reduces redundancy but is not critical for immediate functionality.Improving test coverage and reducing redundant tests provides moderate value to the project.Mutation testing requires significant setup and analysis of test files to determine which ones add value.Both items deal with test hygiene but the candidate focuses on mutation testing to decide file deletions while item 1871 addresses tombstone tests for deleted code.dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).
devops-cli-service commentedon Nov 1, 2026
Staged: branch
test/2162-mutation-runs-decide-which-of-the, draft pull request #2979. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:
These paths of the plan are no file on the default branch, and no group creates them:
openspec/changes/2162-mutation-review-scanner/mutation-report.md,tests/test_custom_personas.py,tests/test_review_advisory_backing.py,tests/test_review_deduplication.py,tests/test_review_defects_comments.py,tests/test_review_defenses_and_verification.py,tests/test_review_history.py,tests/test_review_location_paths.py,tests/test_review_loop_hardening.py,tests/test_review_regression_harness.py,tests/test_review_taxonomy_and_severity.py,tests/test_review_verification.py,tests/test_structural_positional_oracles.py,tests/test_security_kubelinter.py,tests/test_security_tflint.py,openspec/changes/2162-mutation-review-scanner/tasks.md. A person checks that the plan names them right.3 remaining items
docs(openspec): fix plan #2162 measure 17 test files by mutation (#3024)
[-]test(review): mutation runs decide which of the 18 review and scanner test files that add no covered line of their own are merged or deleted[/-][+]test(review): mutation cleanup of 18 test files[/+]dan-petty commentedon Nov 6, 2026
The job shortened the title of this item. The summary had 126 characters, and the limit is 60. The type and the scope stay.
test(review): mutation runs decide which of the 18 review and scanner test files that add no covered line of their own are merged or deletedtest(review): mutation cleanup of 18 test filesdan-petty commentedon Nov 6, 2026
The plan cannot be built as written. The stop rule of
design.mdapplies: the first stats run ofuv run devops ci mutatedoes not end, so no mutation run of the 17 files can start.Evidence, from
origin/mainatc7145511, in a clean worktree:uv run devops ci mutate src/devops_cli/ai/personas/__init__.pystopped after 8 min. mutmut copies the tree tomutants/, and[tool.mutmut].also_copyinpyproject.tomlhas noopenspecentry.tests/roadmap/test_roadmap_stage_form.pyfails at collection withFileNotFoundError: .../mutants/openspec/config.yaml. The stats run stops: "failed to collect stats. runner returned 1"."openspec"toalso_copyand ran again. Mutant generation took 572 s (706 files). The stats run then took 7.5 min for 5 tests and stopped after 2 failures.tests/ai/agents/test_agent.py::test_ollama_stream_400_raises_client_errorfails with "host path reached without a fake: /.git" (the host-path guard; the tests run frommutants/, inside the checkout). Total run time: 21 min 25 s, andmutants/mutmut-stats.jsonwas not written.mutants/than the[tool.mutmut]table names. The plan listspytest_add_cli_args_test_selectionas complete, and that was not true.Feasibilitychecked only--dry-run, never a first run.devops ci coverageon this tree runs 19819 tests in 749 s with 16 workers (3895 s of CPU). The serial stats run needs about 65 min of CPU at the least, before the two runs per file for 17 files in 10 groups, each up to 14400 s.I changed no file and made no commit. The base line coverage of
mainis 95% (TOTAL 106689 statements, 5720 missed).Suggested re-scope: first fix
devops ci mutateso that a first run ends (thealso_copylist, the tests that read the checkout or.gitfrommutants/), with a check that runs the stats step. Then plan this item again, ideally as smaller items of 3 to 4 files each, so that one pull request needs fewer mutation hours. Item #2176 (26 test files, same method) has the same dependency.devops-cli-service commentedon Nov 6, 2026
The proposal at f1130d3 needs splitting into 6 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.
The next refine round also looks at the item again when a commit on the default branch changes one of these files:
pyproject.toml,tests/roadmap/test_roadmap_stage_form.py,tests/ai/agents/test_agent.py.devops-cli-service commentedon Nov 6, 2026
The proposal at 89daf41 needs splitting into 7 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.
openspeccopy entrydevops-cli-service commentedon Nov 6, 2026
Alternatives check: not-applicable
Class: test. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-06. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 9, 2026
The premise fails. The first mutation stats run cannot finish in one command.
mutmut executes all tests serially in mutants/. Tests that touch git fail the sandbox check with 'host path reached without a fake' because mutants/ has no git tracking.
A run of uv run devops ci mutate src/devops_cli/ai/personas/init.py passed 1328 tests and stopped after failures in tests/ai/mcp/test_mcp_roadmap_tools.py and tests/ai/agents/test_embedding_config_retention.py.
The Stop rule in openspec/changes/2162-mutation-runs-decide-which-of-the/design.md and Rule 2 of AGENTS.md apply. This comment returns the item to New with the evidence.
devops-cli-service commentedon Nov 9, 2026
The proposal at 2f20244 needs splitting into 7 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.
openspeccopy entry and the deselected git-dependent tests