Skip to content

feat(service): an idle repository polls less often #3672

Closed

Description

@dan-petty

Problem

A repository with no open work polls at the same rate as a busy repository. Evidence from #3497, in the window 2026-11-03T15:05Z to 2026-11-04T15:05Z:

  • An idle repository costs 1178 to 1373 requests a day. For one such repository, the rows metrics and other are 753 of 1373.
  • The budget is shared across repositories. The spend was at or above 1990 of 2000 for 246 of 1440 minutes (17%).

The code at origin/main f6d57ec:

  • service.poll_interval_seconds is one value for all repositories (src/devops_cli/config/settings.py:1097).
  • RequestBudget.poll_interval makes the interval longer only when the rounds of a poll cost more than the budget pays for (src/devops_cli/server/service.py:278). It does not look at the open work of a repository.

Expected

A setting gives a longer poll interval for a repository with no open work. A webhook delivery still starts its update at once (ADR 0017), and the first new item ends the idle state.

The refine plan on #3497 proposes roadmap.poll_interval_idle_seconds with a default of 600 seconds. The plan of this item confirms the name and section against src/devops_cli/config/settings.py, because the current interval is in the service section, and it defines "no open work".

Acceptance criteria

  • A setting gives a longer poll interval for a repository with no open work, and a test reads it.

Existing tool considered

ADR 0003 keeps the poll, and ADR 0017 keeps the webhooks. The change adds one setting to the existing loop, and no library.

Related

Split from #3497, which holds the evidence. It holds criterion 8 of that issue.

Related: #3497, #1533, #1534

Source: #3497

Proposed design

Problem statement

The Service polls an idle repository at the same rate as a busy repository. The shared request budget pays for that work. This change adds an idle poll interval, and a webhook still starts an update at once.

Acceptance criteria

Requirement: Idle interval setting

The configuration SHALL define service.poll_interval_idle_seconds in the service section with a default of 600 seconds.

Scenario: Default idle interval

  • WHEN The configuration loads with no value for service.poll_interval_idle_seconds.
  • THEN The loaded value is 600 seconds.

Requirement: Idle interval validation

The configuration MUST reject an idle interval that is shorter than service.poll_interval_seconds.

Scenario: Short idle interval

  • WHEN The configuration sets service.poll_interval_idle_seconds to 30 and service.poll_interval_seconds to 60.
  • THEN Loading the configuration fails with a validation error that names both settings.

Requirement: Idle repository interval

The Service SHALL use service.poll_interval_idle_seconds for a repository with no open issues and no open pull requests.

Scenario: Repository with no open work

  • WHEN The repository has zero open issues and zero open pull requests, and the idle interval is 600 seconds.
  • THEN The next poll for the repository is scheduled after 600 seconds.

Requirement: Busy repository interval

The Service SHALL use service.poll_interval_seconds for a repository with at least one open issue or open pull request.

Scenario: Repository with open work

  • WHEN The repository has one open issue or one open pull request, and the normal interval is 60 seconds.
  • THEN The next poll for the repository is scheduled after 60 seconds.

Requirement: Webhook ends idle state

A webhook delivery for an issue or pull request event MUST start the update at once and MUST clear the idle state.

Scenario: New issue webhook on idle repository

  • WHEN A repository is idle and a webhook delivery reports a new open issue.
  • THEN The Service starts the update at once and schedules the next poll with the normal interval.

Requirement: Poll ends idle state

A poll that finds open work MUST clear the idle state and schedule the next poll with the normal interval.

Scenario: New issue found on idle poll

  • WHEN An idle repository poll returns one open issue.
  • THEN The Service clears the idle state and schedules the next poll with the normal interval.

Requirement: No extra request for idle check

The Service MUST derive the idle state from the issue and pull request data that the poll already fetches.

Scenario: Poll of idle repository

  • WHEN The Service polls a repository with no open work.
  • THEN The poll makes no additional GitHub request to decide that the repository is idle.

Existing Tool Considered

No alternatives check has run. This change uses no separate tool or library. It adds one setting and one interval branch to the existing poll loop. The build cost is about 2,000 tokens and under one hour.

Key questions

  • Which configuration key and section hold the idle poll interval?: Use service.poll_interval_idle_seconds in the service section. Set its default to 600 seconds. The current interval is service.poll_interval_seconds, so the idle interval belongs in the same section. (best practice) [sources: src/devops_cli/config/settings.py:1097, src/devops_cli/server/service.py:278]
    • Chosen: service.poll_interval_idle_seconds. It matches the section of service.poll_interval_seconds and keeps one prefix for the poll loop.
    • Rejected: roadmap.poll_interval_idle_seconds. The current poll interval is in the service section, so this key splits one loop across two sections.
    • Rejected: service.idle_poll_interval_seconds. It puts the qualifier before the noun and does not match the existing poll_interval_seconds name.
  • What does "no open work" mean for a repository?: A repository has no open work when it has zero open issues and zero open pull requests. A candidate issue is open work because intake must process it. (best practice) [sources: CONTEXT.md, docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md]
    • Chosen: No open issues and no open pull requests. It includes candidate issues that intake must process and pull requests that the Service must track.
    • Rejected: No open item with a priority label. It ignores candidate issues without a priority label, so intake could wait for the idle interval.
    • Rejected: No open issue, no open pull request and no open event. It needs extra state and does not match the data that the poll already fetches.
  • Where does the Service hold the idle state?: Hold the idle state in the existing per-repository RequestBudget. That class already chooses the poll interval. (best practice) [sources: src/devops_cli/server/service.py:278]
    • Chosen: Extend RequestBudget with an idle flag. The class already selects the interval, so the change stays in one place.
    • Rejected: Add a separate idle-state map. It duplicates per-repository state and adds a second place to update.
    • Rejected: Query GitHub on every poll. It adds a request and works against the goal to reduce requests.
  • How does the Service detect open work without an extra request?: Derive the counts from the issue and pull request data that the poll already fetches. Cache the result for each repository. (best practice) [sources: src/devops_cli/server/service.py:278, docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md]
    • Chosen: Use the poll response. It adds no GitHub request and uses data that the Service already needs.
    • Rejected: Use the GitHub search API. It adds a request and consumes the shared budget.
    • Rejected: Use only webhooks. ADR 0003 keeps polling as the source of truth, so a missed webhook would leave the state wrong.
  • How does a webhook interact with the idle interval?: A webhook delivery for an issue or pull request event starts the update at once. It clears the idle flag. The next poll uses the normal interval. (best practice) [sources: docs/adr/0017-each-subscribed-webhook-event-runs-the-update-scoped-to-it.md, docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md]
    • Chosen: Clear idle on webhook. ADR 0017 runs the update at once, so the repository is active again.
    • Rejected: Keep idle until the next poll. It would delay the first update after the webhook and ignore ADR 0017.
    • Rejected: Disable polling for idle repositories. ADR 0003 keeps polling as the source of truth when a webhook is missed.
  • Should the idle interval be validated against the normal interval?: Yes. The idle interval MUST be at least service.poll_interval_seconds. (best practice) [sources: src/devops_cli/config/settings.py:1097]
    • Chosen: Validate idle >= normal. It prevents a setting that makes an idle repository poll more often than a busy one.
    • Rejected: Accept any positive value. A shorter idle interval contradicts the purpose of the setting.
    • Rejected: Clamp silently. It hides a configuration error from the operator.
  • Which service path uses the idle interval?: The repository poll loop uses the idle interval for every lane trigger. A webhook delivery bypasses the interval and runs at once. (best practice) [sources: docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md, src/devops_cli/server/service.py:278]
    • Chosen: Apply to every lane trigger. The lanes share the repository poll, so one idle interval reduces the shared request budget.
    • Rejected: Apply only to the status lane. The model lane also polls and would keep the idle cost high.
    • Rejected: Apply only to the metrics row. It does not reduce the other idle requests enough to meet the goal.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

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

Activity

  1. added
    source/agent
    on Nov 5, 2026
  2. added
    type/feature
    scope/service
    status/new
    value/medium
    effort/low
    on Nov 5, 2026
  3. dan-petty commented on Nov 5, 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/service. The (service) scope of the title gives the scope.
    • Priority: P2-Medium. It cuts API spend for idle repositories but does not fix a broken feature or a security gap.
    • Value: Medium. Idle repositories stop consuming a share of the shared GitHub budget, freeing it for active work.
    • Effort: Low. The body states the change adds one setting to the existing poll loop and one condition check.
    • Related: perf(roadmap): a Service poll with no event newer than the last round's sends no GraphQL request #1401, which asks for a different change. Both reduce the cost of polling a repository with no new activity, but 1401 skips the request when no event changed, while the candidate lengthens the interval when no open work exists.
  4. added
    priority/p2-medium
    on Nov 5, 2026
  5. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  6. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches returned only unrelated pages (MDN documentation on the browser Idle Detection API and GitHub/MDN community pages); no open, maintained tool or library provides a configurable "poll interval for a repository with no open work" setting for a project's own service loop. The issue itself asks for one new setting plus an interval branch inside the existing poll loop (kept by ADR 0003, webhooks by ADR 0017, scheduling by ADR 0008), which is a code change and no external dependency.

    Tool: none found

    Lacks:

    • No tool was found that supplies a service.poll_interval_idle_seconds setting with validation against the normal interval
    • No tool was found that derives a per-repository idle state from data the poll already fetches
    • No tool was found that couples idle-state clearing to webhook deliveries and to polls that find open work

    Searches run:

    • python scheduler per-repository poll interval backoff idle configurable, results: 5
    • library adaptive polling interval idle repositories reduce GitHub API requests, results: 5
    • "poll interval" configuration setting idle "no open issues" service GitHub sync tool, results: 5
    • open source tool polls GitHub repositories on a schedule with adaptive interval per repository, results: 5

    Sources:

    Checked on 2026-11-08. 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. removed
    status/in-progress
    on Nov 14, 2026
  10. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor
  11. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions