Skip to content

fix(ci): the stats run fails in the mutants tree #6448

Done

Description

@dan-petty

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_dir walks up from the current folder and reads the .git file 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

  1. In a linked worktree, make the mutants tree of all of src/devops_cli (create_mutants of mutmut 3.8.1), as devops ci mutate does.
  2. In mutants/, run pytest -p no:randomly tests/core/test_process_contract.py tests/ai/agents/test_security_sandbox_and_protection.py with PYTHONPATH=mutants/src:mutants.
  3. Copy the tree outside every checkout and run the same command: 32 tests pass. Run tests/commands/k8s/test_k8s.py there: test_k8s_bootstrap_dry_run fails with exit code 1.
  4. Run git init -q in 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_10
  • tests/telemetry/test_telemetry_instruments.py::test_no_gauge_reaches_prometheus_through_two_paths
  • tests/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_workflow
  • tests/ai/review/test_review.py::test_review_multiple_targets_and_findings_options
  • tests/ai/review/test_review.py::test_review_path_workflow
  • tests/ai/review/test_review.py::test_review_pr_workflow
  • tests/ai/review/test_review_repos.py::TestReviewReposSubdirectories::test_review_path_summary_in_repos_directory
  • tests/ai/review/test_review_runner.py::test_make_review_clients
  • tests/ai/review/test_review_runner.py::test_review_clients_wait_a_configured_task_timeout
  • tests/ai/review/test_review_symbol_delta.py::test_a_review_hands_its_base_to_pre_analysis_and_its_diff_to_persona_review
  • tests/ai/review/test_runner.py::test_a_review_outside_the_working_directory_reads_its_targets_analysis_metadata
  • tests/ai/review/test_runner.py::test_a_review_publishes_its_session_after_it_writes_the_profile
  • tests/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_profile
  • tests/ai/review/test_runner.py::test_routed_files_only_branch_diff_makes_no_model_calls
  • tests/ai/review/test_runner.py::test_summary_only_exits_before_orchestrator_construction
  • tests/ai/spend/test_ai_spend_pricing.py::test_a_priced_request_loads_the_settings_at_most_once
  • tests/ai/test_ai_gateway_tune.py::TestBench::test_gateway_bench_imports_only_standard_library
  • tests/ci/test_ci_gate_admission.py::test_a_cached_verdict_takes_no_slot
  • tests/commands/test_ci.py::test_bandit_s_config_skips_only_the_low_rules_that_need_no_decision
  • tests/commands/test_ci.py::test_the_security_row_scans_the_targets_that_bandit_s_config_names
  • tests/commands/test_review_pr_post.py::test_devops_review_pr_post_empty_diff_makes_zero_model_calls
  • tests/commands/test_security_bandit.py::test_the_bandit_targets_hold_every_python_file_the_repository_tracks
  • tests/commands/test_security_bandit.py::test_the_scan_report_runs_bandit_on_this_repository_with_the_gate_s_config
  • tests/commands/test_valkey.py::TestValkeyClientDestination::test_valkey_protocol_is_satisfied_by_valkey_client
  • tests/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_check
  • tests/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_index
  • tests/github/test_github_pages.py::test_the_repository_site_has_readme_as_its_home_page
  • tests/github/test_github_pages.py::test_the_repository_site_settings_pass_the_check
  • tests/invariants/test_agents_md.py::test_every_relative_link_in_the_test_conventions_and_their_pointers_resolves
  • tests/invariants/test_committed_addresses.py::test_no_committed_file_holds_a_private_address_or_a_lan_host
  • tests/invariants/test_declared_dependencies.py::test_declared_dependencies_numpy_and_pytrec_eval
  • tests/invariants/test_mcp_server_image.py::test_the_kubectl_and_helm_pins_hold_the_go_builds_that_fix_the_stdlib_findings
  • tests/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_root
  • tests/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_src
  • tests/output/test_output.py::test_leveled_print_calls_do_not_duplicate_level_prefixes
  • tests/review/test_review_group_analysis.py::test_routed_files_only_with_admitted_gitleaks_finding_runs_group_analysis
  • tests/roadmap/implement/test_roadmap_implement_job.py::test_a_retry_clears_the_stop_before_the_first_step
  • tests/roadmap/project_review/test_review_facts.py::test_the_facts_of_a_version_window
  • tests/roadmap/stage/test_roadmap_stage_class_claim.py::test_a_member_claim_the_staged_class_lacks_is_refused
  • tests/roadmap/stage/test_roadmap_stage_class_claim.py::test_class_sources_reads_a_class_with_no_base
  • tests/roadmap/stage/test_roadmap_stage_constants.py::test_staged_constants_reads_repository
  • tests/roadmap/stage/test_roadmap_stage_eval_compare.py::test_the_staged_item_case_loads_with_its_commit
  • tests/roadmap/stage/test_roadmap_stage_models.py::test_model_fields_reads_module_and_fields
  • tests/roadmap/test_premise.py::test_a_name_of_the_adds_line_that_the_commit_defines_is_a_false_premise
  • tests/roadmap/test_premise.py::test_the_definition_lines_of_an_identifier_come_from_the_commit
  • tests/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 .git in the mutants root
  • Nearest .git resolves inside the guard's allowed root
  • _repository finds a root with no commit

Lacks:

  • 57 tests that read the checkout tracking or src as 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 mutate with a fake process runner and a fake mutmut runner.
  • THEN The test asserts that git init -q ran 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 .git file is above the mutants root.
  • THEN The test asserts that a .git directory exists in the mutants root and that the checkout .git file 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_dir from a folder under a prepared mutants root.
  • THEN The test asserts that the result is the mutants root .git and 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 _repository from a folder under it.
  • THEN The test asserts that _repository returns 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 tree REPO_ROOT is the mutants root. _resolve_git_dir walks up from the test and opens the checkout .git above 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?: _repository finds no .git when 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 mutate before 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 _repository a root inside the copied tree.
    • Rejected: Allow the checkout .git in 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.
  • Does the new repository need a commit?: No. The guard needs a .git path, and _repository needs a root. Neither needs a commit. Tests that need a commit or read src as 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 .git path and _repository needs 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 src as data.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#6474, #6475, #6476

Activity

  1. added
    type/bug
    source/agent
    status/new
    effort/high
    value/high
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p0-critical
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    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:

    • mutation testing mutmut copied mutants tree git repository git init, results: 5
    • git init create empty repository without commit for tests, results: 5
    • mutmut 3.8.1 stats run pytest -x mutants directory, results: 5
    • git init documentation reference git-scm.com, results: 5
    • "git init" man page create empty repository, results: 5
    • git worktree .git file linked worktree documentation, results: 5

    Sources:

  6. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  7. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  8. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    The OpenSpec change openspec/changes/2176-use-mutation-to-merge-or-delete/ is still active on main. 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 & Coverage time of the record) are also open in that tasks.md.

    Two more facts for the mutants tree, from the campaigns of #6461:

    • mutmut 3.8.1 runs its stats run and its clean run as two pytest sessions in one process. A test that writes the global config can write to the home folder of the earlier session, and the host path guard stops it: tests/config/test_config_file_value_errors.py::test_a_refused_global_config_value_names_the_global_file failed this way, and passes in a plain pytest run of the same files in the same order.
    • A kill inside mutmut is not always a kill of the test file: 16 __getattr__ mutants that run 1 of tests/config/test_settings_cache.py killed pass that file in a fresh process with MUTANT_UNDER_TEST set.
  9. added
    owner/agent
    on Nov 23, 2026
  10. changed the title [-]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[/+] on Nov 23, 2026
  11. added
    status/in-progress
    and removed
    status/ready
    on Nov 23, 2026
  12. added a commit that references this issue on Nov 23, 2026
    1996857
  13. added
    status/in-review
    and removed
    status/in-progress
    on Nov 23, 2026
  14. removed
    status/in-review
    owner/agent
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p0-criticalsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions