Skip to content

fix(service): each lane polls the issue events again #3942

Closed

Description

@dan-petty

Problem

The requests that no job row sends are the third largest source of requests that GitHub counts. Prometheus, 2026-11-07, one hour, job="roadmap-service", status other than 304: other 236 (of 696 with 304 included). They are the poll of each lane of each repository, before any row runs (run_due_jobs in src/devops_cli/roadmap/run.py):

  • _fetch_filtered_changes calls store.changes_since, which lists repos/<repo>/issues/events. Each lane that has a row with a due rule reads the same listing.
  • _person_comment_stamps lists repos/<repo>/issues/comments when a row that may run failed before.

The listing of events changes in a busy repository, so each read is a 200 answer and counts.

Expected

The poll of a repository reads the issue events once for all its lanes. The lanes share the result for one poll.

Acceptance criteria

  • A test shows that one poll of a repository with three lanes sends one request for the issue events.
  • After the change is live, sum(increase(devops_cli_github_requests_total{job="roadmap-service", row="other", status!="304"}[1h])) is lower than 236, and the issue records the result.

Existing tool considered

The store and the session already exist, and the change adds a per-poll cache to them. No library is needed.

Related

Related: #3939, #3672 (an idle repository polls less often), #3497.

Proposed design

Problem statement

The Service sends a separate issue-events request for each lane that reads changes in one poll. In a busy repository every read is a 200 answer and increases GitHub request use. The change caches the issue-events listing for one repository poll so all lanes share it.

Acceptance criteria

Requirement: One issue-events request per poll

One poll of a repository SHALL read the issue-events listing once for all lanes that need it.

Scenario: Three lanes share one request

  • WHEN a poll runs three lanes of one repository and each lane has a due row that reads issue events
  • THEN the fake GitHub session records one request for repos/<repo>/issues/events.

Requirement: Cache lifetime

The issue-events cache MUST last for one poll only.

Scenario: A second poll sends a new request

  • WHEN a second poll runs after the first poll has completed
  • THEN the fake GitHub session records a new request for the issue-events listing.

Requirement: Per-lane cutoff

The shared listing MUST contain every event at or after each lane's own cutoff.

Scenario: Lanes with different cutoffs share one listing

  • WHEN two lanes use different cutoffs in the same poll
  • THEN each lane receives every event at or after its own cutoff from the one cached listing.

Requirement: Cache isolation by repository

The cache MUST keep the issue-events listing of one repository separate from another repository's listing.

Scenario: Two repositories in one poll

  • WHEN one poll reads issue events for two repositories
  • THEN the fake GitHub session records one request for each repository's issue-events listing.

Existing Tool Considered

No alternatives check has run. No open, maintained library covers this need: the store and the GitHub session already exist, and the change adds a per-poll cache to them. The written cost is about 100 lines of code, about 20k tokens to build, keep and fix, and one working day.

Key questions

  • Where does the cache live so all lanes of one poll share it?: A PollCache is created once in service_jobs and passed to every lane's service_job. The cache holds a lock because the lanes run in separate workers. (best practice) [sources: src/devops_cli/roadmap/run.py, src/devops_cli/roadmap/run.py:1419]
    • Chosen: Shared PollCache from service_jobs. Each lane builds its own store, so only an object shared by the lane partials can serve all lanes.
    • Rejected: Cache on each RoadmapStore. Each lane gets its own store, so the cache is not shared.
    • Rejected: Module-level global cache. It lives across polls and can hide events from the next poll.
  • What does the cache hold: filtered changes or the raw issue-events listing?: The cache holds the raw issue-events listing for the repository. Each lane filters the listing with its own cutoff. (best practice) [sources: src/devops_cli/roadmap/run.py:995, openspec/changes/archive/2026-11-07-3939-request-budget-counts-github/design.md:13]
    • Chosen: Raw issue-events listing. Lanes can use different cutoffs and still share one request.
    • Rejected: Filtered Change list per cutoff. A lane with a different cutoff misses the cache and sends a second request.
  • How long does the cache live?: The cache lives for one poll only. The Service discards it after the lanes of the poll finish. (best practice) [sources: docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md]
    • Chosen: One poll. The next poll must see new events, as ADR 0003 requires.
    • Rejected: A TTL equal to the poll interval. A TTL can outlive the poll and hide an event from the next poll.
    • Rejected: A persistent cache. It never sees new events.
  • Which reads does this item own?: This item owns the shared read of the issue-events listing only. The comment listing in _person_comment_stamps stays out of scope. Open issues fix(roadmap): stage_ready backs off after a failed check #3671, fix(roadmap): scoped intake reads a bounded page count #3670 and feat(service): an idle repository polls less often #3672 own other status-lane read costs. (best practice) [sources: src/devops_cli/roadmap/run.py:995, src/devops_cli/roadmap/run.py:1188]
    • Chosen: Issue-events listing only. The reply assigns other status-lane read costs to open issues and says to file no new issue.
    • Rejected: Issue-events and comment listings. It changes the scope and duplicates open work.
  • How does the cache identify one listing?: The cache keys the listing by repository and the issue-events request URL. It does not key by lane. (best practice) [sources: src/devops_cli/roadmap/run.py:995]
    • Chosen: Repository and request URL. All lanes request the same listing, so the URL identifies the shared result.
    • Rejected: Lane. A lane key defeats sharing.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-09: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/bug
    scope/service
    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/bug. The fix prefix of the title gives the type.
    • Scope: scope/service. The (service) scope of the title gives the scope.
    • Priority: P2-Medium. The third largest source of counted requests is eliminated, but no feature is broken and no user is blocked.
    • Value: Medium. It removes redundant API calls that consume the project's GitHub quota and may trigger rate limits.
    • Effort: Low. The body states the change adds a per-poll cache to the existing store and session, with no new library needed.
    • Related: fix(service): the metrics row sends too many counted requests #3941, which asks for a different change. Both reduce counted GitHub requests in the roadmap service, but #3941 targets the metrics row while this candidate targets the other row (lane polling of issue events).
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards: this item owns the shared read of issue events for all lanes. The cost of the other status-lane reads has its own open issues:

    The analysis of the status rows (stage_ready, release_comments, metrics) found only request cost in the reads of these rows. File no new issue for that read cost.

    Two other faults of the status lane have their own issues in #3027. One is a state record that the Service cannot write. The other is a status read that fails without failing its row.

    Measure the result of this item with the query in its acceptance criteria, and record the number.

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

    @devops-cli-service
    Contributor

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

    Moved to new items: #4126.

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

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches returned only generic HTTP response-cache libraries (hishel, requests-cache), which cache a URL's response for a TTL or revalidate it with ETags; neither gives the per-poll lifetime shared across lanes that the issue needs, and a TTL cache would hide events from the next poll, which the design explicitly rejects. The fix is a small in-process cache keyed by repository and issue-events URL inside the existing store and session code, so no open tool covers the need.

    Tool: none found

    Lacks:

    • A cache lifetime of exactly one poll, discarded before the next poll reads new events
    • Sharing one listing across lanes that each build their own store and session
    • Per-lane cutoffs applied to one shared raw issue-events listing
    • URL-keyed caching that does not outlive a poll and so cannot hide an event from the next poll

    Tools considered:

    Searches run:

    • python library cache GitHub API issue events listing shared per poll, results: 5
    • hishel httpx caching library GitHub REST API conditional requests, results: 5
    • python request coalescing deduplicate identical API calls single flight library, results: 5
    • hishel python package HTTP cache httpx GitHub, results: 5
    • hishel pypi, results: 5
    • github gidgethub request cache middleware, results: 5
    • requests-cache pypi library cache API responses, 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.

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

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 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/servicesource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions