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 byr.ghprs.mergedandghprs.created: keyed on a hash of the@minescope.ghprs.list: one reading for all sources, keyed on a hash of the searches as sent (source names,@mineexpanded, command-line terms). The key leaves outlimit.
- Leases.
lease_foris 60 s (curl's 45 s plus a margin). It is renewed before every org page, every search request (including each smaller retry insidefetch_round) and every enrichment chunk. If another pane took the lease over, the pass ends withTAKEN_OVERand 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_outcomeandrecord_count_errare unchanged. A ticket borrows its cache, so holding two at once needs two caches: the arrival counts live in a secondCache(its own connection to the same file). This needed no core change. - The list reading carries
prs, the per-sourcecounted,served,deepenedand the budget. Every pane settles it with the samesettle(), sototal,capped,servedandstoppedmatch the fetching pane exactly. The source filter, text filter, sort and stats toggle stay per pane. - Rate limit.
graphql()now usestc::post_answerand keeps the headers. github-prs has its ownparse.rs(parse_rate_headers,classify_rate,header_block,rate_reason) with tests, including the case of a 200 withx-ratelimit-remaining: 0. A spent or secondary limit is recorded once per process. The pollershuts thegraphqlgate untilx-ratelimit-reset. Each pane checksgatebefore 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 saysno list yet · pane N asking now. The counts' provenance is left out while the stats are hidden.updated … agois 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 tosettings.json, andconfig.example.jsonis 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_after2 h,max_value4 MiB,max_pages8192. 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 saystoo large to share.
Out of scope, as briefed: partial publishes during a long pass, and the detail view.
Evidence
cargo test --workspace --all-targetsis green, includingwidgets/tests/check.rs.cargo build --workspace --binsandcargo clippyongithub-prsare 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 andpane 41 asking now, then takes the published list without a request.a_list_too_large_to_share_says_so_on_screena_refused_pass_is_held_for_every_pane_with_the_last_good_lista_spent_limit_stops_every_pane_until_the_reseta_shared_list_settles_exactly_as_the_pane_that_fetched_itthe_list_key_is_the_searches_and_not_the_page_size_or_the_tokencounts_read_back_from_a_shared_reading_and_never_invent_a_daythe_counts_line_is_left_out_when_the_stats_are_hiddena_pass_keeps_a_finished_list_on_screen_until_it_finishes- The
parse.rsheader 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 nowon the first run. On later runs it saidcached 10m ago · pane <pid> asking nowover 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.sqliteis mode 0600. It has the 4 rows and does not contain the token.
- Only one pane ever paged the list. The other said
- 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
macosCI 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.
@codesmith-bot with what you need.
Activity
36WARNING
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.
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.
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.jsonwidgets/src/widgets/github-prs/CONFIGURE.mdwidgets/src/widgets/github-prs/README.mdwidgets/src/widgets/github-prs/help.txtwidgets/src/widgets/github-prs/main.rswidgets/src/widgets/github-prs/parse.rswidgets/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 freshnessPossibly 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
- stealth-factory/opscope#521: The github-prs code uses the Enterprise Cloud host-routing contract introduced by this PR.
- stealth-factory/opscope#657: This PR uses the shared readings lease and provenance behaviour that PR
#657changes.
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 name Status Explanation Title check 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 coordinat… Description check 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, t… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check 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.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
|---|---|---|---|
| 📝 Code Review | ✅ Completed 2026-11-18T03:07:52.151585Z | 60de3bf | Manual 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.
💡 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".
💡 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".
@codex review
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".
OPS-287
OPS-282