Skip to content

fix(roadmap): implement must not take unmerged stage plan PR #4078

Closed as not planned

Description

@dan-petty

Problem Description

The service implement job takes a staged item before a person reviews and merges the plan pull request.
Row stage opens a draft plan pull request and sets stage.pr on the item.
Row implement checks _takeable_status, which accepts status/ready.
_Judge._route reads recorded_branch, which returns stage.branch and stage.pr.
_pull_reason accepts any open draft pull request.
The service then creates a runner Job that implements the staged branch before human approval.
This run sets implement.pr to the plan pull request number.
kind_of in implement_pull.py then treats the plan pull request as an implementation pull request.
The merge readiness check then refuses the draft because tasks in tasks.md are not ticked.

Reproduction Steps

  1. Run row stage on a ready roadmap item.
  2. Confirm that row stage opens a draft plan pull request such as PR docs(openspec): plan #3391 Refuse criteria entries not in the issue body #4069.
  3. Run row implement while the plan pull request is an unmerged draft.
  4. Inspect the created jobs and issue record.

Expected vs Actual Behavior

Expected: Row implement takes only Planned items with changes on the default branch, or retried implementation branches.
Actual: Row implement launches a runner Job for unmerged draft plan pull requests and marks the item In Progress.

Environment Diagnostics

  • DevOps CLI Version: 0.83.2
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64
  • Execution Environment: Roadmap Service / Kubernetes

Logs, Traces, or Terminal Output

implement.job: devops-cli-runner-20261107-201633-cba7
implement.pr: 4069
stage.pr: 4069
PR #4069 is not ready: Task group 1 has a task that is not ticked.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The implement row takes a Staged item before a person merges its plan pull request. The row starts a runner Job on the staged branch. The Job writes the plan pull request number into implement.pr. The draft readiness check then reads the plan as an implementation pull request. The row must take only a Planned item, or the implementation branch of a retried Job.

Acceptance criteria

Requirement: Unmerged plan is not takeable

The implement row SHALL refuse an item whose OpenSpec change folder is not on the default branch.

Scenario: Staged item with an open plan draft

  • WHEN the item has Status Ready and its record holds stage.branch and stage.pr for an open draft plan pull request
  • THEN the row takes no item and reports a reason that names the plan pull request that a person has not merged

Requirement: Refused item keeps its status

The row SHALL leave the Status label and the record of an item that it refuses unchanged.

Scenario: Refused staged item

  • WHEN the row refuses a Staged item with an open plan draft
  • THEN the item keeps Status Ready and its record gains no implement.job, implement.branch or implement.pr

Requirement: Planned item is takeable

The implement row SHALL take an item with Status Planned and no branch on origin.

Scenario: Planned item with no branch

  • WHEN the item has Status Planned, its change folder is on the default branch and origin holds no branch for it
  • THEN the row takes the item on a new branch <type>/<issue>-<slug> at the default branch and with no recorded pull request

Requirement: Retried implementation branch is takeable

The implement row MUST continue the implementation branch of a stopped item after a person comments implement: retry.

Scenario: Retry of a stopped implement job

  • WHEN the item holds implement.branch and implement.pr and its record has no implement.stopped
  • THEN the row takes the recorded implementation branch and pull request and makes no new branch

Requirement: Record reads the implementation branch only

recorded_branch SHALL read implement.branch and implement.pr only.

Scenario: Item with a staged plan and no implementation run

  • WHEN the item holds stage.branch and stage.pr and no implement.branch
  • THEN recorded_branch returns None

Existing Tool Considered

No check has run. No open, maintained tool or library covers this need: the change corrects the route predicate of the project itself. The written cost is about 40 changed lines in src/devops_cli/roadmap/implement/implement.py, about 15k tokens to write them, about 10k tokens to keep and fix them until the new tests pass, and about 3 hours of elapsed time.

Key questions

  • Which condition must stop the implement row from taking an item whose plan is not merged?: The row takes an item only when its Status is Planned, or when its record holds implement.branch with no stop. The change removes stage.branch and stage.pr from recorded_branch. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/implement/implement.py:259, src/devops_cli/roadmap/implement/implement.py:223, openspec/changes/archive/2026-10-31-2865-service-marks-stage-pr-ready/proposal.md:44]
    • Chosen: Require Status Planned, or a recorded implementation branch. The Status label records that a person merged the plan, and the record holds the branch of a retry.
    • Rejected: Refuse only a draft plan pull request in _pull_reason. The record still routes on stage.branch, and the stage_ready row marks the plan ready, so the refusal misses that case.
    • Rejected: Read the default branch for the change folder at route time. An extra GitHub read for each item costs rate limit, and the Status label already holds the answer.
  • Must the implement row keep taking a Staged item whose plan draft pull request is open?: No. A Staged item waits for a person to merge the plan. The row takes it only after the merge, when its Status is Planned. (best practice) [sources: CONTEXT.md, openspec/changes/archive/2026-10-31-2865-service-marks-stage-pr-ready/proposal.md:44]
  • How does the row recognize the implementation branch of a retried Job?: From the record: implement.branch and implement.pr with no implement.stopped. A person's implement: retry clears the stop, and the branch stays on origin. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/implement/implement.py:223]
    • Chosen: The record holds implement.branch and no implement.stopped. The retry clears the stop, and the branch on origin holds the work that the Job kept.
    • Rejected: The Status is In Progress. The Service sets In Progress only when it creates the Job, so a retried item is not yet In Progress.
    • Rejected: The Status is Blocked. A Blocked item is not started, and the retry clears the stop before the row runs.
  • Must kind_of treat a pull request that the record holds in both stage.pr and implement.pr as a plan?: No. The gate stops the wrong record, so no new item holds the plan number in implement.pr. A tie-break would hide the defect. (best practice) [sources: src/devops_cli/roadmap/implement/implement_pull.py, openspec/changes/archive/2026-11-03-2916-one-function-decides-when-any-draft/tasks.md]
    • Chosen: Add no tie-break. The gate prevents the wrong record, and a tie-break hides a defect that the row must not make.
    • Rejected: Tie-break to the stage plan. It repairs one record and adds a rule that no other case needs.
  • Which tests cover the implement route?: tests/roadmap/implement/test_roadmap_implement_plan_reason.py holds the tests of the route reason. tests/roadmap/implement/test_roadmap_implement_planned.py and tests/roadmap/implement/test_roadmap_implement_job.py hold the tests of the row and the Job. [sources: tests/roadmap/implement/test_roadmap_implement_plan_reason.py, tests/roadmap/implement/test_roadmap_implement_planned.py, tests/roadmap/implement/test_roadmap_implement_job.py, tests/core/test_roadmap_implement_planned_run.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-10: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The bug launches unapproved runner Jobs and corrupts item state, but does not cause data loss or a security breach.
    • Value: Medium. It stops wasted compute and incorrect workflow state on unapproved items.
    • Effort: Low. The fix is a condition check in the implement job selection logic to exclude unmerged draft stage plan PRs.
    • Possible duplicate: fix(roadmap): leave out items with unmerged stage plan PRs #4041, which may ask for the same change. The model names Prevent the implement job from selecting items whose stage plan pull request is still an unmerged draft as the change that both ask for. Both items ask the implement job to skip items with unmerged draft stage plan PRs, delivering the same selection filter. A person closes one of the two if that is so.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 8, 2026
  5. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

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

  6. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: One search for a tool that gates work on a merged plan pull request found nothing relevant. The issue is a bug in the project's own route predicate (recorded_branch and _takeable_status in the implement row). It is not a need that an outside tool or library can cover.

    Tool: none found

    Lacks:

    • No outside tool knows this project's Status labels, its stage.* and implement.* record fields, or its implement row logic.

    Searches run:

    • CI job gate: skip work item until plan pull request merged, status label workflow automation, results: 5

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

  7. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Service data, 48 hours to 2026-11-10T23:45Z: implement took drafts with plan/needs-fix

    Count: 2 runner Jobs started on a draft plan pull request that already had the label plan/needs-fix. 8 runner Jobs ran in the window.

    Job Item Plan PR Label added Job ran (UTC, 2026-11-10) Result
    b626 #3443 #4352 10:51:32Z 10:57:29 to 11:16:45 (19.3 min) stopped in group 1 on limit_reached, 8,050,668 input tokens, work discarded, item status/blocked
    c187 #3451 #4353 11:40:27Z 11:47:47 to 12:10:39 (22.9 min) stopped in group 2 on limit_reached, 3,630,613 + 8,103,317 input tokens; a person added a style commit and the archive commit, and the bot commits shipped in #4353

    First and last: 10:57:29Z and 11:47:42Z on 2026-11-10. Still occurring: no take of a labelled draft after 11:47Z. The last 6 hours of the window had 1 Job (#3429, a Planned item). No open pull request carries plan/needs-fix now. The cause is not fixed: no commit changes implement.py or implement_pull.py after aec8ef5 (#4196).

    Cost: 42.2 Job minutes, about 19.8M input tokens, and person work on #4352 (3 plan commits). The evidence does not prove that the plan defect caused the limit_reached stops; the step budget unit is a separate cause (#4387).

    Root cause: _Judge._pull_reason (src/devops_cli/roadmap/implement/implement.py:434) accepts every open draft (PullStatus.is_open_draft, src/devops_cli/github/client.py:108). _takeable_status (implement.py:259) accepts Ready and Planned items. The Service row uses the same judge through plan_implement (implement_submit.py:459). Only stage_ready.py:141 reads plan/needs-fix. Nothing under src/devops_cli/roadmap/implement/ reads the label or the review state of the plan. The label keeps a defective plan a draft, and stage_ready marks a green plan with no finding ready, after which implement refuses it as "not an open draft". So implement takes exactly the plans that the model review refused.

    Notes for the fix:

    Priority: P2 fits the evidence.

    Queries:

    Loki: {namespace="devops", container="service"} |~ "devops-cli-runner-2026"   (2026-11-08T23:45Z to 2026-11-10T23:45Z)
    Loki: runner logs |~ "^- #[0-9]{4} "   (the item of each Job)
    GitHub: issue timelines of #4352 and #4353 (label events); search "plan/needs-fix" in:comments
    git grep -n needs-fix -- src/
    
  8. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    The owner approved the roadmap pipeline split on 2026-11-13 (tracker #5482). Decision D3 replaces the expected behavior of this item. One Staged rule applies to each item by the effort pass (roadmap.implement.effort):

    • When implement takes the item, tests and implement continue on the plan branch, and watch never marks that plan PR ready.
    • Otherwise, watch marks the plan PR ready, and delivery starts at Planned on a new branch.

    #5505 builds this rule and a test that due_jobs never gives both paths for one head. I close this item as not planned, because #5505 replaces it. Reopen it if #5505 does not cover the case of PR #4069.

  9. removed
    status/ready
    on Nov 13, 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/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions