Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/ROADMAP_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ A stop has a class (`roadmap/failure.py`, #3065). A stop site that knows its cau
| `ci_infra` | `retry` | The infrastructure failed, and every failure that no other class matches |
| `no_change_in_fix` | `wait` | A fix step changed no file, so the failed check is as it was. A person reads the failed check in the stop |
| `tests_lost` | `wait` | The agent removed or renamed a test that existed at the start of the step, and the plan on the default branch does not record it in `## Weakened checks` |
| `head_moved` | `retry` | The agent moved HEAD, and a step makes the only commit |
| `head_moved` | `retry` | The agent moved HEAD, and `git reset --soft` could not put it back. A step makes the only commit |
| `output_cap` | `raise_limit` | A model reply reached the output cap of the step |
| `limit_reached` | `raise_limit` | A step spent a token budget or a time limit of `roadmap.implement`. The reason names the setting and its value. See [the budgets](#checks-of-the-implement-job) |
| `read_only_path` | `wait` | A command wrote to a path that the Job mounts read-only. A new attempt or a new runner image writes to the same path, so a person fixes the cause |
Expand Down
2 changes: 2 additions & 0 deletions docs/roadmap/implement.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ For each item, the job does these things in order:

The job never merges. [Checks of the implement job](../ROADMAP_WORKFLOW.md#checks-of-the-implement-job) gives the detail of the hooks, the repair rounds and the time.

**A moved HEAD.** The shell of the agent allows `git`, so the agent can commit. A step makes the only commit, so before its exit checks the step resets a head that the agent moved with `git reset --soft`, to the start commit or to the last `wip:` commit. The reset keeps the work in the checkout, prints one line that names the moved head and the expected head, and the checks judge the work (#3575). The step stops with the class `head_moved` only when the reset fails.

**A stop.** A step that fails stops the item. The job comments why, shows a table of the steps (the step, its attempts, its tokens in and out, and its last failing command), shows the masked diff of the discarded work, and sets the Status to Blocked. The job keeps the trace of its run in `implement.trace`: each model call, tool call, check and retry, with no argument, no output, no secret and no private host name. Read it with `devops roadmap explain <issue> --trace`. The job keeps no Job artifact. The Service runs the item again after the comment `implement: retry`. For a stop whose class a new attempt can fix, it runs the item again with no comment. This happens after a Job that ended with no result, up to `roadmap.implement.continuations_per_item` times (default 2). It also happens after a new runner image, within the limits of `roadmap.implement.digest_clears_per_class` and `roadmap.implement.digest_clears_per_item`.

**The premise of a behavior group.** Before a behavior group starts, the job checks its premise at the branch tip. It reads each task of the group that has an add verb, the word guard or check, and one name in a code span. When the branch tip defines that name, the job returns the item to New. The comment holds the task and the definition line. The job runs no step, makes no model request and writes nothing. The check uses the same definition lookup as the premise check of the stage job (`src/devops_cli/roadmap/premise.py`). It reads the last commit that is not a `wip:` commit, so a guard that an earlier attempt of the same group kept is no defect. A group of another kind gets no check.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-06
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Design

## Decisions

- **`git reset --soft`, not `--mixed` or `--hard`.** `--soft` moves HEAD only, so the index and the checkout keep the work of the agent, and the later `git add -A` stages it. Rejected: `--mixed`, which also resets the index and leaves the work unstaged; and `--hard`, which deletes the work of the agent, the defect that this change fixes.
- **The reset runs in `_exit_failure`, before `keeper.fold()`.** Every exit check runs it, also the one after an extra turn, which can commit too. Rejected: a reset in `_turn` after the run. It misses the extra turn, and the head check of `_exit_failure` would still stop.
- **The target is `keeper.expected_head`.** It is the tip after the last `wip:` commit, or the base once the keeper folded. The `wip:` commits of the step stay, and `fold` folds them into the commit of the step. Rejected: `keeper.base`, which would discard the `wip:` commits that the step kept.
- **A reset that fails stops the step with `head_moved`.** The reason names the command, the exit status and the output of git, so the stop comment names its cause. Rejected: a second try of the reset. It fails for the same reason, and it adds a path that no check covers.
- **No new class and no new action.** `head_moved` keeps `retry` in `ACTION_BY_CLASS`. The reset makes the class rare, and the meaning of the class is the failed reset.
- **The proof uses real git.** The tests run git in a repository in `tmp_path`. A fake of `git` would show the call and not the state of the history. One test fakes the exit of `git reset --soft` at the process edge, the only way to make git refuse a reset to a commit that exists.

Reads: `src/devops_cli/roadmap/implement_wip.py`, `src/devops_cli/roadmap/failure.py`. Changes: `src/devops_cli/roadmap/implement_step.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/test_roadmap_implement_step.py`, `tests/roadmap/test_roadmap_implement_step_failure_class.py`, `tests/roadmap/test_roadmap_implement_step_repair.py`, `docs/ROADMAP_WORKFLOW.md`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Proposal

## Why

Issue #3575, split from #3053. The shell allowlist of the agent admits `git`, so an agent can commit. A step makes the only commit, so today the first exit check stops the step with the class `head_moved` when the head is not at the head of the keeper. The step then discards the work and gives no repair turn. The stop of #2636 read "The agent moved HEAD" after 7,166,584 input tokens, and all that work went. A wider refusal of git commands is not the answer: refused commands are already the largest stop class, and #2695 records the decision on the sandbox.

## What Changes

- `_exit_failure` in `src/devops_cli/roadmap/implement_step.py` puts a moved head back with `git reset --soft <expected head>`, where the expected head is `WipKeeper.expected_head`. The index and the checkout keep the work of the agent. The exit checks then judge that work, and a commit of the agent in an extra turn is reset the same way.
- The step stops with the class `head_moved` only when the reset exits with a status other than 0. The reason names the reset command, its exit status and the output of git.
- The step prints one muted line that names the moved head and the expected head.
- The reset goes to the expected head of the keeper, so the `wip:` commits of the step stay in the history until the step folds them into its commit.
- The class `head_moved` keeps its action `retry`. The change adds no class and no setting.
- The change carries spec deltas in `roadmap-implement-step` and `roadmap-implement-job`, because the stop reason, the Job log line and the cases of the class `head_moved` are observable.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-implement-step`: the requirement `A step makes the only commit` states the reset of a moved head.
- `roadmap-implement-job`: the requirement `A stop site passes a typed class of its cause` states the case of the class `head_moved`.

## Impact

- `src/devops_cli/roadmap/implement_step.py`, `src/devops_cli/lang/en/messages.py`.
- `docs/ROADMAP_WORKFLOW.md` (the row of `head_moved`).
- Tests in `tests/roadmap/` that stated the old stop.

## Feasibility

Checked on `origin/main` ad1e4b83, on 2026-11-06.

1. The defect is real. `_exit_failure` compared `_head(source)` with `keeper.expected_head` and returned a `head_moved` failure before any other check. The tests `test_a_commit_that_the_agent_makes_stops_the_step_and_the_checkout_returns_to_its_start` and `test_an_extra_turn_that_commits_stops_the_step_and_the_checkout_returns_to_its_start` held that stop.
2. The repair works on a real git repository. The new tests run real git in `tmp_path`, as the other step tests do. A step in which the agent commits during the turn ends done, its one commit has the start commit as parent, and it holds the work of the agent. A step in which the agent commits after a `wip:` commit also ends done, and the commit of the step folds the `wip:` commit. The cases in which a check fails after the reset end stopped with that failure, not with `head_moved`.
3. `git reset --soft <commit>` moves HEAD only; the manual of git (`git-reset`) says it touches neither the index file nor the working tree. This is the mode the keeper already uses in `fold` and `unfold`.
4. Not verified: a real run with a real model. A stub model script replays the agent, and one faked `git reset` stands for a reset that fails.

## Existing Tool Considered

git covers the reset with `git reset --soft`, which is open, maintained and installed in the runner. The project adds one call in the step (about 20 lines). Cost to build: about 20,000 tokens and about 1 hour. Cost to keep: about 1,000 tokens each quarter. Cost to fix one miss: about 5,000 tokens. The change deletes the stop of the first exit check and the two tests that held it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## MODIFIED Requirements

### Requirement: A stop site passes a typed class of its cause
Each stop of the job whose cause has a class SHALL pass that class, and the stop comment and `implement.failure` SHALL hold it. The classifier SHALL NOT decide a class that a site passes. The words of the last message of the agent and the words of a task SHALL NOT change a class. A step that changed no file SHALL pass `no_change_in_fix` in a fix step and `plan_defect` in a group step. A step whose reset of a moved `HEAD` failed SHALL pass `head_moved`.

#### Scenario: A fix step that changed no file
- **WHEN** a fix step stops with the reason "The agent changed no file." and its last message says "The item is already implemented."
- **THEN** the comment holds the class `no_change_in_fix` and `implement.failure` is `no_change_in_fix`

#### Scenario: A group step that changed no file
- **WHEN** the step of group 2 stops with the reason "The agent changed no file."
- **THEN** the class is `plan_defect`

#### Scenario: A lost test, a moved HEAD and the output cap
- **WHEN** a step stops because the agent removed a test, because the reset of a head that the agent moved failed, or because it reached the output cap
- **THEN** the classes are `tests_lost`, `head_moved` and `output_cap`

#### Scenario: The tier decision
- **WHEN** a turn ends with an error whose text the classifier reads as `parser`, and a second turn ends with the output cap and a message that holds the words of a parser failure
- **THEN** the step moves to the next tier after the first turn only, and the outcome of the step holds the class `parser` for the first and `output_cap` for the second, the class that the decision read
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## MODIFIED Requirements

### Requirement: A step makes the only commit
The first exit check SHALL put `HEAD` back at the commit where the step started, or at the last `wip:` commit of the step, with `git reset --soft` when the agent moved it, so the checkout keeps the work of the agent and the later exit checks judge that work. The step SHALL stop with the class `head_moved` only when the reset exits with a status other than 0.

#### Scenario: A commit by the agent
- **WHEN** the agent commits its work with `git`, and ticks the tasks
- **THEN** the step resets `HEAD` to the commit where it started, prints one muted line that names the moved head and the expected head, and reports done with one commit whose parent is the commit where the step started and that holds the work of the agent

#### Scenario: A commit by the agent after a `wip:` commit
- **WHEN** the step made a `wip:` commit and the agent then makes its own commit in an extra turn
- **THEN** the step resets `HEAD` to the `wip:` commit, and the commit of the step folds the `wip:` commit and the work of the extra turn

#### Scenario: A failed check after the reset
- **WHEN** the agent commits its work and a later exit check fails
- **THEN** the step reports stopped with the reason of that check, not with the class `head_moved`, makes no commit, and the checkout is back at its last `wip:` commit, or at the commit where the step started when it made none

#### Scenario: A reset that fails
- **WHEN** the agent moved `HEAD` and `git reset --soft` to the expected head exits with a status other than 0
- **THEN** the step reports stopped with the class `head_moved`, and the reason names the reset command, its exit status and the output of git
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## 1. Reset a moved head

Reads: `src/devops_cli/roadmap/implement_step.py`, `src/devops_cli/roadmap/implement_wip.py`. Changes: `tests/roadmap/test_roadmap_implement_step.py`, `tests/roadmap/test_roadmap_implement_step_failure_class.py`, `tests/roadmap/test_roadmap_implement_step_repair.py`, `src/devops_cli/roadmap/implement_step.py`, `src/devops_cli/lang/en/messages.py`.

- [x] 1.1 Replace the tests that held the stop of a moved head with tests on a real git repository: a commit of the agent in a turn and in an extra turn is reset and the step ends done with one commit; the reset line is printed once; a failed check after the reset stops with that failure and the `wip:` commit stays; a failed `git reset --soft` stops with `head_moved` and names the command and the output of git
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_implement_step.py tests/roadmap/test_roadmap_implement_step_failure_class.py tests/roadmap/test_roadmap_implement_step_repair.py`
- [x] 1.2 In `_exit_failure`, reset a head that is not the expected head of the keeper with `git reset --soft`, print the muted line, and stop with `head_moved` only when the reset fails
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_implement_step.py tests/roadmap/test_roadmap_implement_step_failure_class.py tests/roadmap/test_roadmap_implement_step_repair.py`

## 2. Tell the reader

Reads: `docs/ROADMAP_WORKFLOW.md`. Changes: `docs/ROADMAP_WORKFLOW.md`.

- [x] 2.1 In `docs/ROADMAP_WORKFLOW.md`, state the reset of a moved head and the new meaning of the class `head_moved`
- Verification: `uv run devops docs check`

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).
4 changes: 2 additions & 2 deletions openspec/specs/roadmap-implement-job/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ The example ConfigMap SHALL hold `roadmap.implement.effort` with its default val
- **THEN** the value of `roadmap.implement.effort` is `low` and then `medium`

### Requirement: A stop site passes a typed class of its cause
Each stop of the job whose cause has a class SHALL pass that class, and the stop comment and `implement.failure` SHALL hold it. The classifier SHALL NOT decide a class that a site passes. The words of the last message of the agent and the words of a task SHALL NOT change a class. A step that changed no file SHALL pass `no_change_in_fix` in a fix step and `plan_defect` in a group step.
Each stop of the job whose cause has a class SHALL pass that class, and the stop comment and `implement.failure` SHALL hold it. The classifier SHALL NOT decide a class that a site passes. The words of the last message of the agent and the words of a task SHALL NOT change a class. A step that changed no file SHALL pass `no_change_in_fix` in a fix step and `plan_defect` in a group step. A step whose reset of a moved `HEAD` failed SHALL pass `head_moved`.

#### Scenario: A fix step that changed no file
- **WHEN** a fix step stops with the reason "The agent changed no file." and its last message says "The item is already implemented."
Expand All @@ -1228,7 +1228,7 @@ Each stop of the job whose cause has a class SHALL pass that class, and the stop
- **THEN** the class is `plan_defect`

#### Scenario: A lost test, a moved HEAD and the output cap
- **WHEN** a step stops because the agent removed a test, moved HEAD, or reached the output cap
- **WHEN** a step stops because the agent removed a test, because the reset of a head that the agent moved failed, or because it reached the output cap
- **THEN** the classes are `tests_lost`, `head_moved` and `output_cap`

#### Scenario: The tier decision
Expand Down
16 changes: 14 additions & 2 deletions openspec/specs/roadmap-implement-step/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,23 @@ The exit checks SHALL run in this order: the agent made no commit, no test from
- **THEN** the step reports stopped with the reason that names the file and the missing tests, no verification command runs, and the checkout is reset

### Requirement: A step makes the only commit
The first exit check SHALL be that `HEAD` is still the commit where the step started, or the last `wip:` commit of the step.
The first exit check SHALL put `HEAD` back at the commit where the step started, or at the last `wip:` commit of the step, with `git reset --soft` when the agent moved it, so the checkout keeps the work of the agent and the later exit checks judge that work. The step SHALL stop with the class `head_moved` only when the reset exits with a status other than 0.

#### Scenario: A commit by the agent
- **WHEN** the agent commits its work with `git`, and ticks the tasks
- **THEN** the step reports stopped with the reason that `HEAD` moved, makes no commit, and the checkout is back at its last `wip:` commit, or at the commit where the step started when it made none
- **THEN** the step resets `HEAD` to the commit where it started, prints one muted line that names the moved head and the expected head, and reports done with one commit whose parent is the commit where the step started and that holds the work of the agent

#### Scenario: A commit by the agent after a `wip:` commit
- **WHEN** the step made a `wip:` commit and the agent then makes its own commit in an extra turn
- **THEN** the step resets `HEAD` to the `wip:` commit, and the commit of the step folds the `wip:` commit and the work of the extra turn

#### Scenario: A failed check after the reset
- **WHEN** the agent commits its work and a later exit check fails
- **THEN** the step reports stopped with the reason of that check, not with the class `head_moved`, makes no commit, and the checkout is back at its last `wip:` commit, or at the commit where the step started when it made none

#### Scenario: A reset that fails
- **WHEN** the agent moved `HEAD` and `git reset --soft` to the expected head exits with a status other than 0
- **THEN** the step reports stopped with the class `head_moved`, and the reason names the reset command, its exit status and the output of git

### Requirement: The verification commands of a group are the code spans of its Verification lines
The verification commands of a group SHALL be the code spans of the `Verification:` lines of its tasks, each one once, in the order of the file. The step SHALL run each one in the checkout as a list of words, never through a shell. It SHALL refuse to run one whose first word is not a program of the verification list (the shell allowlist, `openspec` and `devops`) and is not the `!` of a negative search in the fixed shape.
Expand Down
7 changes: 6 additions & 1 deletion src/devops_cli/lang/en/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,12 @@ class RoadmapMessages:
)
implement_tests_lost_file: str = "{path}: {tests}"
implement_stop_head_moved: str = (
"The agent moved HEAD from {start} to {head}. A step makes the only commit."
"The agent moved HEAD from {start} to {head}, and the reset to {start} failed.\n"
"`{command}` exited with status {status}.\n{output}"
)
implement_head_reset: str = (
"The agent moved HEAD from {start} to {head}. The step reset HEAD to {start} and kept "
"the changes."
)
implement_stop_commit_failed: str = "The commit failed.\n{output}"
implement_stop_hooks_install: str = (
Expand Down
Loading
Loading