Skip to content

feat(roadmap): an implement refusal halt gets one repair turn #4859

Not planned

Description

@dan-petty

Problem or Motivation

Before the halt of #4659, refused commands were in 25 of 51 implement stops (92 refused commands: uv 33, git 16, grep 8, ls 4 and others). #4659 now halts a step at 3 refusals in a row with 0 repair turns. Implement reaches a ready PR in about 15% of Jobs (12 of 81). The halt has only hours of data, so a wait for 5 events would leave implement with no lever. The shell policy is a sandbox rule and does not change.

Proposed Solution & Architectural Design

At the halt of CONST_ROADMAP_IMPLEMENT_MAX_CONSECUTIVE_REFUSALS refusals in a row (implement_tool_log.py), run the fixable check (point implement.halt_fixable, #4847): map each refused command to its allowed form (implement_shell_refusal.py); fixable when each refused program has an allowed form that the model did not get in this step. Fixable -> one turn with the list as a reminder, then halt on the next 3 refusals in a row. Not fixable -> halt as today with the reason. 1 turn per step, 2 per item. The total of 30 refusals and the shell policy stay.

Target Subsystem

SDLC, Git & PR Governance (roadmap implement).

Existing Tool Considered

The allowed command forms of implement_shell_refusal.py and the #4847 chain. Cost to build: about 0.6M tokens, half a day.

Acceptance Criteria

  • A test: 3 refused 'cd x && uv run pytest' calls get one turn with the allowed form and no halt; 3 more refusals in a row halt the step.
  • A test: a refused program with no allowed form halts at once as not fixable.
  • A test: no third turn in one item.
  • The feat(roadmap): log one result line for each roadmap job attempt #4845 line holds halt_turns.
  • 7 days after deploy: refused_tool stops fall, and each turn has an outcome line.

Dependencies

#4847.

Related: #4659 (the halt of today) and #4115 (stop the step early on stalls and refusals). This item adds a repair turn before the halt; it does not remove the halt.

Source: #4843

Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found only policy engines and generic command/shell references, none of which implement a repair turn with allowed-form mapping at a consecutive-refusal halt inside the project's own implement loop.

Lacks:

  • Repair turn before the consecutive-refusal halt
  • Per-step record of allowed forms already given
  • Fixability rule and decision point with shadow mode
  • Repair-turn outcome lines and halt_turns count

Proposed design

Problem statement

The implement step halts an item at three refused commands in a row. Refused commands were in 25 of 51 implement stops, and implement reaches a ready pull request in about 15% of jobs. This change adds one repair turn before the halt when every refused program has an allowed form that the model did not get in this step. It keeps the shell policy and the total of 30 refusals. The work waits on #6521.

Acceptance criteria

Requirement: Registered point

The implement.halt_fixable decision point SHALL be registered in decision_registry.REGISTRY and decision_table.POINT_CUTS with a cuts file in the repository.

Scenario: Registered point

  • WHEN The test reads REGISTRY.names and POINT_CUTS.
  • THEN Both name implement.halt_fixable, and the cuts file that POINT_CUTS gives is a file of the repository.

Requirement: Rule reads cuts file

The implement.halt_fixable rule MUST read the programs with an allowed form from its cuts file, not from a constant.

Scenario: Cuts file changes the band

  • WHEN The test calls the rule with a program that only a temporary cuts file names as allowed.
  • THEN The rule returns the band that starts the repair turn for that program.

Requirement: Halt calls point

The implement step SHALL call the implement.halt_fixable point at the consecutive-refusal halt.

Scenario: Halt calls the point

  • WHEN The test sets roadmap.decisions to implement.halt_fixable: on and reaches three consecutive refusals.
  • THEN The step calls implement.halt_fixable once before it starts a repair turn or halts.

Requirement: One repair turn

At the third consecutive refusal, the implement step SHALL start one repair turn when the halt is fixable and SHALL NOT halt the step.

Scenario: Fixable halt gets one turn

  • WHEN The test sets implement.halt_fixable to on, drives three refused cd x && uv run pytest calls in a row through implement_tool_log.py, and each refused program has an allowed form that the model did not get in this step.
  • THEN The step starts one repair turn with the allowed form as a reminder and does not raise UnexpectedModelBehavior.

Requirement: Halt after repair turn

The implement step SHALL reset the consecutive refusal count after a repair turn and SHALL halt at the next three consecutive refusals.

Scenario: Three more refusals halt

  • WHEN The test gives the model one repair turn and then three refused calls in a row.
  • THEN The step raises UnexpectedModelBehavior and stops.

Requirement: Not fixable halt

The implement step SHALL halt at the third consecutive refusal when any refused program has no allowed form.

Scenario: No allowed form

  • WHEN The test sets implement.halt_fixable to on and drives three refused calls in a row for a program that implement_shell_refusal.py has no allowed form for.
  • THEN The step raises UnexpectedModelBehavior at the third refusal with the reason and starts no repair turn.

Requirement: Allowed form already given

The implement step SHALL treat a refused program as not fixable when the model already got its allowed form in the same step.

Scenario: Allowed form already given

  • WHEN The test gives the allowed form of the refused program in the step before the three refusals.
  • THEN The step halts at the third refusal and starts no repair turn.

Requirement: Two turns per item

The implement step SHALL start at most one repair turn in a step and at most two in one item.

Scenario: Third turn refused

  • WHEN The test uses the two repair turns of one item and reaches another fixable halt.
  • THEN The step halts at the third refusal and starts no third repair turn.

Requirement: Halt turns recorded

The #4845 result line SHALL hold halt_turns with the count of repair turns of the item.

Scenario: Halt turns in the result line

Requirement: Continued repair turn outcome

The implement step SHALL write one outcome line for each repair turn that ends with a continued step.

Scenario: Continued repair turn

  • WHEN The test ends a repair turn with a continued step.
  • THEN The log holds one outcome line with the turn number and the result continued.

Requirement: Halted repair turn outcome

The implement step SHALL write one outcome line for each repair turn that ends with a halt.

Scenario: Halted repair turn

  • WHEN The test ends a repair turn with a halt.
  • THEN The log holds one outcome line with the turn number and the result halted.

Requirement: Total refusal limit

The repair turn SHALL NOT reset the total refusal count or the shell policy.

Scenario: Total limit

  • WHEN The test reaches more than 30 total refused calls, including one repair turn.
  • THEN The step halts at the total limit and the shell policy still refuses the same commands.

Requirement: Off mode

The implement step SHALL halt at the third consecutive refusal with no repair turn when the mode of implement.halt_fixable is off.

Scenario: Off keeps today's halt

  • WHEN The test sets roadmap.decisions to implement.halt_fixable: off and drives three refused calls in a row.
  • THEN The step raises UnexpectedModelBehavior at the third refusal and writes no repair-turn outcome line.

Requirement: Shadow changes nothing

The implement step SHALL record the implement.halt_fixable band in shadow mode and SHALL halt at the third consecutive refusal with no repair turn.

Scenario: Shadow mode

  • WHEN The test sets roadmap.decisions to implement.halt_fixable: shadow and drives three refused calls in a row.
  • THEN The step records the band, raises UnexpectedModelBehavior at the third refusal, and starts no repair turn.

Requirement: Pending a person after the merge

The owner SHALL run the live check 7 days after the owner sets implement.halt_fixable to on and confirm that refused_tool stops fall and each repair turn has an outcome line.

Scenario: Seven-day live check

  • WHEN The owner runs the live check of the refused_tool stop count in Loki 7 days after the owner sets implement.halt_fixable to on.
  • THEN The refused_tool stop count falls, and each repair turn has one outcome line.

Existing Tool Considered

The alternatives check of 2026-11-21 in the issue body gives the verdict none and names no tool. The check lists what a tool would lack. The change builds its own rule inside the roadmap implement loop. Written cost: about 0.6M tokens and half a day to build. The issue gives no separate keep-and-fix cost.

Key questions

  • What does the implement step do today at three refusals in a row?: implement_tool_log.py counts shell refusals in a row. A call that is not refused resets the count. At roadmap.implement.max_consecutive_refusals (3), the step raises UnexpectedModelBehavior with Too many consecutive commands refused by policy: the limit is 3. The step stops with the class refused_tool, which has the action wait. The item stays Blocked until a person comments implement: retry. The halt writes no line of its own. [sources: src/devops_cli/roadmap/implement/implement_tool_log.py, src/devops_cli/lang/en/messages.py, openspec/specs/roadmap-implement-step/budgets/spec.md:29, docs/CLUSTER.md:49]
  • Which allowed form does the repair turn give the model?: The repair turn repeats the text that refusal_hint gives for each refused command. A program of IMPLEMENT_SHELL_REPLACEMENTS gets its replacement. An allowed program that the step refused for an operator gets the two-call chain. Any other program gets the allowed programs and the uv run form. Rule AW-U3 requires a refusal to name its rule and the next allowed action. (best practice) [sources: docs/guidelines/agentic-jobs.md]
    • Chosen: Allowed-form text of refusal_hint. The map exists, it is the text that the refusal already gives, and AW-U3 says a refusal names the next allowed action.
    • Rejected: Nearest allow entries of the shared command gate. The shared command gate is feat(roadmap): track the shared command gate #5199 and not built, so it holds no allow entries to read.
    • Rejected: The allowed programs alone. It drops the replacement of a known program and the two-call chain of an operator, so the reminder is not the allowed form of that command.
  • When is a halt fixable?: The halt is fixable when every refused program in the run has an allowed form in IMPLEMENT_SHELL_REPLACEMENTS, or is an allowed program refused for an operator, and the model did not get that form in this step. Otherwise, the halt is not fixable, and the step halts at the third refusal as today. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py]
    • Chosen: Every refused program has a new allowed form. The reminder must repair every refusal in the run, not one of them.
    • Rejected: Any refused program has an allowed form. One program with no allowed form leaves the reminder incomplete, and the next turn can repeat it.
    • Rejected: The model already got the allowed form. A reminder of a form that the model already got cannot repair the refusal.
  • What does the implement.halt_fixable cuts file hold?: The cuts file holds the programs that have an allowed form. Each entry names a program. The allowed form itself comes from implement_shell_refusal.py. The rule reads the file as data and does not hard-code the list. The file lives with the other decision-point cuts files. (best practice) [sources: src/devops_cli/roadmap/decision_table.py:29]
    • Chosen: Cuts file of allowed programs. The rule reads the allowed programs as data, and the cuts file records their provenance.
    • Rejected: Constant in the rule. A constant hides the data from the cuts file and from its provenance.
    • Rejected: Read the shared command gate. The shared command gate is feat(roadmap): track the shared command gate #5199 and not built, so it holds no allow entries to read.
  • How does the step know that the model already got an allowed form in this step?: The step records each allowed form that a refusal hint gives in the current step. At the halt, a refused program is not fixable when its allowed form is in that record. The record is cleared at the start of each step. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py]
    • Chosen: Record the allowed forms that the step gives. The step can compare the allowed form of each refused program with the forms that it already sent.
    • Rejected: Compare the command text only. The same command can get a different allowed form, and the text alone does not show that the model got the form.
    • Rejected: Ask the model. The model can be wrong, and the step needs a deterministic check.
  • How many repair turns does one step and one item get?: One repair turn per step and two per item. A second fixable halt in the same step halts the step, and a third fixable halt in the item halts the item. The item cap of 2 matches roadmap.implement.continuations_per_item (default 2), which already bounds a second run of an item. (best practice) [sources: src/devops_cli/config/settings.py:1673, docs/CONFIGURATION.md, docs/ROADMAP_WORKFLOW.md]
    • Chosen: 1 per step, 2 per item. A step gets the one extra turn it needs, and the item cap of 2 matches continuations_per_item and stops a loop.
    • Rejected: 1 per item. A later step can meet a new refused shape, and the item cap would end the item with no repair in that step.
    • Rejected: No cap. A loop of refused commands can spend the step and item token budgets.
  • Does the shared command gate exist, so that a Command gate halt: line can be counted?: No. Rule AW-G1 names the shared command gate as feat(roadmap): track the shared command gate #5199, and until it exists the runner pod is the sandbox. The halt is in implement_tool_log.py and writes no line of its own. The 7-day measurement counts the refused_tool stop lines and the repair-turn outcome lines, not a gate line. [sources: docs/guidelines/agentic-jobs.md, docs/ROADMAP_WORKFLOW.md, src/devops_cli/roadmap/implement/implement_tool_log.py, docs/CLUSTER.md:49]
  • Does the change alter the shell policy or the total refusal limit?: No. The shell policy stays a sandbox rule and the total of 30 refused calls stays. The repair turn adds one model turn before the consecutive-refusal halt. It resets the consecutive refusal count after the turn, and it resets neither the total refusal count nor the shell policy. (best practice) [sources: docs/ROADMAP_WORKFLOW.md, docs/guidelines/agentic-jobs.md, openspec/specs/roadmap-implement-step/budgets/spec.md:33, src/devops_cli/roadmap/implement/implement_tool_log.py]
    • Chosen: Keep the shell policy and the total. The item keeps the sandbox rule and the loop guard, and AW-T6 forbids a tuning pass on a security control.
    • Rejected: Raise the consecutive-refusal limit. That is a tuning pass on the command gate, which AW-T6 forbids, and it does not repair the command.
    • Rejected: Remove the total limit. It removes a guard against a loop and spends the item budget.
  • How does the step record a repair turn?: The step writes one outcome line for each repair turn with the turn number and the result continued or halted. The feat(roadmap): log one result line for each roadmap job attempt #4845 result line holds halt_turns with the count of the repair turns of the item. (best practice) [sources: src/devops_cli/roadmap/job_result.py, src/devops_cli/roadmap/implement/implement_tool_log.py, openspec/specs/roadmap-implement-step/trace/spec.md:93]
    • Chosen: Outcome line and halt_turns. The line shows each turn, and the result line shows the count of the item.
    • Rejected: Only the refused trace line of each call. It shows each refusal and cannot show the result of the turn.
    • Rejected: Only the stop comment of the item. It shows the end of the item and cannot show each turn.
  • Which mode does implement.halt_fixable run in, and who turns it on?: The point starts in shadow in roadmap.decisions, as ADR 0020 section 5 requires of a new point. A person sets it to on in the ConfigMap devops-cli-config after reading the shadow record and the outcome lines. The tests drive the on, shadow and off modes. (best practice) [sources: docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md, src/devops_cli/roadmap/decision_table.py:29]
    • Chosen: Start in shadow, then a person sets on. ADR 0020 section 5 requires a new point to start in shadow, and a person reads the record before the point changes behavior.
    • Rejected: Start in on. It changes the halt behavior with no shadow record, which ADR 0020 forbids.
    • Rejected: Start in off. It adds a registered point with no evidence, and the shadow mode exists for that evidence.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#6521

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. removed
    effort/low
    on Nov 11, 2026
  4. 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 raises implement success from about 15 percent but does not block a release or fix a security gap.
    • Value: Medium. It gives the model one chance to correct a refused command, which should raise the ready-PR rate for implement jobs.
    • Effort: Low. The body estimates about 0.6M tokens and half a day of work.
    • Related: feat(roadmap): Stop the implement step early on stalls and refusals #4115, which asks for a different change. Both work on the implement step refusal path, but #4115 stops the step early on stalls and refusals while this item inserts one repair turn with allowed command forms before the halt triggers.
  5. added
    effort/low
    on Nov 11, 2026
  6. added
    priority/p2-medium
    and removed
    effort/low
    on Nov 11, 2026
  7. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    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. The change gives implement a lever against frequent refusal stops, but the halt has only hours of data.
    • Value: Medium. One repair turn can recover fixable refusals and raise the low ready-PR rate.
    • Effort: Low. The body estimates about 0.6M tokens and half a day of work.
    • Related: fix(roadmap): halt implement step on consecutive command refusals #4043, which asks for a different change. Both items act on consecutive command refusals in implement, but 4043 adds the halt and the candidate adds one repair turn before that halt.
  8. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    The command gate plan (tracker #5199) can make this item unnecessary.

    All 13 measured halts on 3 refusals in a row came from the shapes S1 and S2: a quoted ; in inline Python and a quoted heredoc. #5201 puts both on the allowlist (owner decision of 2026-11-12), and it adds the log line Command gate halt: limit <name>, last rule <id>.. Today no Loki line records a halt.

    New scope:

    1. Seven days after feat(roadmap): check shell commands with a parser and configured lists #5201 deploys, count the Command gate halt: lines in Loki. Use the run-length count of refusal lines of the 7 days before as the baseline.
    2. If there is at most 1 halt each week, close this item as superseded, with the counts (AGENTS.md rule 2).
    3. If not, keep it, and use the nearest allow entries of the gate as its "allowed form".

    Acceptance: a comment on this item holds the LogQL queries and the counts of the 7 days before and after the deploy.

    Dependencies: #5201.

  9. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches surfaced only general shell-parsing and command-policy building blocks (the closest being bashlex, a Python bash parser), none of which carries an allowed-form map, a fixable check, a one-turn repair before a halt, or the consecutive-refusal accounting. The need is a change inside the roadmap implement loop and its own implement_shell_refusal.py/implement_tool_log.py modules, so no open tool covers it.

    Tool: none found

    Tools considered:

    Searches run:

    • python library parse bash command check allowed form bashlex, results: 5
    • open source shell command allowlist policy for AI coding agents refused command, results: 5
    • bashlex github python parse shell commands, results: 5
    • Claude Code permission deny rule suggest allowed command alternative hooks, results: 5
    • "bashlex" PyPI package, results: 5
    • Open Policy Agent shell command allow list policy engine, results: 5
    • bashlex, results: 5
    • tree-sitter bash parser, results: 5
    • Cedar policy language command authorization, results: 5
    • tool to validate shell commands against an allowlist before running agent, 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.

  10. 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.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/implement/implement_tool_log.py, src/devops_cli/roadmap/implement/implement_shell_policy.py.

  11. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 69bf1aa 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.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/implement/implement_shell_policy.py, src/devops_cli/roadmap/implement/implement_tool_log.py.

  12. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Owner question: Which mode does implement.halt_fixable run in, and who turns it on? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  13. 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.

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

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  15. devops-cli-service commented on Nov 21, 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.

  16. 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.

  17. 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

    priority/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