Skip to content

fix(service): Name the row of each GitHub request and cut the waste #6012

Description

@dan-petty

Problem

The Service's GitHub budget (service.github_requests_per_hour, 4000) binds all day, so rounds wait and the jobs work fewer items. On 2026-11-16 the budget held rounds 693 times in 24 hours, 233 in 6 hours and 36 in the last hour (devops_cli_service_budget_holds_total), with 3980 of 4000 requests spent. From 17:50Z to 18:40Z only 4 job results ended, while the Service logged "The Service sent 4000 GitHub requests in the last hour ... no round starts until the window has room".

The largest share of the requests has no row: devops_cli_github_requests_total{job="roadmap-service"} in the hour to 18:40Z:

Row Requests
other, devops-cli 1230 (HTTP 304) + 660 (HTTP 200)
other, each of the 6 other Service repositories about 170 each, about 1050 in all (700 to 1100 an hour since 12:40Z)
metrics 380 to 500 an hour (interval 13 min, a code default)
refine 131; watch 132; implement 42; release_comments 26; intake 21; open 51

So about 1700 requests an hour come from code that names no row, and nobody can tell which loop spends them or whether it needs them. The stage and implement Job pods use the same GitHub App outside this budget (#5497), and the App installation has about 5000 requests an hour, so a higher budget is not a safe fix.

Expected behavior

  • Each GitHub request of the Service names its row or loop (the webhook handler, the reconcile poll, status sync, the telemetry snapshots, and so on). No request is counted as other.
  • With that data, cut the largest waste: for example a poll of the 6 repositories that have little work, which costs about 170 requests an hour each; or reads that a webhook or a conditional request (If-None-Match) can replace. Write the measured saving.
  • A setting for the interval of the metrics row, like the other rows, so the cluster can slow it without a release.
  • A test fails when a request of the Service has no row.
  • Result: the budget holds rounds less than 10 times an hour at the same job load.

Related

Proposed design

Problem statement

The Service sends about 4000 GitHub requests an hour and holds rounds all day. About 1700 of those requests come from code that names no row, so nobody can tell which loop spends them. This item names the loop of each Service request, makes the metrics row interval a setting so the cluster can slow it without a release, and adds a check that fails when a Service request has no row. It cuts only the waste that the project brain cache does not remove; the largest cut waits for the instrumented metric to be observed.

Acceptance criteria

Requirement: The row of each Service request

Each GitHub request that the Service sends SHALL count in devops_cli_github_requests_total under the row label of the loop that sent it.

Scenario: The reconcile poll names its loop

  • WHEN the Service reconcile poll sends its issue-events listing or its comment listing
  • THEN the recorded series carries a row label of poll, not other

Requirement: No Service request counts as other

A GitHub request of the Service MUST NOT count in devops_cli_github_requests_total with row="other".

Scenario: Every Service loop runs

  • WHEN each Service loop and each due row sends its GitHub requests
  • THEN no series with job="roadmap-service" has row="other"

Requirement: A request with no row fails the check

A check MUST fail when a Service code path sends a GitHub request and sets no row.

Scenario: A request path leaves the row unset

  • WHEN a Service code path sends a GitHub request with no row
  • THEN the check fails and names that code path

Requirement: The metrics row interval is a setting

The interval of the metrics row SHALL come from a setting, like the interval of the other rows.

Scenario: The metrics interval changes without a release

  • WHEN roadmap.metrics.interval_minutes holds a new value
  • THEN the metrics row runs at that interval

Existing Tool Considered

The row names are a devops-cli concept: the counter devops_cli_github_requests_total and its row label are the project's own (docs/CLUSTER.md:43, openspec/specs/github-api-metrics/spec.md:60), so no library names the rows. The one part an open, maintained tool covers is the source check: the project already keeps ast-grep (ast-grep-cli==0.51.2, pyproject.toml:124; sgconfig.yml:1) with its rules under .ast-grep/rules/ and the constructs row of devops ci (tests/gate/construct_gate.py:89), so the check that a Service request_scope sets no row is a new ast-grep rule with its rule tests, not new checker code. ast-grep lacks the run-time side: it cannot see the row label a request actually carried, so a test over the recorded metric stays (tests/github/test_service_limits.py:1031, tests/github/test_github_api_metrics.py:141). Written cost of the code the project builds and keeps itself: about 200 to 400 output tokens for each Service request path that must set a row, about 1 to 2 hours to add the loop scopes, the roadmap.metrics section and the tests, and about 30 minutes a month to keep the ast-grep rule and the metric test green when a new request path arrives.

Key questions

  • Which row values do the GitHub requests of the Service carry?: The Service due table holds 14 rows: metrics, implement, plan_drift, watch, stage, open, release_comments, github_status and cloudflare_status in the status lane, intake in the triage lane, and retitle, fix_plan, refine and alternatives in the model lane (src/devops_cli/roadmap/run.py:1056, src/devops_cli/roadmap/run.py:1129, src/devops_cli/roadmap/run.py:1141, src/devops_cli/roadmap/run.py:1178). Each due row runs in request_scope(row=row.name) (src/devops_cli/roadmap/run.py:1943), and a scoped webhook update runs in request_scope(row=update.job) (src/devops_cli/roadmap/run.py:1295). The round's own reads run outside a row and count as other: the issue-events listing of _fetch_filtered_changes (src/devops_cli/roadmap/run.py:1497) and the comment listing of _person_comment_stamps (src/devops_cli/roadmap/run.py:1784). docs/CLUSTER.md:42 records that those reads count under row="other", and docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md:23 measures them as the rows other and intake. The list at docs/CLUSTER.md:43 names only 8 rows and is stale against the code. [sources: src/devops_cli/roadmap/run.py:1056, src/devops_cli/roadmap/run.py:1129, src/devops_cli/roadmap/run.py:1141, src/devops_cli/roadmap/run.py:1178, src/devops_cli/roadmap/run.py:1295, src/devops_cli/roadmap/run.py:1497, src/devops_cli/roadmap/run.py:1784, src/devops_cli/roadmap/run.py:1943, docs/CLUSTER.md:42, docs/CLUSTER.md:43, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md:23]
  • How does the Service set the row on each GitHub request?: Each loop names itself in the request_scope context variable (src/devops_cli/github/request_scope.py:44), and the session and the rate limiter read that scope for each count (src/devops_cli/github/rate_limiter.py:1750, src/devops_cli/github/session_transport.py:227). The Service worker's scope currently names only the repository (src/devops_cli/server/service.py:647, src/devops_cli/server/service.py:705), so the round's own reads fall back to other; the change names the round's trigger loop there too, and each due row keeps overriding it with its own name (src/devops_cli/roadmap/run.py:1943). No request site passes a row itself. (best practice) [sources: src/devops_cli/github/request_scope.py:44, src/devops_cli/github/rate_limiter.py:1750, src/devops_cli/github/session_transport.py:227, src/devops_cli/server/service.py:647, src/devops_cli/server/service.py:705, src/devops_cli/roadmap/run.py:1943]
    • Chosen: Name the loop in the request scope of the worker and of each row. The scope is the existing seam that the session and the rate limiter already read for every count (src/devops_cli/github/request_scope.py:44), and _execute_due_rows already overrides it with the row name (src/devops_cli/roadmap/run.py:1943).
    • Rejected: Infer the row from the call stack. A stack guess breaks when a helper sends the request, and it hides a new loop.
    • Rejected: Keep the other fallback in the Service. The issue requires that no Service request counts as other.
  • Which row name do the Service's own reconcile reads carry?: Name the round's trigger loop: poll for a reconcile poll and webhook for a webhook-started round, from the batch's trigger source. The Service already labels its trigger counter with the bounded sources poll and webhook (src/devops_cli/config/constants.py:1706, src/devops_cli/server/counter_series.py:62), and the issue names exactly those two loops ("the webhook handler, the reconcile poll"). The comment listing is read only on a poll round (src/devops_cli/roadmap/run.py:1767), and the issue-events listing of both kinds of round names its trigger. (best practice) [sources: src/devops_cli/config/constants.py:1706, src/devops_cli/server/counter_series.py:62, src/devops_cli/roadmap/run.py:1497, src/devops_cli/roadmap/run.py:1767]
    • Chosen: Name the round's trigger loop (poll or webhook). The trigger source is already a bounded label of the Service (src/devops_cli/server/counter_series.py:62), and it names the two loops the issue calls out, so the metric can separate the poll's own reads from the rows.
    • Rejected: Name the lane. A default lane is named after its row (CONTEXT.md:189), so the poll of the metrics lane would be indistinguishable from the metrics row, which is the conflation the issue wants to end.
    • Rejected: Use one fixed name such as reconcile for every round's own reads. It hides whether a webhook or the poll spent the requests, which the issue asks to tell apart.
  • Does this item cut the largest waste, or defer the cut?: Defer the largest cut. The owner's reply of 2026-11-16 records that this item is the first step: name the row of each request and measure which loops spend the budget, so the project brain cache (feat(service): Cache GitHub issue and PR state in the brain from webhooks #6013) can replace the listing reads and the webhook work (feat(service): webhook events wake the lanes of their jobs #5555, feat(roadmap): PR, review and check events start a scoped sweep #4413) can replace the polls; cut only waste the cache does not remove. The target loop and the measured saving need the instrumented metric deployed and observed, and the direction of the project is a sweep as the source of truth with the Service as a webhook router (docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:56) and a shared cache of the GitHub answers (docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md:23), so a blind cut now can remove a read those items already remove. This item still cuts the waste the cache does not remove: the metrics row interval becomes a setting. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:56, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md:23]
  • How does the metrics row get a settable interval?: Add a roadmap.metrics section that extends RowCadenceConfig with interval_minutes defaulting to DEFAULT_ROADMAP_METRICS_INTERVAL_MINUTES (13), and give the metrics JobRow a cadence=attrgetter("metrics") in place of its fixed interval, so it reads the setting at each round like the other rows. RoadmapConfig has no metrics section today (src/devops_cli/config/settings.py:1997), the metrics row uses the fixed default (src/devops_cli/roadmap/run.py:1056), and the rows that read their interval from the settings are intake, stage, fix_plan, open, refine and alternatives (docs/CLUSTER.md:58). (best practice) [sources: src/devops_cli/config/settings.py:1187, src/devops_cli/config/settings.py:1997, src/devops_cli/roadmap/run.py:1056, docs/CLUSTER.md:58, tests/config/test_roadmap_row_cadence_settings.py:12]
    • Chosen: Add roadmap.metrics.interval_minutes to the row cadence settings. The repository already holds the row cadence settings and the variable pattern (src/devops_cli/config/settings.py:1187, docs/CLUSTER.md:58), and the issue asks for a setting so the cluster can slow the row without a release.
    • Rejected: Keep the code default of 13 minutes. The issue requires a setting, and a code default needs a release to change.
  • How does the check detect a Service request with no row?: Two checks: a test drives each Service loop and each due row over a fake GitHub session and fails when devops_cli_github_requests_total{job="roadmap-service"} records row="other" (tests/github/test_service_limits.py:1031, tests/github/test_github_api_metrics.py:141), and an ast-grep rule fails when a Service request_scope names no row, so a new request path fails at review time. The project already keeps ast-grep and its rules for source-structure checks (pyproject.toml:124, sgconfig.yml:1, tests/gate/construct_gate.py:89), so the source rule adds no new checker. (best practice) [sources: tests/github/test_service_limits.py:1031, tests/github/test_github_api_metrics.py:141, pyproject.toml:124, tests/gate/construct_gate.py:89]
    • Chosen: A metric test plus an ast-grep rule on the Service request scopes. The metric test shows the label a request actually carried at run time, and the ast-grep rule catches a new scope that sets no row at review time, using the maintained tool the project already runs.
    • Rejected: A run-time raise in the Service. A raise stops the Service on a defect that a review-time rule and a test catch without a production failure.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    on Nov 16, 2026
  2. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. The budget binds all day, holds rounds 693 times in 24 hours, and only 4 job results end per hour, causing severe performance degradation.
    • Related: feat(service): give each roadmap pod an hourly request budget #5497, which asks for a different change. Both manage the Service GitHub request budget, but #5497 extends the budget to other pods while the candidate names rows and cuts waste within the Service.
  3. added
    source/agent
    status/new
    effort/medium
    value/high
    scope/service
    priority/p1-high
    on Nov 16, 2026
  4. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor

    Owner, 2026-11-16: the target is webhook-driven work over polling, with the project brain caching GitHub issue data when it changes (#6013). This item is the first step: name the row of each request and measure which loops spend the budget, so #6013 can replace those reads with the cache and #5555/#4413 can replace the polls with events. Cut only waste that the cache does not remove.

  5. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  6. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 16, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 16, 2026
  8. added a commit that references this issue on Nov 16, 2026
  9. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-16 22:14 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/p1-highscope/servicesource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions