Skip to content

test(cli): use mutation runs to merge or delete 26 test files - #6436

Merged
dan-petty merged 5 commits into
mainfrom
test/2176-mutation-decides-test-files
Nov 19, 2026
Merged

dan-petty merged 5 commits into
mainfrom
test/2176-mutation-decides-test-files

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The mutation test selection of pyproject.toml named test modules at their old paths, so mutmut ran tests that fail in its mutants tree. This change points each entry at the module that holds the test now, removes the entry whose test is gone, and copies the folders that the selected tests read. Then mutation runs decide each of the 26 test files of the 2026-10-24 coverage audit: a file that kills no mutant of its own adds no check, so it goes, or its distinct case moves into the file that covers the same lines. The mutation record of each file is in a comment of this pull request.

Closes #2176

Change: openspec/changes/archive/2026-11-19-2176-use-mutation-to-merge-or-delete/

@dan-petty dan-petty added type/test Type test: a new or changed test scope/cli Core CLI framework, Typer subcommands, options, and tables labels Nov 19, 2026
…ment

The record of each campaign is the proof of one run at one commit, so it
goes into a comment of the pull request and into no committed file. A
census test of a record or of pyproject.toml asserts a value of a
document or of a config file, which the owner rule of 2026-11-16
forbids. Run 2 now selects only the other test files that run the
functions of the row, as per-test coverage gives them.
…tree

Commit 513bb31 moved each test that the selection leaves out into its
package folder, so the old paths left the modules in, and they failed
against the generated code of mutmut. Each entry now names the module
that holds its test, and the entry of a test that no file holds goes.
The copy list adds openspec and design, which selected tests read.
tests/core/test_openspec_command.py reads the skill trees of the
checkout, so the mutants tree needs .agents and .claude/skills. The
proposal and the design now name the record of the pull request comment
in place of the census file and the testing guide.
…nt of their own

The 36 mutants that tests/core/test_consolidation_binaries.py kills all die
again when the other test files that run the same statements run without it.
… mutant of their own

tests/core/test_cleanup_fuzzing.py kills 42 mutants, and the other test files that
run the same statements kill all 42 again. The four XML cases of
tests/ai/test_pydantic_ai_format_prompt.py kill no mutant: they test the function
of pydantic-ai that the module only exports again. The export case stays, because
no mutant can change an import.
@dan-petty
dan-petty force-pushed the test/2176-mutation-decides-test-files branch from 194d829 to 61391ef Compare November 19, 2026 17:32
@dan-petty

dan-petty commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner Author

Mutation record of #2176

mutmut 3.8.1 ran on the tree of 633021e, the commit of the per-test coverage run (COVERAGE_CORE=ctrace, --cov-context=test). Between 633021e and the head of this pull request, the mutated files changed only by added fields and functions, module data and one docstring: no body of a mutated function changed.

A run whose stats run stopped inside a git checkout ran again outside every checkout: in a checkout, the telemetry tracer of a test reads the HEAD of the .git above the mutants tree, and the host path guard of tests/conftest.py stops that read.

  • Run 1: the folder holds the pyproject.toml of this branch, with the files of the row added to pytest_add_cli_args_test_selection. Command: mutmut run --max-children <4 or 8> <globs of each function whose body the files run>.
  • Run 2: the same folder form, with the other test files that run the statement of each mutant that run 1 killed (the 25 fastest when more), and no file of the row. Command: mutmut run --max-children <4 or 8> <names of those mutants>.
  • Run 3: each survivor of a mutant that run 2 sampled, against all of the other files.
  • An own mutant is one that run 1 kills and no later run kills. A mutant whose statement no other file runs is own with no run 2.
  • A row with such a mutant is kept with no run 2. A direct run of the row's files (pytest in the mutants tree of run 1, with MUTANT_UNDER_TEST set to the mutant) confirms the own mutant that the reason names and the test that kills it. A run 1 kill that the direct run does not repeat (a timeout under load, or state that the stats run left) decides nothing.
Table path Path now Decision Reason, commit or result Run 1 Run 2 Own mutants
tests/commands/test_config.py tests/commands/test_config.py pending the campaign of this row runs - - -
tests/core/test_cleanup_fuzzing.py tests/core/test_cleanup_fuzzing.py deleted run 2 kills each of the 42 mutants again 42 killed of 425 run, 232 s 42 killed of 42 (16 on the 25 fastest files) on 43 files, 119 s 0
tests/test_agent.py none settled 513bb31 moved it to tests/ai/agents/test_agent.py, and 5edd7a5 deleted it - - -
tests/test_ai_client_credentials.py tests/ai/client/test_ai_client_credentials.py kept own mutant devops_cli.ai.client.openai.xǁOpenAICompatProviderMixinǁ_openai_models__mutmut_4 (the Authorization header of a client with no key is None, not openai.omit), killed by tests/ai/client/test_ai_client_credentials.py::test_unset_key_sends_no_authorization_header; no other file runs its statement 1175 killed of 5375 run, 2907 s not run: no other file runs the statements of the own mutants at least 2
tests/test_ai_client_style_request.py tests/ai/test_ai_client_style_request.py pending the campaign of this row runs 1813 killed of 6805 run, 4841 s - -
tests/test_ai_gateway_base_url.py tests/ai/client/test_ai_gateway_base_url.py pending the campaign of this row runs - - -
tests/test_ai_init.py tests/ai/analyze/test_ai_init.py unjudged it checks the export lists of two packages, module data that no mutant changes - - -
tests/test_ai_spend_dispatch.py tests/ai/spend/test_ai_spend_dispatch.py pending the campaign of this row runs - - -
tests/test_ai_task_loader.py tests/ai/test_ai_task_loader.py unjudged the mutation selection leaves it out, because it reads src as data - - -
tests/test_config_settings_cache.py tests/config/test_settings_cache.py pending the campaign of this row runs 606 killed of 734 run, 365 s - -
tests/test_data_dir_configuration.py tests/ai/benchmark/test_data_dir_configuration.py pending the campaign of this row runs 196 killed of 711 run, 359 s - -
tests/test_exceptions.py tests/docs/test_exceptions.py kept own mutant devops_cli.exceptions.ai.xǁReviewPoolErrorǁ__init____mutmut_13 (the call of the base __init__ drops message), killed by tests/docs/test_exceptions.py::test_an_error_built_without_an_override_carries_its_class_codes; no other file runs its statement 304 killed of 1531 run, 641 s not run: no other file runs the statements of the own mutants at least 5
tests/test_headless_auth.py tests/config/test_headless_auth.py kept own mutant devops_cli.config.os_keyring.x_has_keyring_secret__mutmut_2 (a remembered secret gives False, not True), killed by tests/config/test_headless_auth.py::test_a_remembered_secret_is_read_before_the_keyring; no other file runs its statement 17 killed of 405 run, 181 s not run: no other file runs the statements of the own mutants at least 1
tests/test_http_async_client.py tests/http/test_http_async_client.py pending the campaign of this row runs 31 killed of 478 run, 201 s - -
tests/test_language_catalogs.py tests/lang/test_language_catalogs.py unjudged it checks catalog data, class data that no mutant changes - - -
tests/test_pydantic_ai_format_prompt.py tests/ai/test_pydantic_ai_format_prompt.py trimmed the module only imports format_as_xml of pydantic-ai, so run 1 kills 0 mutants; the 4 XML cases go, and test_format_as_xml_reexport stays 0 killed of 320 run, 231 s - 0
tests/test_pydantic_ai_retries.py tests/ai/retries/test_pydantic_ai_retries.py pending the campaign of this row runs - - -
tests/test_pydantic_ai_toolsets.py tests/ai/toolsets/test_function_toolset.py, tests/ai/toolsets/test_toolset_authoring.py, tests/ai/toolsets/test_toolset_combinators.py kept own mutant devops_cli.ai.toolsets.xǁFunctionToolsetǁget_instructions__mutmut_1 (if ctx is not None becomes if ctx is None), killed by tests/ai/toolsets/test_function_toolset.py::test_function_toolset_instructions 55 killed of 813 run, 389 s 27 killed of 31 on 3 files, 47 s 28
tests/test_rag_loopback_policy.py tests/ai/rag/test_example_config_loopback_rag.py, tests/ai/client/test_example_config_loopback_endpoints.py unjudged an invariant test: it sends requests to the loopback endpoints of config.example.yaml - - -
tests/test_rag_rrf.py none settled 513bb31 moved it to tests/ai/rag/test_rag_rrf.py, and b6af763 deleted it and put its case into tests/ai/rag/test_hybrid_search.py - - -
tests/test_third_party_telemetry.py tests/core/test_third_party_telemetry.py unjudged an invariant test: it reads the manifests under k8s/ - - -
tests/test_valkey_cache_tier.py tests/valkey/test_valkey_cache_tier.py pending the campaign of this row runs - - -
tests/test_openspec_scaffold.py tests/commands/test_openspec_scaffold.py unjudged an invariant test: it reads the committed OpenSpec files - - -
tests/test_cli_format_adoption.py tests/commands/test_cli_format_adoption.py unjudged it checks the options that the command decorators build and a constant of the test file - - -
tests/test_consolidation_binaries.py tests/core/test_consolidation_binaries.py deleted run 2 kills each of the 36 mutants again 36 killed of 412 run, 260 s 36 killed of 36 (25 on the 25 fastest files) on 107 files, 289 s 0
tests/test_dependency_audit.py tests/commands/test_dependency_audit.py kept own mutant devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_1 (if not isinstance(data, dict) becomes if isinstance(data, dict)), killed by tests/commands/test_dependency_audit.py::test_osv_advisory_ids_reads_json_and_table_reports; no other file runs its statement 495 killed of 1352 run, 884 s not run: no other file runs the statements of the own mutants at least 13

Own mutants of the kept rows

tests/ai/client/test_ai_client_credentials.py: 2 own mutants
  • devops_cli.ai.client.openai.xǁOpenAICompatProviderMixinǁ_openai_models__mutmut_4
  • devops_cli.ai.client.openai.xǁOpenAICompatProviderMixinǁ_openai_models__mutmut_5
tests/docs/test_exceptions.py: 5 own mutants
  • devops_cli.exceptions.ai.xǁReviewPoolErrorǁ__init____mutmut_13
  • devops_cli.exceptions.k8s.xǁChaosExecutionErrorǁ__init____mutmut_8
  • devops_cli.exceptions.k8s.xǁVolumeReclaimErrorǁ__init____mutmut_11
  • devops_cli.exceptions.security.xǁKeyringUnavailableErrorǁ__init____mutmut_1
  • devops_cli.exceptions.security.xǁKeyringUnavailableErrorǁ__init____mutmut_3
tests/config/test_headless_auth.py: 1 own mutants
  • devops_cli.config.os_keyring.x_has_keyring_secret__mutmut_2
tests/ai/toolsets/test_function_toolset.py, tests/ai/toolsets/test_toolset_authoring.py, tests/ai/toolsets/test_toolset_combinators.py: 28 own mutants
  • devops_cli.ai.agents.context.xǁRunContextǁ__init____mutmut_16
  • devops_cli.ai.agents.context.xǁRunContextǁ__init____mutmut_17
  • devops_cli.ai.agents.context.xǁRunContextǁ__init____mutmut_7
  • devops_cli.ai.agents.context.xǁRunContextǁ__init____mutmut_8
  • devops_cli.ai.agents.context.xǁRunContextǁ__init____mutmut_9
  • devops_cli.ai.toolsets.x_create_function_toolset__mutmut_2
  • devops_cli.ai.toolsets.x_create_function_toolset__mutmut_8
  • devops_cli.ai.toolsets.x_extract_tools_from_toolset__mutmut_12
  • devops_cli.ai.toolsets.x_extract_tools_from_toolset__mutmut_13
  • devops_cli.ai.toolsets.x_extract_tools_from_toolset__mutmut_2
  • devops_cli.ai.toolsets.x_extract_tools_from_toolset__mutmut_3
  • devops_cli.ai.toolsets.x_extract_tools_from_toolset__mutmut_4
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁ__init____mutmut_10
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁ__init____mutmut_15
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁ__init____mutmut_17
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁadd_function__mutmut_10
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁadd_function__mutmut_21
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁadd_tool__mutmut_61
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁadd_tool__mutmut_62
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁget_instructions__mutmut_1
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁget_instructions__mutmut_15
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁget_instructions__mutmut_3
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁget_instructions__mutmut_4
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁget_tools__mutmut_37
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁtool__mutmut_40
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁtool_plain__mutmut_1
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁtool_plain__mutmut_13
  • devops_cli.ai.toolsets.xǁFunctionToolsetǁtool_plain__mutmut_26
tests/commands/test_dependency_audit.py: 13 own mutants
  • devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_1
  • devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_12
  • devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_18
  • devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_2
  • devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_24
  • devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_3
  • devops_cli.core.dependency_audit.x__json_advisory_ids__mutmut_6
  • devops_cli.core.dependency_audit.x_npm_advisory_ids__mutmut_1
  • devops_cli.core.dependency_audit.x_osv_advisory_ids__mutmut_14
  • devops_cli.core.dependency_audit.x_osv_advisory_ids__mutmut_5
  • devops_cli.exceptions.ai.x___getattr____mutmut_5
  • devops_cli.exceptions.ai.x___getattr____mutmut_6
  • devops_cli.exceptions.ai.x___getattr____mutmut_7

Check of the selection (task 1.1)

  • uv run pytest --collect-only -q <entry> collects each entry of pytest_add_cli_args_test_selection: 5 modules and 6 tests.
  • A copy of the mutants tree of all of src/devops_cli, outside every checkout and with git init -q in it, runs the selection with pytest -n 4 -p no:randomly: after 75 minutes 25488 tests pass, 57 fail and 3 do not end. Inside a linked worktree, each test that finds the nearest .git stops at the host path guard. fix(ci): the stats run fails in the mutants tree #6448 holds the lists. Task 1.1 stays open until the selection passes there.
  • The run 2 folders leave out these 60 tests and tests/ai/spend/test_ai_spend_pricing.py::test_a_priced_request_loads_the_settings_at_most_once, which fails in the stats run of mutmut. A test that fails before any mutation kills no mutant, so this can only add own mutants and keep a file.

Open rows

The campaigns of the rows with the decision pending run now, one at a time. This comment changes when each row has its decision.

@dan-petty
dan-petty marked this pull request as ready for review November 19, 2026 20:26
@dan-petty
dan-petty merged commit 7dd00af into main Nov 19, 2026
32 checks passed
@dan-petty
dan-petty deleted the test/2176-mutation-decides-test-files branch November 19, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/cli Core CLI framework, Typer subcommands, options, and tables type/test Type test: a new or changed test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(cli): Use mutation to merge or delete 26 test files

1 participant