Skip to content

fix(roadmap): confine repair fix turns to the plan files #4028

Closed

Description

@dan-petty

Problem Description

When a pull request CI check fails after an implement run pushes commits, ImplementRun._repair_after_push invokes run_fix_step.
run_fix_step passes the full CI check failure log to the model without restricting which files the model may edit.
If a repository workflow check or meta-check fails (such as Plan Check or Docs Site Build), the model attempts to fix files outside the OpenSpec change tasks.
In pull request #3961, when Plan Check failed, the repair step edited src/devops_cli/roadmap/plan_check.py instead of files within the change plan.
This behavior spent 217 model requests and 14.4 million tokens on out-of-scope code modifications, duplicated work on main, and caused merge conflicts.

Reproduction Steps

  1. Start an implement run on a staged roadmap item.
  2. Complete task groups and push commits to the pull request branch.
  3. If an external CI check (such as Plan Check) fails, observe ImplementRun._repair_after_push launching run_fix_step.
  4. Inspect the files changed by the model in the repair turn: the model edits arbitrary repository source files outside the planned change files.

Expected vs Actual Behavior

Expected: A repair turn must restrict model edits to the files declared in the change plan and fail or report an error if an out-of-scope workflow check fails.
Actual: run_fix_step permits the model to modify any file in the repository, resulting in large token spend and out-of-scope code changes.

Environment Diagnostics

  • DevOps CLI Version: 0.83.0
  • Python Version: 3.14.10
  • Execution Environment: Kubernetes runner pod

regression of #3824

Proposed design

Problem statement

A repair turn after a push can edit any file in the repository. In pull request #3961 a failed Plan Check made the repair turn edit src/devops_cli/roadmap/plan_check.py. The turn spent 217 model requests and 14.4 million tokens. It duplicated work on main and caused merge conflicts. The change confines a repair turn to the files of the change plan. It stops the item on a check that the plan cannot fix.

Acceptance criteria

Requirement: Repair turn file scope

A repair turn SHALL permit an edit only to a path that the change plan declares.

Scenario: Edit outside the plan

  • WHEN A repair turn edits src/devops_cli/roadmap/plan_check.py and no task group declares that path
  • THEN The step reports a stray file and the turn commits no change to that path.

Requirement: Out-of-scope check spends no model request

The run SHALL stop the item as Blocked with no model request when a failed check names no path of the repair scope.

Scenario: A workflow check outside the plan fails after the push

  • WHEN The check Deploy Preview fails and its annotations and its log name no path of the repair scope
  • THEN _repair_after_push calls no run_fix_step and the stop reason names Deploy Preview.

Requirement: Repair scope holds every plan path

The repair scope SHALL hold each changes and creates path of every task group and each file of the change folder.

Scenario: Two groups declare a path each

  • WHEN A change has two task groups and they declare a.py and b.py
  • THEN The repair scope holds a.py, b.py and each file of the change folder.

Requirement: In-scope check gets a repair turn

The run SHALL give an in-scope failed check at most repair_rounds repair turns.

Scenario: Static Analysis fails on a plan path

  • WHEN The check Static Analysis fails and its log names src/app.py, which the plan declares
  • THEN The run calls run_fix_step with src/app.py in its scope, no more than repair_rounds times.

Requirement: Stop reason names the check and the scope

The stop reason of an out-of-scope check SHALL name the failed check and each path of the repair scope.

Scenario: A person reads the stop comment

  • WHEN The run stops on the check Deploy Preview
  • THEN The stop reason names Deploy Preview and each path of the repair scope.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers the need: the change uses the file confinement and the stray-file check that run_fix_step already holds. The written cost of the own code is about 120 lines, in a scope builder src/devops_cli/roadmap/implement/implement_fix_scope.py, a path argument of run_fix_step in implement_step.py and the call in _repair_after_push in implement_run.py, with four tests. The estimate is 60000 tokens to build it, 10000 tokens each month to keep and fix it, and one day of elapsed time.

Key questions

  • How does the repair turn restrict the files that the model may edit?: Pass the paths of the change plan as the files of the fix group. The step already confines a fix turn to the files of its group and reports a stray file, so _repair_after_push needs no second guard. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/roadmap/implement/implement_step.py, tests/roadmap/implement/test_roadmap_implement_step_fix_paths.py, tests/roadmap/implement/test_roadmap_implement_strays.py]
    • Chosen: Pass the plan paths as the files of the fix group. The step confines a group to its changes and creates paths and reports a stray file, and the tests test_roadmap_implement_step_fix_paths.py and test_roadmap_implement_strays.py hold that behavior.
    • Rejected: Add a separate allowlist argument to run_fix_step. It adds a second path mechanism beside the group files, and the step then enforces two scopes.
    • Rejected: Ask the model in the prompt to edit only plan files. A prompt is no guard. In pull request fix(roadmap): Detect obsolete spec requirements on command rename #3961 the model edited an out-of-scope file with the full log in the prompt.
  • How does the run tell a check that the plan can fix from one that it cannot?: Compare the failed check with the repair scope. A check is in scope when its annotations or its log name a path of the repair scope. A check with no such path is out of scope. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/github/check_verdict.py, docs/adr/0004-ci-is-the-authoritative-gate.md]
    • Chosen: Match the annotations or the log of the check against the repair scope. It uses the evidence of the failing check itself and needs no list of check names. read_check_runs already reads the check runs and their annotations.
    • Rejected: Match the log text only. A log may hold no path, and an annotation names the file and the line.
    • Rejected: Hard-code the names of the workflow checks. The required check names are pinned by ADR 0004, but a repair turn cannot fix the title check, and a new check makes the list stale.
  • What does the run do when a failed check is out of scope?: Stop the item as Blocked with a reason that names the check and the repair scope. Push the ticks that passed, and make no model request. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/implement/implement_run.py]
    • Chosen: Stop the item as Blocked and report the check. Blocked is the status for a wait outside the roadmap, and a person reads the reason and comments implement: retry (CONTEXT.md).
    • Rejected: End the run with an error. An error loses the ticks that passed and the record of the failed check.
    • Rejected: Run the repair turn with no editable file. The model then answers with no edit, and the run spends a model request for nothing.
  • Does the repair scope include the change folder?: Yes. The scope holds each changes and creates path of every task group and each file of the change folder, so a repair turn can tick a task. (best practice) [sources: CONTEXT.md, openspec/changes/archive/2026-11-01-3043-runner-hooks-and-scoped-ci/design.md]
    • Chosen: Include the change folder. The job ticks each task of a group whose exit checks pass, and a repair turn may tick a task (CONTEXT.md).
    • Rejected: Hold only the source paths of the groups. A repair turn that cannot write tasks.md cannot record a tick, and the job then repeats the work.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

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

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 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/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P1-High. The defect wastes 14.4 million tokens per occurrence and causes merge conflicts on main.
    • Value: High. Prevents large token spend and out-of-scope code changes that break the build.
    • Effort: Medium. Requires modifying run_fix_step to enforce a file allowlist and report out-of-scope check failures.
  3. added
    priority/p1-high
    on Nov 7, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

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

  6. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: One search found only generic filesystem MCP servers that limit paths, such as the Filesystem reference server. The issue needs more than that. A repair turn must be confined to the paths a change plan declares, and a failed CI check that names none of those paths must stop the item as Blocked. The need is internal to this project's run_fix_step and _repair_after_push, which already hold the group-file confinement and the stray-file check. No open tool covers it.

    Tool: none found

    Covers:

    • Generic filesystem servers can restrict access to configured paths

    Lacks:

    • Takes the allowed paths from an OpenSpec change plan
    • Classifies a failed CI check as in scope or out of scope
    • Stops a roadmap item as Blocked without a model request
    • Integrates with ImplementRun._repair_after_push

    Searches run:

    • restrict AI coding agent edits to allowlist of file paths, reject out-of-scope file changes, results: 5

    Sources:

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

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

    @devops-cli-service
    Contributor

    Live since 2026-11-11 19:36 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/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions