Repository navigation
Description
Problem Description
devops ci mutate runs the tests in mutants/, inside the git checkout. The host path guard of tests/conftest.py (_install_host_path_guard) allows the files under REPO_ROOT, and in the mutants tree REPO_ROOT is mutants/. A test whose code finds the nearest .git finds the .git of the checkout above mutants/, outside the allowed roots:
src/devops_cli/telemetry/tracer.py_resolve_git_dirwalks up from the current folder and reads the.gitfile of a linked worktree, or.git/HEAD.- The guard then stops the test with
host path reached without a fake: <checkout>/.git.
The stats run of mutmut 3.8.1 gives -x to pytest, so the first such test stops the whole run. A mutants tree outside every checkout does not help: then src/devops_cli/k8s/environment.py _repository finds no .git, and tests such as tests/commands/k8s/test_k8s.py::test_k8s_bootstrap_dry_run and tests/commands/test_grafana.py::test_grafana_dashboards_sync_dry_run fail.
Reproduction Steps
- In a linked worktree, make the mutants tree of all of
src/devops_cli(create_mutantsof mutmut 3.8.1), asdevops ci mutatedoes. - In
mutants/, runpytest -p no:randomly tests/core/test_process_contract.py tests/ai/agents/test_security_sandbox_and_protection.pywithPYTHONPATH=mutants/src:mutants. - Copy the tree outside every checkout and run the same command: 32 tests pass. Run
tests/commands/k8s/test_k8s.pythere:test_k8s_bootstrap_dry_runfails with exit code 1. - Run
git init -qin the copy and run the four modules again: 136 tests pass.
Expected vs Actual Behavior
Expected: the tests of the mutation selection pass in the mutants tree, so the stats run of devops ci mutate ends.
Actual: in a linked worktree, tests/core/test_process_contract.py gives 4 failures and 6 teardown errors with host path reached without a fake: <worktree>/.git, and tests/ai/agents/test_security_sandbox_and_protection.py::test_difftastic_validates_git_references_and_sanitizes_stderr fails the same way.
Other tests that fail or hang in the mutants tree
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 of pyproject.toml (pytest -n 4 -p no:randomly). After 75 minutes, 25488 tests pass and 57 fail. Most of the 57 read the git tracking of the checkout (the new repository has no commit) or read src as data (the generated code of mutmut). Three tests do not end in 70 minutes, because they read the 475 MB generated tree:
tests/server/test_service_memory.py::test_the_heap_at_round_50_is_within_the_byte_budget_of_the_heap_at_round_10tests/telemetry/test_telemetry_instruments.py::test_no_gauge_reaches_prometheus_through_two_pathstests/invariants/test_source_tree.py::test_no_unreachable_calls_in_src
tests/ai/spend/test_ai_spend_pricing.py::test_a_priced_request_loads_the_settings_at_most_once passes in a plain run of the mutants tree, but fails in the stats run of mutmut (MUTANT_UNDER_TEST=stats): it counts the calls of the code object of load_settings, and in the mutants tree that is the code of the trampoline that @_mutmut_mutated puts around each function, so it counts 10 loads where it expects 1.
The 57 failed tests
tests/ai/review/test_review.py::test_review_branch_workflowtests/ai/review/test_review.py::test_review_multiple_targets_and_findings_optionstests/ai/review/test_review.py::test_review_path_workflowtests/ai/review/test_review.py::test_review_pr_workflowtests/ai/review/test_review_repos.py::TestReviewReposSubdirectories::test_review_path_summary_in_repos_directorytests/ai/review/test_review_runner.py::test_make_review_clientstests/ai/review/test_review_runner.py::test_review_clients_wait_a_configured_task_timeouttests/ai/review/test_review_symbol_delta.py::test_a_review_hands_its_base_to_pre_analysis_and_its_diff_to_persona_reviewtests/ai/review/test_runner.py::test_a_review_outside_the_working_directory_reads_its_targets_analysis_metadatatests/ai/review/test_runner.py::test_a_review_publishes_its_session_after_it_writes_the_profiletests/ai/review/test_runner.py::test_a_review_without_a_report_keeps_no_session[profiled]tests/ai/review/test_runner.py::test_a_review_without_a_report_keeps_no_session[routed-files-only]tests/ai/review/test_runner.py::test_a_routed_files_only_review_publishes_its_session_without_a_profiletests/ai/review/test_runner.py::test_routed_files_only_branch_diff_makes_no_model_callstests/ai/review/test_runner.py::test_summary_only_exits_before_orchestrator_constructiontests/ai/spend/test_ai_spend_pricing.py::test_a_priced_request_loads_the_settings_at_most_oncetests/ai/test_ai_gateway_tune.py::TestBench::test_gateway_bench_imports_only_standard_librarytests/ci/test_ci_gate_admission.py::test_a_cached_verdict_takes_no_slottests/commands/test_ci.py::test_bandit_s_config_skips_only_the_low_rules_that_need_no_decisiontests/commands/test_ci.py::test_the_security_row_scans_the_targets_that_bandit_s_config_namestests/commands/test_review_pr_post.py::test_devops_review_pr_post_empty_diff_makes_zero_model_callstests/commands/test_security_bandit.py::test_the_bandit_targets_hold_every_python_file_the_repository_trackstests/commands/test_security_bandit.py::test_the_scan_report_runs_bandit_on_this_repository_with_the_gate_s_configtests/commands/test_valkey.py::TestValkeyClientDestination::test_valkey_protocol_is_satisfied_by_valkey_clienttests/core/test_git_contract.py::test_a_scenario_over_the_git_fake_gives_the_recorded_result[review_window]tests/core/test_git_contract.py::test_a_scenario_over_the_process_fake_starts_the_recorded_commands_and_gives_the_result[review_window]tests/core/test_third_party_telemetry.py::test_the_committed_claude_settings_opt_out_of_openspec_telemetry_and_its_update_checktests/github/test_gh_issues_milestones_labels_runs_dry_run.py::test_request_plan_commands_make_no_external_requests[roadmap_run-run_cmd-argv14]tests/github/test_gh_project_views_pages_dry_run.py::test_no_external_request_commands_run_normally[pages_verify-pages_verify_cmd-argv0]tests/github/test_github_pages.py::test_the_cli_reference_tab_opens_on_the_indextests/github/test_github_pages.py::test_the_repository_site_has_readme_as_its_home_pagetests/github/test_github_pages.py::test_the_repository_site_settings_pass_the_checktests/invariants/test_agents_md.py::test_every_relative_link_in_the_test_conventions_and_their_pointers_resolvestests/invariants/test_committed_addresses.py::test_no_committed_file_holds_a_private_address_or_a_lan_hosttests/invariants/test_declared_dependencies.py::test_declared_dependencies_numpy_and_pytrec_evaltests/invariants/test_mcp_server_image.py::test_the_kubectl_and_helm_pins_hold_the_go_builds_that_fix_the_stdlib_findingstests/invariants/test_skills.py::test_every_project_skill_names_its_commands_and_matches_across_roots[ask-jev/SKILL.md]tests/invariants/test_skills.py::test_every_project_skill_names_its_commands_and_matches_across_roots[devops-openspec-new/SKILL.md]tests/invariants/test_skills.py::test_every_project_skill_names_its_commands_and_matches_across_roots[devops-pr-ci/SKILL.md]tests/invariants/test_skills.py::test_every_project_skill_names_its_commands_and_matches_across_roots[devops-review/SKILL.md]tests/invariants/test_skills.py::test_every_project_skill_names_its_commands_and_matches_across_roots[devops-roadmap/SKILL.md]tests/invariants/test_skills.py::test_every_project_skill_names_its_commands_and_matches_across_roots[new-scaffold/SKILL.md]tests/invariants/test_skills.py::test_the_scaffold_skill_holds_the_same_text_in_each_roottests/invariants/test_skills.py::test_the_scaffold_skill_of_each_root_names_both_commands[.kilocode/skills]tests/invariants/test_source_tree.py::test_no_mock_attribute_probes_in_srctests/output/test_output.py::test_leveled_print_calls_do_not_duplicate_level_prefixestests/review/test_review_group_analysis.py::test_routed_files_only_with_admitted_gitleaks_finding_runs_group_analysistests/roadmap/implement/test_roadmap_implement_job.py::test_a_retry_clears_the_stop_before_the_first_steptests/roadmap/project_review/test_review_facts.py::test_the_facts_of_a_version_windowtests/roadmap/stage/test_roadmap_stage_class_claim.py::test_a_member_claim_the_staged_class_lacks_is_refusedtests/roadmap/stage/test_roadmap_stage_class_claim.py::test_class_sources_reads_a_class_with_no_basetests/roadmap/stage/test_roadmap_stage_constants.py::test_staged_constants_reads_repositorytests/roadmap/stage/test_roadmap_stage_eval_compare.py::test_the_staged_item_case_loads_with_its_committests/roadmap/stage/test_roadmap_stage_models.py::test_model_fields_reads_module_and_fieldstests/roadmap/test_premise.py::test_a_name_of_the_adds_line_that_the_commit_defines_is_a_false_premisetests/roadmap/test_premise.py::test_the_definition_lines_of_an_identifier_come_from_the_committests/roadmap/test_roadmap_runner_tools.py::test_the_version_of_each_dev_dependency_is_the_version_of_the_lockfile
Environment Diagnostics
mutmut 3.8.1, Python 3.14, a linked git worktree. The normal clone is not measured: there _resolve_git_dir finds the .git folder and reads .git/HEAD, which is also outside mutants/.
Logs, Traces, or Terminal Output
FAILED tests/core/test_process_contract.py::test_sync_execution_contract[real] - Failed: host path reached without a fake: <worktree>/.git
failed to collect stats. runner returned 1
A possible fix: devops ci mutate makes mutants/ its own git repository (git init) before mutmut runs, so a test that finds the nearest .git stays inside the tree that the guard allows. The campaigns of #2176 ran this way.
Source: #6436
Alternatives check of 2026-11-19: in-use.
The repository already uses this tool.
Tool: git/git (https://github.com/git/git), NOASSERTION, last activity 2026-11-19, maintained.
Reason: Searches found git init as the only maintained tool for the tree's repository metadata: it fixes the guard stop and the missing .git. The issue's own numbers show 57 failures and 3 hangs remain, so the stats run still stops.
Covers:
- Creates a
.gitin the mutants root - Nearest
.gitresolves inside the guard's allowed root _repositoryfinds a root with no commit
Lacks:
- 57 tests that read the checkout tracking or
srcas data - Trampoline code-object call count under
MUTANT_UNDER_TEST=stats - Three tests that hang on the 475 MB generated tree
Proposed design
Problem statement
The mutants tree that devops ci mutate copies has no Git repository of its own. In a linked worktree, a test finds the checkout .git above mutants/; the host path guard stops it, and -x stops the stats run. Outside a checkout, _repository finds no .git, so the Kubernetes and Grafana dry runs fail. The change initializes mutants/ as its own Git repository before mutmut runs. The remaining 57 failures, the three hangs, and the stats call-count failure are deferred to separate issues.
Acceptance criteria
Requirement: Mutants root is a Git repository
devops ci mutate SHALL initialize the mutants root as a Git repository before it starts mutmut.
Scenario: Git init before mutmut
- WHEN A test runs
devops ci mutatewith a fake process runner and a fake mutmut runner. - THEN The test asserts that
git init -qran with the mutants root as its working directory before the mutmut call.
Requirement: The checkout Git directory stays unchanged
devops ci mutate MUST initialize only the mutants root and MUST NOT change the .git of the checkout.
Scenario: Linked worktree
- WHEN A test runs the preparation from a linked worktree whose
.gitfile is above the mutants root. - THEN The test asserts that a
.gitdirectory exists in the mutants root and that the checkout.gitfile is unchanged.
Requirement: The nearest Git directory is inside the mutants root
The prepared mutants tree SHALL hold the nearest .git of a folder under it inside the mutants root.
Scenario: Nearest Git directory
- WHEN A test calls
_resolve_git_dirfrom a folder under a prepared mutants root. - THEN The test asserts that the result is the mutants root
.gitand that the host path guard allows it.
Requirement: A mutants tree outside a checkout finds a repository
devops ci mutate MUST give a mutants tree outside every checkout its own .git so _repository finds a repository.
Scenario: Tree outside a checkout
- WHEN A test prepares a mutants root that has no checkout above it and calls
_repositoryfrom a folder under it. - THEN The test asserts that
_repositoryreturns a repository whose root is the mutants root.
Existing Tool Considered
The alternatives check in the issue body records in-use for git/git (https://github.com/git/git); the repository already uses Git. This proposal adds one git init -q call in devops ci mutate to prepare the mutants root, and it defers the parts that the check's Lacks: list names. It builds no library. Written cost: about 15 lines and 1,000 tokens to build, 300 tokens a year to keep and fix, under 30 minutes.
Key questions
- Why does the host path guard stop a test in a linked worktree?: The guard allows files under
REPO_ROOT. In the copied treeREPO_ROOTis the mutants root._resolve_git_dirwalks up from the test and opens the checkout.gitabove the mutants root, so the guard stops that open. [sources: tests/conftest.py:624, src/devops_cli/telemetry/tracer.py:640, tests/support/paths.py:21] - Why does a mutants tree outside a checkout fail?:
_repositoryfinds no.gitwhen the mutants tree is outside every checkout. The Kubernetes and Grafana dry runs then fail. [sources: src/devops_cli/k8s/environment.py, tests/commands/k8s/test_k8s.py, tests/commands/test_grafana.py] - Where should the fix go?: Initialize the mutants root as a Git repository in
devops ci mutatebefore mutmut starts. Keep the host path guard unchanged. Do not make each affected test fake Git. (best practice) [sources: tests/conftest.py:624, src/devops_cli/telemetry/tracer.py:640, src/devops_cli/k8s/environment.py]- Chosen: Initialize the mutants root. It keeps the guard unchanged and gives
_repositorya root inside the copied tree. - Rejected: Allow the checkout
.gitin the guard. It lets a test read the checkout outside the copied tree, so a mutant can pass on code that it does not hold. - Rejected: Fake Git in each affected test. It changes many tests and leaves the copied tree broken for a real run.
- Chosen: Initialize the mutants root. It keeps the guard unchanged and gives
- Does the new repository need a commit?: No. The guard needs a
.gitpath, and_repositoryneeds a root. Neither needs a commit. Tests that need a commit or readsrcas data are deferred. (best practice) [sources: tests/conftest.py:624, src/devops_cli/telemetry/tracer.py:640, src/devops_cli/k8s/environment.py]- Chosen: Init only. The guard needs a
.gitpath and_repositoryneeds a root. Neither needs a commit. - Rejected: Init and an empty commit. It writes a commit to a generated tree and does not fix tests that read
srcas data.
- Chosen: Init only. The guard needs a
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 19, 2026
The mutate stats run fails, which causes the CI mutation-testing job to stop.devops ci mutate) #853, which asks for a different change.Both concern devops ci mutate, but 853 delivers the feature and the candidate reports a bug in its stats run.devops-cli-service commentedon Nov 19, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (6)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 19, 2026
Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.
dan-petty commentedon Nov 20, 2026
The OpenSpec change
openspec/changes/2176-use-mutation-to-merge-or-delete/is still active onmain. PR #6436 merged before its archive commit, and #2176 is closed. Task 1.1 of that change waits for this issue.PR #6463 (#6461) decides the last pending rows of tasks 3.1 to 7.1 of that change. Its record comment gives each decision.
The pull request that fixes this issue can tick task 1.1 and archive the change. Tasks 8.1 and 9.1 (the gate result, the coverage total and the
Tests & Coveragetime of the record) are also open in thattasks.md.Two more facts for the mutants tree, from the campaigns of #6461:
tests/config/test_config_file_value_errors.py::test_a_refused_global_config_value_names_the_global_filefailed this way, and passes in a plain pytest run of the same files in the same order.__getattr__mutants that run 1 oftests/config/test_settings_cache.pykilled pass that file in a fresh process withMUTANT_UNDER_TESTset.[-]devops ci mutate: the stats run fails in the mutants tree, in and out of a git checkout[/-][+]fix(ci): the stats run fails in the mutants tree[/+]fix(ci): the stats run fails in the mutants tree
devops-cli-service commentedon Nov 23, 2026
Released in v0.203.6: https://github.com/dan-petty/devops-cli/releases/tag/v0.203.6