From 18eeb168c37286b4aafe4ae8719f621effbbfe78 Mon Sep 17 00:00:00 2001 From: "devops-cli-service[bot]" <349441588+devops-cli-service[bot]@users.noreply.github.com> Date: Sun, 15 Nov 2026 06:55:43 +0000 Subject: [PATCH] docs(openspec): plan #3577 Give failed checks and lost tests a repair turn Plans #3577. --- .../.openspec.yaml | 2 + .../design.md | 27 +++ .../proposal.md | 75 ++++++++ .../exit-checks/spec.md | 166 ++++++++++++++++++ .../tasks.md | 46 +++++ 5 files changed, 316 insertions(+) create mode 100644 openspec/changes/3577-a-failed-verification-command-gets-a/.openspec.yaml create mode 100644 openspec/changes/3577-a-failed-verification-command-gets-a/design.md create mode 100644 openspec/changes/3577-a-failed-verification-command-gets-a/proposal.md create mode 100644 openspec/changes/3577-a-failed-verification-command-gets-a/specs/roadmap-implement-step/exit-checks/spec.md create mode 100644 openspec/changes/3577-a-failed-verification-command-gets-a/tasks.md diff --git a/openspec/changes/3577-a-failed-verification-command-gets-a/.openspec.yaml b/openspec/changes/3577-a-failed-verification-command-gets-a/.openspec.yaml new file mode 100644 index 0000000000..a01998ffe1 --- /dev/null +++ b/openspec/changes/3577-a-failed-verification-command-gets-a/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-11-15 diff --git a/openspec/changes/3577-a-failed-verification-command-gets-a/design.md b/openspec/changes/3577-a-failed-verification-command-gets-a/design.md new file mode 100644 index 0000000000..4565f58b05 --- /dev/null +++ b/openspec/changes/3577-a-failed-verification-command-gets-a/design.md @@ -0,0 +1,27 @@ +# Design + +## Decisions + +- **The class of a failed verification command comes from its program, read after `uv run` by a new `verification_class`: `pytest` is test, `mypy` is types, `ruff` is lint, and the row after `devops ci` gives the same three.**: The program is a stable part of the command line that `read_verification` already admits, while the output is model-visible and can name another tool. +- **A command whose program names no class, such as `uv run devops docs check`, still gets the turn, and its message states a class only when the program names one.**: The issue gives a repair round to a verification command that exits 1, and a command with no class is still a failure that the agent can repair; the class only labels the message. +- **`commands_failure` keeps its `str | None` result, and `_command_failure` records the argv, the exit status and the negative flag in an optional stop list that `_exit_failure` passes in.**: The exact-reason assertions read the reason as a string, and `verification_class` needs the argv of the command that failed, which only `_command_failure` holds. +- **One repair path set serves every new turn: the files that the step changed. `_foreign_change` already compares the checkout with the tree before the turn and allows the change's tasks file.**: A repair turn may change only the work of the step, so an unrelated edit or a stray file still stops the step and the reason names the paths. +- **The change reuses `roadmap.implement.repair_rounds` and adds no setting.**: The issue asks for one more kind of failure with a repair round, not for a second budget, and the spent stop already names that setting. +- **`_extra_ask` returns None for the class `plan_defect` and `premise_false` before it reads the repair paths.**: No attempt can repair a wrong plan or a false premise, and the rule then holds even if a later stop site gives such a failure repair paths. +- **A lost test gets the class `tests_lost`, the changed paths and its own message, and the failure is built where the staged paths are known.**: The lost test is a failure that the agent can repair in the test file that it changed, and the tests check already names the file and its tests. +- **The message of a foreign change in a turn says `the failure` instead of `the static check`, and the two cases that assert the old sentence move in the same group.**: The turn now serves a verification command and a lost test too, and one message keeps one stop text; the same group owns the message and its cases, so no step sees a failing test it did not write. +- **The case of the repair turn writes its files and ticks no task in its first turn.**: The wip keeper runs the verification of each freshly ticked task before the next model request, so a tick in the first turn would spend the command's first run on the keeper and the exit check would already pass. +- **The trace gets no new event: `_trace_attempt` already records one attempt for each turn with its class.**: The acceptance criterion asks that the trace shows both attempts, which the existing attempt event already gives. +- **A case that asserts an exact stop reason sets `roadmap.implement.repair_rounds=0` and expects `rounds_spent(0)`, because a failure that now carries repair paths reports a spent round even when no round is left.**: `_repair_rounds` sets `spent` from the ask alone, and the stop appends the line that names the spent rounds, so the reason of every such stop grows by that line. +- **The lost-test cases of `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py` run with no repair round, except the case that shows the lost-test repair turn, which runs with one.**: Each case keeps its own subject, such as the reason, the request count or the kept commit, and a case that shows a turn keeps the one turn that it tests. +- **The living spec of `roadmap-implement-step/exit-checks` stays unchanged in this change, because `openspec archive` writes it from the delta of this change.**: No task group may change a path under `openspec/specs/`; the archive is the only writer of the living spec. + +## Rejected alternatives + +- **Build a pydantic-ai `ModelRetry` loop for a failed verification command.**: `ModelRetry` validates a tool call or a model output. The exit status of a shell command is no model output, and `ModelRetry` cannot limit the files that the next turn changes, which `_foreign_change` does in `src/devops_cli/roadmap/implement/implement_step.py`. +- **Read the class of a failed verification command from its output.**: The output is model-visible and can name another tool, while the program is a stable part of the command line that `read_verification` already checks in `src/devops_cli/roadmap/implement/implement_shell_policy.py`. +- **Add a second setting for verification repair rounds.**: The step counts its turns against `roadmap.implement.repair_rounds`, whose default is 3 in `src/devops_cli/config/defaults.py`, and a second budget splits one limit. +- **Make `commands_failure` return the failure object with its class and paths.**: The exact-reason assertions compare its result with a string in `tests/roadmap/implement/test_roadmap_implement_step_own_text.py` and `tests/roadmap/implement/test_roadmap_implement_command.py`, so that change would touch code outside this step. +- **Let each exact-reason case run its repair rounds and repeat the last scripted reply.**: The script repeats its last reply, so the stop would name three spent rounds and cost three requests per case; the cases assert a reason and a request count that this change does not make, so they set the budget to 0 instead. +- **Let the first turn of the repair-turn case tick the task, and make the fake command fail twice.**: The keeper runs the verification of a fresh tick before each model request, so the number of runs before the exit check depends on the requests and on the tasks file's mtime; a case that ticks no task has one run at the exit check. +- **Keep the immediate stop of a failed verification command.**: The agent holds the failure text after the command run, as it does for a failed static check that already earns a turn, and the issue names four stops of this kind (#2570, #2531, #2524, #2469). diff --git a/openspec/changes/3577-a-failed-verification-command-gets-a/proposal.md b/openspec/changes/3577-a-failed-verification-command-gets-a/proposal.md new file mode 100644 index 0000000000..f82245e92a --- /dev/null +++ b/openspec/changes/3577-a-failed-verification-command-gets-a/proposal.md @@ -0,0 +1,75 @@ +# Proposal + +## Why + +The implement step gives a repair turn only to a failed static check or hook, so a failed verification command or a lost test stops the item at once, though the agent holds the failure text and can repair it (#3577). + +## What Changes + +- A verification command that exits 1 gets one repair turn with the class of its program, its masked output and a diagnosis hint. +- `verification_class` in `src/devops_cli/roadmap/implement/implement_shell_policy.py` maps the program after `uv run` to the class: `pytest` to test, `mypy` to types, `ruff` to lint, and the row after `devops ci` the same way. +- `_command_failure` records the argv, the exit status and the negative flag of a failed command in an optional stop list, and `commands_failure` passes that list through, so its callers still read a string. +- `_exit_failure` gives a command that exits 1, and that is no negative search, a failure with the class of its program, the changed paths and the verification flag. +- A lost test gets one repair turn that may restore or edit its test file, with the class `tests_lost` and the changed paths. +- `_extra_ask` gives no turn for the class `plan_defect` or `premise_false`, whatever repair paths the failure holds. +- The repair turn changes only the files of the step and the change's tasks file, judged by `_foreign_change`. +- The message of a foreign change in a turn no longer names a static check, and the two cases that assert the old sentence move with it. +- A stop whose failure now carries repair paths and has no round left appends the line that names the spent rounds, so a case that asserts an exact reason sets `roadmap.implement.repair_rounds=0` and expects `rounds_spent(0)`. +- The case of the repair turn writes its files and ticks no task in the first turn, so the wip keeper runs no verification command before the exit check, and the exit check makes the first run of the command. +- The cases that pin the old immediate stop in `tests/roadmap/implement/test_roadmap_implement_step.py`, `tests/roadmap/implement/test_roadmap_implement_command.py`, `tests/roadmap/implement/test_roadmap_implement_step_own_text.py`, `tests/roadmap/implement/test_roadmap_implement_wip.py`, `tests/roadmap/implement/test_roadmap_implement_step_attempts.py` and `tests/roadmap/implement/test_roadmap_implement_step_repair.py` state the new stop with that setting. +- The lost-test cases of `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py` get the setting and the rounds line, and one new case shows the repair turn that restores a test. +- The spec delta of `roadmap-implement-step/exit-checks` states the new turns and their classes, because a roadmap job's stop and repair behavior is observable. +- The change fits one pull request. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `roadmap-implement-step/exit-checks`: A step asks for a fix of a failed check within the repair rounds, A step keeps the tests that existed, A failed exit check stops the step and resets the checkout, A failure that no attempt can fix gets no repair round + +## Impact + +- Code: `src/devops_cli/roadmap/implement/implement_shell_policy.py`, `src/devops_cli/roadmap/implement/implement_step.py`, `src/devops_cli/lang/en/messages.py` +- Tests: `tests/roadmap/implement/test_roadmap_implement_verification_class.py`, `tests/roadmap/implement/test_roadmap_implement_step_attempts.py`, `tests/roadmap/implement/test_roadmap_implement_step_repair.py`, `tests/roadmap/implement/test_roadmap_implement_step.py`, `tests/roadmap/implement/test_roadmap_implement_command.py`, `tests/roadmap/implement/test_roadmap_implement_step_own_text.py`, `tests/roadmap/implement/test_roadmap_implement_wip.py`, `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py` + +## Feasibility + +- The probe of the staging commit says, word for word: The path `src/devops_cli/roadmap/implement_step.py` is no file at the root of the staging commit. These files of the commit are candidates: `src/devops_cli/roadmap/implement/implement_step.py`, `tests/support/implement_step.py`. Commit bff2f14f 2026-11-06 refactor(roadmap): group the job modules in subpackages (#3897) deleted or renamed it. The plan uses the moved path `src/devops_cli/roadmap/implement/implement_step.py`. +- The probe says, word for word: The path `tests/roadmap/test_roadmap_implement_step_repair.py` is no file at the root of the staging commit. These files of the commit are candidates: `tests/roadmap/implement/test_roadmap_implement_step_repair.py`. Commit bff2f14f 2026-11-06 refactor(roadmap): group the job modules in subpackages (#3897) deleted or renamed it. The plan reads and changes the moved path. +- The probe says, word for word: The path `src/devops_cli/roadmap/failure.py` is a file of the staging commit, and the path `docs/ERRORS.md` is a file of the staging commit. The classes that the issue names sit in the first: `src/devops_cli/roadmap/failure.py:73:TESTS_LOST = "tests_lost"`. +- The probe also says, word for word: Not probed, the bound of 10 commands is reached: `roadmap.implement.repair_rounds`, `src/devops_cli/config/settings.py`, `ruff`, `mypy`, `test`, `types`, `lint`, `plan_defect`, `premise_false`, `_extra_ask`, `_exit_failure`, `ModelRetry`, `_repair_rounds`, `repair_paths`, `TESTS_LOST`, `_foreign_change`, `pytest`. This run read `_command_failure`, `commands_failure`, `_exit_failure`, `_plan_failure`, `_extra_ask`, `_foreign_change`, `_repair_rounds`, the rounds line and the wip keeper with the calls below. +- `read_file` of `src/devops_cli/roadmap/implement/implement_step.py` lines 1655 to 1686 confirmed the premise of the issue: the failed verification command is wrapped with no repair paths at `src/devops_cli/roadmap/implement/implement_step.py:1667:return _Failure(early)`, while the failed static check carries the changed paths at `src/devops_cli/roadmap/implement/implement_step.py:1680:return _Failure(static, frozenset(changed))`. +- `read_file` of the same file lines 1830 to 1846 showed the gate of the turn: `src/devops_cli/roadmap/implement/implement_step.py:1836:if failure is None or failure.repair_paths is None:`, so a failure with no repair paths gets no turn today. +- `read_file` of the same file line 1620 showed the lost-test stop with no paths: `src/devops_cli/roadmap/implement/implement_step.py:1620:return _Failure(lost, klass=FailureClass.TESTS_LOST)`, and line 1642 stages the changed files before it at `src/devops_cli/roadmap/implement/implement_step.py:1642:changed = _stage(source)`, so the paths that the lost-test failure needs are at hand. +- `read_file` of the same file lines 1804 to 1822 showed the file limit of a turn: `src/devops_cli/roadmap/implement/implement_step.py:1814:allowed = ask.may_change | {tasks}`, and `src/devops_cli/roadmap/implement/implement_step.py:1406:repair_paths: frozenset[str] | None = None` showed the field that the new failures set. +- `read_file` of `src/devops_cli/roadmap/implement/implement_shell_policy.py` lines 460 to 520 showed `src/devops_cli/roadmap/implement/implement_shell_policy.py:494:argv: list[str]`, so the step reads the program after `uv run` from the argv that `read_verification` returns. +- `read_file` of `src/devops_cli/lang/en/messages.py` lines 3190 to 3260 showed `src/devops_cli/lang/en/messages.py:3222:implement_stop_repair_turn_changed: str = (`, whose text names the static check: `src/devops_cli/lang/en/messages.py:3223:The extra turn for the static check changed files that the step had not changed`. +- The first finding of the review is a real defect and group 2 corrects it: `tests/roadmap/implement/test_roadmap_implement_step_repair.py:195:The extra turn for the static check changed files that the step had not changed: ` and the same sentence at line 216 are the whole expected reason of two cases, so group 2 updates both with the reworded message. +- The `problem` of the previous reply names two paths that no file of the commit holds. They are files that the fake writes inside the temporary checkout: `tests/roadmap/implement/test_roadmap_implement_step_attempts.py:45:write_call("tests/test_sample.py", BAD_TEST),` and `tests/roadmap/implement/test_roadmap_implement_step_attempts.py:46:write_call("src/sample.py", SHOUT_CODE),`. They are no paths of the repository, so the task of group 2 now names them in prose and not in a code span, and the group creates no file. +- `read_file` of `src/devops_cli/roadmap/implement/implement_step.py` lines 1140 to 1260 showed `src/devops_cli/roadmap/implement/implement_step.py:def _command_failure` and `src/devops_cli/roadmap/implement/implement_step.py:def commands_failure`, which return `str | None`, so the reason stays a string and the argv, the exit status and the negative flag travel in an optional list; the same range shows `src/devops_cli/roadmap/implement/implement_step.py:1213:failure = _command_failure(` with the call that passes the found argv. +- The second finding of the earlier plan is a real defect too: `src/devops_cli/roadmap/implement/implement_step.py:2167:log.before_request = keeper.check` runs the keeper before each model request, and it runs the verification of each freshly ticked task at `src/devops_cli/roadmap/implement/implement_wip.py:172:index for index in fresh if self.verify(self.group.tasks[index].verification) is None`. A first turn that ticks a task therefore spends the fake's first run on the keeper, and the exit check would already pass. The new case of group 2 ticks no task in its first turn, so the exit check makes the first run of the command and the repair turn follows; `src/devops_cli/roadmap/implement/implement_step.py:1664:source, inputs.group.verification_commands, log.trace, log.verified` shows that the exit check runs the group's verification commands whatever the ticks are. +- `read_file` of the same file lines 1930 to 1960 showed the round gate: `src/devops_cli/roadmap/implement/implement_step.py:1949:repair = ask is not None and used < start.allowed`, and `src/devops_cli/roadmap/implement/implement_step.py:1952:return _Rounds(run, failure, used, number, start.allowed, spent=ask is not None)`, so a budget of 0 runs no turn and still reports a spent round. +- `read_file` of the same file lines 2088 to 2120 showed the line that the stop appends: `src/devops_cli/roadmap/implement/implement_step.py:2111:if reason and rounds_spent:` and `src/devops_cli/roadmap/implement/implement_step.py:2112:MESSAGES.roadmap.implement_stop_rounds.format(rounds=budget)`, and `tests/support/implement_step.py:def rounds_spent` gives that line to a test as `rounds_spent(0)`. +- The staged value of the repair bound is `src/devops_cli/config/defaults.py:979:DEFAULT_ROADMAP_IMPLEMENT_REPAIR_ROUNDS: int = 3`; the plan adds no setting and gives the existing bound no new name. +- `read_file` of `tests/roadmap/implement/test_roadmap_implement_step_repair.py` lines 180 to 270 showed `tests/roadmap/implement/test_roadmap_implement_step_repair.py:254:test_a_failed_verification_command_gets_no_extra_turn`, which the new turn makes false, so group 2 gives it the setting `roadmap.implement.repair_rounds=0` and names that no round is left. +- `read_file` of `tests/roadmap/implement/test_roadmap_implement_step_attempts.py` lines 1 to 190 showed the case at line 139, `tests/roadmap/implement/test_roadmap_implement_step_attempts.py:139:def test_a_failed_verification_command_gets_no_round_and_names_no_rounds(`, which asserts `requests == 2` and `[(1, "stop")]`; group 2 rewrites it as the case of the repair turn, and the fake's files are written in the temporary checkout at `tests/roadmap/implement/test_roadmap_implement_step_attempts.py:45:write_call("tests/test_sample.py", BAD_TEST),`. +- `read_file` of `tests/roadmap/implement/test_roadmap_implement_step.py` lines 344 to 400 showed `tests/roadmap/implement/test_roadmap_implement_step.py:352:def test_a_failed_verification_command_stops_the_step_and_resets_the_checkout(`, whose group ticks every task, so group 3 keeps the ticks and only sets the setting and the rounds line. +- The cases of `tests/roadmap/implement/test_roadmap_implement_step_own_text.py`, `tests/roadmap/implement/test_roadmap_implement_wip.py` and `tests/roadmap/implement/test_roadmap_implement_step.py` that assert an exact reason or a request count run with `roadmap.implement.repair_rounds=0`, as groups 3 and 4 state. +- The requirement texts of the spec delta sit under the 500-character limit: the masking and the spent-round detail of the first move into its scenarios, and the parse rule of the second stays in its scenario, so no requirement text carries it. +- The scenarios that name no code in a code span are covered by a behavior group: group 2 changes and runs `tests/roadmap/implement/test_roadmap_implement_step_attempts.py` and `tests/roadmap/implement/test_roadmap_implement_step_repair.py`, group 3 runs `tests/roadmap/implement/test_roadmap_implement_step.py`, and group 5 changes and runs `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py`. +- No task names a run-time sample file: the new module of group 1 is a path of the repository, and the files of the cases live in the temporary checkout and are named in prose. +- `_command_failure` runs each command with `cwd=source` at `src/devops_cli/roadmap/implement/implement_step.py:1173:done = run_subprocess(list(argv), cwd=source, quiet=True, timeout=limit)`, so it needs a checkout of the repository; `commands_failure` and `_exit_failure` call it and need a checkout too. `verification_class` reads the argv alone, so it needs no checkout, no client and no network. +- The plan introduces no new program. Every verify runs `uv run devops ci test`, which runs `pytest` in the image: `uv`, `devops`, `pytest`, `git`, `ruff` and `mypy` are in the runner tools list, and NOT_IN_RUNNER names none of them. The tests double the process edge and use a temporary checkout, so they reach no network, no cluster and no real scanner. The pod sets `readOnlyRootFilesystem: true`, `runAsNonRoot: true`, `capabilities.drop: ALL`, `allowPrivilegeEscalation: false` and `seccompProfile: RuntimeDefault`. +- The first checks that the implementation runs are `uv run devops ci test tests/roadmap/implement/test_roadmap_implement_verification_class.py`, then `uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_attempts.py tests/roadmap/implement/test_roadmap_implement_step_repair.py`, then `uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py`, then the gate `uv run devops ci`. + +## Existing Tool Considered + +pydantic-ai `ModelRetry` covers the validation of a model output and a tool call. It cannot judge the exit status of a shell verification command, and it cannot limit the files that the next turn changes, so the step extends its own repair rounds: about 40000 tokens to build, 2000 tokens each quarter to keep, 8000 tokens to repair one miss, and about 3 hours. + +## Dependencies + +None. diff --git a/openspec/changes/3577-a-failed-verification-command-gets-a/specs/roadmap-implement-step/exit-checks/spec.md b/openspec/changes/3577-a-failed-verification-command-gets-a/specs/roadmap-implement-step/exit-checks/spec.md new file mode 100644 index 0000000000..bf1be4851d --- /dev/null +++ b/openspec/changes/3577-a-failed-verification-command-gets-a/specs/roadmap-implement-step/exit-checks/spec.md @@ -0,0 +1,166 @@ +## MODIFIED Requirements + +### Requirement: A step asks for a fix of a failed check within the repair rounds +When a verification command that is no negative search exits 1, or a static check or hook fails, the step SHALL run one more turn under the same `UsageLimits`, while a repair round is left. Its message SHALL hold the class, the failure text masked and cut to `CONST_ROADMAP_IMPLEMENT_REASON_CHARS` characters, and a diagnosis hint. Every exit check SHALL run again after each turn. With no round left the step SHALL stop with the last failure. + +#### Scenario: An unused import +- **WHEN** the model ticks the tasks and ends its run, `ruff check` exits 1 for an unused import in a changed file, and the model removes the import in the extra turn +- **THEN** the step reports done, the extra turn got the text of the failure, the commit holds the file without the import, `ruff check` ran twice, and `repair_rounds` is 1 + +#### Scenario: The failure stays +- **WHEN** `ruff check` still exits 1 after every round, and `repair_rounds` is 3 +- **THEN** the step reports stopped with the reason that names `ruff check`, its exit status and the three spent rounds, the model got three extra turns and no fourth, and the checkout is reset + +#### Scenario: A failed type check +- **WHEN** `mypy --strict` exits 1 after the first turn, and the model fixes the file in the extra turn +- **THEN** the step reports done, and the extra turn got the text of the failure of `mypy` + +#### Scenario: A failure with a task left unticked +- **WHEN** `ruff check` exits 1 after the first turn, and a task of the group is unticked +- **THEN** the message of the extra turn holds the text of the failure and no list of tasks, and the job ticks the group when the repair passes the checks + +#### Scenario: A failed verification command +- **WHEN** the verification command `uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_attempts.py` exits 1, and the model fixes the failing test in the extra turn +- **THEN** the step reports done, the message of the extra turn names the class `test` and holds the output of the command, and the trace holds one attempt for the failure and one attempt for the repair + +#### Scenario: A failure after the repair turn +- **WHEN** the extra turn for the failed check ends and `ruff check` exits 1 +- **THEN** the model gets another turn that holds the text of the failure, while a round is left + +#### Scenario: No round +- **WHEN** `repair_rounds` is 0 and `ruff check` exits 1 +- **THEN** the model gets no extra turn and the step reports stopped with the reason that names `ruff check` and the zero spent rounds + +#### Scenario: A fix step +- **WHEN** a fix step ends with a changed file and `ruff check` exits 1 +- **THEN** the model gets an extra turn that holds the text of the failure and no list of ticks + +#### Scenario: The extra turn shares the budget +- **WHEN** the first turn used all but one of the model requests and the extra turn needs two +- **THEN** the step reports stopped with a reason that starts with `UsageLimitExceeded: ` + +#### Scenario: A hook fails +- **WHEN** the `pre-commit` stage exits 1 for a test that calls a raising function with no match, in a changed test, and the model adds the match in the extra turn +- **THEN** the step reports done, the message of the extra turn holds the output of the hook, and the commit holds the fixed test + +#### Scenario: A hook that the agent cannot fix +- **WHEN** the `pre-commit` stage exits 1 after every turn, and the repair rounds are set to 3 +- **THEN** the step reports stopped with the reason that holds the output of the hook, the model got three extra turns, the repair rounds are 3, and the checkout is reset + +### Requirement: A step keeps the tests that existed +Every test that a `.py` file under `tests/` held at the commit where the step started SHALL be in the checkout after the run, by qualified name (`test_x` or `Class.test_x`), unless `recorded_tests` gives its `path::name`. A test is a function named `test_*`. When another test is lost, the step SHALL give one repair turn while a round is left, and otherwise stop with a reason that names the file and at most `CONST_ROADMAP_IMPLEMENT_REASON_TESTS` of its tests. + +#### Scenario: A test file that the agent replaces +- **WHEN** a test file holds `test_a` and `test_b` at the start, the model writes a file that holds `test_c`, and no round is left +- **THEN** the step reports stopped, the reason names the file, `test_a` and `test_b` and the spent rounds, and the checkout is reset + +#### Scenario: A test that the agent adds +- **WHEN** the model adds `test_c` to a test file that holds `test_a` and `test_b` +- **THEN** the step reports done + +#### Scenario: A test that the agent renames +- **WHEN** the model renames `test_a` to `test_z` in its file, and no round is left +- **THEN** the step reports stopped, and the reason names `test_a` + +#### Scenario: A test file that the agent deletes +- **WHEN** the model deletes a test file that holds `test_a`, and no round is left +- **THEN** the step reports stopped, and the reason names the file and `test_a` + +#### Scenario: A test that the agent moves +- **WHEN** the model moves `test_a` of a class from one test file to a new test file, and no round is left +- **THEN** the step reports stopped, and the reason names the old file and `test_a` + +#### Scenario: A test that loses its body +- **WHEN** the model keeps the name of `test_a` and replaces its body with `pass` +- **THEN** this check does not stop the step: it reads names only + +#### Scenario: A file that does not parse +- **WHEN** a test file has a syntax error after the run, or at the start +- **THEN** this check does not stop the step, and the static check judges the file + +#### Scenario: A long list of lost tests +- **WHEN** the model drops more than `CONST_ROADMAP_IMPLEMENT_REASON_TESTS` tests of a file +- **THEN** the reason names that many tests in order and gives the count of the rest + +#### Scenario: A removal that the record names +- **WHEN** the model removes `test_a`, and `recorded_tests` gives `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py::test_a` +- **THEN** the step reports done + +#### Scenario: A rename or a move that the record names +- **WHEN** the model renames `test_a` to `test_z` or moves it to a new test file, and `recorded_tests` holds the old `path::name` +- **THEN** the step reports done + +#### Scenario: A removal that the record does not name +- **WHEN** the model removes `test_a` and `test_b`, and `recorded_tests` gives only the name of `test_a`, and no round is left +- **THEN** the step reports stopped with the class `tests_lost`, and the reason names `test_b` and not `test_a` + +#### Scenario: A kept task with a recorded removal +- **WHEN** the agent ticks a task whose verification passes, and the only test that it lost is in `recorded_tests` +- **THEN** the keeper makes the `wip:` commit + +#### Scenario: The prompt of the step +- **WHEN** a test reads the prompt of the step +- **THEN** the rule of the tests names the `## Weakened checks` section, and says that an entry from the agent does not count + +#### Scenario: A lost test that the repair restores +- **WHEN** the model removes `test_a` from a test file that existed at the base commit, and the extra turn restores it +- **THEN** the step reports done, the extra turn got the reason that names the file and `test_a`, and the trace holds one attempt for the lost test and one attempt for the repair + +### Requirement: A failed exit check stops the step and resets the checkout +The exit checks SHALL run in this order: the agent made no commit, no test from the start is lost, each verification command passes, the static checks pass, and the hooks pass. Then the job ticks the group, as the requirement of the job ticks says. The step SHALL stop at the first check that fails, name it as the reason, make no step commit, and reset the checkout to its last `wip:` commit, or to its start. A failed check first gets the extra turns of its own requirement. + +#### Scenario: A verification command fails +- **WHEN** the model ends its run with the files written and the tasks ticked, the verification command exits 1, and no round is left +- **THEN** the step reports stopped, the reason names the command, its exit status and the spent rounds, the checkout holds no new commit, and the written files are gone + +#### Scenario: A static check fails +- **WHEN** the verification command exits 0 and `ruff check` exits 1 on the changed file, in the first turn and in every extra turn +- **THEN** the step reports stopped with the reason that `ruff check` failed, makes no step commit and resets the checkout to its last `wip:` commit + +#### Scenario: A task stays unticked +- **WHEN** the model ends its run and leaves a task of the group unticked, and an exit check of the group fails +- **THEN** the job writes no tick, the step reports stopped, and the checkout is reset + +#### Scenario: A task stays unticked and a verification command fails +- **WHEN** the model ends its run and leaves a task of the group unticked, and the verification command exits 1 +- **THEN** the step reports stopped with the reason that names the command and its exit status, the model gets the extra turns and no more, and the checkout is reset + +#### Scenario: The model changes another group +- **WHEN** the model changes the text of a task of group 2 while it works on group 1 +- **THEN** the step reports done, and the commit holds group 2 as it was + +#### Scenario: A task that the agent removes +- **WHEN** the model removes a task of group 1 from the tasks file and ticks the others +- **THEN** the step restores the tasks of group 1 as they were before the run, and the job ticks them when the exit checks pass + +#### Scenario: A task that the agent moves +- **WHEN** the model swaps the texts of two tasks of group 1 and ticks them +- **THEN** the step reports done, and the commit holds the tasks in their order from before the run, ticked + +#### Scenario: A heading that the agent changes +- **WHEN** the model changes the heading of group 1 +- **THEN** the step reports done, and the commit holds the heading from before the run + +#### Scenario: A tasks file that is gone +- **WHEN** the model removes the tasks file of the change +- **THEN** the step writes the file from before the run, and the job ticks the group when the exit checks pass + +#### Scenario: A verification command outside the allowlist +- **WHEN** a Verification line of the group names `curl http://example.com` +- **THEN** the step reports stopped, the reason names `curl` as not allowed, the command does not run, and the checkout is reset + +#### Scenario: A test that the agent removes +- **WHEN** the model replaces a test file with a file that holds fewer of its tests, ticks the tasks, and no round is left +- **THEN** the step reports stopped after the repair turn with the reason that names the file and the missing tests, and the checkout is reset + +### Requirement: A failure that no attempt can fix gets no repair round +A failure of the class `plan_defect` or `premise_false` SHALL get no repair round, whatever the setting `repair_rounds` is. The step SHALL stop with the evidence of the failure. Only a verification command that exits 1, a lost test, a failed static check or a hook gets a round. + +#### Scenario: A group that changes no file +- **WHEN** the model ends its run and changes no file of a group +- **THEN** the step reports stopped with the class plan_defect, the model got one run and no extra turn, and the trace holds one attempt + +## RENAMED Requirements + +- FROM: `### Requirement: A step asks for a fix of a failed static check or hook within the repair rounds` +- TO: `### Requirement: A step asks for a fix of a failed check within the repair rounds` 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 new file mode 100644 index 0000000000..9b6c9d3dd1 --- /dev/null +++ b/openspec/changes/3577-a-failed-verification-command-gets-a/tasks.md @@ -0,0 +1,46 @@ +# Tasks + +## 1. Give a verification command the class of its program + +Kind: behavior. Reads: `src/devops_cli/roadmap/implement/implement_shell_policy.py`, `src/devops_cli/roadmap/failure.py`, `tests/roadmap/implement/test_roadmap_implement_shell_policy.py`. Changes: `src/devops_cli/roadmap/implement/implement_shell_policy.py`, `tests/roadmap/implement/test_roadmap_implement_verification_class.py` (new). + +- [ ] 1.1 Write `test_a_pytest_command_has_the_class_test` in `tests/roadmap/implement/test_roadmap_implement_verification_class.py` first: the class of a `pytest` command of the verification list is `FailureClass.TEST` + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_verification_class.py` fails on the base +- [ ] 1.2 Add `verification_class(argv)` to `src/devops_cli/roadmap/implement/implement_shell_policy.py`: it skips `uv` and `run`, returns `FailureClass.TEST` for `pytest`, `FailureClass.TYPES` for `mypy`, `FailureClass.LINT` for `ruff`, reads the row after `devops ci` the same way for `test`, `lint` and `typecheck`, and returns None for another program. Write the cases in the new module `tests/roadmap/implement/test_roadmap_implement_verification_class.py`: one for each of the three programs, one for `uv run devops ci test tests/roadmap/implement/test_roadmap_implement_shell_policy.py`, one for `uv run devops docs check` and one for a program that names none of them + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_verification_class.py` passes + +## 2. Give a failed verification command one repair turn + +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 + - 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 + - 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 + +Kind: other. Reads: `tests/roadmap/implement/test_roadmap_implement_step.py`, `tests/roadmap/implement/test_roadmap_implement_command.py`, `src/devops_cli/roadmap/implement/implement_step.py`, `tests/support/implement_step.py`. Changes: `tests/roadmap/implement/test_roadmap_implement_step.py`, `tests/roadmap/implement/test_roadmap_implement_command.py`. + +- [ ] 3.1 In `tests/roadmap/implement/test_roadmap_implement_step.py`, give `test_a_failed_verification_command_stops_the_step_and_resets_the_checkout` the `config` fixture with `roadmap.implement.repair_rounds=0` and the expected reason `f"{CHECK} exited with status 1.\nno docs" + rounds_spent(0)`, because the failure now carries repair paths and a stop with no round left names the spent rounds. Rewrite `test_a_failed_verification_command_stops_the_step_with_no_extra_turn` as `test_a_failed_verification_command_gets_one_repair_round_and_stops_after_it`: it sets `roadmap.implement.repair_rounds=1`, scripts one more reply for the repair turn, and asserts `len(script.seen) == 3` with the reason `f"{DOCS} exited with status 1.\nno docs" + rounds_spent(1)`. In `tests/roadmap/implement/test_roadmap_implement_command.py`, give `test_a_stopped_step_exits_1_and_prints_its_reason_as_json` the `config` fixture with the same setting and the printed reason `f"{DOCS} exited with status 1.\nno docs" + rounds_spent(0)`, and import `rounds_spent` from `tests.support.implement_step` + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step.py tests/roadmap/implement/test_roadmap_implement_command.py` passes + +## 4. State the rounds line in the own-text and wip cases + +Kind: other. Reads: `tests/roadmap/implement/test_roadmap_implement_step_own_text.py`, `tests/roadmap/implement/test_roadmap_implement_wip.py`, `src/devops_cli/roadmap/implement/implement_step.py`. Changes: `tests/roadmap/implement/test_roadmap_implement_step_own_text.py`, `tests/roadmap/implement/test_roadmap_implement_wip.py`. + +- [ ] 4.1 Give `test_a_command_that_the_model_rewrites_to_pass_does_not_run_and_the_original_is_named` in `tests/roadmap/implement/test_roadmap_implement_step_own_text.py` the `config` fixture with `roadmap.implement.repair_rounds=0` and the reason `f"{CHECK} exited with status 1.\nno test" + rounds_spent(0)`, so its list of the commands that ran stays as it is. Give the cases that build on `_docs_check_fails_once` in `tests/roadmap/implement/test_roadmap_implement_wip.py` the same setting: `test_a_stopped_step_keeps_the_task_that_passed_its_verification`, `test_the_diff_of_a_stopped_step_holds_only_the_work_after_the_last_kept_task`, `test_a_second_attempt_starts_from_the_kept_task_and_ends_done_in_one_commit` and `test_a_task_that_fails_its_verification_is_not_kept`, because the check fails only its first run and a repair turn would pass it and end the step done + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_own_text.py tests/roadmap/implement/test_roadmap_implement_wip.py` passes + +## 5. Give a lost test one repair turn + +Kind: behavior. Reads: `src/devops_cli/roadmap/implement/implement_step.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.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_tests_kept.py`. + +- [ ] 5.1 Add `test_a_lost_test_gets_one_repair_turn_that_restores_it` in `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py` for the case A lost test that the repair restores, where `recorded_tests` does not name the lost `test_a`, the repair turn restores it, and the trace holds one attempt for the lost test and one for the repair + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py` fails on the base +- [ ] 5.2 Pass the staged `changed` paths of `_exit_failure` to `_plan_failure` in `src/devops_cli/roadmap/implement/implement_step.py`, so the lost-test failure carries them as `_Failure(lost, frozenset(changed), klass=FailureClass.TESTS_LOST)` while the `outside_plan` failure keeps none. Add `implement_tests_lost_turn` to `src/devops_cli/lang/en/messages.py` with the `{failure}` and `{removed}` placeholders of `implement_repair_turn`, and choose it in `_extra_ask` for the class `tests_lost`. In `tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py`, add the new case with one repair round, and give these cases the `config` fixture with `roadmap.implement.repair_rounds=0` and `+ rounds_spent(0)` in the expected reason: `test_a_step_that_replaces_a_test_file_and_drops_tests_stops_and_names_them`, `test_a_removal_that_the_record_does_not_name_stops_and_names_only_that_test`, `test_a_record_of_the_same_name_in_another_file_does_not_pass`, `test_a_step_that_renames_a_test_stops`, `test_a_step_that_deletes_a_test_file_stops`, `test_a_step_that_moves_the_tests_to_a_new_file_stops`, `test_a_step_that_moves_the_tests_to_a_file_that_pytest_does_not_collect_stops`, `test_a_step_that_replaces_a_test_file_with_a_byte_order_mark_still_stops`, `test_the_reason_names_a_bounded_number_of_tests` and `test_a_kept_task_makes_no_commit_when_the_lost_test_is_not_in_the_record`. Give `test_the_extra_turn_for_a_static_failure_cannot_remove_a_test` `repair_rounds: 1` and `+ rounds_spent(1)`, give `test_the_check_runs_before_the_formatter_and_the_verification_commands` rounds 0 so `len(script.seen)` stays 2, and give `test_a_fix_step_keeps_the_tests_as_well` rounds 0 so no repair turn runs. The group's verify runs the whole module, so a case left with the old reason fails the group + - Verification: `$ uv run devops ci test tests/roadmap/implement/test_roadmap_implement_step_tests_kept.py` passes + +## Workflow follow-up + +- Pending a person: review the diff in tuicr (tuicr -r ..HEAD).