Skip to content

fix(roadmap): an implement step stops on ruff format, which the job can apply itself #2789

Description

@dan-petty

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 runs ruff check and mypy --strict as today. The ruff format --check row 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 check stays 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 ci passes, and devops docs generate --sync-readme is 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 check error 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 .py files and has the source path. The formatter runs there, outside the agent's shell. (best practice) [sources: src/devops_cli/roadmap/implement_step.py:995]
    • Chosen: Inside _static_failure before 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_failure before calling _static_failure. This would duplicate the .py filter 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.
  • How does the job detect that the formatter changed a file?: Capture the stdout of ruff format in 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 format in 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-only after 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.
  • Does the ruff format --check row stay in the check loop?: No. The body states: 'The ruff format --check row goes, because the formatter has already run.' The loop keeps only ruff check and mypy --strict. (best practice) [sources: src/devops_cli/roadmap/implement_step.py:995]
    • Chosen: Remove ruff format --check from 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 --check as a safety net. This adds a second run of the same tool for no benefit. The apply mode already guarantees the output is formatted.
  • Does ruff check stay 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 check as 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 --fix to 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.
  • 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 in RoadmapMessages in messages.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_muted to stderr for informational lines.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Oct 30, 2026
  2. dan-petty commented on Oct 30, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The step discards correct agent work on every unformatted file, but the work can be redone.
    • Value: Medium. It removes a recurring stop reason that wastes a full agent run on a fixable, deterministic issue.
    • Effort: Low. The change edits one function to swap a check for a format call and drops one check row.
    • Related: feat(ci): automatically apply formatting and linting across CLI and CI commands #158, which asks for a different change. 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.
  3. added
    priority/p2-medium
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Oct 30, 2026
  4. removed
    status/in-review
    on Oct 30, 2026
  5. added a commit that references this issue on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions