Repository navigation
Description
Problem or Motivation
When a person merges or closes a staged plan pull request (Plans #<issue>), the Service does not react to the GitHub pull_request closed event. Instead, two separate polling timers delay the next step.
First, when a person merges a plan pull request at Gate G1 (merged=true), the item waits up to 7 minutes. Only then does implement_submit.py sync the label to status/planned (status_sync.py) and submit a devops-cli-runner Job.
Second, when a person closes a plan pull request unmerged (merged=false), the item waits up to 37 minutes. During that window, the issue stays Ready until stage_rejected.py runs in the next stage round.
Proposed Solution & Architectural Design
- Subscribe to
pull_requestinCONST_ROADMAP_WEBHOOK_EVENTSand parsenumber,state,merged, andclosed_atinGitHubWebhookPayload. - Add scoped
("pull_request", "closed")handling insrc/devops_cli/server/routes/webhooks.pyandsrc/devops_cli/roadmap/run.py. - When
mergedisTrue, enqueue astatuslane update to fetch the clone, runsync_statuses, and callrun_implement_round. - When
mergedisFalse, enqueue a scoped update (stage_rejected.py) to check whether an open item recordsstage.pr == number. - For a rejected plan, copy the trusted reason, delete a session-only branch, record
stage.rejected, and setstatus/new. - Ignore closed pull requests that match no staged item, and keep the reconciling polls intact (ADR 0017).
- Keep open-draft
stage_readycheck handling separate so this item covers only("pull_request", "closed")merge and rejection transitions.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
GitHub Actions can trigger on pull_request: [closed], and gidgethub parses webhook payloads. However, ADR 0008 and ADR 0015 keep ClusterJobs submission and roadmap records inside roadmap-service, not in GitHub-hosted workflows. Wiring ("pull_request", "closed") to implement_submit.py and stage_rejected.py costs about 120,000 tokens to build, maintain, and fix, and 3 hours of elapsed time.
Acceptance Criteria
- A
pull_requestclosedwebhook withmerged=truesyncsstatus/plannedand submits the next eligibleimplementJob when none runs. - A
pull_requestclosedwebhook withmerged=falseforstage.prrecordsstage.rejected, comments the reason, deletes a session branch, and setsstatus/new. - A closed pull request unrelated to roadmap items leaves all items unchanged and calls no LLM.
- Offline unit tests verify both
merged=trueandmerged=falsewebhook deliveries, andk8s/README.mddocuments the event flow.
Standards Compliance
- I confirm this proposal aligns with AGENTS.md engineering principles (cyclomatic complexity <= 10, nesting <= 5, zero bare exceptions, tests that cover the changed lines).
- I am willing to submit a pull request implementing this feature with accompanying tests.
Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub), Apache-2.0, last activity 2026-11-20, maintained.
Reason: Searches found no tool that performs the roadmap transitions; gidgethub, already the project's GitHub session, parses and routes the pull_request closed delivery, but the status sync, Job submit and plan rejection remain project code.
Covers:
- Parses and validates GitHub webhook deliveries
- Routes an event to its per-action handler
- Async GitHub API reads of the pull request state
- Already the project's GitHub request session
Lacks:
- Batch-key due rows for the stage and implement lanes
- Label sync to
status/plannedand runner Job submit - Session branch delete, rejection comment and
status/new - Webhook event subscription and router wiring
Proposed design
Problem statement
The roadmap Service reacts to a closed plan pull request only at its next poll. A merged plan waits up to 7 minutes for the implement Job. A plan closed with no merge waits up to 37 minutes for the stage rejection. This item adds the ("webhook", "pull_request", "closed") batch key to the stage and implement rows of DEFAULT_DUE_TABLE. Their existing rounds then run on the delivery. #4413 adds the event subscription and the trigger.
Acceptance criteria
Requirement: Closed pull request batch key
The stage and implement rows of DEFAULT_DUE_TABLE SHALL declare the batch key ("webhook", "pull_request", "closed") in their batch_keys.
Scenario: Closed pull request makes both rows due
- WHEN a test asks each row of
DEFAULT_DUE_TABLEwhether it is due with the batch{("webhook", "pull_request", "closed"): 1} - THEN the
stageandimplementrows are due, and each other row is not due with that batch.
Requirement: Merged plan pull request
A pull_request closed delivery for a merged plan pull request SHALL make the implement row set status/planned and create the next runner Job.
Scenario: Merged plan pull request
- WHEN a test runs the
implementrow with the closed batch for an item whosestage.pris the closed number and whose change folder is on the default branch - THEN the item label is
status/plannedand onedevops-cli-runnerJob is created for the item.
Requirement: Unmerged closed plan pull request
An unmerged closed plan pull request SHALL make the stage row record stage.rejected, delete the session-only branch and set status/new.
Scenario: Rejected plan pull request
- WHEN a test runs the
stagerow with the closed batch for an item whosestage.pris the closed number and whose pull request is closed with no merge - THEN the item records
stage.rejected, its newest comment holds the reason, the session-only branch is gone and the label isstatus/new.
Requirement: Unrelated closed pull request
A pull_request closed delivery for a number no open item records SHALL change no item, create no Job and make no model call.
Scenario: Closed pull request of no roadmap item
- WHEN a test runs the
stageandimplementrows with the closed batch and a number that no open item records - THEN no item changes, no runner Job is created and no model request is recorded.
Existing Tool Considered
gidgethub (verdict in-use, https://github.com/gidgethub/gidgethub, Apache-2.0, maintained) is the existing tool. The reason is that the repository already uses gidgethub for GitHub deliveries, and no tool performs the roadmap transitions. The alternatives check in the issue body records what the tool covers and lacks. The proposal adds the ("webhook", "pull_request", "closed") batch key to the stage and implement rows. Their existing rounds do the status sync, runner Job submit, rejection comment, branch delete and status/new. The proposal builds no new parsing code.
Key questions
- How does a
pull_requestcloseddelivery make the roadmap work start?: The consumer enqueues a trigger for the event and action when the payload holds no issue number. A row that declares("webhook", "pull_request", "closed")in itsbatch_keysbecomes due and runs its round. The delivery cache drops a repeated delivery id. (best practice) [sources: src/devops_cli/server/routes/webhooks.py, src/devops_cli/roadmap/run.py:1190, tests/roadmap/test_roadmap_run_webhook_keys.py]- Chosen: Batch key on the stage and implement rows. The router already enqueues a trigger for a subscribed event with no subject. The row's own
batch_keysdecide whether it runs. - Rejected: New status-lane handler. It duplicates the implement row and needs a clone that the handler does not have.
- Rejected: Scoped runner that calls
stage_rejected.py. The router builds a scoped delivery only when the payload holds an issue number, and apull_requestpayload holds none.
- Chosen: Batch key on the stage and implement rows. The router already enqueues a trigger for a subscribed event with no subject. The row's own
- Does the change add a payload model for the
pull_requestdelivery?: No.GitHubWebhookPayloadvalidates the delivery, and the router readspayload.issueonly when the payload holds it. The trigger carries the event and the action. Each row reads the pull request from GitHub for the merge state, the reason and the branch. (best practice) [sources: src/devops_cli/models/webhooks.py:43, src/devops_cli/server/routes/webhooks.py]- Chosen: No new payload model. The batch key matches on event and action, and each row reads the pull request anyway. A model would add fields that no code reads.
- Rejected: A
WebhookPullRequestmodel withnumber,state,mergedandclosed_at. Nothing reads those fields. The rows read the merge state, the reason and the branch from GitHub. - Rejected: Flat pull request fields on
GitHubWebhookPayload. It carries the same unread fields and mixes issue fields with pull request fields in one model.
- Which row handles a merged plan pull request, and which calls run?: The
implementrow, on its own lane. Its round runsimplement_submit.py, which syncs the status labels and creates the runner Job of the first item with no Job. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py, src/devops_cli/roadmap/run.py:1190, src/devops_cli/k8s/cluster_job_api.py:187]- Chosen: The implement row, made due by the batch key. The row owns the status sync and the Job create, runs in its own lane and needs no new clone.
- Rejected: A new status-lane handler that fetches a clone. It duplicates the implement row and needs a clone that the handler does not have.
- Rejected: Only the watch row's status sync. It writes the label but submits no Job, so the Job waits for the next implement interval.
- Which row handles an unmerged closed plan pull request, and which calls run?: The
stagerow, on its own lane. Its round runsstage_rejected.py, which deletes the session-only branch, comments the reason, recordsstage.rejectedand returns the item to New. The stage row already holds the clone that the branch delete needs. (best practice) [sources: src/devops_cli/roadmap/stage/stage_rejected.py, src/devops_cli/roadmap/stage/stage_submit.py, src/devops_cli/roadmap/run.py:1190]- Chosen: The stage row, made due by the batch key. The stage round already finds a closed unmerged plan, writes the rejection and holds the clone.
- Rejected: A new scoped update that calls
stage_rejected.py. The branch delete needs the stage row's clone, and the stage row already owns the write. - Rejected: The watch row. The watch row has no clone and writes no rejection. The rejection lives in the stage round.
- What happens when a closed pull request matches no staged item?: Nothing. Each row selects by
stage.prand by the plans on the default branch. A number that no item records matches no item. No item changes, no Job is created and no model call is made. [sources: src/devops_cli/roadmap/implement/implement_submit.py, src/devops_cli/roadmap/stage/stage_rejected.py] - Do the reconciling polls stay after the webhook handles the closed event?: Yes. The sweep stays the source of truth, and the webhook only cuts the delay. GitHub never sends a failed delivery again. (best practice) [sources: docs/adr/0017-each-subscribed-webhook-event-runs-the-update-scoped-to-it.md, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]
- Chosen: Keep the polls. ADR 0017 keeps the poll as the reconciler, and ADR 0021 keeps the sweep as the source of truth.
- Rejected: Remove the polls. A lost delivery or a label change would never be seen again.
- Which document holds the closed plan pull request flow?:
docs/CLUSTER.md. Its roadmap service section holds the webhook setup and the row triggers. The flow, the two outcomes and the new key go there. The body'sk8s/README.mddocuments the cluster, not the service webhook flow. (best practice) [sources: docs/CLUSTER.md, CONTEXT.md]- Chosen:
docs/CLUSTER.md. The roadmap service setup steps, the lanes and the row triggers live in this document. - Rejected:
k8s/README.md. It documents the cluster manifests, and it holds no webhook step of the Service. - Rejected:
docs/ROADMAP_WORKFLOW.md. It documents the workflow of an item, not the setup of the Service.
- Chosen:
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 10, 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.It removes 7 to 37 minute delays but the polling fallback still works, so it is an improvement not a blocker.Users wait minutes less per plan PR transition, which speeds the roadmap pipeline but does not change correctness.The body estimates about 120,000 tokens and 3 hours of work across webhook parsing, two code paths, tests, and docs.Both subscribe to pull_request webhooks to replace polling, but #4413 triggers stage_ready on open drafts while the candidate triggers implement_submit and stage_rejected on closed PRs.devops-cli-service commentedon Nov 10, 2026
Refine cannot set this item to Ready at 1ca0133 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
pull_requestevent to each repository's webhook? (a person decides)devops-cli-service commentedon Nov 11, 2026
Alternatives check: in-use
Reason: gidgethub is an open, maintained Python library that parses and validates GitHub webhook deliveries and routes them by event type and action, so it covers the pull_request payload parsing and dispatch part of this item and is already the project's GitHub client (ADR 0006). It does not cover the roadmap-specific transitions (status sync and implement submission, or stage.rejected and branch deletion), which remain code in this service.
The item already names this tool.
Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-11. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 12, 2026
Scope update from the Service step jobs plan (#5014).
This issue folds into #4413 (
pr-events). That item covers this scope with the other repeated steps. Close this issue with evidence after the pull request of that item merges. The pull request body names only its own issue after a closing keyword.devops-cli-service commentedon Nov 14, 2026
Refine cannot set this item to Ready at 3d6cae6 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
pull_requestevent to each managed repository's webhook? (a person decides)devops-cli-service commentedon Nov 20, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.
15 remaining items
devops-cli-service commentedon Nov 24, 2026
The draft pull request #6945 holds the final title and body. In mode
onofroadmap.fix_checks.mode, the watch row marks it ready when its checks pass, and a fix-checks Job repairs a failed check whose name gives the class test, lint or types. In each other case the watch row stops the item: another failed check, a cancelled check, a conflict, a fix-checks Job that ended with no repair, or another mode.Spend: 158 model requests, 13694018 input tokens, 61538 output tokens.
feat(roadmap): handle closed plan PRs from GitHub webhooks (#4414)
docs(openspec): archive the change (#4414)
devops-cli-service commentedon Nov 24, 2026
Released in v0.206.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.206.0
devops-cli-service commentedon Nov 24, 2026
Live since 2026-11-24 13:45 UTC