Repository navigation
feat(roadmap): Give failed checks and lost tests a repair turn - #5904
Conversation
9ffc8f6 to
a3b97f4
Compare
|
The steps of the job: Stopped at group 2. Failure class:
Reason: Last message of the agent (a claim that no check verified): Group 2 is done and both of its tasks are ticked. What I changed: - The job discarded this work. The diff is cut to 20000 characters. Read it before you retry: diff --git a/openspec/changes/3577-a-failed-verification-command-gets-a/tasks.md b/openspec/changes/3577-a-failed-verification-command-gets-a/tasks.md
index 9ed997951..f93028d49 100644
--- a/openspec/changes/3577-a-failed-verification-command-gets-a/tasks.md
+++ b/openspec/changes/3577-a-failed-verification-command-gets-a/tasks.md
@@ -13,9 +13,9 @@ Kind: behavior. Reads: `src/devops_cli/roadmap/implement/implement_shell_policy.
Kind: behavior. Reads: `src/devops_cli/roadmap/implement/implement_step.py`, `src/devops_cli/roadmap/implement/implement_shell_policy.py`, `src/devops_cli/roadmap/implement/implement_wip.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/implement/test_roadmap_implement_step_attempts.py`, `tests/roadmap/implement/test_roadmap_implement_step_repair.py`, `tests/support/implement_step.py`. Changes: `src/devops_cli/roadmap/implement/implement_step.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/implement/test_roadmap_implement_step_attempts.py`, `tests/roadmap/implement/test_roadmap_implement_step_repair.py`.
-- [ ] 2.1 Change `test_a_failed_verification_command_gets_no_round_and_names_no_rounds` in `tests/roadmap/implement/test_roadmap_implement_step_attempts.py` to `test_a_failed_verification_command_gets_one_round_and_ends_done`: the first turn writes a test file and a source file of the temporary checkout and ticks no task, the exit check runs the group's verification command and it exits 1, the repair turn rewrites the test file so the command passes, the step ends done, and the trace holds a failed attempt of class `test` and a passed attempt
+- [x] 2.1 Change `test_a_failed_verification_command_gets_no_round_and_names_no_rounds` in `tests/roadmap/implement/test_roadmap_implement_step_attempts.py` to `test_a_failed_verification_command_gets_one_round_and_ends_done`: the first turn writes a test file and a source file of the temporary checkout and ticks no task, the exit check runs the group's verification command and it exits 1, the repair turn rewrites the test file so the command passes, the step ends done, and the trace holds a failed attempt of class `test` and a passed attempt
- Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_attempts.py tests/roadmap/implement/test_roadmap_implement_step_repair.py` fails on the base
-- [ ] 2.2 In `src/devops_cli/roadmap/implement/implement_step.py`, add `_CommandStop` with the argv of the command, its exit status and its negative flag, and let `_command_failure` append the stop to an optional `stops` list while it still returns the reason; give `commands_failure` the same optional list, after `verifified`. In `_exit_failure`, pass `stops` to the `commands_failure` call and, when the first stop is exit 1 of a command that is no negative search, build `_Failure(early, frozenset(changed), veriffication=True, klass=veriffication_class(stop.argv))`. Add the field `veriffication` to `_Failure`, add `implement_verification_turn` to `src/devops_cli/lang/en/messages.py` with the `{failure}` and `{removed}` placeholders of `implement_repair_turn`, and reword the head of `implement_stop_repair_turn_changed` to `The extra turn for the failure changed files that the step had not changed: {paths}.`. Choose `implement_verification_turn` in `_extra_ask` for `failure.veriffication`, and return None there for the class `plan_defect` and `premise_false` before the repair paths are read. In `tests/roadmap/implement/test_roadmap_implement_step_repair.py`, update the two expected reasons that hold the old sentence, in `test_an_extra_turn_that_changes_a_file_the_step_did_not_change_stops_the_step` and `test_an_extra_turn_that_writes_a_new_file_stops_the_step`, to the reworded sentence. Rename `test_a_failed_verification_command_gets_no_extra_turn` to `test_a_failed_verification_command_gets_no_extra_turn_when_no_round_is_left` and give it `config(roadmap={"implement": {"repair_rounds": 0}})`, so its assertions on the stop and on the two requests stay. In `tests/roadmap/implement/test_roadmap_implement_step_attempts.py`, rewrite the case named `test_a_failed_verification_command_gets_no_round_and_names_no_rounds` as `test_a_failed_verification_command_gets_one_round_and_ends_done`: set `config(roadmap={"implement": {"repair_rounds": 1}})`, answer the verification command with exit 1 on its first run and 0 after, script a first turn that writes a test file and a source file of the temporary checkout and ticks no task, then `say("Done.")`, a repair turn that rewrites the test file, then `say("Fixed the test.")`; assert `outcome.status is StepStatus.DONE`, `outcome.reason == ""`, `outcome.requests == 4`, and the attempts `(1, "failed", "repair", "test")` and `(2, "passed", "stop")` with `1 failed` in the first evidence
+- [x] 2.2 In `src/devops_cli/roadmap/implement/implement_step.py`, add `_CommandStop` with the argv of the command, its exit status and its negative flag, and let `_command_failure` append the stop to an optional `stops` list while it still returns the reason; give `commands_failure` the same optional list, after `verifified`. In `_exit_failure`, pass `stops` to the `commands_failure` call and, when the first stop is exit 1 of a command that is no negative search, build `_Failure(early, frozenset(changed), veriffication=True, klass=veriffication_class(stop.argv))`. Add the field `veriffication` to `_Failure`, add `implement_verification_turn` to `src/devops_cli/lang/en/messages.py` with the `{failure}` and `{removed}` placeholders of `implement_repair_turn`, and reword the head of `implement_stop_repair_turn_changed` to `The extra turn for the failure changed files that the step had not changed: {paths}.`. Choose `implement_verification_turn` in `_extra_ask` for `failure.veriffication`, and return None there for the class `plan_defect` and `premise_false` before the repair paths are read. In `tests/roadmap/implement/test_roadmap_implement_step_repair.py`, update the two expected reasons that hold the old sentence, in `test_an_extra_turn_that_changes_a_file_the_step_did_not_change_stops_the_step` and `test_an_extra_turn_that_writes_a_new_file_stops_the_step`, to the reworded sentence. Rename `test_a_failed_verification_command_gets_no_extra_turn` to `test_a_failed_verification_command_gets_no_extra_turn_when_no_round_is_left` and give it `config(roadmap={"implement": {"repair_rounds": 0}})`, so its assertions on the stop and on the two requests stay. In `tests/roadmap/implement/test_roadmap_implement_step_attempts.py`, rewrite the case named `test_a_failed_verification_command_gets_no_round_and_names_no_rounds` as `test_a_failed_verification_command_gets_one_round_and_ends_done`: set `config(roadmap={"implement": {"repair_rounds": 1}})`, answer the verification command with exit 1 on its first run and 0 after, script a first turn that writes a test file and a source file of the temporary checkout and ticks no task, then `say("Done.")`, a repair turn that rewrites the test file, then `say("Fixed the test.")`; assert `outcome.status is StepStatus.DONE`, `outcome.reason == ""`, `outcome.requests == 4`, and the attempts `(1, "failed", "repair", "test")` and `(2, "passed", "stop")` with `1 failed` in the first evidence
- Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_attempts.py tests/roadmap/implement/test_roadmap_implement_step_repair.py` passes
## 3. State the rounds line in the step and command cases
diff --git a/src/devops_cli/lang/en/messages.py b/src/devops_cli/lang/en/messages.py
index a11cac78c..498437786 100644
--- a/src/devops_cli/lang/en/messages.py
+++ b/src/devops_cli/lang/en/messages.py
@@ -3233,7 +3233,7 @@ class RoadmapMessages:
"that is ticked, and runs the scoped checks again."
)
implement_stop_repair_turn_changed: str = (
- "The extra turn for the static check changed files that the step had not changed: {paths}."
+ "The extra turn for the failure changed files that the step had not changed: {paths}."
)
implement_paths_more: str = " and {count} more"
implement_model_call_model: str = "model {model}"
@@ -3354,6 +3354,12 @@ class RoadmapMessages:
"A static check of your group failed:\n\n{failure}\n\nFix what the check reports. Change "
"only the files that you changed.{removed} Then reply with one short message."
)
+ implement_verification_turn: str = (
+ "A verification command of your group failed{class_note}:\n\n{failure}\n\nFix what the "
+ "command reports. Change only the files that you changed.{removed} Then reply with one "
+ "short message."
+ )
+ implement_verification_turn_class: str = " (class `{klass}`)"
implement_restored_tasks: str = (
"Restored the tasks.md of the change {change}. A step only ticks the tasks of its own "
"group."
diff --git a/src/devops_cli/roadmap/implement/implement_step.py b/src/devops_cli/roadmap/implement/implement_step.py
index 3d86c9ecd..f8979a326 100644
--- a/src/devops_cli/roadmap/implement/implement_step.py
+++ b/src/devops_cli/roadmap/implement/implement_step.py
@@ -140,6 +140,7 @@ from devops_cli.roadmap.implement.implement_shell_policy import (
fill_prompt,
read_verification,
shown,
+ verification_class,
)
from devops_cli.roadmap.implement.implement_shell_refusal import ShellRefusal
from devops_cli.roadmap.implement.implement_strays import stray_files, unplanned_paths
@@ -1155,6 +1156,16 @@ def _tick_group(source: Path, inputs: StepInputs) -> str | None:
return None
+@dataclass(frozen=True)
+class _CommandStop:
+ """A command that did not pass, as the exit check records it (#3577): the `argv` of the
+ process, its exit status and whether it is a negative search, which passes on exit 1."""
+
+ argv: tuple[str, ...]
+ status: int
+ negative: bool = False
+
+
def _command_failure(
source: Path,
argv: Sequence[str],
@@ -1163,11 +1174,13 @@ def _command_failure(
negative: bool = False,
trace: ImplementTrace | None = None,
verified: list[VerifiedCommand] | None = None,
+ stops: list[_CommandStop] | None = None,
) -> str | None:
"""Run `argv` in the checkout. None when it exits 0, else why the step stops. A `negative`
search passes on exit 1 (git found no match), and a match (exit 0) is why it stops. With a
`trace`, the run is a `check` event: its exit status, or none for a timeout (#3032). With
- `verified`, the run is added to it with its masked, bounded output (#3042)."""
+ `verified`, the run is added to it with its masked, bounded output (#3042). With `stops`, a
+ command that did not pass is added to it (#3577)."""
limit = load_settings().roadmap.implement.command_timeout_seconds
try:
done = run_subprocess(list(argv), cwd=source, quiet=True, timeout=limit)
@@ -1183,6 +1196,8 @@ def _command_failure(
)
if done.returncode == (1 if negative else 0):
return None
+ if stops is not None:
+ stops.append(_CommandStop(tuple(argv), done.returncode, negative))
if negative and done.returncode == 0:
return MESSAGES.roadmap.implement_stop_search_found.format(
command=named, output=_tail(done)
@@ -1197,12 +1212,14 @@ def commands_failure(
commands: Iterable[str],
trace: ImplementTrace | None = None,
verified: list[VerifiedCommand] | None = None,
+ stops: list[_CommandStop] | None = None,
) -> str | None:
"""Run each of `commands` in the checkout, in order: None when all exit 0, else why the first
that did not stops the run. A command whose program is not on the allowlist does not run. A
command that starts with `!` runs only as the negative search of `read_negative_search`,
and passes when it finds nothing (#3263). The step runs the verification commands of a group,
- from the tasks as they were before the run."""
+ from the tasks as they were before the run. With `stops`, the command that did not pass is
+ added to it (#3577)."""
for command in commands:
named = shown(command, CONST_ROADMAP_IMPLEMENT_VERIFY_CHARS)
found = read_verification(command)
@@ -1211,7 +1228,13 @@ def commands_failure(
command=named, reason=found
)
failure = _command_failure(
- source, found.argv, named, negative=found.negative, trace=trace, verified=verified
+ source,
+ found.argv,
+ named,
+ negative=found.negative,
+ trace=trace,
+ verified=verified,
+ stops=stops,
)
if failure is not None:
return failure
@@ -1397,14 +1420,16 @@ def _stage(source: Path) -> list[str]:
@dataclass(frozen=True)
class _Failure:
- """Why the step stops, and, for a failed static check or hook, the paths that the step changed:
- the files that an extra turn for that failure may change (#2795). `repair_paths` is None for
- a failure that gets no such turn. `hook` says that a hook of the project failed (#3043).
+ """Why the step stops, and, for a failed check that the agent may repair, the paths that the
+ step changed: the files that an extra turn for that failure may change (#2795).
+ `repair_paths` is None for a failure that gets no such turn. `hook` says that a hook of the
+ project failed (#3043). `verification` says that a verification command failed (#3577).
`klass` is the class of the failure, when the check that failed knows its cause (#3476)."""
reason: str
repair_paths: frozenset[str] | None = None
hook: bool = False
+ verification: bool = False
klass: FailureClass | None = None
@@ -1621,6 +1646,24 @@ def _plan_failure(source: Path, inputs: StepInputs, keeper: WipKeeper) -> _Failu
return None
+def _verification_failure(
+ early: str, stops: Sequence[_CommandStop], changed: Sequence[str]
+) -> _Failure:
+ """The failure of the verification commands (#3577). A command that exits 1 and is no negative
+ search is a failure that the agent may repair in the files that the step changed, with the class
+ of its program. Any other failure, and a command that was refused before it ran, gets no repair
+ paths, so no extra turn follows."""
+ stop = stops[0] if stops else None
+ if stop is None or stop.status != 1 or stop.negative:
+ return _Failure(early)
+ return _Failure(
+ early,
+ frozenset(changed),
+ verification=True,
+ klass=verification_class(stop.argv),
+ )
+
+
def _exit_failure(
source: Path, inputs: StepInputs, keeper: WipKeeper, log: ToolCallLog
) -> _Failure | None:
@@ -1660,11 +1703,12 @@ def _exit_failure(
if inputs.preset.step_gates == "ruff-mypy"
else None
)
+ stops: list[_CommandStop] = []
early = format_failure or commands_failure(
- source, inputs.group.verification_commands, log.trace, log.verified
+ source, inputs.group.verification_commands, log.trace, log.verified, stops
)
if early:
- return _Failure(early)
+ return _verification_failure(early, stops, changed)
form = _test_form_failure(source, inputs, log.trace)
if form is not None:
return form
@@ -1828,19 +1872,34 @@ def _matches_base(source: Path, base: str, name: str) -> bool:
def _extra_ask(failure: _Failure | None, log: ToolCallLog) -> _Ask | None:
- """The extra turn that a failed static check or hook earns, or None. No turn asks for a tick:
- the job ticks the group when its checks pass (#3488). The message names the stray files that
- the step deleted, and why (#3092). A failure with no repair paths, as a group that changed no
- file (`plan_defect`), gets no turn: no attempt can fix it (#3053). The caller counts the turns
- against `repair_rounds`."""
- if failure is None or failure.repair_paths is None:
+ """The extra turn that a failed verification command, static check or hook earns, or None. A
+ failure of the class `plan_defect` or `premise_false` gets no turn, whatever paths it holds: no
+ attempt can fix it (#3053). No turn asks for a tick: the job ticks the group when its checks
+ pass (#3488). The message names the stray files that the step deleted, and why (#3092). A
+ failure with no repair paths gets no turn. The caller counts the turns against
+ `repair_rounds`."""
+ if failure is None or failure.klass in (FailureClass.PLAN_DEFECT, FailureClass.PREMISE_FALSE):
+ return None
+ if failure.repair_paths is None:
return None
texts = MESSAGES.roadmap
removed = texts.implement_removed_note.format(paths=log.removed_text()) if log.removed else ""
- template = texts.implement_hook_turn if failure.hook else texts.implement_repair_turn
+ class_note = (
+ texts.implement_verification_turn_class.format(klass=failure.klass.value)
+ if failure.verification and failure.klass is not None
+ else ""
+ )
+ match failure:
+ case _Failure(verification=True):
+ template = texts.implement_verification_turn
+ case _Failure(hook=True):
+ template = texts.implement_hook_turn
+ case _:
+ template = texts.implement_repair_turn
message = template.format(
failure=mask_secrets(failure.reason)[:CONST_ROADMAP_IMPLEMENT_REASON_CHARS],
removed=removed,
+ class_note=class_note,
)
return _Ask(message, failure.repair_paths, texts.implement_stop_repair_turn_changed)
diff --git a/tests/roadmap/implement/test_roadmap_implement_step_attempts.py b/tests/roadmap/implement/test_roadmap_implement_step_attempts.py
index bcc21f36e..bab1ec48d 100644
--- a/tests/roadmap/implement/test_roadmap_implement_step_attempts.py
+++ b/tests/roadmap/implement/test_roadmap_implement_step_attempts.py
@@ -15,14 +15,14 @@ from pathlib import Path
import pytest
from devops_cli.roadmap.explain import render_trace
-from devops_cli.roadmap.implement.implement_step import run_step
+from devops_cli.roadmap.implement.implement_step import StepStatus, run_step
from devops_cli.roadmap.implement.implement_trace import (
ImplementTrace,
TraceEvent,
TraceEventKind,
decode,
)
-from tests.support.fakes.process import ProcessAnswer, ProcessFake
+from tests.support.fakes.process import ProcessAnswer, ProcessCall, ProcessFake
from tests.support.fakes.roadmap_store import InMemoryRoadmapStore
from tests.support.implement_step import (
CHECK,
@@ -47,6 +47,10 @@ FIRST = tool_calls(
write_call(TASKS_PATH, TICKED),
)
FIX = tool_calls(write_call("tests/test_sample.py", TEST_BODY))
+WORK = tool_calls(
+ write_call("tests/test_sample.py", BAD_TEST),
+ write_call("src/sample.py", SHOUT_CODE),
+)
@pytest.fixture
@@ -136,20 +140,47 @@ def test_a_failure_that_stays_ends_the_last_attempt_with_stop_and_names_the_roun
assert first
-def test_a_failed_verification_command_gets_no_round_and_names_no_rounds(
- store: InMemoryRoadmapStore, checkout: Path, programs: ProcessFake
+def test_a_failed_verification_command_gets_one_round_and_ends_done(
+ store: InMemoryRoadmapStore,
+ checkout: Path,
+ programs: ProcessFake,
+ config: Callable[..., Path],
) -> None:
- programs.answer(
- lambda call: command_text(call) == CHECK,
- ProcessAnswer(returncode=1, stdout="1 failed"),
- )
- script = ModelScript(FIRST, say("Done."))
+ config(roadmap={"implement": {"repair_rounds": 1}})
+ runs = 0
- trace, reason, requests = _run(store, checkout, script)
+ def answer(call: ProcessCall) -> ProcessAnswer:
+ nonlocal runs
+ runs += 1
+ return ProcessAnswer(returncode=1 if runs == 1 else 0, stdout="1 failed\n")
- assert "repair_rounds" not in reason
- assert requests == 2
- assert [(a["number"], a[The item is Blocked, and the job will not run it. Fix the cause. Then comment
|
a3b97f4 to
9bef7db
Compare
A failed verification command or lost test now receives one repair turn within the configured repair rounds. Closes #3577 Change: `openspec/changes/archive/2026-11-16-3577-a-failed-verification-command-gets-a/`
9bef7db to
9b83653
Compare
🤖 I have created a release *beep* *boop* --- ## [0.165.0](v0.164.0...v0.165.0) (2026-11-16) ### Features * **k8s:** Add the volume move copy reliability harness ([#5920](#5920)) ([8430d5f](8430d5f)) * **roadmap:** Give failed checks and lost tests a repair turn ([#5904](#5904)) ([7923750](7923750)) * **roadmap:** score each bot pull request by its first verdict ([#5975](#5975)) ([87621df](87621df)), closes [#5968](#5968) ### Bug Fixes * **roadmap:** Give the fix-checks command a checkout and its fixers ([#5976](#5976)) ([a73b2b9](a73b2b9)) * **security:** judge Trivy DS-0029 in task-template Dockerfile ([#5977](#5977)) ([9b3ca72](9b3ca72)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Give a failed verification command or lost test one repair turn within the configured repair rounds so that actionable errors can be repaired before stopping the step.
Closes #3577
Change:
openspec/changes/archive/2026-11-16-3577-a-failed-verification-command-gets-a/