Skip to content

feat(service): webhook events wake the lanes of their jobs #5555

Description

@dan-petty

Problem or Motivation

Owner direction (2026-11-13): "jobs should run async and ready for event driven triggers". After each job has its own lane (see Dependencies), a webhook event must wake only the lanes of the jobs that the event concerns. The poll stays as the reconcile path. Today a delivery coalesces into lane rounds, and each lane still finds its work through its own poll of the issue events (#3942).

Proposed Solution & Architectural Design

  • Add one routing table from a GitHub event (event, action, and labels or the PR kind where needed) to the jobs that it can make due. It must be data, with a test that reads it. For example:
    • issues.opened -> intake;
    • issues.labeled status/new -> refine;
    • issues.labeled status/ready -> stage;
    • issues.edited -> intake, refine, retitle;
    • pull_request.* of a plan PR -> stage_ready, fix_plan (label plan/needs-fix), pr_conflicts;
    • pull_request.* of a delivery PR -> implement, pr_conflicts;
    • check_suite and check_run completed -> implement;
    • issue_comment with implement: retry -> implement;
    • release.published -> release_comments;
    • push to the default branch -> pr_conflicts, stage_ready.
  • The webhook handler puts the trigger, with the subject (issue or PR number), on the queue of each routed lane and returns 202. A lane round that has a subject can work on that subject first.
  • An event that the table does not route wakes no lane. The poll finds its effect at the next interval.
  • The table is the seam that due_jobs (feat(roadmap): one due_jobs function names the due jobs of an item #5504) replaces: an event gives a subject, and due_jobs(subject) gives the jobs.
  • Metrics: devops_cli_service_triggers_total{event, lane}, and the time from delivery to the start of the round for each lane.

Target Subsystem

Roadmap Service webhooks and lanes (src/devops_cli/server/routes/webhooks.py, src/devops_cli/server/service.py, src/devops_cli/roadmap/run.py).

Existing Tool Considered

GitHub webhooks are already delivered and verified (#1533). Valkey events (#4517) come later for units outside the pod. This issue uses the in-pod queues. Cost: about 400,000 tokens and 1 day.

Acceptance Criteria

  • A test of each routing row proves that its event enqueues exactly the routed lanes, and that an unrouted event enqueues none (devops ci fail-to-pass).
  • A test proves that a routed delivery starts the round of its lane before the next poll interval.
  • Live proof after the release: a label status/ready on an issue starts a stage round within one minute when the stage lane is idle, as shown by the metric of the time to the round start.

Dependencies

Alternatives check of 2026-11-23: rejected.
Rejected by ADR 0021. A newer fact can change an ADR.
Tool: argoproj/argo-events (https://github.com/argoproj/argo-events), Apache-2.0, last activity 2026-11-17, maintained.
Reason: Searches found Argo Events, which routes webhook events by filter to triggers, but ADR 0021 rejected it as a second receiver; it brings no in-pod lane queues, subject-first round or per-lane latency metric.

Covers:

  • Webhook and GitHub event sources, with CloudEvents payloads
  • Data filters that route one event to chosen triggers
  • Triggers that start Kubernetes objects, workflows or serverless work
  • Declarative event-to-consumer mapping held as resources

Lacks:

  • Second receiver beside the verified GitHub webhook router
  • Subject-first pass on the in-pod lane queues
  • Per-lane time from delivery to round start
  • Poll kept as the reconcile path for lost deliveries

Proposed design

Problem statement

Today a non-scoped issue delivery wakes every lane, and a scoped delivery wakes all other lanes. A lane round ignores the subject that its trigger carries. This issue uses the existing batch_keys as the routing data, so a webhook wakes only the lanes that declare its event. A lane round processes its subjects first. Push and check_run routes wait in a separate issue.

Acceptance criteria

Requirement: Batch key routing

The Service SHALL route a webhook trigger to the lanes whose batch_keys declare its source, event and action.

Scenario: Ready label route

  • WHEN A signed issues.labeled delivery with label status/ready arrives for a managed repository.
  • THEN The handler enqueues each lane whose batch keys declare the issues labeled key and enqueues no other lane.

Requirement: No unscoped lane wake

A non-scoped issue delivery MUST NOT enqueue a trigger with lane=None.

Scenario: Issue closed

  • WHEN A signed issues.closed delivery arrives for a managed repository.
  • THEN Every enqueue_trigger call names a lane from the batch-key route and no call has lane=None.

Requirement: Scoped wake filter

A scoped update SHALL wake only the lanes whose batch_keys declare its key or whose due stamp names the job.

Scenario: Labeled scoped update

  • WHEN A scoped issues.labeled update ends for the stage job.
  • THEN lanes_to_wake returns only the lanes whose batch keys declare issues labeled or whose due stamp names the stage job.

Requirement: Subject first round

A lane round MUST process the subjects of its TriggerBatch before its normal poll rows.

Scenario: Subject first

  • WHEN A routed delivery puts subject 42 on an idle lane and run_due_jobs starts its round.
  • THEN The round processes subject 42 before the poll rows and a fake clock records the start before the next poll interval.

Existing Tool Considered

The alternatives check of 2026-11-23 in the issue body gives rejected for argoproj/argo-events (https://github.com/argoproj/argo-events). ADR 0021 rejected it as a second receiver beside the verified GitHub webhook router. The block in the issue body gives what the tool covers and lacks. The proposal keeps the one verified receiver and the in-pod lane queues. It uses the existing batch_keys to route triggers and gives the subject-first lane round that the tool lacks. The issue records the written cost of building this code: about 400,000 tokens and 1 day.

Key questions

  • Which data routes a webhook event to lanes?: Use each roadmap row's existing batch_keys. Do not add a second table. (best practice) [sources: src/devops_cli/config/constants.py:4017-4033, src/devops_cli/server/routes/webhooks.py:482-492, openspec/specs/roadmap-scoped-updates/spec.md:106-115]
    • Chosen: Existing batch keys. They already declare the source, event and action of each row, and tests hold them.
    • Rejected: New event-to-lane table. It duplicates the batch keys, and its stage_ready and pr_conflicts rows no longer exist.
    • Rejected: Handler branches. The routes are not data, and a test cannot read each row.
  • How does a non-scoped issue delivery choose lanes?: Filter to the lanes whose batch_keys declare the delivery key. Never call enqueue_trigger with lane=None. (best practice) [sources: src/devops_cli/server/routes/webhooks.py:488-492, src/devops_cli/config/constants.py:4017-4033, tests/roadmap/test_roadmap_run_webhook_keys.py]
    • Chosen: Filter by batch keys. It wakes only the lanes that declare the event and it uses one data source.
    • Rejected: Wake all lanes. It starts rounds for no work and hides gaps in the keys.
    • Rejected: Drop the delivery. The poll would delay the work until its next interval.
  • Should issues.labeled status/ready wake only the stage lane?: No. It wakes every lane whose batch_keys declare issues labeled, including refine and stage when their keys declare it. (best practice) [sources: src/devops_cli/config/constants.py:4017-4033, openspec/specs/roadmap-scoped-updates/spec.md:106-115, tests/roadmap/test_roadmap_run_webhook_keys.py]
    • Chosen: All matching lanes. The batch keys hold the route, and refine and stage both declare the labeled key.
    • Rejected: Stage only. It conflicts with the refine batch keys and the scoped-update spec.
    • Rejected: No lane. It loses a trigger that the keys declare.
  • How does a scoped delivery wake other lanes?: lanes_to_wake returns only lanes whose batch keys declare the delivery key or whose due stamp names the job. (best practice) [sources: src/devops_cli/roadmap/run.py:1463-1473]
    • Chosen: Filter by key or due stamp. It keeps the wake path and removes the wake of every other lane.
    • Rejected: Keep all other lanes. It starts rounds for no work and makes the trigger count misleading.
    • Rejected: New wake queue. It duplicates the lane queues and adds a second ordering path.
  • How does a lane round process a subject first?: run_due_jobs reads TriggerBatch.subjects and processes them before its poll rows. (best practice) [sources: src/devops_cli/server/service.py:98, src/devops_cli/roadmap/run.py:2315-2349]
    • Chosen: Consume TriggerBatch.subjects. The batch already carries the subjects, so no new state is needed.
    • Rejected: New subject queue. It duplicates the batch and adds a second ordering path.
    • Rejected: Work in the handler. It makes the request long and moves roadmap work out of the lane.
  • Which row serves pull request and check suite events after feat(roadmap): one watch row for plan and delivery PRs #5024?: The watch row. stage_ready and pr_conflicts no longer exist. (best practice) [sources: src/devops_cli/roadmap/run.py:1222-1226, openspec/specs/roadmap-watch-row/spec.md:8-14, tests/roadmap/test_roadmap_run_due_table.py:114-129]
  • Which metrics change?: No metric labels or histogram change. Keep devops_cli_service_triggers_total{repo,source}. (best practice) [sources: openspec/specs/roadmap-service-counters/spec.md:23-28, src/devops_cli/server/counter_series.py:161-168, tests/telemetry/test_service_counter_series.py:193-201, k8s/devops/dashboards/roadmap-service-telemetry.json:591]
    • Chosen: Keep the existing counter. The spec, the series code, the test and the dashboard bind its labels to repo and source.
    • Rejected: Add event and lane labels. It conflicts with the counter spec and the series test.
    • Rejected: Add a latency histogram. The deferred follow-up test(service): prove webhook wake latency after release #6279 rejected it.
  • Should this issue add push and check_run routes now?: No. Defer them. The event list excludes both, the payload parses neither, and a test expects push to return no subscriber. (best practice) [sources: src/devops_cli/config/constants.py:4049-4058, src/devops_cli/models/webhooks.py:107-122, tests/server/test_server_service.py:1961]
    • Chosen: Defer to a new issue. The core route change needs no new event subscription or payload field.
    • Rejected: Add both routes now. It expands the scope and changes a test that expects no subscriber.
    • Rejected: Drop them permanently. The issue still records the need, and a later issue can add it.
  • Does the webhook handler run a scoped update in the request?: No. It queues work through enqueue_scoped and enqueue_trigger and returns. [sources: src/devops_cli/server/routes/webhooks.py:482-492]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#6279, #7038

Activity

  1. added
    source/agent
    type/feature
    scope/service
    status/new
    value/high
    effort/medium
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: rejected

    Reason: Searches found Argo Events, an open Kubernetes event-driven framework that routes webhook events to triggers, but it lacks the in-pod lane queues, and ADR 0021 rejected it as a second receiver beside the router.

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

    Tool: argoproj/argo-events (https://github.com/argoproj/argo-events), Apache-2.0, last activity 2026-11-16, maintained.

    Covers:

    • Routes webhook events to triggers by payload filters
    • Triggers create Kubernetes objects, Jobs or Workflows
    • CloudEvents envelope with business-level constraint logic

    Lacks:

    • No in-pod lane queue that a lane round drains
    • A second receiver beside the already verified webhook router
    • No subject-first round or per-lane delivery latency metric
    Searches (10)

    Tools considered:

    Searches run:

    • Argo Events event source sensor trigger workflow, results: 5
    • open source event router route GitHub webhook events to jobs triggers, results: 5
    • github webhook payload filter map event to job trigger queue service, results: 5
    • argoproj argo-events github repository event-driven workflow automation kubernetes, results: 5
    • Argo Events documentation, results: 5
    • KEDA ScaledJob Valkey stream, results: 5
    • event-driven automation webhook receiver Kubernetes sensor, results: 5
    • argo-events, results: 5
    • argo events github webhook event source sensor filter trigger, results: 5
    • argo-events event sources sensors triggers documentation, results: 5

    Sources:

    A person decides what this check of 2026-11-17 means for the item.

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

    @devops-cli-service
    Contributor

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

    Moved to new items: #6279.

  7. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Returning #5555 to status/new without implementing because the specification cannot be built as written on origin/main (49b8c0db8):

    1. Removed rows (stage_ready, pr_conflicts): The issue and its refine design (sha=86358b6c) require routing pull_request and push events to stage_ready and pr_conflicts. #5024 deleted both rows and replaced them with watch (src/devops_cli/roadmap/run.py:1222-1226, openspec/specs/roadmap-watch-row/spec.md:8-14, tests/roadmap/test_roadmap_run_due_table.py:114-129). Neither lane exists.
    2. Superseded webhook dispatch and conflicting route requirements (#4413, #4414, #4415, #4416, #4660, #6013):
      • The HTTP webhook handler already returns 202 after queueing work onto worker threads via enqueue_scoped and enqueue_trigger (src/devops_cli/server/routes/webhooks.py:482-492) without running run_scoped_update synchronously in the request.
      • Newer merged changes already route pull_request, pull_request_review, and check_suite to _SCOPED_WATCH (watch lane, #4413/#4414), trusted issue_comment events to _SCOPED_IMPLEMENT or _SCOPED_REFINE after bot/PR/author refusals (#4415), release.published to _SCOPED_RELEASE (#4416), and brain-cache updates to _remember_delivery_issue (#6013). Dropping run_scoped_update as written would undo ADR 0017 and those shipped routes.
      • The requirement that issues.labeled (status/ready) wakes only stage, and issues.closed wakes no lane (Unrouted event), conflicts with CONST_ROADMAP_REFINE_BATCH_KEYS and CONST_ROADMAP_STAGE_BATCH_KEYS (src/devops_cli/config/constants.py:4017-4033, openspec/specs/roadmap-scoped-updates/spec.md:106-115, #4660, verified by tests/roadmap/test_roadmap_run_webhook_keys.py).
      • push and check_run are outside CONST_ROADMAP_WEBHOOK_EVENTS (src/devops_cli/config/constants.py:4049-4058), GitHubWebhookPayload (src/devops_cli/models/webhooks.py:107-122) parses neither ref nor check_run, and tests/server/test_server_service.py:1961 asserts push returns 200 {"status": "no_subscriber"}.
    3. Conflicting metrics requirements: openspec/specs/roadmap-service-counters/spec.md:23-28, src/devops_cli/server/counter_series.py:161-168, tests/telemetry/test_service_counter_series.py:193-201, and k8s/devops/dashboards/roadmap-service-telemetry.json:591 bind devops_cli_service_triggers_total to labels {repo, source} rather than {event, lane}, and deferred follow-up #6279 explicitly rejected adding devops_cli_service_trigger_latency_seconds.

    What still remains unbuilt for re-scoping in refinement:

    • Non-scoped issues deliveries (labeled, unlabeled, closed, assigned) still call enqueue_trigger(..., lane=None) in src/devops_cli/server/routes/webhooks.py:488-492, waking all 14 lanes instead of only lanes whose batch_keys declare that (source, event, action) key.
    • lanes_to_wake (src/devops_cli/roadmap/run.py:1463-1473) still wakes all other lanes instead of filtering to lanes matching the trigger key or refine_due stamp.
    • TriggerBatch.subjects (src/devops_cli/server/service.py:98) is still not consumed by service_job / run_due_jobs (src/devops_cli/roadmap/run.py:2315-2349) for subject-first processing.
  8. 1 remaining item

  9. added
    status/new
    on Nov 25, 2026
  10. added
    status/ready
    and removed
    status/new
    on Nov 25, 2026
  11. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  12. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 28, 2026
  13. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  14. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-28 17:56 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/servicesource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions