Extend tc::readings with what the GitHub and Linear widgets need. A pass there is many requests and can take minutes, where agent-usage's is one request.
Context / problem
The stealth-factory/opscope#613 code has one 90 s lease for every reading, blocks the poller for up to 95 s while another pane fetches, and stops sharing for 10 minutes after one busy timeout. A version mismatch deletes the shared file while other panes still have it open. Each of these breaks or degrades once more widgets share a store. Part of stealth-factory/opscope#630.
Scope
In:
- A claim API that returns serve, fetch (with a lease guard), waiting (another pane is asking) or refused. The guard releases the lease when dropped, including on a panic.
- A lease length chosen per claim and renewed before each request of a long fetch.
- A non-blocking mode: while another pane fetches, keep showing the last reading.
- A busy store means "not this pass". Only a real error stops sharing.
- Keys built through one constructor that hashes credentials (SHA-256) and registers them with the secret guard in the same step. Tokens never appear in a key or a value.
- Publish reports when a value was too large or held a secret, so the pane can say it was not shared.
- A rate-limit record per widget: one refusal that covers every reading of that API until its reset time.
- Freshness and provenance: one wording in core, for example
fetched 2m ago by pane 48213,cached 7m ago · pane 48213 asking now,cached 7m ago · too many requests, next ask in 3m. It is wrapped to the pane and never squeezed onto the status line. - A follow step: the poller checks for another pane's newer reading every 5 s without network or row reads when nothing changed.
- Version policy: never delete a file for a version mismatch. New columns only ever add. A breaking change uses a new file name. Notice when the file was replaced, and reopen.
- Size caps per widget.
- One store file per widget, under
tc::state_dir(), mode 0600. docs/shared-readings.mdand a paragraph inwiki/making-a-widget.md.
Out:
- Moving any widget onto it beyond agent-usage.
Acceptance
- A pane that dies in the middle of a long fetch is taken over within one request's lease, not one whole pass.
- A busy store never stops sharing.
- Two binaries with compatible schemas share. Two with incompatible ones run side by side without either deleting the file.
- A value too large to share says so on screen.
- The provenance rows fit every width from 12 columns.
cargo testpasses on Linux and macOS, includingcheck.rs(pollers that die record why; notice ids are literal).
Agent notes
Proposed API sketch (Fable): Key::new(unit, shape, plain, secret), fingerprint(parts), Policy { ttl, ask_floor, lease_for, wait, askable }, Cache::open(namespace, share), begin_pass, ask, take(key, policy) -> Take::{Serve, Fetch(Ticket), Waiting, Refused}, Ticket::renew/publish/refuse, provenance, provenance_rows, gate/shut/budget. Keep agent-usage's closure form (held) built on take.
- Put a shape number in the key (
gha.runs/1:...) so an old and a new binary with different reading shapes use different rows. - Stamp
taken_atwhen the fetch ends (today it is the start, while the doc comment says the end). - Reserved refusal shape for new widgets:
{"opscope_refusal": {"why", "until"}}. - The "not sharing readings" wording: row or notice is an open question on stealth-factory/opscope#630.
OPS-284