Skip to content

feat(ci): fail-to-pass check proves a fix's tests fail on its base (devops ci fail-to-pass) #844

Closed

Description

@dan-petty

Context & Rationale

AGENTS.md:203 requires test-first fixes, and #601 made 'fails unpatched, passes patched' the evidence standard. In practice the evidence is typed by hand: '16 of them fail on 07a52ef' in #802 and task-786. #704 forbids cross-checking typed numbers, and CI keeps no artifact to compare against.

A read-only replay ran each fix's tests against its base tree, with the head's tests overlaid, the head's .venv, and pythonpath=['src'] putting the base src first (pyproject.toml:101-105). 10 of 11 sampled fix commits fail on their base:

The exception, e8eaf4a (#758), fixed the test harness itself.

Scope & Deliverables

  • Deliverable:
    • devops ci fail-to-pass --base <ref>:
      • resolves the merge base;
      • lists the added or modified tests/**/test_*.py files;
      • materialises the base tree in a temporary directory, with the head's tests/ overlaid;
      • runs those files with the current pytest (-o addopts=, -p no:cacheprovider, --junitxml);
      • reports, per test, whether it failed, errored or passed on base.
    • Defect PRs:
      • A defect PR has a title starting fix( or fix:, or a type/bug or type/security label. This is the same classifier as feat(github): defect prs carry their hardening readiness blocker and post-merge audit #697.
      • A defect PR exits non-zero unless at least one changed test fails in the call phase on base (any exception type), or the PR body holds a Fail-to-pass: not applicable: <reason> line, which the job summary echoes.
      • Collection errors are reported but do not count. Other PRs get the report and exit 0.
    • .github/workflows/fail-to-pass.yml:
      • triggers on pull_request [opened, synchronize, reopened, edited, labeled] into main and release/**;
      • uses fetch-depth: 0;
      • passes the title, labels and body through env, with no expression inside run:;
      • replays one recorded fix as a self-check when its own files change.
    • AGENTS.md and instruction_generator.py tell fix PRs to cite this check run instead of typing failure counts.
  • Acceptance criteria:
    • Unit tests with a mocked pytest run cover:

      • a test that fails on base exits 0 and reports '1 failed on base';
      • a test that passes on base exits 1 and names the test;
      • a collection error does not satisfy the check;
      • the not-applicable line exits 0 and prints its reason;
      • a non-defect PR exits 0.

      Together they take at most 1 s.

    • The workflow's self-check replays 5768cd9 against 36b2bee and reports 16 failed and 24 passed in tests/test_ai_fixer.py. It runs outside devops ci.

    • A workflow contract test asserts that the job calls devops ci fail-to-pass and has no expression inside run:.

    • uv run devops ci gains no stage.

  • Key questions:
  • Constraint:
    • The check proves that a test detects a change, not that it detects the right change; reviewers still judge that.
    • PRs that change dependencies error on base and need the escape line.

Strategic Alignment

Proposed design

Problem statement

The project requires test-first fixes (AGENTS.md:203, #601) and forbids cross-checking hand-typed failure counts (#704), yet CI keeps no artifact to compare against. In practice, evidence that a fix's tests fail on the base commit is typed by hand in PR bodies. This issue adds a devops ci fail-to-pass command and a GitHub Actions workflow that automatically replays a defect PR's changed tests against its merge-base tree, proving they fail there, and gates defect PRs on that evidence.

Acceptance criteria

  • Criterion 1: A test that fails on base causes the command to exit 0 and report '1 failed on base'.
    Verification: Run the unit test suite for devops ci fail-to-pass with a mocked pytest run that returns one failure; assert exit code 0 and that the output contains '1 failed on base'.
  • Criterion 2: A test that passes on base causes the command to exit 1 and name the test.
    Verification: Run the unit test suite with a mocked pytest run where all tests pass; assert exit code 1 and that the output names the specific test that passed.
  • Criterion 3: A collection error does not satisfy the fail-to-pass check.
    Verification: Run the unit test suite with a mocked pytest run that produces a collection error; assert the check is not satisfied (exit non-zero for a defect PR) and the error is reported.
  • Criterion 4: A PR body containing 'Fail-to-pass: not applicable: ' causes the command to exit 0 and print the reason.
    Verification: Run the unit test suite with a mocked PR body holding the not-applicable line; assert exit code 0 and that the reason text appears in the output.
  • Criterion 5: A non-defect PR (title not starting with fix(/fix: and no type/bug or type/security label) exits 0 regardless of test results.
    Verification: Run the unit test suite with a non-defect PR title and labels; assert exit code 0.
  • Criterion 6: The five unit tests above complete in at most 1 second together.
    Verification: Run uv run pytest tests/ -k fail_to_pass --durations=0 and confirm total duration is ≤ 1 s.
  • Criterion 7: The workflow self-check replays commit 5768cd9 against base 36b2bee and reports 16 failed and 24 passed in tests/test_ai_fixer.py, running outside devops ci.
    Verification: Inspect .github/workflows/fail-to-pass.yml for a self-check job that invokes the replay of 5768cd9 against 36b2bee and asserts the 16/24 counts; confirm it is a separate job not part of the devops ci stage.
  • Criterion 8: A workflow contract test asserts the job calls devops ci fail-to-pass and contains no expression inside run:.
    Verification: Run the workflow contract test (e.g. uv run pytest tests/ -k workflow_contract_fail_to_pass); it parses the YAML and asserts the run: block contains the literal string devops ci fail-to-pass and no ${{ expression.
  • Criterion 9: uv run devops ci gains no new stage from this change.
    Verification: Run uv run devops ci --help and confirm the stage list is unchanged from before this PR.
  • Criterion 10: AGENTS.md and instruction_generator.py instruct fix PRs to cite the fail-to-pass check run instead of typing failure counts.
    Verification: Grep AGENTS.md and src/devops_cli/ (instruction_generator) for a reference to the fail-to-pass check; confirm the old guidance about typing counts is replaced or supplemented.
  • Criterion 11: The workflow triggers on pull_request [opened, synchronize, reopened, edited, labeled] into main and release/**, uses fetch-depth: 0, and passes title, labels, and body through env with no expression inside run:.
    Verification: Parse .github/workflows/fail-to-pass.yml; assert the on.pull_request.types list, branches list, fetch-depth: 0, and that env carries PR_TITLE, PR_LABELS, PR_BODY while run: contains no ${{.

Key questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/cli
    priority/p1-high
    on Oct 1, 2026
  2. modified the milestone: v0.2.28 on Oct 1, 2026
  3. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    Placement (2026-10-02): moved from v0.2.28 to the top of the backlog, by the owner's decision. #921 (hand-written docs fixes, P1, high value, medium effort) took its slot as the lowest-ranked item there. This item stays P1 and takes the next open slot.

  4. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    Status set to Ready at 69c99cf (see proposed design in issue body).

  5. added this to the v0.2.36 milestone on Oct 11, 2026
  6. added
    status/in-progress
    on Oct 16, 2026
  7. dan-petty commented on Oct 16, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1596, merged into release/v0.2.36 as 3bb1951.

    Summary

    Implements devops ci fail-to-pass and .github/workflows/fail-to-pass.yml so defect pull requests automatically prove their changed tests fail on the merge-base tree.

    • Fail-to-Pass Replay (src/devops_cli/ci/fail_to_pass.py, src/devops_cli/commands/ci.py):
      • Resolves the merge base of --base and --head, lists added or modified tests/**/test_*.py files, materialises the base tree in a temporary directory with the head's tests/ overlaid, and executes pytest (-o addopts=, -p no:cacheprovider, --junitxml).
      • Reports per-test outcomes (failed, errored, passed) and summary counts.
      • Classifies defect PRs via is_defect_pr (src/devops_cli/github/defect_classifier.py): exits non-zero unless at least one changed test fails in the call phase on base or the PR body declares Fail-to-pass: not applicable: <reason> (echoed to $GITHUB_STEP_SUMMARY). Collection errors are reported as errored and do not satisfy the check; non-defect PRs print the report and exit 0.
    • GitHub Actions Workflow (.github/workflows/fail-to-pass.yml):
      • Triggers on pull_request [opened, synchronize, reopened, edited, labeled] into main and release/** with fetch-depth: 0.
      • Passes PR_TITLE, PR_LABELS, and PR_BODY via env with no ${{ expression inside run:.
      • Includes a self-check job that replays 5768cd9 against 36b2bee and verifies 16 failed and 24 passed in tests/test_ai_fixer.py when its own files change.
    • **Instr…

    15 file(s) changed.

    How it was verified

    Check runs at 943cad9:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • Changed-Test Independence: pass
    • Fail-to-Pass Self-Check: pass
    • Fail-to-Pass Check: pass
    • Static Analysis: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-844-fail-to-pass.md:

    No Acceptance Criteria section.

  8. added a commit that references this issue on Oct 17, 2026
  9. removed
    status/in-progress
    on Oct 30, 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

    priority/p1-highscope/clitype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions