Skip to content

feat(roadmap): PR, review and check events start a scoped sweep #4413

Closed

Description

@dan-petty

Problem or Motivation

The stage_ready row (src/devops_cli/roadmap/stage/stage_ready.py) marks a staged draft pull request ready when CI checks pass and plan/needs-fix is absent. Today, CONST_ROADMAP_WEBHOOK_EVENTS (src/devops_cli/config/constants.py:3545) subscribes only to issues. Every pull_request and check_suite webhook returns 200 {"status": "no_subscriber"}.

Because the Service ignores those events, stage_ready relies on a 3-minute polling timer (DEFAULT_ROADMAP_STAGE_READY_INTERVAL_MINUTES). Each waiting draft costs two GitHub requests per round, or 40 requests per hour (#3671). In addition, open issue #3671 resets its failed-check backoff when a pull_request webhook arrives, which requires subscribing to pull_request events.

Proposed Solution & Architectural Design

  • Extend GitHubWebhookPayload (src/devops_cli/models/webhooks.py) with optional models for pull_request and check_suite.
  • Add "pull_request" and "check_suite" to CONST_ROADMAP_WEBHOOK_EVENTS (src/devops_cli/config/constants.py). Open issue feat(roadmap): onboard checks the webhook of a repository #3772 reads CONST_ROADMAP_WEBHOOK_EVENTS, so onboarding checks pick up the new events from one source.
  • Add a scoped update in src/devops_cli/roadmap/stage/stage_ready.py and src/devops_cli/roadmap/run.py on the status lane.
  • Trigger the scoped update on check_suite (completed) and pull_request (opened, reopened, synchronize, labeled, unlabeled).
  • Narrow the scoped run to open items whose stage.pr matches the delivered pull request numbers.
  • Keep the 3-minute reconciling poll in STATUS_LANE_ROWS so missed deliveries still settle (ADR 0003, ADR 0017).

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

gidgethub (https://github.com/gidgethub/gidgethub, ADR 0006) and githubkit (https://github.com/yanyongyu/githubkit) parse webhook schemas. GitHub auto-merge acts only after a draft becomes ready. None of these tools inspect stage.pr records, enforce plan/needs-fix holds, or run the Jev completeness check. Extending models/webhooks.py, webhooks.py, run.py, and stage_ready.py costs about 110,000 tokens to build, maintain, and fix, and 2.5 hours of elapsed time.

Acceptance Criteria

  • CONST_ROADMAP_WEBHOOK_EVENTS includes "pull_request" and "check_suite", and k8s/README.md step 8 lists the same events.
  • GitHubWebhookPayload validates pull_request and check_suite payloads while keeping issue optional.
  • check_suite completed and pull_request draft-change deliveries run a scoped stage_ready pass on status for the matching stage.pr item.
  • Payloads for pull requests that match no open staged draft make zero GET pulls/<n> or check-runs requests.
  • Offline unit tests cover payload parsing, consumer routing, and scoped stage_ready execution.

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.

Proposed design

Problem statement

The Service ignores pull_request and check_suite webhook events. The stage_ready row therefore waits for a 3-minute poll and costs two GitHub requests for each waiting draft in each round. This change subscribes to those events and runs a scoped stage_ready pass on the status lane for the delivered pull request numbers. The poll stays as the reconciling path.

Acceptance criteria

Requirement: Webhook event list

The roadmap webhook event set and k8s/README.md step 8 SHALL both list issues, pull_request and check_suite.

Scenario: Event list and README agree

  • WHEN A test reads CONST_ROADMAP_WEBHOOK_EVENTS and step 8 of k8s/README.md.
  • THEN Both name issues, pull_request and check_suite.

Requirement: Optional payload models

GitHubWebhookPayload SHALL validate optional pull_request and check_suite objects and keep issue optional.

Scenario: Both new payloads validate

  • WHEN The model validates a pull_request payload with number 42 and a check_suite payload with check_suite.pull_requests holding 42.
  • THEN Both expose number 42, and each has issue equal to None.

Requirement: Scoped stage ready routing

The Service SHALL route check_suite.completed and the five listed pull_request actions to a scoped stage_ready update on the status lane.

Scenario: Subscribed actions map to stage ready

  • WHEN A test looks up each event and action in SCOPED_UPDATES.
  • THEN Each entry names job stage_ready and lane status, and its runner is the scoped stage ready runner.

Requirement: Scoped pull request filter

A scoped stage_ready pass SHALL read only open items whose stage.pr equals a delivered pull request number.

Scenario: Only the delivered draft is read

  • WHEN The store holds open staged drafts 42 and 43, and the delivery names pull request 42.
  • THEN The pass reads pull request 42 and sends no request for pull request 43.

Requirement: No match sends no request

A scoped stage_ready pass with no matching open staged draft SHALL send zero GET pulls/<n> and zero check-runs requests.

Scenario: Unmatched delivery is silent

  • WHEN The delivery names pull request 99, and the store holds no open item with stage.pr 99.
  • THEN The pass sends no GitHub request and returns empty marked, settled and waiting tuples.

Requirement: Reconciling poll remains

The stage_ready row SHALL remain in STATUS_LANE_ROWS with DEFAULT_ROADMAP_STAGE_READY_INTERVAL_MINUTES and first_run_due set.

Scenario: Poll row stays in the status lane

  • WHEN A test inspects STATUS_LANE_ROWS.
  • THEN The stage_ready row has the 3-minute interval and is due on its first run.

Requirement: Scoped run writes no schedule success

A scoped stage_ready update SHALL NOT write a stage_ready success to schedule.json.

Scenario: Poll still judges later changes

  • WHEN A pull_request synchronize delivery runs a scoped stage_ready pass.
  • THEN schedule.json keeps the previous stage_ready success time.

Requirement: Offline unit tests

The change SHALL add offline unit tests for payload parsing, scoped routing and scoped stage_ready execution.

Scenario: Offline suite covers the new paths

  • WHEN The new unit tests run with no network access.
  • THEN Payload parsing, routing and scoped execution tests pass.

Existing Tool Considered

No alternatives check has run. The body names gidgethub and githubkit. They parse webhook schemas only. They do not inspect stage.pr records, enforce plan/needs-fix holds, or run the Jev completeness check. Building the change costs about 110,000 tokens to build, keep and fix, and 2.5 hours of elapsed time.

Key questions

  • Which webhook events and actions should the Service subscribe to for stage_ready?: Add pull_request and check_suite to CONST_ROADMAP_WEBHOOK_EVENTS. Route check_suite.completed and pull_request opened, reopened, synchronize, labeled and unlabeled to scoped stage_ready on the status lane. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/roadmap/run.py, k8s/README.md, docs/adr/0017-each-subscribed-webhook-event-runs-the-update-scoped-to-it.md]
    • Rejected: Add only check_suite. It misses the pull request label and synchronize changes that the issue needs.
    • Chosen: Add pull_request and check_suite with the listed actions. It covers the issue and keeps one event list for onboarding checks.
    • Rejected: Add every pull_request action. It runs the scoped pass for actions that do not change the draft or its checks.
  • What fields should the webhook payload model add for pull_request and check_suite?: Add optional WebhookPullRequest with number, and optional WebhookCheckSuite with pull_requests numbers. Keep issue optional and ignore extra fields. (best practice) [sources: src/devops_cli/models/webhooks.py, docs/adr/0009-one-webhook-router-delivers-each-event-to-the-consumers-subscribed-to-it.md]
    • Rejected: Use gidgethub or githubkit models. It adds a dependency and still does not route stage_ready.
    • Chosen: Add minimal pydantic models. It follows the existing payload model and reads only the numbers that routing needs.
    • Rejected: Read a raw dict in the route. It bypasses validation and the typed contract of the webhook route.
  • How should a check_suite delivery name its pull requests?: Read check_suite.pull_requests[].number. A suite with no pull requests yields an empty tuple and runs no scoped update. (best practice) [sources: src/devops_cli/models/webhooks.py]
    • Rejected: Match by check_suite.head_sha. stage.pr stores a pull request number, so head_sha would need extra reads.
    • Chosen: Read check_suite.pull_requests numbers. It matches the stage.pr record directly and needs no extra request.
    • Rejected: Run every open staged draft. It defeats the scoped run and its request saving.
  • How should WebhookDelivery carry more than one pull request number?: Add pull_numbers: tuple[int, ...] = () to WebhookDelivery. A pull_request delivery sets one number, and a check_suite delivery sets every number in its payload. (best practice) [sources: src/devops_cli/roadmap/run.py]
    • Rejected: One delivery for each pull request. A check_suite can name several pull requests, and separate deliveries repeat the round.
    • Chosen: One delivery with a tuple of pull request numbers. It keeps one scoped round for the delivery and supports multiple pull requests.
    • Rejected: A new event-specific delivery class. It adds a parallel type where one optional tuple is enough.
  • How should the scoped pass narrow stage_ready to the delivered pull requests?: Add an optional pull_numbers argument to mark_stage_ready and filter _recorded_pull by that set. The default None keeps the full poll, and an empty tuple makes no match. (best practice) [sources: src/devops_cli/roadmap/stage/stage_ready.py]
    • Rejected: Add a second stage_ready function. It duplicates the draft readiness, needs-fix and Jev logic.
    • Rejected: Filter the store items before the call. It puts stage.pr knowledge outside the row that owns it.
    • Chosen: Add an optional pull_numbers filter to mark_stage_ready. It keeps one decision path and makes the zero-request case explicit.
  • Should the scoped update run on the status lane, and should the poll remain?: Run the scoped update on the status lane. Keep the stage_ready row in STATUS_LANE_ROWS with its 3-minute interval and first-run rule. (best practice) [sources: src/devops_cli/roadmap/run.py, src/devops_cli/config/defaults.py, docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md, docs/adr/0017-each-subscribed-webhook-event-runs-the-update-scoped-to-it.md]
    • Chosen: Status lane and keep the poll. stage_ready calls no model, and ADR 0003 makes the poll the reconciling path.
    • Rejected: Model lane and keep the poll. It delays a GitHub-only row behind model-bound work.
    • Rejected: Status lane and remove the poll. A lost delivery would leave a green draft a draft with no later recovery.
  • Should a completed check_suite trigger the scoped pass for every conclusion?: Yes. Trigger on check_suite.completed for every conclusion. The pass reads the check runs and leaves a failing draft a draft. (best practice) [sources: src/devops_cli/roadmap/stage/stage_ready.py, src/devops_cli/roadmap/run.py]
    • Rejected: Only a successful conclusion. It duplicates the check-run decision and misses a suite that settles after a failure.
    • Chosen: Every completed conclusion. The row is idempotent and reads the check runs before it marks a draft ready.
    • Rejected: No check_suite trigger. It keeps the 3-minute poll as the only path after checks end.
  • Should pull_request labeled and unlabeled trigger for every label or only plan/needs-fix?: Trigger for every labeled and unlabeled action on a matching staged pull request. The scoped pass then reads plan/needs-fix and decides. (best practice) [sources: src/devops_cli/roadmap/stage/stage_ready.py]
    • Rejected: Only the plan/needs-fix label. It puts label knowledge in the router and can miss a label change that the row must record.
    • Chosen: Every label on a matching staged pull request. The stage.pr filter makes a non-staged label change cost no request.
    • Rejected: No label trigger. The row would wait for the poll after a person removes or adds the hold.
  • Should CONST_ROADMAP_INTAKE_BATCH_KEYS gain the new events?: No. Add the events to CONST_ROADMAP_WEBHOOK_EVENTS only. Intake keeps its issues batch keys, so a pull_request or check_suite delivery never runs intake. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/roadmap/run.py, docs/adr/0017-each-subscribed-webhook-event-runs-the-update-scoped-to-it.md]
    • Rejected: Add the events to both constants. It makes PR and check events run intake, which only reads issues.
    • Chosen: Add the events to the webhook event set only. It routes the new events to stage_ready and leaves intake unchanged.
    • Rejected: Add a second event set. It splits the source that onboarding checks read.
  • Should a scoped update write a stage_ready success to schedule.json?: No. The scoped update leaves the previous stage_ready success time, so the poll still judges every change since that time. (best practice) [sources: src/devops_cli/roadmap/run.py, docs/adr/0017-each-subscribed-webhook-event-runs-the-update-scoped-to-it.md]
    • Rejected: Write a success for the scoped update. It hides changes from the reconciling poll.
    • Chosen: Write no success. It follows the existing scoped update contract and keeps the poll authoritative.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-18: rejected.
Rejected by ADR 0009. A newer fact can change an ADR.
Tool: yanyongyu/githubkit (https://github.com/yanyongyu/githubkit), MIT, last activity 2026-11-15, maintained.
Reason: Searches found githubkit, which validates pull_request and check_suite webhook payloads with typed Pydantic models, but no tool routes those events to a scoped sweep or filters by stage.pr; ADR 0009 rejects its parse in the router.

Covers:

  • Typed Pydantic models for pull_request and check_suite payloads
  • Optional validation of webhook event data
  • REST and GraphQL client beside the webhook models

Lacks:

  • No scoped sweep of open stage.pr items
  • No filter by the delivered pull request numbers
  • No plan/needs-fix hold or Jev completeness check
  • No routing of events to the status lane

Owner decision 2026-11-13

D8 (approved, tracker #5482): subscribe the App to pull_request, pull_request_review, check_suite and issue_comment. Only a person changes the App webhook events (owner step). Add pull_request_review. The router runs a scoped sweep for the delivered PR (due_jobs for that subject) in place of a scoped stage_ready, and it keeps its refusal of the deliveries of the App. The poll stays the fallback. The title changes to match.

  • Live proof: after the merge, the release and the owner step, a check end on an open bot PR makes a watch result line within 2 min. A comment gives the delivery ID and the result line.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 10, 2026
  2. dan-petty commented on Nov 10, 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. Reduces API cost and improves responsiveness but a polling fallback still works, so it is not critical.
    • Value: Medium. Cuts repeated GitHub requests per draft and lets readiness settle faster on check completion.
    • Effort: Medium. Requires new payload models, webhook routing, scoped execution logic, and offline tests across four files.
    • Related: feat(roadmap): the Service marks a stage pull request ready when its checks pass #2865, which asks for a different change. Both extend the stage_ready feature from #2865; the candidate adds webhook-triggered scoped execution, while #2865 delivered the polling-based readiness check.
  3. added
    priority/p2-medium
    on Nov 10, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 10, 2026
  5. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    Alternatives check: rejected

    Reason: The searches show githubkit ships verify and parse for GitHub webhook deliveries, which turn a named event such as pull_request or check_suite into a validated, typed Pydantic model, so it covers the payload-model half of the issue (and gidgethub only offers signature validation plus untyped event data and a router). It does not cover the rest: routing a delivery to a scoped stage_ready pass on the status lane, narrowing by stage.pr pull numbers, the zero-request case, or the plan/needs-fix and Jev decisions, and ADR 0009 explicitly rejected githubkit's verify and parse for this router.

    Rejected by ADR 0009. A newer fact can change an ADR.

    Tool: yanyongyu/githubkit (https://github.com/yanyongyu/githubkit)

    • License: MIT
    • Last activity: 2026-11-06
    • Maintained: yes

    Covers:

    • Verifies the X-Hub-Signature-256 of a webhook delivery
    • Parses a delivery by event name into a typed Pydantic model for every GitHub event, including pull_request and check_suite
    • Exposes the payload fields (for example pull request numbers and check_suite.pull_requests) without hand-written models

    Lacks:

    • No routing of check_suite.completed or the listed pull_request actions to a scoped stage_ready update on the status lane
    • No filter on open items whose stage.pr matches the delivered pull request numbers, and no zero-request path when nothing matches
    • No enforcement of plan/needs-fix holds or the Jev completeness check before marking a draft ready
    • Adds a dependency and the whole REST and webhook model set for the few numbers the router reads

    Tools considered:

    Searches run:

    • githubkit parse webhook payload pull_request check_suite models, results: 5
    • gidgethub sansio Event parse webhook payload delivery, results: 5

    Sources:

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

  7. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Scope update from the Service step jobs plan (#5014).

    The owner asked on 2026-11-12 for a separate job for each step that the Service jobs run the same way every time. This issue is the pr-events item of that plan. The plan is extract-first: each repeated step becomes one module and one command (devops roadmap step <name>) that every caller uses, and then the steps that cost most move to their own Jobs.

    Proposed title: feat(roadmap): pull_request events make the watch row due

    Problem (plan evidence)

    The live hook sends issues, milestone, pull_request and release, but the roadmap consumer takes issues only (CONST_ROADMAP_WEBHOOK_EVENTS, src/devops_cli/config/constants.py:3659). k8s/README.md:696 says that the hook sends only issues. So the Service sees a new head, a close or a merge only at the next poll. #4413 planned a scoped stage_ready on these events, and #4414 a handler for closed plan pull requests. The watch row replaces both rows.

    Added scope

    Change the scope of #4413: the consumer takes pull_request (opened, synchronize, reopened, ready_for_review, closed) and sets the due mark of the watch row for that repository, with the pull request number as a hint. It drops the writes of its own bot. The poll stays the floor, because deliveries get lost. A closed plan pull request goes to cleanup through the CLOSED verdict, so #4414 folds here. check_suite comes only after owner decision O1. Change k8s/README.md:696 and the hook check text in the same pull request.

    Cost: about 0.6M tokens and 0.5 agent-day. The full value also needs webhook-403.

    Added acceptance

    • A router test: a signed pull_request delivery makes the watch row due and starts no other lane; an unsigned delivery gets 401; a delivery from the App bot starts nothing.
    • A test holds that the event list in k8s/README.md equals the event set of the consumer.

    Merge first

    Coordination

    #4414 (closed plan pull requests from webhooks) folds into this item: a closed plan pull request goes to cleanup through the CLOSED verdict. Close #4414 with evidence after the pull request of this item merges.

  8. changed the title [-]feat(roadmap): run scoped stage_ready on PR and check events[/-] [+]feat(roadmap): PR, review and check events start a scoped sweep[/+] on Nov 13, 2026
  9. 24 remaining items

  10. added
    status/in-progress
    status/in-review
    and removed
    status/in-progress
    on Nov 23, 2026
  11. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    Contributor

    The draft pull request #6889 holds the final title and body. In mode on of roadmap.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: 268 model requests, 23521076 input tokens, 103618 output tokens.

  12. removed
    owner/service
    on Nov 23, 2026
  13. removed
    status/in-review
    on Nov 23, 2026
  14. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-23 17:41 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/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions