Skip to content

fix(roadmap): allow test-turn file restorations in implement repair #4011

Closed

Description

@dan-petty

Problem Description

The implement repair turn aborts when an agent restores or reverts a source file.

During an implement repair turn for fail-to-pass checks, _fail_to_pass_failure restricts repair_paths to the test files. At the start of the repair turn, tree = _tree(source) records the git tree of the checkout.

If the model agent runs git commands or restores a non-test file to match the base commit (keeper.base), _foreign_change compares the checkout to tree. Because the restored file differs from tree, _foreign_change detects a change in an unallowed file.

The step then aborts with:
The extra turn for the static check changed files that the step had not changed: <paths>.

This stops the job even when the agent only cleaned up uncommitted edits.

Reproduction Steps

  1. In an implementation step with a fail-to-pass test failure, enter a repair round.
  2. The repair round permits edits only to test files.
  3. In the repair round, touch or revert an edit in a non-test file (such as running git stash or git checkout -- <file>).
  4. Complete the repair turn.
  5. Observe that _foreign_change aborts the step with implement_stop_repair_turn_changed.

Expected vs Actual Behavior

Expected: _foreign_change allows working files whose contents match keeper.base. Reverting a file back to its base state does not abort the repair turn.

Actual: _foreign_change compares only against tree from the start of the turn. Reverting a modified file back to base is treated as an unauthorized modification.

Environment Diagnostics

  • DevOps CLI Version: 0.82.0
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64
  • Execution Environment: DevContainer

Alternatives check of 2026-11-10: covers.
Tool: git/git (https://github.com/git/git), NOASSERTION, last activity 2026-11-09, maintained.

Proposed design

Problem statement

The extra repair turn of an implement step stops with implement_stop_repair_turn_changed when the agent restores a file to its content at keeper.base. _foreign_change compares the checkout only with tree, the tree taken at the start of the turn. A restoration then looks like an edit of a file outside repair_paths. The step must accept a file whose content equals keeper.base. It must still stop on a real foreign change.

Acceptance criteria

Requirement: Restored file passes

The extra turn SHALL accept a file outside repair_paths whose content equals its content at keeper.base.

Scenario: Revert a modified source file to base

  • WHEN The step modified a source file before the extra turn, and the agent reverts that file to its content at keeper.base.
  • THEN _foreign_change returns None, and the step continues with the exit checks.

Requirement: Foreign edit stops the turn

The extra turn MUST stop when a file outside repair_paths holds content that differs from tree and from keeper.base.

Scenario: Write new content into a source file

  • WHEN The agent writes new content into a source file outside repair_paths, and that content differs from tree and from keeper.base.
  • THEN _foreign_change returns the reason implement_stop_repair_turn_changed and names that file.

Requirement: Deleted base file stops the turn

The extra turn MUST stop when the agent deletes a file outside repair_paths that exists at keeper.base.

Scenario: Delete a source file

  • WHEN The agent deletes a source file outside repair_paths that exists in tree and at keeper.base.
  • THEN _foreign_change returns the reason implement_stop_repair_turn_changed and names the deleted file.

Requirement: New file stops the turn

The extra turn MUST stop when the agent adds a file outside repair_paths that exists in neither tree nor keeper.base.

Scenario: Add a source file

  • WHEN The agent adds a file outside repair_paths that exists in neither tree nor keeper.base.
  • THEN _foreign_change returns the reason implement_stop_repair_turn_changed and names the new file.

Requirement: Repair paths pass

The extra turn SHALL accept any change to a path in repair_paths and any change to the tasks.md of the change.

Scenario: Edit a test file

  • WHEN The agent changes a test file that _fail_to_pass_failure put in repair_paths.
  • THEN _foreign_change returns None, and the step continues with the exit checks.

Requirement: Hook turn uses the same rule

The extra turn for a failed hook SHALL use the same rule for a restoration to keeper.base as the repair turn for a failed static check.

Scenario: Restore a source file in the hook turn

  • WHEN The agent restores a source file outside repair_paths to its content at keeper.base during the turn for a failed hook.
  • THEN _foreign_change returns None, and a source file with new content still gives the stop reason.

Existing Tool Considered

Git (https://github.com/git/git, maintained) covers the need, and the step already calls it. git diff --cached --name-only -z <commit> lists the paths that differ from a commit. The change runs it once more, against keeper.base, and subtracts the result from the paths that differ from tree. Git lacks the project rule that decides which paths the turn may change. That rule stays in _foreign_change, and so do its unit tests. No new dependency, library or parsing code is needed. The cost of own code is one small function change and its unit tests.

Key questions

  • How does _foreign_change tell a restoration to keeper.base from a foreign change?: Add a base argument to _foreign_change (src/devops_cli/roadmap/implement/implement_step.py:1565). _extra_turn passes keeper.base, a commit id that the keeper sets in __post_init__ (src/devops_cli/roadmap/implement/implement_wip.py:117). After git add -A, run git diff --cached --name-only --no-renames -z <base> as well as the diff against tree. A path that differs from tree but not from base is a restoration and passes. Every other path outside repair_paths and the tasks.md stays foreign. A deleted or added file differs from base, so it stays foreign. (best practice) [sources: src/devops_cli/roadmap/implement/implement_step.py:1565, src/devops_cli/roadmap/implement/implement_wip.py:117, openspec/changes/archive/2026-10-30-2795-static-failure-repair-turn/proposal.md:37]
    • Chosen: Subtract the base diff from the tree diff. It reuses the Git call that _foreign_change already makes. It needs one more Git call and one set operation.
    • Rejected: Compare the blob id of each changed path. It needs one git rev-parse <base>:<path> call for each path and more parsing code.
    • Rejected: Add every file the step touched to repair_paths. It permits a real edit of those files during the turn, so the check stops guarding them.
    • Rejected: Compare content hashes in Python. It reads every changed file into the process and copies a function that Git already provides.
  • Does the allowance change the other extra turn, which shares _foreign_change?: Yes. The extra turn for a failed hook and the extra turn for a failed static check or fail-to-pass check call the same helper through _extra_turn. Both get the rule. No turn asks for a tick now, because the job ticks the group (fix(roadmap): the job owns the ticks and the strays of a step #3488), so the old tick turn rule no longer applies. (best practice) [sources: src/devops_cli/roadmap/implement/implement_step.py:1578, src/devops_cli/roadmap/implement/implement_step.py:1624]
    • Chosen: One shared rule in _foreign_change. A restoration to base is no content change in any turn. One helper keeps one rule.
    • Rejected: A flag that allows restorations in the repair turn only. It adds a parameter and a branch for no gain, because the hook turn has the same case.
  • Where do the unit tests for the restoration case go?: Put them in the test module for implement_step.py that calls _foreign_change. No test calls _foreign_change now, so the change adds the first unit tests for it. Use a temporary Git repository with a base commit. [sources: src/devops_cli/roadmap/implement/implement_step.py:1565]
  • The alternatives check says that Git covers the need (https://github.com/git/git). Adopt it as it is, or keep the item with a reason?: Keep the item. The step already uses Git, and the change adds one Git call and one set operation. Git does not hold the project rule for the paths that a turn may change. My recommendation is to keep the item as proposed. (a person decides)

Open questions

  • The alternatives check says that Git covers the need (https://github.com/git/git). Adopt it as it is, or keep the item with a reason? (a person decides)
  • The alternatives check found that https://github.com/git/git covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    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: P2-Medium. A false positive that aborts a step, but the agent can avoid it by not restoring files.
    • Value: Medium. Prevents a legitimate cleanup action from stopping the job.
    • Effort: Low. The fix adds a keeper.base comparison to the existing _foreign_change check.
    • Related: feat(roadmap): a failed verification command gets a repair round #3577, which asks for a different change. Both concern the implement repair turn, but #3577 adds repair rounds while the candidate fixes a false positive in that turn's foreign-change check.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 8, 2026
  5. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    Alternatives check: covers

    Reason: Git already covers the need. git diff --cached --name-only -z <keeper.base> lists the paths that differ from the base commit, and the issue's design subtracts that set from the paths that differ from tree. No new library is needed. No ADR in decisions rejects Git for this.

    Tool: git/git (https://github.com/git/git)

    • License: NOASSERTION
    • Last activity: 2026-11-09
    • Maintained: yes

    Covers:

    • Listing the paths that differ from keeper.base
    • Telling a restoration to base from a foreign edit by set subtraction

    Lacks:

    • The change to _foreign_change and its unit tests still has to be written in the project's code
    • The repair_paths allowance stays project logic

    Tools considered:

    Searches run:

    • git diff --cached --name-only compare working tree to commit list paths differing, 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
    status/new
    and removed
    status/ready
    on Nov 10, 2026
  8. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Status set back to New at e99dc01. Refine cannot set this item to Ready at e99dc01 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.

    • The alternatives check says that Git covers the need (https://github.com/git/git). Adopt it as it is, or keep the item with a reason? (a person decides)
    • The alternatives check found that https://github.com/git/git covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
  9. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 14, 2026
  10. removed
    status/in-review
    on Nov 14, 2026
  11. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 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/lowpriority/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