Skip to content

fix(roadmap): the strength check sets a denied env key #5887

Closed

Description

@dan-petty

Problem

The test-strength check of the implement job (#3051, PR #5770, merged 2026-11-15 05:43Z) cannot run. run_mutation (src/devops_cli/roadmap/implement/implement_strength.py:170) starts uv run mutmut run with env={"PYTEST_ADDOPTS": ...}. run_subprocess refuses this key, because PYTEST_ADDOPTS is in the list of dangerous environment keys (src/devops_cli/config/constants.py:1949, #2747: --junitxml=<path> makes pytest write a file at a path that the caller names). The refusal is SecurityError: Prohibited dangerous environment variable override: 'PYTEST_ADDOPTS' (src/devops_cli/core/process.py:226).

So each implement run that passes its groups stops at the scoped checks. Since 05:43Z, 3 of 9 implement attempts stopped this way, all after every group passed:

The job gives this stop the class ci_infra with the action retry, and the Service clears the stop when a new runner image rolls out. The stop is a code defect, so each retry fails in the same way.

The unit tests of #5770 replace run_subprocess, so no test ran the real command with the real env check.

Expected behavior

  • The strength check runs mutmut on the scoped tests and keeps the env deny list as it is. Do not remove PYTEST_ADDOPTS from the list; it is a security control.
  • A SecurityError from a check command gets a class that is not ci_infra, so the Service does not retry it on each rollout.

Fix options (the plan decides)

  • Give mutmut 3.8.1 the test selection through its own setting (for example pytest_add_cli_args_test_selection in a mutmut config that the run writes in the work tree), not through the environment.
  • Map SecurityError in the check runner to a code class (for example plan_defect or a new class), with the command in the stop.
  • Test first: one test calls the real run_subprocess env check with the env that run_mutation builds, and fails on the base.

Related

Source: #3529

Proposed design

Problem statement

The strength check of the implement job cannot run. run_mutation sets PYTEST_ADDOPTS in the environment of uv run mutmut run, and run_subprocess refuses that key as a dangerous environment override. Each implement run that passes its groups stops at the scoped checks with the class ci_infra, and the Service retries it on each new runner image. The fix gives mutmut the test selection through its own setting and maps a SecurityError from a check command to a class that a retry cannot clear.

Acceptance criteria

Requirement: The mutation run passes the environment guard

The strength check SHALL give the scoped test selection to mutmut through the mutmut configuration, and SHALL NOT put PYTEST_ADDOPTS in the environment of run_subprocess.

Scenario: The environment of the mutation run is accepted

  • WHEN run_mutation builds the environment for uv run mutmut run
  • THEN the real run_subprocess environment check accepts the environment and raises no SecurityError.

Requirement: The deny list keeps PYTEST_ADDOPTS

CONST_DANGEROUS_ENV_KEYS SHALL keep PYTEST_ADDOPTS.

Scenario: A caller sets PYTEST_ADDOPTS

  • WHEN a caller passes PYTEST_ADDOPTS to run_subprocess
  • THEN run_subprocess raises SecurityError: Prohibited dangerous environment variable override: 'PYTEST_ADDOPTS'.

Requirement: The mutation run selects the scoped tests

The mutation run SHALL select only the scoped test modules through pytest_add_cli_args_test_selection.

Scenario: The written configuration holds the scoped tests

  • WHEN the strength check writes the mutmut configuration for two scoped test modules
  • THEN the pytest_add_cli_args_test_selection value names both test modules.

Requirement: A refused check command gets a code class

The check runner SHALL classify a SecurityError from a scoped check command as plan_defect, and SHALL name the command in the stop.

Scenario: A scoped check command raises SecurityError

  • WHEN a scoped check command raises SecurityError
  • THEN the stop has the class plan_defect and its text names the command.

Requirement: The docs name the mutmut setting

The implement documentation SHALL name pytest_add_cli_args_test_selection as the source of the scoped test selection of the mutation run.

Scenario: The docs describe the mutation run

  • WHEN a reader opens docs/roadmap/implement.md and docs/ROADMAP_WORKFLOW.md
  • THEN both texts name the mutmut setting and neither text names PYTEST_ADDOPTS for the mutation run.

Requirement: The regression test runs the real guard

A test SHALL call the real run_subprocess environment check with the environment that run_mutation builds.

Scenario: The new test runs on the base commit

  • WHEN the new test runs against the code before the fix
  • THEN it fails with SecurityError: Prohibited dangerous environment variable override: 'PYTEST_ADDOPTS', and it passes after the fix.

Existing Tool Considered

No alternatives check has run. The tool is mutmut 3.8.1, which already runs the mutation check. Its pytest_add_cli_args_test_selection setting covers the scoped test selection without an environment key. It lacks nothing for this fix, so the change adds no new tool and no replacement code.

Key questions

  • Where does the strength check set PYTEST_ADDOPTS, and why does the guard refuse it?: run_mutation sets the key in the environment of uv run mutmut run. run_subprocess refuses it because CONST_DANGEROUS_ENV_KEYS lists it, after fix(security): the subprocess environment guard accepts the pytest and npm keys that make a child write a file #2747: --junitxml=<path> makes pytest write a file at a path that the caller names. [sources: src/devops_cli/roadmap/implement/implement_strength.py:170, src/devops_cli/config/constants.py:1949, src/devops_cli/core/process.py:226]
  • How does the strength check give the scoped test selection to mutmut?: The strength check writes the pytest_add_cli_args_test_selection key of the mutmut configuration in the work tree before the run. The child gets no PYTEST_ADDOPTS key. (best practice) [sources: src/devops_cli/config/constants.py:1949]
  • Which failure class does the check runner give a SecurityError from a check command?: The check runner gives it plan_defect and puts the command in the stop text. (best practice) [sources: src/devops_cli/config/settings.py:1164, src/devops_cli/roadmap/failure.py, docs/CLUSTER.md:47]
    • Rejected: ci_infra. Its action is retry, so the Service clears the stop on each new runner image and the same defect runs again.
    • Chosen: plan_defect. A retry cannot fix a refused command, so its action does not clear the stop on a new runner image.
    • Rejected: A new class. It needs a new FailureClass value, ledger, alert and settings changes for one case.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 15, 2026
  2. added
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Nov 15, 2026
  3. dan-petty commented on Nov 15, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p0-critical
    owner/agent
    on Nov 15, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  6. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 15, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 15, 2026
  8. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-15 23:51 UTC

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/mediumpriority/p0-criticalscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions