#634

feat(github): share identity, calendar, board totals, day counts and landed timing across panes

Openwiiiimmwants to merge intofrom

Fixes OPS-288 · Fixes OPS-289 · Part of OPS-282

Summary

Several github panes on one machine now share five readings through tc::readings, in a store file of their own (~/.local/state/opscope/github.sqlite, 0600):

  • gh.who: who the token belongs to. Key: host, with the token as a fingerprint. Held 6 h, and r does not re-ask it.
  • gh.calendar: the contribution calendar. Key: host and token. It does not depend on the window, so panes on different windows share it.
  • gh.board: every account's aggregates (the 8-alias build_query per account) as one reading. Key: host, a fingerprint of the sorted accounts, the window in days, today's date, and the token. One reading, so every account is counted against the same pinned rolling_now. A failed account is stored inside it as {"failed": why}. On every pane it is named in the error line and loses its 24h pair; it never lands as zeros. An account missing from the reading is treated the same way.
  • gh.days (OPS-289): one account's per-day counts, as one map of day → [merged, created] for every window. Key: host, account, token. Held for the pane's refresh. The pane that wins the lease reads only the days the map has never held plus the trailing FRESH_DAYS (2), and merges them into the stored map. So a second pane on a 90-day window makes no day-count requests when the first already has them, and a narrower window is free. A fresh map that cannot draw a pane's window (a wider window, or a new day after midnight) is claimed again for just the missing days.
  • gh.timing (OPS-289): one account's merged-PR timing (R24 / T2D) per window. Key: host, account, window days, token. It stays good while the merged count it was read for still matches the board's count, not on a timer. When the count moves, it is claimed again, so it is fetched once per change in the count across all panes. A reading where a request failed (retry) is asked for again after a refresh, as before. The 6 h hold is only a ceiling. A timing the account's own screen read is recorded into the store, not fetched again.

How the code is laid out:

  • one_pass runs the shared part on every FOLLOW_EVERY (5 s) tick. It calls take for who, calendar and board. Then day_counts and merged_timing each make one claim_many, fetch what they won, and make one answer_many. Before a request they call renew_all once a third of the lease has gone, so a long pass keeps all its leases. A map or timing the pane has not finished is given back with release. If another pane takes a lease over mid-fetch, this pane drops its answer.
  • r: the pane that pressed it records a clear request (gh.clear, host and token) in the store. Whichever pane next wins each day map's lease rebuilds that map from nothing. A map read in the last 30 s is not rebuilt until it is older (ASKED_FLOOR). r also still re-asks every reading older than the floor in the pane that pressed it.
  • The pane that fetches still fills its own rows account by account. The store hears the whole pass in one commit.
  • Out of scope, as the issue says: the oldest-PR lookup (fetch_oldest) stays per pane. So does the org discovery for an empty accounts.
  • A board cut short by the rate limit is refused until GitHub's reset, not shared. A board cut short because another pane took the lease over is dropped, and the other pane's board is the one shown.
  • Rate limit: graphql uses post_answer, so it sees a refusal's status and headers. parse::parse_rate_headers and parse::parse_rate_spent are always compiled and tested. A spent budget ends in shut on a gate for that host and token, and every github pane on them stops until the reset. The pane says GitHub's rate limit is spent · next ask in 41m.
  • "updated … ago" is the newest taken_at among the readings on screen. The freshness line comes from tc::readings::sharing_rows and now covers the day maps as well as the calendar and board. Timing is left off it on purpose: it is valid by count, so its age says nothing about staleness and would only make the line read hours old.
  • New setting share_readings, on by default. config.example.json is regenerated. README, help, CONFIGURE and the settings text say what is shared.
  • The store keeps account and org names, counts and timing figures. It never stores a token or a PR title. It uses the default Caps.
  • Core: one small change in core/src/readings/store.rs. An existing store file is reset to 0600 when it is opened, and a test covers it. OPS-289 made no further core change.

Evidence

  • cargo test from the root: all green, including check.rs.
  • OPS-289 tests (two panes on one temporary store, with a local stand-in for GitHub that counts requests):
    • a_second_pane_on_a_ninety_day_window_asks_for_no_day_counts: the first pane makes 5 chunked requests. The second pane on 90 days, and a third on 14 days, make none. The second pane's provenance names the first pane.
    • a_stale_map_asks_again_for_only_the_trailing_days: the single request carries m0/m1 and no m2. Both panes then draw the merged map.
    • an_r_in_one_pane_is_honoured_by_the_pane_that_holds_the_lease: pane B records the clear. Pane A rebuilds the map in one request, and neither pane asks again.
    • an_r_inside_the_floor_waits_rather_than_asking
    • timing_is_asked_once_per_merged_count_between_panes: one request for count 3 across both panes. One more when the count moves to 4, made by whichever pane asks first. Another window is another reading.
    • a_timing_the_detail_screen_read_is_shared_not_asked_again
    • day_count_chunks_stop_when_the_first_answer_spends_the_rate_limit, moved onto the new pass.
    • parse.rs: round trips for the stored day map and timing.
    • Mutation checks: if timing ignores the merged count, the timing test fails. If a clear request is ignored, the r test fails.
  • OPS-288 tests: two_panes_on_one_window_share_one_board_and_its_failures, panes_on_different_windows_still_share_who_and_the_calendar, a_refused_reading_does_not_land_and_an_absent_account_is_not_zero, a_pane_alone_says_why_on_the_freshness_line, and four parse_rate_* tests.
  • Live two-pane run against a real token: 10 discovered accounts, an 18-day window, release build, isolated XDG_STATE_HOME. Pane B started 100 s after pane A. I counted requests from the curl configs each pane wrote:
    • Day counts across both panes came to one request per account per refresh, split between the panes. B's first minute asked for only the 2 maps that had gone stale, not 10.
    • Timing was fetched once, by A, for all 10 accounts. Every gh.timing row stayed at A's first taken_at for the whole run, because no merged count moved.
    • During A's own first pass (day counts and timing) its freshness line stayed empty. The cached 1m ago that #658 showed during a pane's own long day-count pass is gone.
    • The line still reads cached 2m ago · pane N asking now for the few seconds the other pane spends refreshing the trailing days. That is accurate.
  • Store writes, one pane, nothing changing (disk.py 150 600 110 50): about 8 MiB/hour (4.1 MiB to github.sqlite plus 4.2 MiB to its journal). The OPS-288-only build (c3b735b), run beside it at the same time, measured 8.0 MiB/hour, so sharing two more readings adds nothing measurable. A first version of this work measured 20 MiB/hour: a lease renew before every request was most of the writing. Renews now happen only once a third of the 45 s lease is gone (Renewal), which still covers a request's 30 s timeout. That applies to the board pass too.
  • macOS: no Mac was available. The hosted macos CI job is the check. Nothing here is behind a cfg.

Merge Danger

  • Medium. This is the largest of the set. one_pass is split into the shared board pass and two shared batch passes. The poller wakes every 5 s, and a tick with nothing stale makes no request and no store write. Day counts and timing are now asked on whichever tick finds them stale, not only on this pane's full refresh pass.
  • r now rebuilds the day maps in every pane on the token, not only in the pane that pressed it. That is the point of OPS-289, but it costs a full window of day requests, at most once per 30 s.
  • A long timing walk (a merged count change on a busy account) still blocks the pane doing it. Only that pane is blocked; the others show · pane N asking now.
  • Each new reading has its own key, so builds without sharing are not affected.

Activity

66
coderabbitai[bot]11d ago

NOTE

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

  • Last reviewed commit: 37fa29bd9ee936a0e2c923b81454301c6a8cc0c0
  • Latest commit, not reviewed: b349c23a7906ebd8a9038a46644a3d6a7ab3d94b

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

Summary by CodeRabbit

  • New Features
    • GitHub panes can share account identity, contribution calendars, board totals, daily counts and merged pull-request timing.
    • The widget reports reading freshness, sharing status and rate-limit waits. Shared rate limits can pause requests across panes.
    • Sharing is enabled by default and can be disabled per pane. Shared readings are stored locally with restricted file permissions and cleaned up when stale.
    • Pressing r rebuilds daily counts across panes.
  • Bug Fixes
    • Failed account readings are reported instead of appearing as zero counts. Failed daily-count refreshes are identified, and affected accounts are excluded from the chart.
    • If another pane takes over a reading, the widget follows the replacement reading.
  • Documentation
    • GitHub guides describe shared readings, local storage, refresh behaviour, status messages and rate limits.

Walkthrough

The GitHub widget now shares identity, contribution calendars, board totals, day counts and merged-PR timing between panes. It coordinates fetches through shared leases and rate-limit state. The widget displays reading provenance and wait status, and provides a setting to disable sharing.

Changes

GitHub shared readings

Layer / File(s)Summary
Lease outcomes and store permissions
core/src/readings.rs, core/src/readings/store.rs
Lease results now distinguish extended, held, busy and lost outcomes. Publishing restores prior local state and follows the successor reading after takeover. Reopening an existing store file sets its mode to 0600.
Shared data and rate-limit handling
widgets/src/widgets/github/parse.rs, widgets/src/widgets/github/main.rs
The widget serializes day-count and timing readings and parses rate-limit headers. GraphQL requests update shared rate state. Timing walks stop or retain partial results when rate limits apply or lease ownership changes.
Shared polling and fetch coordination
widgets/src/widgets/github/main.rs
The poller claims, publishes and follows shared identity, calendar, board, day-count and timing readings. It tracks failed readings and partial results without converting failures to zero values.
Settings, status and documentation
config.example.json, widgets/src/widgets/github/settings.json, widgets/src/widgets/github/CONFIGURE.md, widgets/src/widgets/github/README.md, widgets/src/widgets/github/help.txt, widgets/src/widgets/github/main.rs
The share_readings setting defaults to enabled. The widget displays reading provenance and rate-limit wait information. Documentation describes sharing scope, stored data, expiry and refresh behaviour.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant GitHubPoller
  participant ReadingsStore
  participant GitHubGraphQL
  participant WidgetState
  GitHubPoller->>ReadingsStore: Follow or claim readings
  ReadingsStore-->>GitHubPoller: Return available readings
  GitHubPoller->>GitHubGraphQL: Fetch readings not available in the store
  GitHubGraphQL-->>GitHubPoller: Return response and rate-limit headers
  GitHubPoller->>ReadingsStore: Publish successful readings
  GitHubPoller->>WidgetState: Apply readings and fetch status

Possibly related issues

Possibly related PRs

Suggested reviewers: greptile-apps

Merge Risk: Low · previous review 37fa2

Panes now share GitHub readings and respect a shared rate-limit pause. A few narrow gaps remain: a detail timing fetch can send extra requests after another pane hits the limit, partial day-count progress is discarded when a rate-limit stop interrupts a refresh, and the "updated" time can lag behind newer shared timing. These cost extra requests or a stale label, not data, so the change is reasonably safe to merge with follow-up.

Security architecture risk: Minimal · up to 37fa2

The change adds local persistence and coordination between panes, but the inspected paths preserve credential separation, owner-only file access and publication fencing. No introduced or worsened risk materially affecting security, failure containment or ownership was established.

Retained concerns No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The added persistent exposure is local GitHub identity, scope, contribution and aggregate-reading data shared by panes using the same state directory. Credential fingerprints prevent unintended cross-credential reuse, but are not access controls against another process already able to read the store as the same operating-system user.

Trust Boundaries and Controls

  • observed — The store is created with mode 0600 and existing files are now restricted to that mode before opening. Shared writes reject oversized payloads and payloads containing registered secrets of at least eight bytes, checking both raw and JSON-escaped forms; shorter strings are outside that filter.
  • observed — Claims are serialized in immediate transactions. Publication checks for another live holder and successor publications before writing, and lease release is holder-scoped. These controls fence late writers rather than relying only on the caller's renewal result.

Resilience and Maintainability Implications

  • observed — A non-busy renewal error stops sharing before returning the local-continuation Extended outcome. Subsequent single and batch answers update local memory but cannot write through the removed store handle. Ticket interruption releases an owned lease where possible; abandoned leases remain eligible for expiry-based takeover.
Pre-merge checks: 4

Check nameStatusExplanation
Title checkThe title names the main change: GitHub panes now share identity, contribution calendar, board totals, day counts and landed timing. The raw summary confirms cross-pane sharing of readings through a r…
Description checkThe description is closely related to the changeset. It describes the five shared readings (gh.who, gh.calendar, gh.board, gh.days, gh.timing), the share_readings setting, the 0600 store file, the rat…
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 main change: GitHub panes now share identity, contribution calendar, board totals, day counts and landed timing. The raw summary confirms cross-pane sharing of readings through a readings store, which matches. The title is long at 95 characters, but it is specific and on topic.

Full details: Description check

Explanation

The description is closely related to the changeset. It describes the five shared readings (gh.who, gh.calendar, gh.board, gh.days, gh.timing), the share_readings setting, the 0600 store file, the rate-limit gate, the freshness line, and the core store permission change. This matches the raw summary and the PR objectives.

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 board at dawn,
Shared counts arrive, then hop along.
A lease is held; a wait is shown,
Fresh readings cross panes of their own.
With carrots near, the charts look bright,
The rabbit rests until the next poll’s flight.

linear-code[bot]11d ago
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-18T06:23:50.002241Zb349c23New commits
ℹ️ 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: d6876413d3

ℹ️ 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
cursor[bot]reviewed11d ago
cursor[bot]reviewed11d ago
cursor[bot]reviewed11d ago
cursor[bot]reviewed11d ago
cursor[bot]reviewed11d ago
cursor[bot]reviewed11d ago
cursor[bot]reviewed11d ago
cursor[bot]reviewed11d ago
coderabbitai[bot]approved changes11d ago
chatgpt-codex-connector[bot]reviewed10d ago