Skip to content

fix(roadmap): a rejected plan keeps the implement record of its item #5251

Done

Description

@dan-petty

Problem Description

A person closes a plan pull request with no merge after the implement job worked on it. The implement record of the item stays: implement.job, implement.stopped, implement.failure, implement.branch and implement.pr. No path that sends the item back for a new plan clears these keys:

  • The implement: retry clear removes only implement.stopped, implement.failure and implement.check (src/devops_cli/roadmap/stop_clear.py:314-329, _marks).
  • devops roadmap return writes only the Status (src/devops_cli/roadmap/return_item.py:62-68).
  • The stage job's rejection clears only the stage keys (src/devops_cli/roadmap/stage/stage.py:2998-3011, _reject_plan).

Only the implement job's own return clears the run keys (src/devops_cli/roadmap/implement/implement_run.py:860-880, _return_to_new).

The kept keys stop the new plan in three places:

  1. implement.job stays, so stage_ready (src/devops_cli/roadmap/stage/stage_ready.py:95) and fix-plan (src/devops_cli/roadmap/steps/fix_plan.py:300) leave out the new draft. A new draft with plan/needs-fix waits for a person.
  2. implement.branch and implement.pr stay, and recorded_branch reads that pair before the stage pair (src/devops_cli/roadmap/implement/implement.py:237-248). While no plan is on the default branch, _route returns it, and _pull_reason finds the closed pull request (implement.py:474-484). The implement job leaves out the new draft.
  3. After devops roadmap return, implement.stopped stays. When refine sets the item Ready, the status sweep derives Blocked from the stop (src/devops_cli/roadmap/status_sync.py:191-198 facts_of, called by sync_statuses). A stop of class types or plan_defect has no automatic clear rule, so the item waits for an implement: retry before the stage job can plan it again.

Reproduction Steps

  1. Item refactor(ai): rank the benchmark with numpy and pytrec-eval #1928: the implement job stopped on plan PR docs(openspec): plan #1928 Rank the embedding benchmark with numpy #5140 (class types). On 2026-11-12 a person closed docs(openspec): plan #1928 Rank the embedding benchmark with numpy #5140 with no merge and commented implement: retry. The record still holds implement.job devops-cli-runner-20261112-163430-77e5, implement.branch refactor/1928-rank-the-benchmark-with-numpy-and and implement.pr 5140.
  2. Item test(warnings): Turn all warnings into errors with reasoned exceptions #1878: the implement job stopped on plan PR docs(openspec): plan #1878 Fail tests on warnings and mark ty advisory #5105 (class plan_defect, stop group 1). A person closed docs(openspec): plan #1878 Fail tests on warnings and mark ty advisory #5105 and ran devops roadmap return 1878. The record still holds implement.stopped, implement.job and implement.pr 5105.
  3. Read stop_clear._marks, return_item.apply_return and stage._reject_plan on main: none of them writes an ImplementRecordKey other than the three of the retry clear.

Expected vs Actual Behavior

Expected: when the stage job records a rejected plan, it clears the implement keys of the run on that plan, as _return_to_new does. The new draft then flows: stage_ready and fix-plan read it, the implement job takes it, and the status sweep does not set Blocked again.

Actual: the new draft of #1928 will be left out by implement (it reads closed #5140), and #1878 will go back to Blocked after refine sets it Ready.

Environment Diagnostics

Main at 0a14161 (release 0.123.0).

Logs, Traces, or Terminal Output

Source: the plan PR backlog triage of 2026-11-12 (rule 11 finding 1), extended with the return and route evidence above.

Source: #5140

Alternatives check of 2026-11-22: none.
Tool: none found.
Reason: Searches for tooling that clears stale per-item job state on a closed, unmerged plan pull request found only unrelated pages (workflow engines, stale-element docs, issue triage guides); no external tool manages this repository's implement record keys.

Lacks:

  • Clearing implement.job, implement.stopped, implement.failure, implement.branch and implement.pr on a rejected plan
  • Clearing the same run keys from devops roadmap return
  • Reading only a live implement Job in stage_ready and fix_plan
  • Status sweep not deriving Blocked from a cleared implement stop

Proposed design

Problem statement

A person closes a plan pull request with no merge after the implement job ran. The stage job records the rejection but leaves implement.job, implement.stopped, implement.failure, implement.branch and implement.pr. The stale keys hide the new plan, route the implement job to the closed pull request, and derive Blocked. The fix clears the run keys on the stage rejection and on devops roadmap return. It also makes stage_ready and fix_plan read only a live implement Job.

Acceptance criteria

Requirement: Rejected plan clears implement run keys

The stage job SHALL clear the implement run keys of an item when it records a rejected plan.

Scenario: Rejected plan clears the implement record

  • WHEN the stage job records a closed plan pull request as rejected for an item that holds implement.job, implement.stopped, implement.failure, implement.branch and implement.pr
  • THEN the item's job record holds no implement.job, implement.stopped, implement.failure, implement.branch or implement.pr

Requirement: Manual return clears implement run keys

devops roadmap return SHALL clear the implement run keys when it returns an item to New.

Scenario: Manual return clears the implement record

  • WHEN an item holds implement.job, implement.stopped, implement.failure, implement.branch and implement.pr, and a person runs devops roadmap return with an evidence comment
  • THEN the item's job record holds no implement.job, implement.stopped, implement.failure, implement.branch or implement.pr

Requirement: Status sweep does not derive Blocked after rejection

The status sweep SHALL NOT derive Blocked from an implement stop after a rejected-plan clear.

Scenario: Ready after rejected plan

  • WHEN the stage job records a rejected plan for an item, and refine sets the item Ready
  • THEN sync_statuses derives Ready from the cleared implement.stopped

Requirement: Implement job does not route to the closed plan

The implement job SHALL NOT route to the closed plan pull request after the stage job records it as rejected.

Scenario: No branch from the closed plan

  • WHEN the stage job records a closed plan pull request as rejected for an item that holds implement.branch and implement.pr
  • THEN recorded_branch returns no branch from those cleared keys

Requirement: Stage ready reads only a live implement Job

stage_ready SHALL use job_holds to decide whether a live implement Job holds an item.

Scenario: Finished Job does not hide a new draft

  • WHEN an item has implement.job set and implement.job_state set to a finished value, and a new plan draft exists
  • THEN stage_ready does not skip the new plan draft because of the finished Job

Requirement: Fix-plan reads only a live implement Job

fix_plan SHALL use job_holds to decide whether a live implement Job holds an item.

Scenario: Finished Job does not hide a fix plan

  • WHEN an item has implement.job set and implement.job_state set to a finished value, and a plan draft needs a fix
  • THEN fix_plan does not skip the plan draft because of the finished Job

Existing Tool Considered

No open, maintained tool covers this need. The alternatives check of 2026-11-16 found none. actions/stale and the Temporal cancellation documentation do not manage this repository's implement record keys. The change builds its own code: a small edit to the clear path and two readers, about 5,000 tokens and under one hour to keep and fix.

Key questions

  • Which paths that send an item back to New must clear the implement run keys?: The stage job's rejected-plan record and devops roadmap return must clear the run keys. The implement: retry clear stays as it is. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/return_item.py, src/devops_cli/roadmap/stop_clear.py]
    • Rejected: Clear in the stage job only. test(warnings): Turn all warnings into errors with reasoned exceptions #1878 uses devops roadmap return and would stay Blocked.
    • Chosen: Clear in the stage job and devops roadmap return. Both paths send the item back for a new plan, and both leave the stale keys.
    • Rejected: Also clear in implement: retry. A retry continues the implement job and needs its branch and pull request record.
  • Which implement record keys does the clear remove?: The clear removes the run keys that _return_to_new clears: implement.job, implement.stopped, implement.failure, implement.branch and implement.pr. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/roadmap/implement/implement.py, src/devops_cli/roadmap/stores/store.py]
    • Rejected: Clear only implement.stopped and implement.failure. implement.branch and implement.pr still route the implement job to the closed plan.
    • Chosen: Clear the run keys that _return_to_new clears. This removes the job, stop, branch and pull request that block the new plan.
    • Rejected: Clear every implement key. This erases digest, continuation and kept-work records that are not part of the run.
  • Where should the shared run-key clear live?: In src/devops_cli/roadmap/implement/record_clear.py, as a small function that returns the run-key marks. implement_run.py, stage.py and return_item.py import it. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/return_item.py, src/devops_cli/roadmap/stores/store.py]
    • Rejected: Duplicate the marks in each caller. The three paths would drift.
    • Rejected: Import _return_to_new from implement_run.py. The private run function carries more than the marks and can create an import cycle.
    • Chosen: Add a small helper module. Each caller imports the same marks with no cycle.
  • Should stage_ready and fix_plan read job_holds instead of the bare implement.job?: Yes. stage_ready._recorded_pull and fix_plan._record_reason must call job_holds, the live-Job predicate that fix-checks already uses. (best practice) [sources: src/devops_cli/roadmap/status_sync.py, src/devops_cli/roadmap/steps/fix_plan.py, src/devops_cli/roadmap/stage/stage_ready.py]
    • Rejected: Keep the bare implement.job read. A finished Job keeps the key and hides a new draft.
    • Chosen: Read job_holds. This checks the live Job state and ignores a finished Job.
  • Should the rejected-plan clear use the same Status write as the return to New?: Yes. The clear passes the run-key marks to the one Status write that returns the item to New. (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/status_sync.py, src/devops_cli/roadmap/return_item.py]
    • Rejected: Write the clear before the Status write. A failed Status write leaves the record and the Status apart.
    • Chosen: Pass the marks to the Status write. One write changes the record and the Status together.

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/medium
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor

    A note from #5983 (PR #5986): the step fix-checks now leaves out an item that a live implement Job holds. It reads job_holds (src/devops_cli/roadmap/status_sync.py:170: implement.job set and implement.job_state empty), not the bare implement.job. The bare key stays after the Job ends, so it would stop fix-checks on every implement draft.

    fix_plan._record_reason (src/devops_cli/roadmap/steps/fix_plan.py:532) and stage_ready._recorded_pull (src/devops_cli/roadmap/stage/stage_ready.py:99) still read the bare key. Point 1 of this issue also goes away if those two read job_holds, independent of the clear of the record.

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

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The need is a fix inside this project's own roadmap module: clear the stale implement record keys (implement.job, implement.stopped, implement.failure, implement.branch, implement.pr) when the stage job records a rejected plan, reusing the clearing that _return_to_new already performs. Searches surfaced only generic stale-issue/PR automation (e.g. actions/stale), workflow cancellation/reset docs and state-machine glossaries; none of these is a library that manages this repository's own implement record keys or the GitHub-label record of ADR 0016, so no external tool covers the need.

    Tool: none found

    Lacks:

    • Clearing the project's implement record keys (implement.job, implement.stopped, implement.failure, implement.branch, implement.pr) when a plan pull request is closed without merge
    • Making stage_ready and fix-plan read the new draft after a rejected plan
    • Preventing the status sweep from deriving Blocked from a stale implement.stopped

    Searches run:

    • library to reset workflow item state after cancelled run python, results: 5
    • clear stale implement record keys when a plan pull request is rejected without merge, results: 5
    • tool to reconcile and prune stale workflow state records idempotent, results: 5
    • python state machine library cleanup stale attributes on transition rejection, results: 5

    Sources:

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

  6. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  7. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 1812dd2 (see proposed design in issue body).

  8. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 25, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 25, 2026
  10. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 08:43 UTC

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