Skip to content

fix(ci): the fail-to-pass base replay fails every test on the worktree HEAD guard #3124

Closed

Description

@dan-petty

Problem Description

The base replay of devops ci fail-to-pass fails every test it runs, also the tests that the pull request does not change. Each test fails with the hermetic guard error host path reached without a fake: <checkout>/.git/worktrees/tree/HEAD. So the check passes for each fix pull request that changes a test, also when the changed tests pass on the base. The check proves nothing.

Reproduction Steps

  1. Open a fix pull request that changes a test in tests/commands/test_argo.py. Example: fix(argo): replace a token that Argo CD refuses #3121.
  2. Read the log of the Fail-to-Pass Check job (run 41359122060, job 125005470880).

Expected vs Actual Behavior

  • Expected: a test that the pull request does not change, such as test_argo_cd_apps_list_null_items, passes on the base. Only the tests that the fix changes fail on the base.
  • Actual: 29 failed on base (29 failed and 27 passed ...; 30 errored). The failures include unchanged tests such as test_status_exits_1_when_argo_cd_refuses_the_read and test_status_dry_run_sends_no_request, each with Failed: host path reached without a fake: /home/runner/work/devops-cli/devops-cli/.git/worktrees/tree/HEAD. The teardown reports network edge reached without a fake.

The same result occurs locally with uv run devops ci fail-to-pass --base origin/main at 7735d8b.

Environment Diagnostics

CI runner ubuntu-latest, and a cloud sandbox. Both replay in the git worktree .git/worktrees/tree.

Logs, Traces, or Terminal Output

failed on base: tests.commands.test_argo_apps_status::test_status_dry_run_sends_no_request (Failed: host path reached without a fake: /home/runner/work/devops-cli/devops-cli/.git/worktrees/tree/HEAD)
errored on base: tests.commands.test_argo::test_argo_cd_apps_list_null_items (failed on teardown with "Failed: network edge reached without a fake — ... host path reached without a fake: /home/runner/work/devops-cli/devops-cli/.git/worktrees/tree/HEAD. ...")

Existing Tool Considered

None. The cause is in the replay tree of devops ci fail-to-pass and the host-path guard of the test harness. #2197 made git work in the replay tree, but the guard now refuses the read of the worktree HEAD file.

Filed directly because devops roadmap intake had no GitHub login in the agent sandbox. The next intake run places it.

Evaluation 2026-11-04

Answers to the two refine questions.

  • The guard is at tests/conftest.py:567-590 (_install_host_path_guard, message at line 590). The allow list is at lines 484-513, and line 500 hard-codes the main worktree path.
  • The code that reads HEAD is probably _read_git_head_ref (src/devops_cli/telemetry/tracer.py:592-600). It is the only such read that a search of src/ found. The call path from a test is unverified until a run confirms it.

The same guard stops test runs in a runner worktree, not only the replay. The stop of #3230 (2026-11-04T10:22Z) holds host path reached without a fake: <model-clone>/.git/worktrees/w-3230/HEAD, with teardown errors in tests/ai/mcp/test_mcp.py. The stop of #3368 (11:15Z) holds the network edge reached text. These 2 stops took 5.72M input tokens. Other stops on #2116 and #2462 may have this cause, but that is inferred. A run of their test files in a linked worktree can settle it.

Scope to add.

  1. The guard allows the common git directory of any linked worktree. Reuse _linked_worktree_common_dir (src/devops_cli/core/repo.py:88), with no git rev-parse subprocess in conftest. Add it first. Remove the hard-coded path only after the test passes in both the devcontainer and the GitHub runner.
  2. A test runs the hermetic floor in a linked worktree outside the repository.
  3. A test of tests/ai/mcp/test_mcp.py passes in a worktree of the runner form.
  4. satisfied (src/devops_cli/ci/fail_to_pass.py:104-107) is false when a failure carries a guard message (host path reached, network edge reached, process edge reached), or when a test that the pull request did not change fails in the changed files. A failure of every test alone does not refuse the report, because a fix with one new test correctly fails in full on the base.

Setup and teardown errors need no new rule: fail_to_pass.py:99-101 counts errored apart from failed.

Proposed design

Problem statement

The fail-to-pass base replay fails every test in a linked worktree. The hermetic guard denies the read of .git/worktrees//HEAD and reports host path reached without a fake. The check then passes for a fix that changes a test, also when the changed tests pass on the base. The fix must allow the linked worktree common git directory and refuse a replay that carries a guard failure or an unchanged-test failure.

Acceptance criteria

Requirement: linked-worktree-head-read

The hermetic guard SHALL allow a read of the HEAD file under the common git directory of a linked worktree.

Scenario: linked-worktree-head-read-allowed

  • WHEN a test runs in a linked worktree outside the repository and opens .git/worktrees//HEAD
  • THEN the open succeeds and the guard raises no host path reached without a fake error

Requirement: no-git-subprocess-in-guard

The host path guard SHALL allow the linked worktree common directory without a git rev-parse subprocess in tests/conftest.py.

Scenario: guard-allows-without-subprocess

  • WHEN a test runs in a linked worktree and git rev-parse is patched to fail
  • THEN the linked worktree HEAD read succeeds and tests/conftest.py starts no git rev-parse subprocess

Requirement: runner-form-mcp-tests

The test suite SHALL run tests/ai/mcp/test_mcp.py in a linked worktree with the GitHub runner path form.

Scenario: runner-form-mcp-test-passes

  • WHEN the test suite runs tests/ai/mcp/test_mcp.py in a linked worktree under a path with the GitHub runner form
  • THEN the test file passes and the guard raises no host path error

Requirement: guard-message-refuses-replay

The fail-to-pass gate SHALL refuse a base replay when any failure carries a hermetic guard message.

Scenario: guard-message-makes-replay-unsatisfied

  • WHEN a base replay reports a failure with host path reached without a fake, network edge reached without a fake or process edge reached without a fake
  • THEN satisfied is false

Requirement: unchanged-test-refuses-replay

The fail-to-pass gate SHALL refuse a base replay when a test that the pull request did not change fails in a changed test file.

Scenario: unchanged-test-failure-makes-replay-unsatisfied

  • WHEN a changed test file has one changed test that fails on the base and one unchanged test that also fails on the base
  • THEN satisfied is false

Requirement: one-new-test-keeps-replay-valid

The fail-to-pass gate SHALL accept a base replay when every test fails and the pull request adds only one new test.

Scenario: new-test-fails-in-full-on-base

  • WHEN a fix pull request adds one new test and the base replay fails every test in the changed file with no guard message
  • THEN satisfied is true

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers this need: the fix changes the repository's own hermetic test guard and fail-to-pass gate. The written cost is about 30k tokens and 2-4 hours to locate the guard and HEAD read, change the allow list and the satisfied rule, and run the focused tests.

Key questions

  • Where does the hermetic guard raise host path reached without a fake?: _install_host_path_guard in tests/conftest.py raises the message at line 590 when _is_allowed_host_path rejects the path. The allow list hard-codes the main worktree path at line 500. [sources: tests/conftest.py:500, tests/conftest.py:567, tests/conftest.py:590]
  • Which code reads the worktree HEAD file?: _read_git_head_ref in src/devops_cli/telemetry/tracer.py reads git_dir / "HEAD" at line 592. It is the only such read that a search of src/ found. A focused test must confirm the call path from the failing test. [sources: src/devops_cli/telemetry/tracer.py:592, src/devops_cli/telemetry/tracer.py:651]
  • How should the guard allow the linked worktree HEAD read?: Add the common git directory of a linked worktree to the guard's allowed roots. Reuse _linked_worktree_common_dir from src/devops_cli/core/repo.py:88. Do not run git rev-parse in tests/conftest.py. (best practice) [sources: src/devops_cli/core/repo.py:88, tests/conftest.py:500, tests/conftest.py:567]
    • Chosen: Add linked-worktree common dir to allowed roots. Reuses the existing helper, needs no subprocess, and covers .git/worktrees//HEAD and other common git files.
    • Rejected: Allow only .git/worktrees/*/HEAD by pattern. Too narrow. Other reads in the common git directory can still fail.
    • Rejected: Fake the HEAD read in the test harness. The fake needs the exact HEAD content and breaks when the code changes. The read is legitimate.
    • Rejected: Remove the HEAD read from tracer.py. This is invasive and removes telemetry data that git operations need.
  • Should this change remove the hard-coded main worktree path from the guard?: Yes, after the linked-worktree test passes in the devcontainer and the GitHub runner. Keep the hard-coded path until both runs pass. Then remove it in the same pull request. (best practice) [sources: tests/conftest.py:500]
    • Chosen: Keep the path until both environments pass, then remove it. The new common-dir root fixes the bug. The removal waits on evidence from the devcontainer and the GitHub runner.
    • Rejected: Remove the path at once. The removal can break the devcontainer or runner before the linked-worktree test proves the new root.
    • Rejected: Keep the hard-coded path permanently. The path is redundant and can hide a regression in the linked-worktree root.
  • How should satisfied treat a guard message in the base replay?: satisfied SHALL return false when any base failure carries host path reached, network edge reached or process edge reached. The report SHALL name the guard message as the reason. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py:104]
    • Chosen: Refuse on any guard message. A guard failure is a harness failure, not a fail-to-pass result. It can make every test fail.
    • Rejected: Refuse only when every test fails. A fix that adds one new test correctly fails in full on the base.
    • Rejected: Add no gate rule. The check can pass when a changed test fails for the guard reason, so it proves nothing.
  • How should the gate identify a test that the pull request did not change?: Compare each failed test ID with the changed test IDs that the replay command gets from the pull request diff. A failed test that is not in the changed set refuses the report. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py:104, .github/workflows/ci.yml:571]
    • Chosen: Compare failed test IDs with changed test IDs. Uses the test IDs in the JUnit report and the changed files that the command already selects. No new source of truth.
    • Rejected: Refuse on any failure in a changed file. A changed file can hold unchanged tests that fail for a real base defect. The rule must name the unchanged test.
    • Rejected: Refuse when every test fails. A fix that adds one new test correctly fails in full on the base.
  • How are setup and teardown errors counted?: fail_to_pass.py counts errored apart from failed. A teardown error needs no new rule. [sources: src/devops_cli/ci/fail_to_pass.py:99]
  • Which tests prove the change offline?: Add a test that runs the hermetic floor in a linked worktree outside the repository. Add a test that runs tests/ai/mcp/test_mcp.py in a runner-form worktree. Add gate tests in tests/ci/test_fail_to_pass.py for the guard-message and unchanged-test rules. (best practice) [sources: tests/conftest.py:567, tests/ci/test_fail_to_pass.py, tests/ai/mcp/test_mcp.py]
    • Chosen: Add focused guard and gate tests. They prove the fix offline and cover the two failure modes.
    • Rejected: Rely on the end-to-end fail-to-pass run only. The run needs a pull request and does not isolate the guard or gate rule.
    • Rejected: Add only a guard test. The gate rules would stay untested and can regress.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/ci
    status/new
    value/high
    effort/medium
    on Nov 1, 2026
  2. devops-cli-service commented on Nov 1, 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.

    • 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: P1-High. The fail-to-pass check is the project's evidence standard and currently proves nothing for every fix pull request. The failed run 41359122060 does not set P0: no failed run of this repository has that id. A person can set P0 with the label priority/p0-critical.
    • Value: High. A broken verification gate undermines the test-first evidence standard for all fix pull requests.
    • Effort: Medium. The fix targets one guard interaction with the worktree HEAD file but requires understanding the replay and guard interplay.
    • Related: test(ci): the devops ci, devops test and fail-to-pass tests start no git and reach git through the git fake #2179, which asks for a different change. Both concern the hermetic test guard and the fail-to-pass replay, but #2179 asks tests to stop starting real git while the candidate asks the replay to work despite the guard blocking the worktree HEAD file.
  3. added
    priority/p1-high
    on Nov 1, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 6c57c85 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Where is the hermetic guard that produces 'host path reached without a fake' defined? (missing verified source)
    • What code path reads the worktree HEAD file during test execution? (missing verified source)
  5. added
    status/ready
    and removed
    status/new
    on Nov 4, 2026
  6. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 46cf288 (see proposed design in issue body).

  7. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 4, 2026
  8. removed
    status/in-review
    on Nov 4, 2026
  9. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-04 21:19 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/p1-highscope/citype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions