Repository navigation
Description
Problem or Motivation
An implement step that wrote correct code stops on a formatting check, and the job discards the work. On 2026-10-30 Job devops-cli-runner-20261030-165513-98d9 ran on #2656 with the 0.22.4 image. The agent fixed round_trip.py and added a test. The step then stopped:
uv run ruff format --check src/devops_cli/config/round_trip.py exited with status 1. unformatted: File would be reformatted ... raise ConfigurationError(f"Cannot unset {name}: the key {dotted!r} comes from a YAML merge key.") ... would be split over three lines.
_static_failure in implement_step.py runs ruff check, ruff format --check and mypy --strict on the changed Python files and stops on the first failure. Formatting is deterministic: a formatter gives one result for one input, and a person's editor or pre-commit hook applies it without asking. A model has no reason to be the one that applies it.
Proposed Solution & Architectural Design
- Before the static checks, the job runs
uv run ruff format <changed Python files>in the checkout, outside the agent's shell. It then runsruff checkandmypy --strictas today. Theruff format --checkrow goes, because the formatter has already run. - The job logs one line when the formatter changed a file ("Formatted: "), so a person sees that the job, not the model, made the change.
ruff checkstays a check and does not fix: a lint rule can point at a real defect that the model should see.- The formatter runs on the changed files only (the list the step already builds), never on files the agent did not touch.
Target Subsystem
src/devops_cli/roadmap/implement_step.py (_static_failure), src/devops_cli/lang/en/messages.py.
Existing Tool Considered
ruff format, already pinned and used by the job. Nothing new is built.
Acceptance criteria
- With the model faked, a step whose code is correct but unformatted ends done, the commit holds the formatted file, and the step prints one line that names it.
- A step whose code has a lint error or a type error still stops with that error.
- The formatter touches no file outside the changed list.
uv run devops cipasses, anddevops docs generate --sync-readmeis run.
Evidence: Job devops-cli-runner-20261030-165513-98d9 and the stop comment on #2656 at 17:00 UTC.
Proposed design
Problem statement
An implement step that wrote correct code stops on a formatting check, and the job discards the work. The formatter is deterministic: it gives one result for one input. The job should apply the formatter itself, outside the agent's shell, before the static checks. Then the step ends done instead of stopped.
Acceptance criteria
Requirement: formatter-applies-to-unformatted-code
The step SHALL run ruff format on the changed Python files before the static checks, so that correct but unformatted code ends done.
Scenario: unformatted code passes
- WHEN the model writes correct code that is not formatted to the project style
- THEN the step ends done, the commit holds the formatted file, and the step prints one line that names the formatted file
Requirement: lint-and-type-errors-still-stop
The step SHALL stop with the lint or type error when the code has a ruff check violation or a mypy --strict error.
Scenario: lint error stops the step
- WHEN the model writes code with a lint violation
- THEN the step stops with the
ruff checkerror message
Requirement: formatter-scope-limited-to-changed-files
The formatter SHALL touch only the files in the changed list, and no file outside it.
Scenario: unchanged file is not formatted
- WHEN the changed list holds one file and another file in the checkout is unformatted
- THEN the other file is not modified
Requirement: ci-passes
The change SHALL pass uv run devops ci, and devops docs generate --sync-readme SHALL be run.
Scenario: ci gate passes
- WHEN the change is committed and CI runs
- THEN all checks pass
Existing Tool Considered
No alternatives check has run. The tool ruff format (https://github.com/astral-sh/ruff) is already pinned in the project and used by the job. It covers the need: it formats Python files deterministically. It lacks nothing for this use case.
Key questions
- Where does the job run the formatter?: Inside
_static_failure, before the check loop. The function already filters the changed list to.pyfiles and has thesourcepath. The formatter runs there, outside the agent's shell. (best practice) [sources: src/devops_cli/roadmap/implement_step.py:995]- Chosen: Inside
_static_failurebefore the loop. The function already holds the filtered file list and the source path. The body says 'Before the static checks, the job runs ruff format'. This is the natural place. - Rejected: In
_exit_failurebefore calling_static_failure. This would duplicate the.pyfilter and the file-list logic. It separates the formatter from the checks it serves. - Rejected: In the agent's shell as a verification command. The body says the formatter runs 'outside the agent's shell'. The agent should not be the one that applies formatting.
- Chosen: Inside
- How does the job detect that the formatter changed a file?: Capture the stdout of
ruff formatin apply mode. It prints the paths of the files it reformatted. When stdout is non-empty, the job prints one line: 'Formatted: '. (best practice) [sources: src/devops_cli/roadmap/implement_step.py:995]- Chosen: Parse stdout of
ruff format.ruff formatin apply mode prints the paths of reformatted files to stdout. This is the tool's own report. No extra file read is needed. - Rejected: Compare file contents before and after. This reads every file twice. It is slower and adds no information that the tool does not already give.
- Rejected: Use
git diff --name-onlyafter the format. This works but mixes the formatter's effect with any other change the agent made. The tool's own output is more direct.
- Chosen: Parse stdout of
- Does the
ruff format --checkrow stay in the check loop?: No. The body states: 'The ruff format --check row goes, because the formatter has already run.' The loop keeps onlyruff checkandmypy --strict. (best practice) [sources: src/devops_cli/roadmap/implement_step.py:995]- Chosen: Remove
ruff format --checkfrom the loop. The formatter already ran in apply mode. A check after an apply is redundant and would only fail if the apply was incomplete, which is a bug in the tool, not in the code. - Rejected: Keep
ruff format --checkas a safety net. This adds a second run of the same tool for no benefit. The apply mode already guarantees the output is formatted.
- Chosen: Remove
- Does
ruff checkstay a check that does not fix?: Yes. The body states: 'ruff check stays a check and does not fix: a lint rule can point at a real defect that the model should see.' A lint violation is a defect, not a style choice. (best practice) [sources: src/devops_cli/roadmap/implement_step.py:995]- Chosen: Keep
ruff checkas a check (no--fix). A lint rule can point at a real defect. The model should see the error and fix the logic, not just the style. - Rejected: Run
ruff check --fixto auto-fix lint issues. This hides real defects from the model. A lint fix can change behavior, and the model should be the one that sees and fixes a defect.
- Chosen: Keep
- What message does the job print when the formatter changed a file?: One line: 'Formatted: ', printed to stderr via
print_muted. A new entry goes inRoadmapMessagesinmessages.py. (best practice) [sources: src/devops_cli/lang/en/messages.py]- Chosen: Print 'Formatted: ' to stderr. The body states this exact format. It goes to stderr so it does not pollute the stdout that the step's report reads. A person sees that the job, not the model, made the change.
- Rejected: Print to stdout. This would mix the formatter's note with the step's report output. The existing pattern in this file uses
print_mutedto stderr for informational lines.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 30, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.The step discards correct agent work on every unformatted file, but the work can be redone.It removes a recurring stop reason that wastes a full agent run on a fixable, deterministic issue.The change edits one function to swap a check for a format call and drops one check row.Both items want ruff format applied automatically, but #158 changes the devops ci command defaults while this candidate changes the roadmap implement step's internal static-failure flow.chore(main): release 0.22.6 (#2793)