Skip to content

feat(roadmap): detect drift against default branch on open plan PRs #3968

Description

@dan-petty

Problem

The Service opens a draft pull request for each staged roadmap item. The stage_ready row marks the pull request ready when all CI checks pass.

When subsequent changes merge into the default branch, the open plan pull request can become invalid. For example, moving modules to subpackages or adding verification command syntax requirements invalidates older plans. GitHub does not re-run CI checks automatically without new pushes. The Service does not detect this drift against the default branch. The pull request stays open until an engineer discovers the failure during review or implementation.

Proposed change

Add automated plan drift detection for open plan pull requests to the Service.

The Service evaluates open plan pull requests against the current default branch:

  1. Identify open plan pull requests whose target branch is the default branch.
  2. Run plan-check against the head commit of the default branch.
  3. If plan-check reports problems, add the label plan/needs-fix to the pull request.
  4. Post a comment on the pull request that lists each detected problem.

Acceptance criteria

  1. A function evaluates whether open plan pull requests satisfy plan-check against the default branch.
  2. When an open plan pull request fails the check, the pull request receives the label plan/needs-fix.
  3. A comment is posted to the pull request that details each reported problem.
  4. When a previously failing plan pull request is updated and passes, remove the plan/needs-fix label.
  5. Unit tests cover drift detection, labeling, and comment generation.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

No open tool validates OpenSpec proposals against custom repository stage gates. Building this feature requires approximately 25,000 tokens to implement and 5,000 tokens annually to maintain. Elapsed time is approximately 3 hours.

Proposed design

Problem statement

Open plan pull requests can become invalid when the default branch changes. The Service does not detect this drift, so a stale plan stays open until an engineer finds the failure. This change makes the Service check open plan pull requests against the default branch, label failures plan/needs-fix, and comment each problem.

Acceptance criteria

Requirement: Detect drift on open plan pull requests

The Service SHALL evaluate each open plan pull request against the head commit of the default branch.

Scenario: A stale plan cites a moved path

  • WHEN An open plan pull request cites a path that the default branch head does not hold.
  • THEN The drift check reports a problem for that path.

Requirement: Recognize a plan pull request

The Service SHALL treat an open pull request whose base is the default branch and whose title or body has the plan form as a plan pull request.

Scenario: A delivery is not a plan

  • WHEN An open pull request into the default branch holds the title and body of a delivery.
  • THEN The drift check reports no problem for it.

Requirement: Run the drift row in the status lane

The status lane SHALL run a plan_drift row before the stage_ready row on each round.

Scenario: A status-lane round starts

  • WHEN A status-lane round starts for a repository.
  • THEN The round runs plan_drift before stage_ready.

Requirement: Keep the drift check model-free

The plan_drift row MUST run without a model call.

Scenario: The drift row runs

  • WHEN The plan_drift row runs on a status-lane round.
  • THEN The row makes no model call.

Requirement: Label a failing plan pull request

The Service SHALL add the label plan/needs-fix to a plan pull request when the drift check reports at least one problem.

Scenario: The drift check reports a problem

  • WHEN The drift check returns one or more problems for an open plan pull request.
  • THEN The pull request has the label plan/needs-fix.

Requirement: Comment each detected problem

The Service SHALL post a comment on a failing plan pull request that lists each problem the drift check reports.

Scenario: The drift check reports two problems

  • WHEN The drift check returns two problems for an open plan pull request.
  • THEN The comment contains the message of each problem.

Requirement: Keep one drift comment

The Service SHALL keep one drift comment per pull request and update it when the problem list changes.

Scenario: The problem list changes

  • WHEN A plan pull request already has a drift comment and a later drift check reports a different problem list.
  • THEN The Service updates the existing drift comment and creates no second drift comment.

Requirement: Remove the label after a passing check

The Service SHALL remove the label plan/needs-fix from a plan pull request when a later drift check reports no problem.

Scenario: A previously failing plan passes

  • WHEN A plan pull request has the label plan/needs-fix and a later drift check reports no problem.
  • THEN The pull request does not have the label plan/needs-fix.

Requirement: Block readiness for a failing plan

The stage_ready row MUST NOT mark a plan pull request ready while it has the label plan/needs-fix.

Scenario: Green checks with the needs-fix label

  • WHEN A draft plan pull request has passing checks and the label plan/needs-fix.
  • THEN The stage_ready row leaves the pull request as a draft.

Requirement: Cover drift behavior with unit tests

The change MUST add unit tests for drift detection, label changes and comment generation.

Scenario: The drift unit tests run

  • WHEN The unit test suite runs the roadmap stage tests.
  • THEN The suite passes with tests for a detected problem, a label addition, a label removal and a comment body.

Existing Tool Considered

No alternatives check has run. The OpenSpec CLI (@fission-ai/openspec, pinned 1.14.3, ADR 0010) validates a change folder with openspec validate --strict, and the project's own plan_check already runs the stage gates with no model, but neither covers the need: OpenSpec knows no pull request, label or comment, and plan_check judges the pull request head tree, where a path that moved on the default branch still exists. No open, maintained tool detects, labels and comments plan drift on open pull requests. The change reuses both and builds only the row: about 25,000 tokens to implement, 5,000 tokens each year to maintain, and about 3 hours of elapsed time.

Key questions

  • Which Service row runs the drift check?: Add a plan_drift row to the status lane, before stage_ready, so a draft that this round finds drifted holds the label before readiness is decided. Do not extend stage_ready: it reads only the staged items whose record holds stage.pr and no stage.ready, so it stops reading a plan pull request once it marks it ready. (best practice) [sources: CONTEXT.md:150, src/devops_cli/roadmap/stage/stage_ready.py:84, docs/roadmap/stage.md:91, src/devops_cli/roadmap/run.py:750]
    • Chosen: Add plan_drift to the status lane before stage_ready. It covers every open plan pull request, including a ready one, it calls no model, and it runs before readiness is decided.
    • Rejected: Extend stage_ready. stage_ready reads only a staged item until it marks the draft ready, so it misses a plan pull request that is already ready.
    • Rejected: Run it in the stage job. The stage job is in the model lane and spends model tokens.
  • How does the Service identify an open plan pull request?: List the open pull requests with store.open_pulls(), keep those whose title starts with docs(openspec): plan #, read each with get_pull, and keep those whose base ref is the default branch. plan_check.is_plan then excludes a pull request that the implement job has taken over as a delivery. (best practice) [sources: src/devops_cli/roadmap/plan_check.py:173, src/devops_cli/roadmap/stores/store.py:484, docs/roadmap/plan-check.md:56, docs/roadmap/stage.md:12]
    • Chosen: Plan title plus the default branch base. The stage job gives every plan pull request the title docs(openspec): plan #<issue> <summary>, and is_plan excludes a delivery.
    • Rejected: Label status/ready. The status label is on the issue, not on the pull request.
    • Rejected: Branch prefix. The branch keeps the type of the issue, so it is not a stable plan marker.
  • What plan check does the plan_drift row run?: Read the plan from the pull request head with read_change, then run the deterministic gates check_proposal and validate_change against a detached checkout of the default branch head, with the pull-form rules of plan_check; do not run the model verification pass. This reuses the core of plan_check, which judges the pull request head tree, where a path that moved on the default branch still exists. (best practice) [sources: src/devops_cli/roadmap/plan_check.py:368, src/devops_cli/roadmap/stage/stage_change.py:1203, src/devops_cli/roadmap/stage/stage_validate.py:77, docs/roadmap/plan-check.md:26, docs/roadmap/stage.md:69]
    • Chosen: Reuse the plan-check gates against the default branch tree. It catches a moved path and a changed base spec without model tokens, and it keeps one rule set.
    • Rejected: Call plan_check as it stands. It reads the gates on the pull request head tree, so a path moved on the default branch is still present and the drift is missed.
    • Rejected: Full stage job with the model review. The model review adds cost and latency to a periodic check.
    • Rejected: New plan-check program. It duplicates the stage validation that the repository already keeps.
  • When does the plan_drift row run?: Run it on its own interval on the status lane, every 37 minutes, the interval of the stage row, and on a first run. The poll is the source of truth; the Service takes no push webhook event, so a new default commit is found by the next round. (best practice) [sources: docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md:7, docs/adr/0009-one-webhook-router-delivers-each-event-to-the-consumers-subscribed-to-it.md:8, src/devops_cli/config/constants.py:3451, src/devops_cli/config/defaults.py:898, docs/roadmap/stage.md:29]
    • Chosen: Every 37 minutes on the status lane. It matches the stage interval, and the check is heavier than the other status rows because it fetches a commit and runs openspec validate for each plan.
    • Rejected: On every status round, every 3 minutes. A plan check per open plan every 3 minutes is a fetch and an openspec validate run, for a change that only a merge or a push causes.
    • Rejected: On a push webhook. The Service takes the issues event only, so a push delivery gets no_subscriber, and a new subscription is a person's change to the repository hook.
  • How does the Service prevent repeated drift comments?: Add the marker &lt;!-- devops roadmap plan drift --> as a new constant in src/devops_cli/config/constants.py and add it to CONST_ROADMAP_JOB_COMMENT_MARKERS. Read the pull request comments with list_issue_comments, post with create_issue_comment when no comment holds the marker, and replace the marked comment with update_issue_comment when its body differs from the rendered one. (best practice) [sources: src/devops_cli/config/constants.py:3520, src/devops_cli/config/constants.py:3532, src/devops_cli/github/client.py:605, src/devops_cli/github/client.py:610, docs/roadmap/stage.md:86, k8s/README.md:673]
    • Chosen: One marked comment, updated in place. It follows the marker convention of every roadmap job's comment, and the client already lists and updates issue comments.
    • Rejected: New comment each run. A periodic row would add a comment on every round.
    • Rejected: No update. The comment would show problems that are already fixed.
  • Does stage_ready already refuse a plan pull request with plan/needs-fix?: Yes. The stage_ready row refuses a green draft that holds plan/needs-fix, comments once that the label is the reason, and records stage.needs_fix. [sources: src/devops_cli/roadmap/stage/stage_ready.py:103, docs/roadmap/stage.md:69]
  • Where does the drift code and its row registration live?: Add the row to STATUS_LANE_ROWS in src/devops_cli/roadmap/run.py and its interval to src/devops_cli/config/defaults.py. Put the check in src/devops_cli/roadmap/stage/plan_drift.py, beside stage_ready.py, and its tests in tests/roadmap/stage/test_roadmap_stage_drift.py. (best practice) [sources: src/devops_cli/roadmap/run.py:735, src/devops_cli/config/defaults.py:901, docs/roadmap/package-layout.md:11, src/devops_cli/roadmap/stage/stage_ready.py:1]
    • Chosen: New module under src/devops_cli/roadmap/stage/. The stage package holds the plan validation and stage_ready, the other status-lane row of the stage job.
    • Rejected: New top-level src/devops_cli/roadmap/plan_drift.py. The plan validation it calls lives in the stage package, and plan_check.py is the command module, not a Service row.
    • Rejected: Add the logic to src/devops_cli/roadmap/run.py. run.py registers rows and should stay a thin dispatcher.
  • Which tests cover the affected row?: The status round tests are tests/roadmap/test_roadmap_status_round.py, the due table tests are tests/roadmap/test_roadmap_run_due_table.py, and the readiness test is tests/roadmap/stage/test_roadmap_stage_ready.py. The new drift tests go in tests/roadmap/stage/test_roadmap_stage_drift.py. [sources: tests/roadmap/test_roadmap_status_round.py, tests/roadmap/test_roadmap_run_due_table.py, tests/roadmap/stage/test_roadmap_stage_ready.py, tests/roadmap/test_roadmap_plan_check.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-09: partly.
Tool: danger/danger-js (https://github.com/danger/danger-js), MIT, last activity 2026-10-26, maintained.

Activity

  1. added
    source/agent
    type/feature
    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/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. Prevents stale plan PRs from sitting open, but does not block delivery or expose a security risk.
    • Value: Medium. Saves engineer time by surfacing drift early, but the project functions without it.
    • Effort: Low. The body estimates approximately 3 hours and 25,000 tokens of work.
    • Related: feat(roadmap): add a plan-check command for a plan pull request #3201, which asks for a different change. Both use the plan-check command on plan pull requests, but #3201 delivers the command itself while the candidate adds an ongoing drift-detection loop that re-runs it, labels, and comments.
  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 1f03ee3 (see proposed design in issue body).

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

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: Searches for tooling that re-validates open pull requests against the default branch found no dedicated drift detector; the closest fit is Danger JS, a pull-request rule engine that can run a check, add and remove labels, and keep one comment updated in place. It covers the labeling, label-removal and single-comment half of the acceptance criteria, but it runs on pull-request events, so it does not itself notice a new default-branch commit, and it carries no plan/OpenSpec gates.

    Tool: danger/danger-js (https://github.com/danger/danger-js)

    • License: MIT
    • Last activity: 2026-10-26
    • Maintained: yes

    Covers:

    • Runs a repository-defined rule set against an open pull request, so a plan check can be invoked from those rules
    • Adds and removes labels on the pull request through the GitHub API (the plan/needs-fix label)
    • Posts one sticky comment per pull request and updates it in place instead of adding a comment on every run
    • Can be pointed at an arbitrary pull request (danger pr), so a scheduled sweep of open plan pull requests is possible

    Lacks:

    • No drift detection on its own: it is driven by pull-request events, so a merge into the default branch with no new push triggers nothing
    • No plan gates: it does not read an OpenSpec change folder or run openspec validate / check_proposal against the default-branch tree
    • No integration with the Service's status lane or the stage_ready refusal while plan/needs-fix is set
    • A Node/JS tool, adding a second runtime beside the project's Python Service rows

    Tools considered:

    Searches run:

    • Danger JS pull request rules add label post comment update existing comment, results: 5
    • open source tool detects pull request out of date with base branch, labels and comments on open PRs, results: 5
    • openspec CLI validate change proposal, results: 5
    • danger-js github pull request automation, results: 5
    • bot that rebases open pull requests when default branch changes mergify kodiak, results: 5
    • GitHub merge queue reruns required checks when base branch changes, results: 5
    • mergify-engine pull request automation labels comments update, results: 5
    • danger-js, results: 5

    Sources:

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

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

    @devops-cli-service
    Contributor

    Live since 2026-11-14 22:29 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/lowpriority/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