Skip to content

fix(roadmap): stop implement early when a test outside diff_scope fails #3983

Closed

Description

@devops-cli-service

Split from #3972.

Problem: The implement runner keeps trying to edit a test file outside the Changes: list after that test fails. diff_scope forbids the edit. The runner loops until it reaches LimitReached and blocks the item. Why deferred: The stage path check in #3972 now requires the test in the plan. This removes the reported deadlock. The early-stop guard is separate runtime behavior and needs its own design and tests. Acceptance criteria: - The implement runner SHALL stop the step when an invariant test fails on a file outside the Changes: list. - The stop SHALL name the failing test and the path outside Changes:. - The stop SHALL not spend the remaining token budget on edit attempts. - An offline test SHALL cover a failing invariant test outside Changes:.

Proposed design

Problem statement

The implement runner keeps trying to edit a test file outside the Changes: list after that test fails. diff_scope forbids the edit, so the runner loops until LimitReached and blocks the item. The step spends its remaining token budget on edit attempts that cannot succeed. This change stops the step early and names the failing test and path.

Acceptance criteria

Requirement: Stop on out-of-scope invariant test

The implement runner SHALL stop the step when an invariant test fails on a file outside the Changes: list.

Scenario: Invariant test outside Changes: stops the step

  • WHEN the step exit check reports a failing invariant test whose file is not in the group's Changes: list and is not the change's tasks.md
  • THEN the step ends with a stop result and starts no fix step

Requirement: Stop names the test and path

The stop SHALL name the failing test and the path outside Changes:.

Scenario: Stop evidence names the failing test and its path

  • WHEN the guard stops a step for an out-of-scope test failure
  • THEN the stop result holds the test identifier and its file path, and the item comment shows both

Requirement: Stop spends no further tokens

The stop SHALL not spend the remaining token budget on edit attempts.

Scenario: No model request follows the stop

  • WHEN the guard stops a step for an out-of-scope test failure
  • THEN the step makes no model request after the stop and the recorded token spend does not increase

Requirement: Offline test covers the guard

An offline test SHALL cover a failing invariant test outside Changes:.

Scenario: Offline test feeds a failing invariant test outside Changes:

  • WHEN the offline test supplies a step result with a failing invariant test whose file is outside Changes:
  • THEN the runner returns the stop with the test and path and makes no fix attempt

Existing Tool Considered

No check has run. No open, maintained tool or library covers this need: the early-stop guard is internal to the implement runner. The change adds a guard to src/devops_cli/roadmap/implement/implement_step.py and one offline test. Written cost: about 20k to 30k tokens to build, about 2k tokens per later change to keep, and one day elapsed.

Key questions

  • Where does the implement runner compare a diff with the Changes: list?: The eval property diff_scope in src/devops_cli/roadmap/implement/implement_eval_properties.py compares the diff with the Changes: line of the group and allows the change's tasks.md. [sources: src/devops_cli/roadmap/implement/implement_eval_properties.py, docs/ROADMAP_WORKFLOW.md:390, openspec/changes/archive/2026-11-01-3030-implement-fixtures-eval/design.md:9]
  • Where does the implement runner raise a stop?: run_step and run_fix_step in src/devops_cli/roadmap/implement/implement_step.py raise the stop. LimitReached in src/devops_cli/exceptions/ai_pydantic.py is the stop for a spent budget. [sources: src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/exceptions/ai_pydantic.py:67, docs/ERRORS.md:80, openspec/changes/archive/2026-11-05-3568-implement-step-budgets-and-attempts/proposal.md:12]
  • How does the runner find the path of a failing test?: The runner parses the test output of the step exit check. It maps each failing test to its file and compares that file with the Changes: list. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:390, src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/roadmap/implement/implement_eval_properties.py]
    • Chosen: Parse the test output at the exit check. The exit check already runs the tests, so the runner reads the failing node IDs and maps them to files with no new command.
    • Rejected: Block edits to paths outside Changes: at the tool boundary. A write guard stops the edit but does not name the failing test or stop the step.
    • Rejected: Run a separate invariant-test command. It duplicates the exit check and adds a command to keep.
  • What stop kind does the guard raise?: The guard raises a false-premise stop. It returns the item to New with the failing test and path as evidence. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/implement/implement_step.py]
    • Chosen: False premise returns the item to New. The plan does not permit the fix. fix(roadmap): stage includes perimeter tests for network policies #3972 makes the stage job require the test in the plan, so a new plan fixes the cause.
    • Rejected: Blocked stop waits for implement: retry. A retry runs the same plan and repeats the loop.
    • Rejected: LimitReached. It is the current bad behavior and spends the budget.
  • When does the guard run relative to the fix step?: The guard runs at the step exit check, as soon as a test fails, and before the fix step starts. (best practice) [sources: CONTEXT.md, docs/ROADMAP_WORKFLOW.md:390, src/devops_cli/roadmap/implement/implement_step.py]
    • Chosen: At the step exit check, before the fix step. It stops before the model spends tokens on an edit that diff_scope forbids.
    • Rejected: After the diff_scope property fails. The model already made the forbidden edit and spent the tokens.
    • Rejected: At plan parse. The failing test is known only at runtime.
  • Which paths does the guard treat as allowed?: The guard allows the group's Changes: paths and the change's tasks.md, as diff_scope does. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:390, openspec/changes/archive/2026-11-01-3030-implement-fixtures-eval/design.md:9]
    • Chosen: The Changes: paths and the change's tasks.md. It matches diff_scope, which allows the tasks.md of the change.
    • Rejected: Only the Changes: paths. It would stop a valid tick of tasks.md.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-09: none.
Tool: none found.

Activity

  1. added
    type/bug
    source/agent
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    ContributorAuthor

    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/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The guard prevents wasted token budget and a blocked item, but #3972 removes the reported deadlock.
    • Value: Medium. The change makes the implement runner stop cleanly on an invariant test failure outside the plan.
    • Effort: Medium. The change needs new runtime behavior, design decisions and an offline test.
    • Related: fix(roadmap): stage includes perimeter tests for network policies #3972, which asks for a different change. Both items address a test outside the Changes list. #3972 adds that test to the stage plan; this item stops the implement step when the test fails.
  3. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  4. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    ContributorAuthor

    Status set to Ready at 1f03ee3 (see proposed design in issue body).

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

    @devops-cli-service
    ContributorAuthor

    Alternatives check: none

    Reason: One search for an early-stop guard for coding agents returned only unrelated MDN pages. The need is runner-internal: parse the exit-check test output, compare the failing file with the group's Changes: list, and raise a false-premise stop. No open tool covers that, and no ADR rejects one.

    Tool: none found

    Lacks:

    • No tool found that ties a failing test to the plan's Changes: list inside this project's implement runner
    • Stop result, item comment and offline test are project-specific

    Searches run:

    • AI coding agent stop loop when test fails outside allowed file scope early-stop guard, results: 5

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

  6. dan-petty commented on Nov 12, 2026

    @dan-petty
    Owner

    Evidence from #1928 (plan PR #5140, 2026-11-12): the implement job stopped on an invariant test whose fix is outside the plan paths, and the stop got the wrong class.

    • Group 1 added a second [[tool.mypy.overrides]] entry, so test_suppressions_stay_under_their_ceilings failed: "[[tool.mypy.overrides]]: 2 > ceiling 1". The fix is a stub typings/pytrec_eval.pyi, and the plan does not name typings/.
    • The class was types, because the TYPES rule of src/devops_cli/roadmap/failure.py:281 matches the word "mypy" in the name of the suppression kind. TYPES maps to the action repair (failure.py:122). A repair turn can change only the plan paths, so it could not fix the cause. Loki: "job=implement item=refactor(ai): rank the benchmark with numpy and pytrec-eval #1928 result=stopped success=false class=types repair_rounds=1 tokens=6541201 seconds=2079".
    • The right class is plan_defect (action amend), because the fix needs a path outside the Changes: list. When this item stops the step early on such a test, the stop should record that class, so that nobody retries the same plan.

    Related: #5253 (the ceiling message names the wrong file) and #5251 (a rejected plan keeps the implement record of its item).

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

    @devops-cli-service
    ContributorAuthor
  10. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    ContributorAuthor

    Live since 2026-11-17 06:41 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/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions