Repository navigation
Description
Problem or Motivation
Some gate problems have one right edit that needs no model. The dependencies gate names the other open plan item whose files overlap: about 10 refusals in 7 days, 3 of 3 sampled were deterministic, and the model did not fix them in its one return. The module-test gate names a module whose known test is not in the reads; a criterion text or a registry task can be missing. Each one spends a return of about 0.31M prompt tokens or fails the item.
Proposed Solution & Architectural Design
Before a return, apply the mechanical findings (#4846 codes) as a rewrite in the style of plan_rewrite.py: add the named item to the dependencies, add the known test of the module to the reads, copy the criterion text, add the registry task. Gate the rewritten plan again; a rewrite costs no return. The refused file names each edit. Citation re-anchoring stays with #4479.
Target Subsystem
SDLC, Git & PR Governance (roadmap stage gates).
Existing Tool Considered
The rewrite pattern of plan_rewrite.py; no model call. Cost to build: about 0.6M tokens, half a day.
Acceptance Criteria
- On the saved refused records, every dependencies and registry finding, and each module-test finding that names an existing test, passes with no model request.
- A test: no rewrite changes text outside its finding.
devops_cli_roadmap_fix_checks_total{site="stage.gate",path="mechanical"}counts each rewrite.
Dependencies
Source: #4843
Alternatives check of 2026-11-14: none.
Tool: none found.
Proposed design
Problem statement
Some stage gate refusals have one right edit. The dependencies gate names the item to add, the module and perimeter test gates name the test to add, and a criterion or registry finding names the text or declared path to add. The job sends these refusals to the model, and each return costs about 0.31M prompt tokens or fails the item. This change applies these edits as a rewrite of the plan reply with no model call and gates the plan again. Citation re-anchoring stays with #4479.
Acceptance criteria
Requirement: Mechanical edits before the model
The stage job SHALL apply every mechanical finding of a refused reply before it sends the remaining findings of that reply to the model.
Scenario: One mechanical and one model finding
- WHEN A refused reply holds a dependencies finding and a finding that needs the model
- THEN The dependencies edit is applied, the gate runs again, and the model receives only the findings that remain.
Requirement: Dependencies rewrite
The stage gate SHALL add the item that a dependencies finding names to the plan's dependencies before it calls the model.
Scenario: Dependencies finding on a saved record
- WHEN A saved refused record holds a dependencies finding that names one open item
- THEN The rewritten plan lists that item under Dependencies and the gate passes with no model request.
Requirement: Perimeter test in the manifest group
The rewrite SHALL add the named perimeter test path to the Changes: line of the group that changes the manifest.
Scenario: Missing perimeter test
- WHEN A refused record holds
stage_problem_missing_perimeter_testfor a test file that exists - THEN The
Changes:line of that group names the test path and the gate passes with no model request.
Requirement: Module test in the reads
The rewrite SHALL add the known test of a module to the reads of the plan when a module-test finding names it.
Scenario: Missing module test
- WHEN A refused record holds
stage_problem_missing_module_testfor a test file that exists - THEN The reads list that test path and the gate passes with no model request.
Requirement: Criterion text copy
The rewrite SHALL copy the criterion text that a finding names into the plan.
Scenario: Missing criterion text
- WHEN A refused record holds a finding for a criterion with no text
- THEN The plan holds the criterion text and the gate passes with no model request.
Requirement: Registry task add
The rewrite SHALL add the registry task that a finding names to the plan.
Scenario: Missing registry task
- WHEN A refused record holds a finding for a registry task that the plan lacks
- THEN The plan lists the registry task and the gate passes with no model request.
Requirement: Rewrite pass bound
The stage job SHALL run at most two rewrite passes on one refused reply before it calls the model.
Scenario: A rewrite exposes a second finding
- WHEN The first rewrite pass leaves a mechanical finding that its edit exposed
- THEN The second pass applies that edit and the gate runs again, and no third pass runs.
Requirement: No edit outside the finding
A rewrite MUST change no text outside the lines that its finding names.
Scenario: Diff of one rewrite
- WHEN The rewrite applies one finding to a saved plan
- THEN The diff touches only the line or lines of that finding.
Requirement: Skip a finding with no target
The rewrite MUST leave the plan unchanged when the named test, item or task is absent from the repository.
Scenario: Module test that does not exist
- WHEN A module-test finding names a test file that the repository does not hold
- THEN The plan text is unchanged and the gate returns the finding to the model.
Requirement: Rewrite metric and log
The rewrite SHALL write one log line for each applied edit and increment devops_cli_roadmap_fix_checks_total with site="stage.gate" and path="mechanical".
Scenario: One applied rewrite
- WHEN The gate applies one mechanical rewrite
- THEN The counter increases by one and the log holds one line that names the code and the edited path.
Requirement: Idempotent rewrite
A second rewrite of an already rewritten plan SHALL make no change.
Scenario: Second pass on the rewritten plan
- WHEN The rewrite runs again on its own output
- THEN The plan text is identical and the counter does not increase.
Existing Tool Considered
No open, maintained tool covers the need. The alternatives check of 2026-11-14 found no open, maintained tool that reads the stage gate codes, adds a named item to the plan's dependencies, adds a test to the Changes: line or to the reads, copies criterion text, adds a registry task, or re-runs the gate. The work belongs in the project's code. The body gives the written cost: about 0.6M tokens and half a day to build, keep and fix it.
Key questions
- Which finding codes does the mechanical rewrite handle?: The three codes that
stage_findings.pyalready classes as mechanical (stage_problem_dependencies,stage_problem_missing_module_test,stage_problem_missing_perimeter_test), plusstage_problem_criterionandstage_problem_registry, whose messages name the exact text or declared path to add. The change adds the last two codes to_MECHANICALand sets their class instage_finding_classes.jsontomechanical. (best practice) [sources: src/devops_cli/roadmap/stage/stage_findings.py:88, src/devops_cli/lang/en/messages.py:4953, src/devops_cli/lang/en/messages.py:5096, src/devops_cli/roadmap/stage/stage_finding_classes.json:100, docs/adr/0005-review-findings-come-from-tools-not-models.md]- Rejected: The codes that
_MECHANICALlists today. It leaves out the criterion and registry findings that the body names and whose messages give the one edit. - Chosen: The body's codes plus the perimeter test code. It covers the criterion, registry, dependencies and module-test findings, and the perimeter test that was 36 of 104 gate codes in 3 days.
- Rejected: Every gate code. A code such as
plan_defecthas no one right edit, so the model must read it.
- Rejected: The codes that
- Where in the stage step does the rewrite run?: In
_returned, after_settlereturns a_Refusedand before_ask_plansends the reply to the model. The rewrite edits theStageProposal,_settlejudges it again, and only the findings that remain go back to the model. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py:1707, src/devops_cli/roadmap/stage/stage.py:1710, src/devops_cli/roadmap/stage/stage.py:1749, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]- Chosen: In the stage step, before the model call. It uses the gate result that the step already holds and spends no return.
- Rejected: As instructions in the model prompt. It spends the return that this change removes.
- Rejected: As a separate job. It adds a pod and a round trip for work that takes no model call.
- What does the job do when the gate reports a mechanical finding and a model finding together?: It applies the mechanical edits, gates the rewritten proposal again, and sends only the findings that remain to the model. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py:1710, src/devops_cli/roadmap/stage/stage.py:1749, src/devops_cli/roadmap/stage/stage_findings.py:88]
- Chosen: Apply the mechanical edits, then re-gate. The model then reads a shorter list and spends less on the same return.
- Rejected: Send all findings to the model. It spends a return on edits that need no model.
- Rejected: Skip the mechanical edits when a model finding is present. The mechanical finding stays and the gate refuses the plan again.
- How many rewrite passes run before the model gets the plan?: Two passes at most. One pass applies every mechanical finding. A second pass handles a finding that the first edit exposes. Then the gate result goes to the model. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py:1707, src/devops_cli/roadmap/stage/stage.py:1729, src/devops_cli/roadmap/stage/stage.py:1746]
- Rejected: One pass. A dependencies edit can expose a second finding, which then spends a return.
- Chosen: Two passes. It covers a finding that the first edit exposes and cannot loop.
- Rejected: Repeat until no finding remains. A defect in the rewrite can loop with no bound.
- What does the rewrite do when the named test or task is absent?: It leaves the plan unchanged for that finding and lets the gate return the finding to the model. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py:638, src/devops_cli/roadmap/stage/stage_paths.py:457, src/devops_cli/roadmap/stage/stage.py:1749]
- Rejected: Write a stub test. The plan would name a test that no one wrote.
- Chosen: Skip the finding. The plan keeps its text and the model reads the finding as before.
- Rejected: Fail the item. The item can still pass when the model fixes the plan.
- Which metric counts a mechanical rewrite?: The body's
devops_cli_roadmap_fix_checks_totalwithsite="stage.gate"andpath="mechanical". No counter of that name exists ininstruments.pytoday, so the change adds it as a new counter and increments it once for each applied rewrite. (best practice) [sources: src/devops_cli/telemetry/instruments.py:642, src/devops_cli/telemetry/instruments.py:652, src/devops_cli/roadmap/stage/stage.py:1778]- Chosen: Add the body's counter as a new instrument. The body's acceptance criterion names it, and no counter of that name exists, so it is one new series.
- Rejected: Reuse
devops_cli_roadmap_stage_gate_problems. That histogram counts findings in a reply, not the rewrites that remove them. - Rejected: Add a new stage-named counter. It would contradict the metric that the body's acceptance criterion names.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.Saves roughly 3M tokens per week and prevents item failures, but no data loss or security risk.Prevents about 10 failed or costly model returns per week.Body states about half a day of work.Both reduce wasted model returns on stage gate refusals, but #4348 retries the model while the candidate fixes the plan mechanically before the model is called.devops-cli-service commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.The change saves model tokens and prevents item failures, but it is not critical.It prevents repeated gate failures and saves about 0.31M prompt tokens for each refusal.The author estimates about half a day and 0.6M tokens to build and test the rewrite.Both items concern stage gate findings. #4846 records each finding with a code. The candidate rewrites the plan from those codes.dan-petty commentedon Nov 13, 2026
New evidence of 2026-11-13 (review of failing jobs). The perimeter-test finding is now the largest single class of stage gate codes, so this item has a larger effect than its body states.
stage_problem_missing_perimeter_test36 andstage_problem_missing_module_test1 of 104 logged gate codes, in 4 or more items. One reply got 22 findings of this class.stage reply refusedlines over 40 items, with a median of 39 tool calls for each reply.plan_defect7).stage_findings.py(lines 84-94) already classes both codes as mechanical. The job still sends them to the model as text (messages.py, near lines 4832-4836;stage_paths.py, near lines 457-470).Scope point: add
stage_problem_missing_perimeter_testto the rewrite list in the body. The rewrite adds the named test path to theChanges:line of the group that changes the manifest, logs the edit, and runs the gate again, with no model call. Each such rewrite saves one plan round of about 38 tool calls.Measure:
stage_problem_missing_perimeter_testfindings that go back to the model go to 0, refusal rounds per stage item go down, and the stage success ratio goes up (7 days after the release).devops-cli-service commentedon Nov 14, 2026
Alternatives check: none
Reason: Eight web searches for an open, maintained tool that turns stage-gate finding codes into deterministic plan edits returned only unrelated documentation pages, no matching project or library. The needed mapping — add the overlapping item to the dependencies, add the module/perimeter test to the reads, copy the criterion text, add the registry task, re-gate, and count the rewrite — is specific to this repository's plan format and its own
plan_rewrite.py, so no external tool covers it and the work belongs in the project's code.Tool: none found
Lacks:
Changes:/dependencies or a test path to the readsdevops_cli_roadmap_fix_checks_totalSearches run:
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
1 remaining item
devops-cli-service commentedon Nov 15, 2026
Status set to Ready at ca62d6a (see proposed design in issue body).
feat(roadmap): fix mechanical stage gate problems with no model call (#…
feat(roadmap): fix mechanical stage gate problems with no model call (#…
feat(roadmap): fix mechanical stage gate problems with no model call (#…
feat(roadmap): fix mechanical stage gate problems with no model call (#…
devops-cli-service commentedon Nov 16, 2026
Released in v0.160.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.160.0
devops-cli-service commentedon Nov 16, 2026
Live since 2026-11-16 03:02 UTC