Skip to content

fix(roadmap): return a stage item to New after three refused plans - #4537

Merged
dan-petty merged 4 commits into
mainfrom
fix/4491-stage-plan-defect-cap
Nov 11, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/4491-stage-plan-defect-cap

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

The stage job took a Ready item again each time the 6-hour wait of plan_defect passed, with no limit, so refused plans held the one model lane.

The job now counts the plan_defect failures of an item on the same body (stage.plan_defects, with the body hash in stage.plan_defects_body). A body edit starts a new count, and a failure of another class keeps the count and its own wait. The failure that reaches CONST_ROADMAP_STAGE_PLAN_DEFECT_LIMIT (3) returns the item to New in the same round, with one comment that lists the problems of the last plan in sequence, and clears the count. The list holds the problem of each refused reply, and then the reason of the failure, such as a stopped plan run, when the checks did not refuse the last reply. Refine reads that comment when it looks at the item again (#3483). A staged item clears the count.

The count keys on the body only: a gate or a stage prompt changed about once each 6 hours, so a key with their version let no looping item reach the limit.

Closes #4491

Change: openspec/changes/archive/2026-11-11-4491-stage-retries-a-refused-plan-with/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 11, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main (base 9087b39 before the rebase): 13 failed on base (13 failed and 0 passed in tests/roadmap/stage/test_roadmap_stage_plan_defect_limit.py; 0 errored). On the branch the 13 tests pass.

Other tests

  • The 689 tests of the files that use StageFailure, StageRecordKey, StageWriter, apply_stage or _run_stage_adapter pass.
  • uv run devops openspec archive validates every spec and change.

Data for the limit and the key

The failures of the 48-hour window of #4491 (2026-11-08T23:45Z to 2026-11-10T23:45Z, 81 plan_defect failures on 44 items), replayed through the rule. The replay keeps each body as it was.

Limit Key Items returned Attempts not made in the window
2 body 23 20
3 body 10 4
4 body 3 1
3 body and prompt version 2 2
3 body and gate version 0 0
  • 8 releases in the window changed a file of STAGE_EVAL_TRIGGER_PATHS or a stage prompt (v0.98.0, v0.100.0, v0.103.0, v0.103.3, v0.106.0, v0.106.1, v0.107.0, v0.107.2). That is about one each 6 hours, the same as the plan_defect wait. So the count keys on the body only.
  • 5 of the 6 plans that staged in the window came after 2 refused plans, and 1 (fix(roadmap): refuse a behavior group that omits a test it changes #3414) after 3. From 2026-11-04, 4 of 39 staged plans came after 3 or more. At the limit, refine looks at such an item once more and the count starts again, so the change delays these items by one refine round and loses none.
  • The window ends before the effect of the change. The saved attempts grow after it: a returned item no longer comes back each 6 hours.

Not done

  • No uv run devops roadmap eval stage --replay: the change touches no gate of check_proposal and no stage prompt.
  • No live step: the change adds two job record keys and no setting, so the live ConfigMap needs no change. The first return of a looping item comes after its third plan_defect failure after the deploy.

@dan-petty
dan-petty force-pushed the fix/4491-stage-plan-defect-cap branch from 0fc1c58 to 61ee056 Compare November 11, 2026 07:44
@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 09:01
@dan-petty

Copy link
Copy Markdown
Owner Author

The first CI run failed tests/roadmap/test_roadmap_limit_classes.py::test_every_numeric_limit_of_the_roadmap_jobs_has_a_class: the new limit CONST_ROADMAP_STAGE_PLAN_DEFECT_LIMIT had no class in the limit registry. Commit 5545fd0 gives it the class kept, as CONST_ROADMAP_REFINE_MAX_TRIES has. On 61ee056, all 29 checks pass and 3 are skipped.

@dan-petty
dan-petty marked this pull request as draft November 11, 2026 10:47
@dan-petty
dan-petty force-pushed the fix/4491-stage-plan-defect-cap branch from 61ee056 to ffe942a Compare November 11, 2026 11:28
@dan-petty

Copy link
Copy Markdown
Owner Author

Review findings: verdict and changes

1. CONFIRMED: the return comment hides the reason of a later stop

Evidence. _Planner._returned (src/devops_cli/roadmap/stage/stage.py) adds each refused reply to self._refused. It raises the gate error only when returns == CONST_ROADMAP_STAGE_GATE_RETURNS. A raise after a refused reply keeps _refused. An example is the RoadmapStageError from stage_toolbox._stopped, for a stopped plan run or a stopped verifier run. So failure.problems was not empty, and failure.problems or (failure.reason or failure.error,) dropped the reason.

The reproduction in the review used Fixes #4. That reply is not a refused reply: _plan_body stops the item at once on a closing keyword (stage_closing), so that run did not get to the second ask. The new round test uses a reply that the paths gate refuses.

Change.

  • _Planner.stopped_by_checks is true only when the checks refused the last reply past its returns. _failure_of copies it to StageFailure.stopped_by_checks.
  • _return_plan_defects lists the problems of the refused replies in sequence, and then the reason of the failure. It leaves out the reason only when the checks refused the last reply, because then the reason only repeats the last problem.
  • stage_returned_plan_defects now starts with "The stage job could not plan this item {count} times on the same body". It no longer says that the checks refused each plan. Before the list it says "These are the problems of the last plan, in sequence. The last problem stopped the plan:".
  • New tests: test_a_round_gives_the_reason_of_a_plan_run_that_stops_after_a_refused_reply (a round where the paths gate refuses a reply and then the plan run stops) and test_a_failure_after_the_refused_replies_gives_its_reason_after_their_problems. On the old PR head (61ee0560) both tests fail: ValueError: not enough values to unpack (expected 2, got 1), and a list with no stop reason. On the new head all 15 tests of the file pass.
  • The archive commit changes the requirement "The limit of refused plans returns the item to New" (now 444 characters) and adds the scenario "A plan run that stops after a refused reply". The archived design.md, proposal.md and tasks.md, docs/roadmap/stage.md, docs/ROADMAP_WORKFLOW.md and the PR body now say the same.

2. CONFIRMED: docs/roadmap/stage.md said "three cases only"

Evidence. Line 85 named three cases: a path that an open item reads, a class field that the body says is absent, and a rejected plan. _return_plan_defects is a fourth path to New.

Change. The sentence now says "four cases only". It adds "the item reached the limit of plan_defect failures on one body (CONST_ROADMAP_STAGE_PLAN_DEFECT_LIMIT, see the paragraph above)".

Checks

  • uv run pytest -q tests/roadmap/stage tests/roadmap/test_roadmap_limit_classes.py tests/lang: 2280 passed, 1 skipped.
  • uv run devops ci fail-to-pass --base 61ee0560 used the merge-base with main as its base, so the result does not isolate this fix. For that reason I ran the new tests on the old PR head in a scratch worktree (results above).
  • uv run devops roadmap eval stage --replay: not run. This change does not change a gate. It changes only the text of the return comment and the data in StageFailure.
  • Live steps: none.

@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 12:09
The stage job took a Ready item again each time the 6-hour wait of plan_defect
passed, with no limit. It now counts the plan_defect failures of an item on the
same body. The third one returns the item to New with one comment that lists
the problems of the refused replies, and refine looks at the item again.
@dan-petty
dan-petty force-pushed the fix/4491-stage-plan-defect-cap branch from ffe942a to 25300d3 Compare November 11, 2026 12:14
@dan-petty
dan-petty merged commit 9c666ea into main Nov 11, 2026
32 checks passed
@dan-petty
dan-petty deleted the fix/4491-stage-plan-defect-cap branch November 11, 2026 12:51
@dan-petty

Copy link
Copy Markdown
Owner Author

Second fix round: verifier findings

This pull request merged at 2026-11-11T12:51:48Z (merge commit 9c666ea) before the second fix round. For this reason I pushed nothing to the branch, and I filed the confirmed finding as an issue.

Finding 1 (minor): the return comment repeats the problem of a degenerate reply - CONFIRMED

_Planner._stop_degenerate in src/devops_cli/roadmap/stage/stage.py adds the degenerate reply with MESSAGES.roadmap.stage_degenerate to self._refused, but it does not set self._stopped_by_checks. Then _return_plan_defects adds failure.reason, which is the same text. Before this pull request, failure.problems or (reason,) gave one bullet. This does not agree with the spec text "unless the checks refused the last reply".

Evidence: in a scratch worktree at origin/main (1936572), I added a round test: _two_items, _fail_to_the_limit(store, 1, less=1), a plan answer of _placeholders() for item 1, and one _run_stage_adapter round. Item 1 went to New, and the comment had two bullets that are the same. The assert len(bullets) == len(set(bullets)) failed with assert 2 == 1. RoadmapStageDegenerateError is a subclass of RoadmapStageError, so the failure is plan_defect and counts toward the limit. I removed the scratch test after the run.

Filed: #4618. Proposed fix: set self._stopped_by_checks = True in _stop_degenerate before the raise, and add the round test above as the fail-to-pass test. The spec text needs no change.

What I changed

Nothing on this branch. The fix goes through #4618.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): stage retries a refused plan with no cap

1 participant