Skip to content

fix(roadmap): an unchanged refine item reads no comments #3667

Closed

Description

@dan-petty

Problem

Refine reads the comments of each item that waits, also when nothing changed on the item. These reads are the largest part of the Service GET requests. Evidence from #3497, in the window 2026-11-03T15:05Z to 2026-11-04T15:05Z:

  • The Service sent 39248 GitHub requests. 38179 of them were GET requests (97.3%).
  • Refine sent 7727 GET requests, 7069 of them in devops-cli. 7069 reads over 160 New items fit about 44 reads for each item. This is inferred, because the metric has no endpoint label.

The code at origin/main f6d57ec:

A conditional GET does not repair this cost. A page with no next link is not stored, so a single-page comment list never answers 304 (ADR 0006).

Expected

A refine round reads the comments of a waiting item only when its updated_at changed since refine last read them. The round keeps the other exits with no comment read: a closed blocker, a commit that changed a cited path, and an issue or file that a wait on a person names. So the job record keeps what these exits need, such as the time of the last refine comment and the text of the wait.

Acceptance criteria

  • A test: a refine round with no changed item makes no comment read.
  • A test: a closed blocker and a changed cited path still end a wait with no change of updated_at.
  • The docstring of src/devops_cli/roadmap/refine.py states the new cost.
  • After this change is live, sum(increase(devops_cli_github_requests_total{job="roadmap-service"}[24h])) is lower than the baseline of 39248 by a share that the plan states. This query gives the baseline at 2026-11-04T15:05Z. This criterion moved here from fix(service): the rows stop repeating reads that find no change #3497 because this part removes the largest cost. The plan states the other changes that are live at the time of the measure.

Existing tool considered

Item.updated_at covers the main cost, and the job record already holds the state of refine. hishel is a maintained HTTP cache for httpx, but it meets the same last-page rule, so it does not help. This change adds no library.

Related

Split from #3497, which holds the evidence. It holds criteria 2, 3, 4 and 10 of that issue.

Related: #3497, #2005, #3483, #1758, #3631, #3495

Source: #3497

Proposed design

Problem statement

Refine reads the comments of every waiting item in each round, even when the item did not change. These reads are the largest part of the Service GET requests. The change reads comments only when the item's updated_at changed, and it keeps the other wait exits from recorded state.

Acceptance criteria

Requirement: Unchanged item reads no comments

A refine round SHALL make no comment read for a waiting item whose updated_at equals the value recorded when refine last read its comments.

Scenario: Unchanged item skips the comment listing

  • WHEN A refine round considers a waiting item with an unchanged updated_at.
  • THEN The fake store records no comments_on call for that item.

Requirement: A reply still ends the wait

A refine round SHALL read comments and end a wait when updated_at differs from the recorded value and a reply follows refine's last comment.

Scenario: Changed item reads a reply

  • WHEN A waiting item has a different updated_at and a reply after refine's last comment.
  • THEN The round reads the comments and ends the wait.

Requirement: A closed blocker ends the wait with no comment read

A refine round SHALL end a wait on an unchanged item when every recorded blocker is closed, without reading the item's comments.

Scenario: Closed blocker ends the wait

  • WHEN A waiting item has an unchanged updated_at and every recorded blocker is closed.
  • THEN The round ends the wait and the fake store records no comments_on call.

Requirement: A changed cited path ends the wait with no comment read

A refine round SHALL end a wait on an unchanged item when a commit changed a recorded block path at or after the recorded time of refine's last comment, without reading the item's comments.

Scenario: Changed cited path ends the wait

  • WHEN A waiting item has an unchanged updated_at and a later commit changed a recorded block path.
  • THEN The round ends the wait and the fake store records no comments_on call.

Requirement: A named cause ends the wait with no comment read

A refine round SHALL end a wait on an unchanged item when the issue or file named in the recorded wait text ends, without reading the item's comments.

Scenario: Named cause ends the wait

  • WHEN A waiting item has an unchanged updated_at and the issue or file named in its recorded wait text is closed or changed.
  • THEN The round ends the wait and the fake store records no comments_on call.

Requirement: The job record holds the wait state

Refine SHALL record the item's updated_at after a comment read, the time of its last comment, and the text of its wait in the job record.

Scenario: Record holds the state for later rounds

  • WHEN Refine writes a wait on an item.
  • THEN The job record holds the item's updated_at, the time of the last refine comment, and the wait text.

Requirement: The docstring states the new cost

The module docstring of src/devops_cli/roadmap/refine.py SHALL state that an unchanged waiting item costs no comment read and one body read.

Scenario: Docstring states the cost

  • WHEN A test reads the module docstring.
  • THEN The docstring states that refine reads comments only when updated_at changes and states the remaining body read cost.

Existing Tool Considered

No alternatives check has run. Item.updated_at and the existing refine job record cover the need, and the change adds no library. hishel is an open, maintained HTTP cache for httpx, but it lacks the ability to cache a single-page comment list under ADR 0006: GitHub does not store a page with no next link, so the list never answers 304. The change builds no new library.

Key questions

  • How does an unchanged refine item avoid a comment read while a reply still ends its wait?: Record the item's updated_at when refine reads comments. Read comments again only when updated_at differs. A reply with a new updated_at still ends the wait. (best practice) [sources: src/devops_cli/roadmap/refine.py:1813, src/devops_cli/roadmap/refine.py:1701]
    • Chosen: Record the last comment read updated_at in the job record. The job record already holds refine state, and updated_at changes on a new comment.
    • Rejected: Use a conditional GET for the comment list. A single-page comment list is not stored, so it never answers 304 (ADR 0006).
    • Rejected: Read comments in every round. This keeps the largest part of the Service GET requests.
  • What state must the refine job record keep so a closed blocker, a changed cited path and a named cause end a wait without comments?: Keep the item's updated_at at the last comment read, the time of refine's last comment, and the text of the wait. These three values feed the exits that no longer read comments. (best practice) [sources: src/devops_cli/roadmap/refine.py:1723, src/devops_cli/roadmap/refine.py:1772, openspec/changes/archive/2026-10-24-2005-refine-block-paths/design.md:23, docs/adr/0001-github-is-the-roadmap-source.md]
    • Chosen: Store the watermark, last comment time and wait text. The three exits then need no comment read.
    • Rejected: Store only the comment read watermark. _cited_code_changed needs the last comment time and _named_cause_ended needs the wait text.
    • Rejected: Read comments to get the time and text. That keeps the cost that the change removes.
  • Where does refine keep this state?: In the hidden refine job record in the issue body, as ADR 0001 requires. [sources: docs/adr/0001-github-is-the-roadmap-source.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 5, 2026
  2. added
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/medium
    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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It removes the largest share of GET requests but does not break a feature or expose a security risk.
    • Value: High. It cuts the largest cost in the Service GET budget and lowers rate-limit pressure for all users.
    • Effort: Medium. It needs a new field in the job record, a conditional read in _still_waiting, updated docstrings, and two tests.
    • Related: perf(roadmap): a settled item costs no body read or model call until its text changes, with refine judging it from the listing it already read #1539, which asks for a different change. Both reduce refine API cost, but #1539 targets settled items and body or model reads while this candidate targets waiting items and comment reads.
  4. added
    priority/p2-medium
    on Nov 5, 2026
  5. added
    status/ready
    and removed
    status/new
    on Nov 6, 2026
  6. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

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

    Moved to new items: #3866.

  7. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 7, 2026
  8. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

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

    Question: the issue proposes the updated_at of the item as the mark for "comments read". Does that work, and what does refine still read?

    Answer: updated_at does not work as the mark. Every write to an issue moves it, the write of the job record and the comment of refine included (contract case test_every_write_to_an_issue_a_comment_included_moves_its_updated_at). A mark that holds the updated_at of the last read cannot match the value after the write that stores it, so each round would read again. The issue listing already carries comments, the count of comments (checked on 2026-11-07 with devops gh api repos/dan-petty/devops-cli/issues). Only a comment moves it, so the change keeps the intent of the issue with that count: refine reads the comments of a waiting item only when the count moved.

    What a waiting item still costs after the change (the answer to the review note of 2026-11-06, "check what is still read"):

    • No comment read and no body read while the count is the recorded one. The closed blocker, the changed cited path and the named issue or file use the record (refine.commented_at, refine.wait_refs).
    • One comment read after each new comment, also a comment that is no reply. The round then records the new count.
    • One comment read in each round for an item that refine set Ready and a person or the stage job set back to New, and for an item of an account that the jobs do not trust (it needs the notice marker). The module docstring says so.
    • One read for each blocker, cited path and named issue, once a round.

    Rule and code: AGENTS.md rule 3 (an open tool first: hishel meets the same rule of ADR 0006, so it does not help), src/devops_cli/roadmap/refine.py (_still_waiting), ADR 0001 (the record lives in the issue body). The measure of the drop of requests stays with #3866.

  9. removed
    status/in-progress
    owner/agent
    on Nov 7, 2026
  10. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 05:06 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/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions