Skip to content

feat(roadmap): extend implement repair rounds while the errors fall #4861

Not planned

Description

@dan-petty

Problem or Motivation

roadmap.implement.repair_rounds is 3. 4 stops in 7 days came after all repair rounds (lint 2, not_ticked 1, plan_defect 1), and 0 of 3 sampled were fixable by more rounds of the same kind, so a fixed raise wastes tokens. A soft cap that extends only while the error count falls keeps the cost on runs that make progress.

Proposed Solution & Architectural Design

Point implement.repair_rounds (#4847): soft = roadmap.implement.repair_rounds (3), step +1, at most 2 extensions, hard 5. Rule: the error count of the failing checks (ruff, mypy, tests) fell at the last round and the error set did not repeat. Jev (Noul: yes/no with a probability) 'progressing'. Guard: step seconds left >= 1.5 x the longest round + 300 s. Linked, not folded: #3569 (strategy per round), #3570 (no repeated failed tool call).

Target Subsystem

SDLC, Git & PR Governance (roadmap implement).

Existing Tool Considered

The #4847 chain; the error counts that ruff, mypy and pytest report. Cost to build: about 0.8M tokens, half a day.

Acceptance Criteria

  • A test: a round that lowers the ruff error count from 6 to 2 gets a fourth round.
  • A test: the same error set two times stops.
  • A test: no sixth round.
  • A test: no round starts past the time guard.

Dependencies

#4847.

Source: #4843

Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found only generic retry libraries, tenacity and retryguard, which cap attempts, delay or error class; none parses ruff, mypy or pytest error counts, compares masked error sets across rounds, or applies the longest-round time guard, so none covers the extension policy.

Covers:

  • Bounded attempt and elapsed-time stop conditions
  • Custom stop callable that receives the retry state
  • Wait strategies between attempts

Lacks:

  • No parsing of ruff, mypy or pytest error counts
  • No comparison of masked error sets between rounds
  • No time guard relative to the longest round

Proposed design

Problem statement

The implement job stops after 3 repair rounds. Four stops in 7 days came after all 3 repair rounds. 0 of 3 sampled stops were fixable by more rounds of the same kind, so a fixed raise wastes tokens. This change extends a repair round only while the failing check's error count falls and its error set does not repeat, within a hard cap and a time guard.

Acceptance criteria

Requirement: Round record

The repair-round policy SHALL hold the failing check of each repair round and the error count that the check reports in a round record.

Scenario: A ruff failure with six errors

  • WHEN A test reads ruff output that reports 6 errors for one repair round.
  • THEN The round record holds the check ruff and the error count 6.

Requirement: Extension on a falling count

The repair-round policy SHALL allow one more round when the failing check repeats and its error count is lower.

Scenario: Ruff errors fall from six to two

  • WHEN A test gives the policy a third ruff round with 2 errors after a second ruff round with 6 errors and different masked lines.
  • THEN The policy returns an extension of one round.

Requirement: No extension on an equal count

The repair-round policy MUST NOT allow an extension when the failing check repeats and its error count is equal.

Scenario: Ruff errors stay at six

  • WHEN A test gives the policy a ruff round with 6 errors after a ruff round with 6 errors and different masked lines.
  • THEN The policy returns no extension.

Requirement: No extension on a changed check

The repair-round policy MUST NOT allow an extension when the failing check differs from the round before.

Scenario: Ruff falls and pytest fails next

  • WHEN A test gives the policy a round on pytest with 10 errors, after a round on ruff with 6 errors.
  • THEN The policy returns no extension.

Requirement: No extension without an error count

The repair-round policy MUST NOT allow an extension when the failing check reports no error count.

Scenario: A stop that reports no count

  • WHEN A test gives the policy a round whose failing check reports no error count.
  • THEN The policy returns no extension.

Requirement: Stop on a repeated error set

The repair-round policy MUST NOT allow an extension when the masked error lines equal those of the round before.

Scenario: The same error at a new line number

  • WHEN A test gives the policy two rounds on ruff with the same rule in the same file, at line 12 and at line 40.
  • THEN The policy masks the digits, finds the same error set, and returns no extension.

Requirement: One round per extension

The repair-round policy SHALL grant exactly one repair round for each extension that it allows.

Scenario: The fourth round

  • WHEN A test sets the soft cap to 3 and gives the policy a round that qualifies for one extension.
  • THEN The policy allows 4 repair rounds.

Requirement: Hard cap

The repair-round policy MUST NOT allow a repair round past the hard cap, which is the soft cap plus the extension limit.

Scenario: No sixth round at the default caps

  • WHEN A test sets the soft cap to 3 and the extension limit to 2, and the fifth repair round lowers the error count.
  • THEN The policy allows no sixth repair round.

Requirement: Time guard

The repair-round policy MUST NOT allow an extension when fewer than 1.5 times the longest round plus 300 seconds remain before the step time limit.

Scenario: Too little time left

  • WHEN A test sets 600 seconds left before the step time limit and a longest repair round of 300 seconds.
  • THEN The policy returns no extension, since it needs 750 seconds and 600 are left.

Requirement: Extension count setting

The roadmap settings SHALL hold the maximum repair-round extension count as roadmap.implement.repair_round_extensions with a default of 2.

Scenario: Default maximum extension count

  • WHEN A test loads the roadmap settings with no value for roadmap.implement.repair_round_extensions.
  • THEN The settings give the value 2 for roadmap.implement.repair_round_extensions.

Requirement: Step asks the policy

The implement step SHALL ask the repair-round policy before it starts a repair round past the soft cap.

Scenario: A fourth round after a falling count

  • WHEN A test runs the implement step with soft cap 3 and a third ruff round with fewer errors than the round before.
  • THEN The step starts a fourth repair round.

Requirement: Step respects the time guard

The implement step MUST NOT start a repair round when the time guard of the repair-round policy fails.

Scenario: The step holds at the soft cap with too little time

  • WHEN A test runs the implement step with soft cap 3, a qualifying third round, 600 seconds left, and a longest round of 300 seconds.
  • THEN The step starts no fourth repair round.

Existing Tool Considered

The alternatives check in the issue body records Alternatives check of 2026-11-21: none with Tool: none found. Its Reason: names jd/tenacity as the closest tool, a generic retry library, and the block lists what it lacks. No open, maintained tool or library covers the need. The proposal covers those lacks in the implement loop with a proven rule over the failing check, its error count and its masked error lines, and it calls no model. Cost to build, keep and fix the policy until it matches the tool: about 0.8M tokens and half a day.

Key questions

  • Which rule decides that a repair run is progressing?: A proven rule decides. The policy allows an extension when the failing check repeats, its error count is lower, and the masked error lines differ. The policy calls no model. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/implement/implement_limits.py]
    • Chosen: Proven rule on the error count and the masked error set. CONTEXT.md puts a proven rule before the decision model, and implement.extension already runs a rule with no model.
    • Rejected: Jev model judge with a yes/no answer. It adds a model call to each round, and no labelled outcome gives its cut.
    • Rejected: A fixed raise of the repair rounds. 0 of 3 sampled stops were fixable by more rounds of the same kind, so a fixed raise wastes tokens.
  • What are the soft cap, the extension step and the hard cap?: The soft cap is roadmap.implement.repair_rounds, which is 3. Each extension adds one round. roadmap.implement.repair_round_extensions bounds the extensions with a default of 2, so the hard cap is 5 by default and follows a change of the soft cap. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/roadmap/implement/implement_limits.py]
    • Chosen: Soft cap plus a bounded extension count. The stage job already bounds extra gate returns with roadmap.stage.gate_return_extensions, and the bound follows a change of the soft cap.
    • Rejected: A fixed hard cap of 5. A fixed hard cap ignores a change of the soft cap.
    • Rejected: No limit while the error count falls. A run with a falling count and no ceiling spends tokens without bound.
  • Which failing checks give the error count?: The error count comes from the output of the failing check: ruff (lint), mypy (types) or pytest (test). The count_errors helper in src/devops_cli/roadmap/steps/fix_checks.py counts the errors that the check reports. A check that reports no error count gives no extension. [sources: src/devops_cli/roadmap/steps/fix_checks.py:149]
  • How does the policy compare the error counts of the checks?: It compares the count of the round's failing check with the count of the same check in the round before. It reads each count with the tested count_errors helper. A changed check gives no comparable count, so it gives no extension. (best practice) [sources: src/devops_cli/roadmap/steps/fix_checks.py:149, tests/roadmap/steps/test_roadmap_step_fix_checks.py]
    • Chosen: The round's own failing check. A round stops at one failing check, and count_errors already parses that check with tests.
    • Rejected: The total across ruff, mypy and pytest. A round stops at one failing check, so the job never holds the three counts of one round.
    • Rejected: A count that the plan states. The plan names no error count, and the check output is the evidence of progress.
  • How does the job tell a repeated error set from a new one?: It masks the digits in each error line of the round's failing check and takes the set of those lines. A set that equals the set of the round before stops the extensions, so a changed line number cannot make an old error look new. (best practice) [sources: src/devops_cli/roadmap/steps/fix_checks.py:149]
    • Chosen: Compare the masked error lines. A moved line number is the same error, and the parser at src/devops_cli/roadmap/steps/fix_checks.py:149 gives the error lines that the mask reads.
    • Rejected: Compare the error count alone. An equal count can hold a different error set.
    • Rejected: Compare the raw error text. A changed line number would make the same error look new.
  • How does the job measure the seconds left and the longest round?: StepBudget counts the seconds that the step has run and holds step_time_limit_seconds, so the seconds left are the limit minus the run. The job times each round with the clock that the budget reads and keeps the longest. It allows an extension only when the seconds left are at least 1.5 times that round plus 300 seconds. (best practice) [sources: src/devops_cli/roadmap/implement/implement_limits.py]
    • Chosen: The step time limit and the longest timed round. StepBudget already holds the seconds of the step and reads the clock, so a test sets both the seconds left and the longest round.
    • Rejected: The Job deadline. The step stops at its own time limit first, so the Job deadline is no bound on a repair round.
    • Rejected: A fixed time constant. A fixed constant ignores the size of the round.
  • Where does the policy live and how does it reuse the error counter?: The policy is a pure function beside StepBudget in src/devops_cli/roadmap/implement/implement_limits.py, which the implement step already imports. It takes the check name, the error count and the error lines as arguments. count_errors moves to the leaf module src/devops_cli/roadmap/error_count.py, and the implement step and fix_checks.py import it. (best practice) [sources: src/devops_cli/roadmap/steps/fix_checks.py:149, tests/roadmap/steps/test_roadmap_step_fix_checks.py, src/devops_cli/roadmap/implement/implement_limits.py, src/devops_cli/roadmap/implement/implement_step.py]
    • Chosen: Move count_errors to a shared leaf module. Two callers need one tested parser, and a leaf module keeps the import graph acyclic.
    • Rejected: Import count_errors from fix_checks.py into the implement step. The implement step would then depend on the whole fix-checks step, its GitHub calls included.
    • Rejected: Write a second parser in the implement step. Two parsers drift, and the fix-checks tests cover only one.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#6521, #4847

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 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/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It reduces wasted tokens on unproductive runs but does not block a release or fix a defect.
    • Value: Medium. It saves tokens on runs that stop improving, but the benefit is cost rather than new capability.
    • Effort: Low. The body states about 0.8M tokens and half a day of work.
    • Related: feat(roadmap): each repair round changes the strategy of a step #3569, which asks for a different change. Both work on repair rounds in the roadmap implement step, but #3569 changes the strategy of each round while the candidate extends the number of rounds based on progress.
  4. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches returned no open tool that extends a repair-round budget while the error count of the failing checks falls; the closest match, the generic retry library tenacity, only offers a fixed attempt/delay cap or a custom stop predicate over its own call state, not progress measured from ruff, mypy and pytest error counts. The issue asks for policy code inside the project's own roadmap implement loop (soft cap 3, step +1, hard 5, repeated-error-set stop, time-left guard, Jev "progressing" decision), which no existing library provides.

    Tool: none found

    Lacks:

    • Extending the repair-round cap only while the error count of the failing checks falls
    • Comparing the error set of a round with the previous round to stop on a repeat
    • A time-left guard of 1.5 x the longest round + 300 s before starting a round
    • A Jev yes/no decision on whether the run is 'progressing'
    • Wiring into the roadmap implement loop and its repair_rounds setting (feat(roadmap): add the soft-cap and fix-check chain to decision points #4847)

    Tools considered:

    Searches run:

    • LLM agent repair loop retry until no progress in errors framework, results: 5
    • python library adaptive retry budget stop when error count stops decreasing, results: 5
    • tenacity python retry stop after attempts adaptive, results: 5
    • aider auto lint test fix loop retries until tests pass, results: 5
    • tenacity documentation stop_after_attempt retry library github, results: 5
    • python backoff library exponential retry stop condition callable, results: 5
    • github jd tenacity retry library, results: 5
    • "repair rounds" agent error count progress stop condition, results: 5
    • open source tool extends retry budget while lint errors decrease, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at ca62d6a while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  6. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.

  7. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  8. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  9. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor

    Triage under #6519 (owner instruction of 2026-11-30), before the hold #6521 closes. This item adds or extends a gate, refusal, screen, cap, limit, retry, result line, shell allowlist, tool catalog or plan-shape rule of the stage, implement or fix-checks job. #6519 found that 263 of about 900 issues in four weeks added such rules and none replaced the engine. Stage now runs on stock Coder (grade 60 on 30 graded attempts), where the agent reads the repository, runs the checks in its loop and has a real shell; implement follows (#6527). The code paths that this item names have also moved. If the failure class still shows in graded attempts, file a new item from that evidence. Closed as not planned; a person may reopen it.

  10. removed
    status/new
    on Nov 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/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions