Skip to content

fix(service): the rows stop repeating reads that find no change #3497

Closed
5 of 5 issues completed
Closed

Description

@dan-petty

Problem

The Service spends most of its GitHub budget on reads, and a hold stops each row of each repository. Evidence in the window 2026-11-03T15:05Z to 2026-11-04T15:05Z:

  • 39248 requests, of which 38179 are GET (97.3%).
  • The live budget is 2000, and k8s/README.md:688 gives 500 as the default. The spend was 1990 or more for 246 of 1440 minutes (17%).
  • 66 holds by the sum of the per-pod maximum. increase() reads 57.7. It undercounts, because each new pod starts a new series and increase() loses the first value of a series (fix(telemetry): Service counters read true across pods and repos #3495).
  • Refine sent 7727 GET requests, 7069 of them in devops-cli. consider (src/devops_cli/roadmap/refine.py:1679) calls _still_waiting for an unchanged item, and that function reads the comments (:1607). 7069 reads over 160 New items fit about 44 reads for each item. This is inferred, because the metric has no endpoint label. refine.py:15-16 says that an unchanged item costs no body read, but it still costs a comment read.
  • _execute_scoped runs with no row (src/devops_cli/server/service.py:564), so its requests count as other. devops-cli has 4683 in that row. src/devops_cli/roadmap/github_store.py:924-927 reads state=all, about 35 pages for this repository (inferred from the highest issue number).
  • Row stage_ready spent 1841 requests on vibes. Its 3 open drafts of the Service each have 1 failed and 2 cancelled check runs.
  • An idle repository costs 1178 to 1373 requests a day. For homelab, the rows metrics and other are 753 of 1373.
  • src/devops_cli/github/rate_limiter.py:1046 and :1092 log at INFO. They wrote 1317 of 2459 lines (53.6%) in a log sample.

A conditional GET does not repair the main cost. _forget_last_page (src/devops_cli/github/session_transport.py:348-356) drops each page with no next link, so a single-page comment list never answers 304. The store holds 64 answers (DEFAULT_GH_SESSION_ETAG_CACHE_SIZE), and devops-cli has 160 New items. So the loss of the store at a restart is minor. The share of 304 answers is not known, because devops_cli_github_requests_total has no status label. The limiter also charges each attempt, a 304 too (src/devops_cli/github/session_transport.py:24-25).

Expected

A row reads the comments of an item only when its updated_at changed. A closed blocker and a changed cited path still end a wait (#2005). Scoped intake has a bounded read. A draft with a failed check is read less often. An idle repository polls less often. The limiter logs at DEBUG.

This scope is too wide for one pull request, so this issue is split into 5 items, as the refine proposal below states. This issue keeps only the first item.

Acceptance criteria

The pull request of this issue delivers these criteria. The section below names the issue that holds each other criterion.

  • A test: the request metric has a status label or a 304 counter. (Criterion 1: the metric has a status label.)
  • A test: the limiter lines log at DEBUG. (Criterion 5.)
  • A test holds the charge of a 304. The charge is 0 only if the plan cites a measure that shows that GitHub does not count a 304. (Criterion 9: no such measure exists, so the charge stays.)

Moved criteria

Existing tool considered

Item.updated_at covers the main cost. GitHub conditional requests (#983) already serve pages that link a next page. hishel is a maintained HTTP cache for httpx, but it meets the same last-page rule, so it does not lead.

Related

Related: #2479, #3069, #2919, #983, #2754, #3484, #3495, #3634, #3631

Proposed design

Problem statement

The Service spends most of its GitHub request budget on reads. The request counter has no status label, so a 304 answer is invisible. The limiter logs each request at INFO. This change adds a status label to the counter, moves the limiter lines to DEBUG, and tests that a 304 keeps its charge.

Acceptance criteria

Requirement: GitHub request status metric

The GitHub request counter SHALL record each request with a status label.

Scenario: A 304 response is counted

  • WHEN A GitHub GET returns 304.
  • THEN The counter devops_cli_github_requests_total has a sample with status="304" and the request counts once.

Requirement: Limiter log level

The rate limiter SHALL log its per-request lines at DEBUG level.

Scenario: Limiter logs a request

  • WHEN The rate limiter writes the line at src/devops_cli/github/rate_limiter.py:1046 or src/devops_cli/github/rate_limiter.py:1092.
  • THEN The log record has level DEBUG.

Requirement: 304 request charge

The limiter SHALL charge a 304 response like any other request.

Scenario: A 304 response is charged

  • WHEN A GitHub GET returns 304.
  • THEN The limiter records one charge for the request.

Existing Tool Considered

No alternatives check has run. The change edits existing modules and builds no new component. OpenTelemetry carries the project's counters but lacks a status label on this request counter; no separate open tool or library covers the need. The written cost to build, keep and fix the three code paths is about 6,000 tokens and half a working day.

Key questions

  • How does this issue close when one pull request delivers only part of it?: Split the issue, and close it with the part that the pull request delivers. This pull request delivers criteria 1, 5 and 9. fix(roadmap): an unchanged refine item reads no comments #3667, fix(roadmap): scoped intake reads a bounded page count #3670, fix(roadmap): stage_ready backs off after a failed check #3671 and feat(service): an idle repository polls less often #3672 hold the other criteria. (best practice) [sources: AGENTS.md]
    • Chosen: Split and close with the delivered part. AGENTS.md rule 1 keeps one issue to one pull request, and the moved criteria already have issues.
    • Rejected: Keep all criteria in one pull request. The body states that the scope is too wide for one pull request.
    • Rejected: Close the issue with no pull request. The delivered criteria still need a pull request.
  • Which metric shape records a 304 answer?: Add a status label to devops_cli_github_requests_total. The status values are bounded. (best practice) [sources: src/devops_cli/github/rate_limiter.py, docs/adr/0006-github-session-requests-go-through-gidgethub.md:12]
    • Chosen: Add a status label to the request counter. One counter keeps the total and splits 200 from 304 with bounded cardinality.
    • Rejected: Add a separate 304 counter. It adds a second metric and makes the total a sum of two metrics.
  • Which log level do the limiter lines use?: DEBUG. (best practice) [sources: src/devops_cli/github/rate_limiter.py:1046, src/devops_cli/github/rate_limiter.py:1092]
    • Chosen: DEBUG. The lines are per-request detail and wrote 53.6% of a log sample at INFO.
    • Rejected: INFO. It keeps the log volume.
  • Does the limiter charge a 304 response?: Yes. Keep the charge and test it. (best practice) [sources: docs/adr/0006-github-session-requests-go-through-gidgethub.md:12, src/devops_cli/github/session_transport.py:24-25]
    • Chosen: Keep the charge for every attempt. ADR 0006 records that every attempt, a 304 too, is paced and charged.
    • Rejected: Set the charge to 0 for a 304. No measure shows that GitHub does not count a 304.
  • Does a separate item keep a page with no next link in the conditional-request store?: No. GitHub's ETag covers the body of a page, and its 304 has no Link header. A full last page that gains a next page keeps its ETag, so this issue files no item for it. (best practice) [sources: docs/adr/0006-github-session-requests-go-through-gidgethub.md:12]
    • Chosen: Keep the existing last-page rule. The 304 has no Link header, so the stored ETag still matches when a last page gains a next page.
    • Rejected: Add an item to cache the last page. The ETag rule already covers the last page, so the item adds no benefit.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    source/agent
    type/bug
    scope/service
    status/new
    value/high
    effort/high
    on Nov 4, 2026
  2. dan-petty commented on Nov 4, 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: P1-High. The Service hits its budget in 17% of minutes and accumulates 66 holds, which blocks all rows of every repository.
    • Value: High. Cutting redundant reads frees GitHub budget, removes holds, and lets the Service process work without stalling.
    • Effort: High. The body spans six acceptance areas across refine, scoped intake, drafts, idle polling, log level, and the 304 charge, and the author states the scope is too wide for one pull request.
    • Related: feat(telemetry): the roadmap Service counts its GitHub writes, budget holds, Firecrawl searches and self-filtered webhooks, and caps its comments on one issue #2475, which asks for a different change. Both items reduce or observe the Service GitHub API spend and touch devops_cli_github_requests_total, but the candidate cuts redundant reads while 2475 adds write counters and a comment cap.
  3. added
    priority/p1-high
    on Nov 4, 2026
  4. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    The proposal at e272a33 needs splitting into 5 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.

    1. fix(roadmap): skip comment reads for an unchanged refine item and keep the blocker and path exits
    2. fix(github): add a status label to the request metric and log the limiter at DEBUG
    3. fix(roadmap): cap the pages that scoped intake reads
    4. fix(roadmap): back off stage_ready reads after a failed check
    5. feat(service): add an idle poll interval for a repository with no open work
  5. added
    owner/agent
    on Nov 5, 2026
  6. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards, under the owner's instruction of 2026-11-05.

    Question: how does this issue close when one pull request delivers only part of it?

    Answer: split the issue, and close it with the part that the pull request delivers. The pull request delivers criteria 1, 5 and 9. The issue body now lists these criteria and names the issue that holds each moved criterion: #3667 (criteria 2, 3, 4 and 10), #3670 (criterion 6), #3671 (criterion 7) and #3672 (criterion 8). These follow the 5 items of the refine proposal on this issue.

    Source: AGENTS.md rule 1 (one issue, one pull request), and the refine comment above, which proposes the split.

    Question: does the limiter charge a 304?

    Answer: yes. The charge stays. No measure shows that GitHub does not count a 304, and criterion 9 allows a charge of 0 only with such a measure. The test test_a_304_answers_with_the_stored_body_paced_and_charged_with_the_quota_it_reports in tests/github/test_github_session.py holds the charge.

    Source: docs/adr/0006-github-session-requests-go-through-gidgethub.md, which says that every attempt, a 304 too, is paced and charged.

    Question: does a separate item keep a page with no next link in the conditional-request store?

    Answer: no. GitHub's ETag covers the body of a page, and its 304 has no Link header, so a full last page that gains a next page keeps its ETag. So the session reads that page in full, and this issue files no item for it.

    Source: docs/adr/0006-github-session-requests-go-through-gidgethub.md, and the proposal section of this issue.

  7. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 5, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 5, 2026
  9. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-05 19:48 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/highpriority/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