Skip to content

fix(ci): fail-to-pass replays the support fix of the head on the base #4908

Done

Description

@dan-petty

Problem Description

devops ci fail-to-pass checks out the merge base and puts the whole tests/ tree of the head on it. Thus a fix whose cause is in tests/support/ (or in another file under tests/ that is not a test_*.py file) gets its fixed support code on the base too. The changed tests then pass on the base, and the replay exits 1, also when the tests fail on the real base. AGENTS.md rule 4 tells each fix pull request to cite this run, so the author must write the proof by hand.

Reproduction Steps

  1. Check out PR fix(tests): refuse test writes under the real home #4857 (a fix of the hermetic floor in tests/support/, with no change under src/).
  2. Run uv run devops ci fail-to-pass --base origin/main.
  3. The command exits 1: 0 failed on base (0 failed and 27 passed in tests/invariants/test_hermetic_floor.py; 0 errored).
  4. Run the same tests with the base versions of the changed tests/support/ files: 3 failed.

Expected vs Actual Behavior

Expected: the replay shows the three new tests as failed on base, because the base holds the defect.

Actual: the replay runs the fixed support code on the base, and the new tests pass there.

Proposed Fix

Replay the base versions of the changed files under tests/ that are neither a changed tests/**/test_*.py file nor a changed check module of tests/gate/<row>_checks/, and keep the head versions of those two kinds. A changed test that needs a new helper of the head then cannot be collected on the base, which is reported as errored, so the design must name how a fix that adds a helper and fixes a helper proves itself.

Environment Diagnostics

Reported in a comment of #4554 by the agent of #4739. #4554 adds the gate check replay and keeps the overlay of the head's tests/ tree, because the check modules of the head must run against the base manifests.

Source: #4554

Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found only SWE-bench-style evaluation harnesses and container images; they apply the whole test patch, support files included, to the base commit, which is the same defect. No tool classifies changed tests/ files or replays base support versions.

Lacks:

  • Classifies changed files under tests/ into test, check and support modules
  • Writes base version of changed support modules and conftest files
  • Keeps head version of changed test and gate check modules
  • Reports an uncollectable changed test as errored and names its file

Proposed design

Problem statement

devops ci fail-to-pass checks out the merge base and puts the whole tests/ tree of the head on it. A fix whose cause is in tests/support/ or tests/conftest.py then gets its fixed support code on the base. The changed tests pass on the base, the command exits 1, and the author writes the proof by hand. The command must replay the base versions of the changed support files and keep the head versions of the changed test modules and gate check modules. The replay runs only when the fix changes a src/ module or a tests/gate/ file, and it keeps the merged rule that a changed test which errors on the base proves the fix.

Acceptance criteria

Requirement: A changed support file takes the base version

The replay SHALL write the base version of each changed file under tests/ that is neither a tests/**/test_*.py module nor a module directly under tests/gate/<row>_checks/, when the base holds that path.

Scenario: Changed support module

  • WHEN The changed files hold src/devops_cli/ci/fail_to_pass.py and tests/support/base_replay.py, and the base holds tests/support/base_replay.py.
  • THEN The base worktree holds the base version of tests/support/base_replay.py when pytest starts.

Requirement: A changed test module keeps the head version

The replay SHALL keep the head version of each changed tests/**/test_*.py file.

Scenario: Changed test module

  • WHEN The changed files hold src/devops_cli/ci/fail_to_pass.py and tests/ci/test_fail_to_pass.py.
  • THEN The base worktree holds the head version of tests/ci/test_fail_to_pass.py when pytest runs.

Requirement: A changed gate check module keeps the head version

The replay SHALL keep the head version of each changed module directly under a tests/gate/<row>_checks/ folder, other than __init__.py.

Scenario: Changed check module

  • WHEN The changed files hold a module directly under a tests/gate/<row>_checks/ folder.
  • THEN The base worktree holds the head version of that module when its gate row runs.

Requirement: A changed tests conftest takes the base version

The replay SHALL write the base version of a changed tests/conftest.py when the base holds that path.

Scenario: Changed tests conftest

  • WHEN The changed files hold src/devops_cli/ci/fail_to_pass.py and tests/conftest.py.
  • THEN The base worktree holds the base version of tests/conftest.py when pytest starts.

Requirement: A support file that the base lacks keeps the head version

The replay SHALL keep the head version of each changed file under tests/ that the base does not hold.

Scenario: Added helper module

  • WHEN The head adds tests/support/new_helper.py and the base holds no such path.
  • THEN The base worktree holds the head version of tests/support/new_helper.py when pytest runs.

Requirement: A support file that the head deletes stays at its base version

The replay SHALL leave the base version of each file under tests/ that the head deletes.

Scenario: Deleted helper module

  • WHEN The head deletes tests/support/old_helper.py and the base holds that path.
  • THEN The base worktree still holds tests/support/old_helper.py when pytest runs.

Requirement: The dry run lists the base support file reads

The dry run SHALL list each git read of the base version of a changed support file and SHALL start no process.

Scenario: A dry run of a support file fix

  • WHEN uv run devops ci fail-to-pass --dry-run runs for a fix that changes src/devops_cli/ci/fail_to_pass.py and tests/support/bootstrap.py.
  • THEN The plan lists a git request that reads the base version of tests/support/bootstrap.py, and the process fake records no call.

Requirement: The report names a changed test that errors on the base

The replay SHALL count a changed test that it cannot collect on the base as errored and SHALL name its file in the report.

Scenario: A changed test that needs a head-only name

  • WHEN The replay writes the base version of a changed support file, and a changed test imports a name that only the head version of that file holds.
  • THEN The report prints errored on base for that changed test file, and the summary counts one errored test.

Requirement: The contributing guide states the base support file rule

CONTRIBUTING.md SHALL state that the replay writes the base version of each changed support file under tests/ and keeps the head version of each changed test module and check module.

Scenario: The guide after the change

  • WHEN The fail-to-pass section of CONTRIBUTING.md is read.
  • THEN It says that a changed tests/conftest.py or tests/support/ module is replayed at its base version, and that a new helper goes in a new file or in the changed test file.

Existing Tool Considered

The alternatives check of 2026-11-27 in the issue body records the verdict none, with no tool found. Its block lists what a tool lacks. The change builds the classification of the changed files and the overlay in devops ci fail-to-pass. Written cost: about 2,000 tokens to build, about 1,000 tokens to keep, about 500 tokens per fix, and about 2 hours of elapsed time.

Key questions

  • Which changed files under tests/ must come from the base, and which must come from the head?: The base version of every changed file under tests/ that is neither a tests/**/test_*.py module nor a module directly under tests/gate/<row>_checks/, when the base holds that path. The head version of each changed test module, each changed check module, and each changed support file that the base does not hold. A file that the head deletes stays at its base version. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py, tests/ci/test_fail_to_pass.py, tests/conftest.py, openspec/specs/ci-fail-to-pass/spec.md, CONTRIBUTING.md]
    • Chosen: Base version of every changed file under tests/ except test modules and check modules. pytest loads conftest and support modules from the tree, so the base tree must hold their base versions to show the defect.
    • Rejected: Base version of changed tests/support/ files only. A fix in tests/conftest.py alone stays on the base.
    • Rejected: Keep the whole head tests/ tree on the base. That is the defect: the fixed support code lands on the base and the changed tests pass there.
    • Rejected: Base version of every changed file under tests/, test modules included. The changed test module must be the head version, else the replay runs no new test.
  • How does the base support-file replay interact with the merged collection-error proof of fix(ci): count a test that errors on base as fail-to-pass proof #6372 and fix(ci): finish the fail-to-pass error rule of #6379 #6400?: The replay keeps the merged rule that a changed test which errors on the base proves the fix, from TestCaseOutcome.proves_fix in src/devops_cli/ci/fail_to_pass.py:146 and the spec requirement A changed test that errors on base proves the fix. The overlay writes the base version of the changed support files and keeps the head version of the changed test and check modules. A changed test that needs a new helper of the head takes it from a new support file that the base does not hold, or from the changed test file. The report still names each errored changed test. (best practice) [sources: openspec/specs/ci-fail-to-pass/spec.md, src/devops_cli/ci/fail_to_pass.py:146, tests/ci/test_fail_to_pass.py:949]
  • Does the replay run for a fix that changes no src/ module and no tests/gate/ file?: No. The replay runs only when the fix changes a .py file under src/ or a file under tests/gate/. A pure tests/support/ or tests/conftest.py fix replays nothing and needs no failing proof. The base support-file replay applies only to a fix that also changes src/ code or a tests/gate/ file. [sources: openspec/specs/ci-fail-to-pass/spec.md, src/devops_cli/ci/fail_to_pass.py]
  • When does devops ci fail-to-pass exit 0?: It exits 0 when the report is satisfied: no replay could not run, no head replay could not run, no failure carries the host path guard message, no unchanged test fails on the base, no gate row refuses, and at least one changed test fails or errors on the base, or a case of a changed gate check fails on the base and passes on the head. [sources: src/devops_cli/ci/fail_to_pass.py, src/devops_cli/commands/ci.py, openspec/specs/ci-fail-to-pass/spec.md]
  • What happens when a new support file of the head imports a name that the base src/ lacks?: The replay writes the base version of a changed support module, so the head import never loads and pytest starts. A new support file that the base does not hold keeps the head version, so it must import the module and call the attribute. It must not import a name that the base src/ lacks at module import time. (best practice) [sources: tests/conftest.py, tests/support/git_scenarios.py, src/devops_cli/roadmap/project_review/git_read.py, src/devops_cli/ci/fail_to_pass.py]
    • Chosen: Replay changed support modules at the base version and import the module in a new support file. The base version removes the head import from a changed support module; a new support file avoids a name that the base lacks.
    • Rejected: Keep the head version of a changed support module that adds a name. The fixed support code would be on the base and the changed tests would pass there.
    • Rejected: Ignore a pytest start failure on the base. The replay would prove nothing and the author would get no useful result.
  • Which commit does the replay check out, and which diff gives the changed files?: It resolves the merge base of --base and --head and checks out that merge base as a detached git worktree. It lists the changed files with git diff --name-status -z --find-renames <merge_base>...<head>. For HEAD, it also lists the untracked files under tests/. The change alters only which versions of those changed files the worktree holds. [sources: src/devops_cli/ci/fail_to_pass.py, src/devops_cli/git/operations.py, src/devops_cli/commands/ci.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/ci. The (ci) scope of the title gives the scope.
    • Priority: P2-Medium. The check gives false proof for fix PRs that change support files, but a manual workaround exists.
    • Value: Medium. Fix PRs touching tests/support/ cannot get automated fail-to-pass proof, breaking the AGENTS.md rule 4 requirement.
    • Effort: Medium. Requires classifying changed files under tests/ and handling the edge case where a test needs a new helper from the head.
    • Related: feat(ci): fail-to-pass check proves a fix's tests fail on its base (devops ci fail-to-pass) #844, which asks for a different change. Both concern the devops ci fail-to-pass replay; #844 created the command, this candidate fixes a bug where support files leak into the base replay.
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Scope: scope/ci. The (ci) scope of the title gives the scope.
    • Priority: P2-Medium. The bug causes false failures for a limited set of fixes, and a manual proof is a workaround.
    • Value: Medium. The change restores correct proof for fixes that touch test support code.
    • Effort: Medium. The fix changes the replay file selection and needs a design for helper files.
    • Related: feat(ci): fail-to-pass check proves a fix's tests fail on its base (devops ci fail-to-pass) #844, which asks for a different change. Both items concern the fail-to-pass base replay, but #844 adds the check and the candidate fixes its support-file overlay.
  6. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    A second case of this defect: the fix of #3990 is in tests/conftest.py only. The floor fixture isolate_devops_cli_config now removes DEVOPS_CLI_ROADMAP_IMPLEMENT_IN_RUNNER. The pull request changes no file under src/.

    • uv run devops ci fail-to-pass --base origin/main prints 0 failed on base (0 failed and 35 passed in tests/invariants/test_hermetic_floor.py, tests/roadmap/implement/test_roadmap_implement_records.py; 0 errored). The replay puts the fixed tests/conftest.py of the head on the base.
    • The same new test, test_the_runner_variable_of_the_outer_environment_reaches_no_test, fails on the commit before the fix, where tests/conftest.py is the same as on main: AssertionError: assert ('true', True) == (None, False).

    So the proposed fix must also replay the base version of a changed conftest.py, not only the files of tests/support/.

  7. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Another case: the fix of #4711 is in tests/conftest.py and tests/support/bootstrap.py, with no change under src/.

    • uv run devops ci fail-to-pass --base origin/main exits 1: 0 failed on base (0 failed and 31 passed in tests/invariants/test_hermetic_floor.py; 0 errored).
    • The base tree (origin/main 8a7b113) with only the changed test file of the head gives 2 failed, 1 passed: test_caught_udp_sends_and_name_lookups_fail_with_edge_name and test_git_refuses_a_network_remote_at_once fail on the base.

    The root conftest.py is a third kind of file that the replay must take from the base.

  8. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches for a tool that replays a fix's changed tests on the base commit with base versions of the changed test-support files found only pytest-replay (re-executes a previous run's test order) and git replay (rebases commits); neither checks out a base tree, classifies changed files under tests/, or overlays base support/conftest files while keeping head test and check modules. The needed change is therefore specific to this project's own devops ci fail-to-pass command, and no external tool covers it.

    Tool: none found

    Lacks:

    • No tool found that checks out the merge base and classifies the head's changed files under tests/ into test modules, gate check modules and support files
    • No tool found that replays the base version of changed support files such as tests/support/*.py, tests/conftest.py and the root conftest.py while keeping the head's changed test files and check modules
    • No tool found that reports a head test that cannot be collected on the base (because it needs a new head helper) as errored
    • pytest-replay only re-executes the order of tests from a previous run; it does not select files per commit or overlay base versions
    • git replay only rewrites commits onto another base; it runs no tests and proves nothing about fail-to-pass

    Tools considered:

    Searches run:

    • pytest fail-to-pass replay changed tests on base commit, results: 5
    • tool replay only changed test files on base commit git overlay, results: 5
    • pytest plugin run changed tests against previous commit checkout worktree, results: 5
    • tool verify new test fails on base commit before fix automatically fail-to-pass, results: 5
    • "fails on base" "passes on head" test verification CLI tool, results: 5
    • automatically check new tests fail on the parent commit git worktree tool, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  9. added
    status/ready
    and removed
    status/new
    on Nov 16, 2026
  10. 5 remaining items

  11. added
    status/new
    and removed
    status/ready
    owner/agent
    on Nov 28, 2026
  12. added
    status/ready
    and removed
    status/new
    on Nov 28, 2026
  13. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  14. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  15. removed
    status/in-review
    on Nov 29, 2026
  16. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 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/p2-mediumscope/cisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions