#636

feat(github-prs): share the counts and the pooled pull-request list across panes

Openwiiiimmwants to merge intofrom

Fixes OPS-287 · Part of OPS-282

Summary

Several github-prs panes on one machine now make one list pass and one set of counts per refresh between them, through tc::readings (take / Ticket), in the widget's own store github-prs.sqlite.

  • Four readings, keyed by host plus a hash, with the token only as the fingerprint part:
    • ghprs.who: the viewer and orgs. Held for an hour and not re-asked by r.
    • ghprs.merged and ghprs.created: keyed on a hash of the @mine scope.
    • ghprs.list: one reading for all sources, keyed on a hash of the searches as sent (source names, @mine expanded, command-line terms). The key leaves out limit.
  • Leases. lease_for is 60 s (curl's 45 s plus a margin). It is renewed before every org page, every search request (including each smaller retry inside fetch_round) and every enrichment chunk. If another pane took the lease over, the pass ends with TAKEN_OVER and publishes nothing.
  • Counts. Both are claimed on the poller thread. Only the HTTP runs on the count threads, and both are published after the join. spawn_count, count_outcome and record_count_err are unchanged. A ticket borrows its cache, so holding two at once needs two caches: the arrival counts live in a second Cache (its own connection to the same file). This needed no core change.
  • The list reading carries prs, the per-source counted, served, deepened and the budget. Every pane settles it with the same settle(), so total, capped, served and stopped match the fetching pane exactly. The source filter, text filter, sort and stats toggle stay per pane.
  • Rate limit. graphql() now uses tc::post_answer and keeps the headers. github-prs has its own parse.rs (parse_rate_headers, classify_rate, header_block, rate_reason) with tests, including the case of a 200 with x-ratelimit-remaining: 0. A spent or secondary limit is recorded once per process. The poller shuts the graphql gate until x-ratelimit-reset. Each pane checks gate before asking, and a gate another pane shut also stops this pane's detail fetch.
  • Refusals. The 502/503/504 retries stay inside the fetch. A pass that still fails is Ticket::refused for one refresh, or until the reset when the budget ran out, so N panes make one retry, not N. The last good list stays on screen with the reason.
  • Freshness line. One line under the status line, drawn with tc::readings::sharing_rows. A pane started during another pane's first pass says no list yet · pane N asking now. The counts' provenance is left out while the stats are hidden. updated … ago is now the newest of the list and counts readings on screen, whichever pane fetched them.
  • One behaviour change in the fetching pane. A pane that already shows a finished list keeps it during its own pass, as the panes waiting on it do. Before, it shrank to the first page and regrew every refresh. A fresh pane puts up the stored list (stale or not) before it starts paging.
  • share_readings (default on) is added to settings.json, and config.example.json is regenerated. The README, help and CONFIGURE say that PR titles, authors, branches and repo names are stored 0600 and forgotten after 2 hours.
  • Caps: forget_after 2 h, max_value 4 MiB, max_pages 8192. Measured, 723 PRs stored as 469 KB, about 0.65 KB per PR. So 4 MiB holds about 7,000 PRs, against about 3,000 at the 2 MB default. The store keeps the value and the last good value side by side, so the file cap is doubled (32 MiB, vacuum at 16 MiB). A larger list stays with the pane that fetched it, and its line says too large to share.

Out of scope, as briefed: partial publishes during a long pass, and the detail view.

Evidence

  • cargo test --workspace --all-targets is green, including widgets/tests/check.rs. cargo build --workspace --bins and cargo clippy on github-prs are clean.
  • New tests:
    • two_panes_with_the_same_sources_make_one_list_pass: a second pane during the first one's pass shows the previous list and pane 41 asking now, then takes the published list without a request.
    • a_list_too_large_to_share_says_so_on_screen
    • a_refused_pass_is_held_for_every_pane_with_the_last_good_list
    • a_spent_limit_stops_every_pane_until_the_reset
    • a_shared_list_settles_exactly_as_the_pane_that_fetched_it
    • the_list_key_is_the_searches_and_not_the_page_size_or_the_token
    • counts_read_back_from_a_shared_reading_and_never_invent_a_day
    • the_counts_line_is_left_out_when_the_stats_are_hidden
    • a_pass_keeps_a_finished_list_on_screen_until_it_finishes
    • The parse.rs header tests.
  • Live, two panes in ptys with a real token, on a board of 723 PRs across 10 accounts, where one list pass takes about 3 minutes:
    • Only one pane ever paged the list. The other said no list yet · pane <pid> asking now on the first run. On later runs it said cached 10m ago · pane <pid> asking now over the full 723-PR list while the first pane paged.
    • After a pass landed, the other pane said fetched 1m ago by pane <pid>.
    • Counts were refreshed by whichever pane was free while the other paged.
    • github-prs.sqlite is mode 0600. It has the 4 rows and does not contain the token.
  • Not exercised live: a spent rate limit, which would mean exhausting the budget. The parser and gate tests cover it.
  • macOS: no Mac was available. The hosted macos CI job is the check.

Merge Danger

Low to medium. The change is contained to github-prs and makes no core change. The poller now ticks every FOLLOW_EVERY (5 s) rather than sleeping a whole refresh. Fetching is still gated by each reading's TTL (= refresh), so the request rate per machine goes down, not up. A pane on an older build shares nothing with this one: it has no store.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Activity

36
linear-code[bot]11d ago
coderabbitai[bot]11d ago

WARNING

Review limit reached

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 84 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64bcc533-3518-4326-ab07-133ac988ae85
Commits

Reviewing files that changed from the base of the PR and between 84181df46090bbf2dd908ce7752d771e00469edc and 60de3bfec5234f5a86f6a38f5ad0f0fa5bbad4f0.

Files selected for processing: 7

  • config.example.json
  • widgets/src/widgets/github-prs/CONFIGURE.md
  • widgets/src/widgets/github-prs/README.md
  • widgets/src/widgets/github-prs/help.txt
  • widgets/src/widgets/github-prs/main.rs
  • widgets/src/widgets/github-prs/parse.rs
  • widgets/src/widgets/github-prs/settings.json

Summary by CodeRabbit

  • New Features
    • Pull-request lists and counts can now be shared across panes on the same machine. Sharing is on by default and can be disabled per pane.
    • A completed list stays visible while a refresh runs, and new results appear as they arrive.
    • Panes show when another pane is fetching and can share rate-limit handling.
  • Documentation
    • Updated setup and help information to explain sharing, stored data and its two-hour retention period.

Walkthrough

The github-prs widget now shares pull-request lists and counts between panes. It coordinates fetch leases and rate-limit stops, retains completed lists during refreshes, and displays reading provenance. The settings, help text, and README describe sharing and its opt-out.

Changes

Shared GitHub PR readings

Layer / File(s)Summary
Rate-limit response handling
widgets/src/widgets/github-prs/parse.rs, widgets/src/widgets/github-prs/main.rs
The new parser classifies rate-limit headers and responses. GraphQL requests inspect response status and headers, record rate data, and refuse requests while a rate-limit stop is active.
Lease-aware reading fetches
widgets/src/widgets/github-prs/main.rs
Fetch functions return serialisable readings. Owner discovery, list paging, and enrichment renew their leases and stop when another pane takes over.
Shared polling and presentation
widgets/src/widgets/github-prs/main.rs, widgets/src/widgets/github-prs/settings.json, config.example.json, widgets/src/widgets/github-prs/CONFIGURE.md, widgets/src/widgets/github-prs/README.md, widgets/src/widgets/github-prs/help.txt
The poller follows and applies shared readings for panes. The widget displays reading provenance and preserves completed lists during refreshes. The configuration and documentation describe the sharing setting, stored data, and opt-out.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Pane as github-prs pane
  participant Poller
  participant Store as shared readings store
  participant GitHub as GitHub GraphQL
  participant Renderer
  Pane->>Poller: request a refresh
  Poller->>Store: follow cached readings and fetch leases
  Poller->>GitHub: fetch stale readings while holding the lease
  GitHub-->>Poller: return list, counts, and rate data
  Poller->>Store: apply readings and provenance
  Poller->>Renderer: provide shared state and freshness

Possibly related issues

  • Issue 630 asks for shared API readings across panes, including github-prs readings, rate-limit records, and a freshness line. This PR implements the github-prs portion.
  • Issue 635 asks for github-prs panes to share token identity, counts, the pull-request list, rate-limit data, and a freshness row. This PR covers those github-prs objectives.

Possibly related PRs

Merge Risk: Moderate · previous review 84181

Panes now share pull-request lists, counts and rate-limit stops. However, when one GitHub account or host spends its GraphQL budget, panes using a different account or host are also stopped until the reset time. In addition, stored pull-request titles can outlive the documented two-hour limit once every pane has closed. A few smaller refresh and gating inconsistencies remain. Fix the per-identity rate-limit gate before merging; the other issues are bounded.

Security architecture risk: Low · up to 84181

Sharing is isolated by host, credential and search scope, and lease checks protect against stale shared writes. Two limited risks remain: private pull-request metadata can outlive the advertised two-hour retention period, and one account or server’s rate limit can pause unrelated panes using the same local store.

Retained concerns

  • Low · security · observed: The newly persisted pull-request metadata does not have the advertised two-hour lifetime. Expiration runs during publication, not merely as time passes or when sharing is disabled. Refusals also republish the previous good list with a new row timestamp, so repeated failures can retain old titles beyond two hours even while other writes continue. Closing the panes or disabling sharing leaves the existing file behind. Owner-only file creation limits access, but does not enforce the new privacy lifecycle promise.
  • Low · reliability · observed: The new shared rate gate crosses otherwise separate host and credential scopes. Every sharing pane uses github-prs.sqlite and gate/graphql, although its readings are identity-scoped. A quota exhaustion on one credential or enterprise server therefore suppresses requests from panes with an independent budget. This introduces cross-identity availability coupling absent from the base. The reach is limited to sharing panes using the same user’s state directory.
Security review details

Security Blast Radius

  • inferred — The introduced exposure is principally local metadata retention and shared widget availability. Reading-key isolation separates credentials and searches, but the gate can affect every sharing github-prs pane using the same state directory, including panes configured for another host.

Security Findings and Attack Paths

  • observed — The supported privacy failure requires no malicious response: a successful list followed by repeated refusals carries old metadata forward under newer timestamps. Stopping all publishers also leaves cleanup dormant. This extends the lifetime of the newly introduced on-disk copy; it does not establish access by another user.

Trust Boundaries and Controls

  • observed — Rate-control inputs are response headers from the configured GitHub API, not pull-request titles or descriptions. They flow through classification into the process stop and shared gate. Ordinary content authors were not shown to control these headers; malicious header injection would require control over the responding endpoint or transport.

Resilience and Maintainability Implications

  • observed — Failed check enrichment marks checks unknown rather than treating missing results as successful CI. Combined with lease-loss termination and fenced shared publication, this preserves important uncertainty and ownership controls during partial failure.

Hardening Proposals

  • proposed — Separate sensitive-value expiration from refusal and gate lifetime, including a defined cleanup policy when sharing stops. Scope rate gates by API host and applicable quota identity; a bounded deadline policy would further contain erroneous server responses.
Pre-merge checks: 4

Check nameStatusExplanation
Title checkThe title names the feature and its scope: sharing pull-request counts and the pooled list across github-prs panes. This matches the changeset, which adds shared readings, leases, and counts coordinat…
Description checkThe description states the purpose: several github-prs panes make one list pass and one set of counts per refresh through tc::readings. It also covers the four readings, leases, rate-limit handling, t…
Linked Issues checkCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkCheck skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the feature and its scope: sharing pull-request counts and the pooled list across github-prs panes. This matches the changeset, which adds shared readings, leases, and counts coordination for github-prs panes.

Full details: Description check

Explanation

The description states the purpose: several github-prs panes make one list pass and one set of counts per refresh through tc::readings. It also covers the four readings, leases, rate-limit handling, the freshness line, the share_readings setting, storage caps, and the tests. This matches the changeset files.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the list at dawn,
While panes share readings as they run.
The counts arrive, the leases renew,
Rate-limit waits are noted too.
A fresh line shows what each pane can see.
Then carrots celebrate the sync.

chatgpt-codex-connector[bot]11d ago
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

ReviewStatusCommitReview trigger
📝 Code Review✅ Completed 2026-11-18T03:07:52.151585Z60de3bfManual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]reviewed11d ago
chatgpt-codex-connector[bot]11d ago

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84181df460

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chatgpt-codex-connector[bot]reviewed11d ago
chatgpt-codex-connector[bot]reviewed11d ago
coderabbitai[bot]reviewed11d ago
coderabbitai[bot]reviewed11d ago
coderabbitai[bot]reviewed11d ago
wiiiimmreviewed11d ago
wiiiimmreviewed11d ago
chatgpt-codex-connector[bot]reviewed11d ago
chatgpt-codex-connector[bot]reviewed11d ago
chatgpt-codex-connector[bot]11d ago

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55c0592c1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

coderabbitai[bot]reviewed11d ago
coderabbitai[bot]reviewed11d ago
wiiiimmreviewed11d ago
wiiiimmreviewed11d ago
wiiiimm11d ago

@codex review

chatgpt-codex-connector[bot]11d ago

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 60de3bfec5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".