Skip to content

perf(roadmap): the project review keeps its own listing snapshot #6603

Closed

Description

@dan-petty

Problem

A first 7-day project review with no intake snapshot sends 49 GitHub requests (PR #6586). The limit of #4692 for a 7-day collection is 45 requests.

The listing reader of the review (_ReviewListing in src/devops_cli/roadmap/project_review/readers.py) reads the snapshot that intake keeps. With no such snapshot, it reads each issue and pull request that changed at or after the window start. The review writes no snapshot, so each review with no intake snapshot reads the whole window again.

Scope

Acceptance criteria

  • Test first: a test shows that a second review over a new window reads only the gap pages. The test fails on the base.
  • A test: a 7-day review with no intake snapshot stays at or under 45 GitHub requests.

Dependencies

Source

Source: #6586

Alternatives check of 2026-11-21: not-applicable.
Class: perf, no search.
Tool: none found.

Proposed design

Problem statement

A 7-day project review with no intake snapshot sends 49 GitHub requests. The limit of #4692 for a 7-day collection is 45 requests. The review reads the snapshot that intake keeps and writes no snapshot, so each review reads the whole window again. A snapshot with an old watermark also makes the review read more pages than the window needs. The review reads about 25 run pages. This change gives the review its own snapshot, reads the gap from the later of its watermark and the window start, and reads the run counts with one request for each status.

Acceptance criteria

Requirement: Review snapshot store

The project review SHALL write its listing snapshot to a store that only the review writes.

Scenario: A review writes the review snapshot

  • WHEN A test runs one review over a 7-day window with an empty review store and an empty intake store.
  • THEN The review store holds one snapshot for the repository with the schema key LISTING_SCHEMA_KEY, and the intake store holds no file.

Requirement: Gap read from the review watermark

The project review SHALL read only the issues and pull requests changed at or after the watermark of its own snapshot.

Scenario: A second review over a new window reads only the gap pages

  • WHEN A test runs a review over a 7-day window that starts after the watermark of the review snapshot, and runs the same review with an empty review store.
  • THEN The listing count of the first run is lower than the listing count of the run with the empty store, and its first listing request names since=<watermark>.

Requirement: Gap start at the window start

The project review SHALL read the gap from the window start when the watermark of its snapshot is before the window start.

Scenario: A stale review snapshot reads from the window start

  • WHEN A test runs a review over a 7-day window with a review snapshot whose watermark is 3 weeks before the window start, and runs the same review with an empty review store.
  • THEN The listing count of the first run equals the listing count of the run with the empty store, and each listing request names a since at or after the window start.

Requirement: Second 7-day review under the request limit

A 7-day project review MUST send at most 45 GitHub requests when the review snapshot exists and the intake snapshot does not.

Scenario: A second 7-day review stays under 45 requests

  • WHEN A test runs a 7-day review with the review snapshot of the previous review and no intake snapshot, and sums the counts of Reads.
  • THEN The sum of the counts in Reads.counts is at most 45.

Requirement: First 7-day review under the request limit

A 7-day project review MUST send at most 45 GitHub requests when no snapshot of any kind exists.

Scenario: A first 7-day review stays under 45 requests

  • WHEN A test runs a 7-day review with an empty review store and an empty intake store, and sums the counts of Reads.
  • THEN The sum of the counts in Reads.counts is at most 45.

Requirement: Run counts with one request for each status

The project review SHALL read the count of the Actions runs of each status with one GitHub request.

Scenario: The review reads the run counts of a window

  • WHEN A test runs a review over a window whose runs number more than the result cap, and counts the github_runs reads.
  • THEN The github_runs count is at most 5.

Requirement: One writer for each snapshot file

The project review MUST NOT write the snapshot file that intake writes.

Scenario: A review leaves the intake snapshot unchanged

  • WHEN A test runs a review with an intake snapshot that holds a record of an older schema key.
  • THEN The intake snapshot file is byte-identical after the review, and the review store holds a new snapshot.

Requirement: Snapshot of another schema

The project review MUST read the whole window when its own snapshot has a schema key other than LISTING_SCHEMA_KEY.

Scenario: A review snapshot of an older schema is replaced

  • WHEN A test runs a review with a review snapshot whose schema_key is not LISTING_SCHEMA_KEY.
  • THEN Each listing request names a since at or after start, and the review store holds a snapshot with LISTING_SCHEMA_KEY.

Existing Tool Considered

The alternatives check of 2026-11-21 in the issue body gives not-applicable with no tool, for the class perf with no search (see the block). No open, maintained tool or library covers a GitHub issue-listing snapshot with a watermark. The change reuses the project's SnapshotStore and IncrementalListing in src/devops_cli/roadmap/stores/listing_snapshot.py, so it builds no snapshot code of its own. It adds a review store directory, one save call, the clamp of the gap start and the read of the run counts: about 40 lines of code, about 80 lines of test, about 15,000 tokens to build, keep and fix, and about 3 hours of elapsed time.

Key questions

  • Does the project review write the snapshot that intake keeps?: No. _ReviewListing.read loads the snapshot, merges the changed records and returns them. It calls no save, and the docstring of the module states that the review never writes a snapshot. [sources: src/devops_cli/roadmap/project_review/readers.py:97, src/devops_cli/roadmap/project_review/readers.py:110]
  • Where does the project review keep its listing snapshot?: In a FileSnapshotStore under listing-review in the roadmap state directory. The review reads its own store and the intake store, and writes only its own store. (best practice) [sources: src/devops_cli/roadmap/stores/listing_snapshot.py, src/devops_cli/roadmap/project_review/readers.py:97]
  • Which watermark does the review write after a read?: The earlier of the read start and the newest updated_at read, less the overlap. IncrementalListing._keep does the same. The read starts at the window end, so the next gap is the time since the last review. (best practice) [sources: src/devops_cli/roadmap/stores/listing_snapshot.py]
    • Chosen: The earlier of the read start and the newest change, less the overlap. A record changed during the read is at or after the watermark, so the next read gets it.
    • Rejected: The window start. The next gap would cover the whole window again, and the snapshot would save nothing.
    • Rejected: The window end with no overlap. A local clock ahead of GitHub's would skip a change at the boundary.
  • Which gap start does the review read when the snapshot watermark is older than the window?: The later of the watermark and the window start. The held records cover the time before the watermark, so the read from the window start leaves no hole. (best practice) [sources: src/devops_cli/roadmap/project_review/readers.py:110, src/devops_cli/roadmap/stores/listing_snapshot.py:69]
    • Chosen: The later of the watermark and the window start. A 3-week-old watermark reads 40 listing pages for a 7-day window. The window start reads 19.
    • Rejected: The watermark alone. A stale watermark reads about 70 requests for a 7-day window.
    • Rejected: The window start alone. Each review would read the whole window again.
  • Which snapshot does the review read when its own store is empty?: Its own store first, then the intake store, then the whole window. The review writes only its own store. (best practice) [sources: src/devops_cli/roadmap/project_review/readers.py:110, src/devops_cli/roadmap/stores/listing_snapshot.py]
    • Chosen: Own store, then intake store, then the window. The review keeps the intake reuse and adds its own snapshot.
    • Rejected: Own store only. A repository with an intake snapshot and no review snapshot would read the whole window once more.
    • Rejected: Intake store only. The review writes no snapshot, so each review reads the whole window again.
  • How does the first review, with no snapshot of any kind, stay at or under 45 requests?: It reads the count of the Actions runs of each status with per_page=1, in 4 requests in place of about 25 run pages. The reply on this issue measures 2,072 runs as success 1,927, failure 29, cancelled 104 and in_progress 12. (best practice) [sources: src/devops_cli/roadmap/project_review/readers.py]
    • Chosen: One count request for each status with per_page=1. total_count is exact above the cap of 1,000, and 4 requests replace about 25.
    • Rejected: Keep the per-run pages and the split read. About 25 run pages leave no room under 45 for a 19-page listing.
    • Rejected: One total count with no status filter. It gives no count for each status.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4692

Activity

  1. added
    type/infra
    source/agent
    scope/roadmap
    on Nov 21, 2026
  2. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. The review exceeds the 45-request budget for a 7-day window, causing performance degradation.
    • Related: feat(roadmap): read project review facts through a catalog #4692, which asks for a different change. Both items change how the project review reads data, but #4692 adds a catalog for facts while this item adds a snapshot file so the review reads only the gap.
  3. added
    status/new
    value/medium
    effort/medium
    priority/p1-high
    on Nov 21, 2026
  4. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    Two more budget points from the second review of PR #6586. Both are on main (752c6ed), in src/devops_cli/roadmap/project_review/readers.py. Point 1 is necessary for the first review, which has no snapshot of its own: with the listing at 19 pages, 5 + 25 more requests give 49.

    1. The main push runs use about half of the requests: 24 to 25 of the 48 to 49 of a 7-day review. read_runs reads each run page, and it discards and reads again a slice whose first page has more than 1,000 runs (2 discarded pages in the 7-day run). total_count is exact also above the cap of 1,000 (2,072 = 750 + 598 + 724), and per_page=1 with a status filter gives one count in one request (success 1,927, failure 29, cancelled 104, in_progress 12, sum 2,072). If the run facts need only the counts, about 4 requests replace about 25.
    2. With a snapshot whose watermark is before the window start, _ReviewListing.read reads the gap from the watermark, not from the start. A watermark 3 weeks old reads 40 listing pages for a 7-day window (about 70 requests), but no snapshot gives 19 pages. The fix: read from the later of the watermark and the window start.

    Measured: --last 7d sent 48 requests in 110.8 s. The 7 days to 2026-11-11T14:51:23Z sent 60 (listing 34). A 1-day window on 2026-10-15 sent 64 (listing 54).

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

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. added
    owner/service
    on Nov 21, 2026
  9. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Plan state: branch perf/6603-the-project-review-keeps-its-own, draft pull request #6619. The pull request plans the item and closes no issue. The stage job and the step fix-plan edit this comment, and a comment of each run tells what the run did.

    The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:

    1. Keep the review's own listing snapshot: 37696 tokens
    2. Count the runs of each status with one request: 50847 tokens
    3. Remove the unused runs result cap: 31804 tokens
    4. Describe the review snapshot and the run counts: 18121 tokens
  10. 18 remaining items

  11. added
    status/in-progress
    status/in-review
    and removed
    status/in-progress
    on Nov 21, 2026
  12. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    The draft pull request #6716 holds the final title and body. In mode on of roadmap.fix_checks.mode, the watch row marks it ready when its checks pass, and a fix-checks Job repairs a failed check whose name gives the class test, lint or types. In each other case the watch row stops the item: another failed check, a cancelled check, a conflict, a fix-checks Job that ended with no repair, or another mode.

    Spend: 279 model requests, 28236249 input tokens, 153118 output tokens.

  13. removed
    owner/service
    on Nov 22, 2026
  14. added
    owner/agent
    on Nov 22, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 22, 2026
  16. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor
  17. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-22 02:54 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/roadmapsource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions