Repository navigation
Move githubCache out of the durable state file into a quit-time sidecar - #7101
Conversation
Every PR/issue poll restamps fetchedAt even when nothing changed, which defeated the content-hash write guard by construction: ~100KB of refetchable 5-min-TTL cache rewrote the whole 1.6MB orca-data.json once per refresh cycle - the last remaining non-user-driven writer. The cache is now memory-only during the session (setGitHubCache no longer schedules a save; the durable payload and state hash both omit it) and is snapshotted best-effort to orca-github-cache.json at flush (quit/reload), so PR/issue badges still paint instantly on next launch. A legacy in-file cache is used as the seed and stripped by the next durable write; downgrades just recreate the key, which the next upgrade strips again. Sidecar loss costs nothing - the data is refetchable. Co-authored-by: Orca <[email protected]>
A corrupt-but-valid-JSON sidecar ({"pr":null}) would seed
state.githubCache.pr = null and crash mobile worktree.ps PR grouping
until the renderer's first cache save repaired it.
Co-authored-by: Orca <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe persistence layer now stores GitHub cache data ( Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Store
participant DurableStateFile as orca-data.json
participant SidecarFile as orca-github-cache.json
Caller->>Store: setGitHubCache(data)
Store->>Store: update in-memory githubCache
Store->>Store: set githubCacheDirty = true
Caller->>Store: flush()
Store->>Store: getDurableState() (excludes githubCache)
Store->>DurableStateFile: write durable payload (unchanged if only cache changed)
alt githubCacheDirty
Store->>SidecarFile: writeGithubCacheSnapshotSync() (tmp+rename)
Store->>Store: githubCacheDirty = false
end
Caller->>Store: new Store / load()
Store->>DurableStateFile: read state
alt legacy in-file githubCache present
Store->>Store: seed githubCache from legacy data, mark loadNeedsSave
else
Store->>SidecarFile: readGithubCacheSnapshot()
SidecarFile-->>Store: cache snapshot
Store->>Store: seed githubCache from sidecar
end
Related issues: None found. Related PRs: None found. Suggested labels: persistence, github-cache Suggested reviewers: None identified from the provided context. Poem: A rabbit hops with cache in paw, into a sidecar file it saw. The main state stays untouched and neat, while GitHub data finds its own seat. Flush by flush, atomic and light, the cache and state now sleep well at night. 🐇📁 ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ar (stablyai#7101) * Move githubCache out of the durable state file into a quit-time sidecar Every PR/issue poll restamps fetchedAt even when nothing changed, which defeated the content-hash write guard by construction: ~100KB of refetchable 5-min-TTL cache rewrote the whole 1.6MB orca-data.json once per refresh cycle - the last remaining non-user-driven writer. The cache is now memory-only during the session (setGitHubCache no longer schedules a save; the durable payload and state hash both omit it) and is snapshotted best-effort to orca-github-cache.json at flush (quit/reload), so PR/issue badges still paint instantly on next launch. A legacy in-file cache is used as the seed and stripped by the next durable write; downgrades just recreate the key, which the next upgrade strips again. Sidecar loss costs nothing - the data is refetchable. Co-authored-by: Orca <[email protected]> * Reject null/array pr-issue shapes when reading the github cache sidecar A corrupt-but-valid-JSON sidecar ({"pr":null}) would seed state.githubCache.pr = null and crash mobile worktree.ps PR grouping until the renderer's first cache save repaired it. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Follow-up to #7092:
githubCachewas the last remaining non-user-driven writer oforca-data.json.Problem
Every PR/issue poll restamps
fetchedAteven when the fetched data is unchanged, which defeats #7092's content-hash guard by construction: ~100KB of refetchable, 5-minute-TTL cache rewrote the entire 1.6MB durable state file once per refresh cycle (~every 2 minutes with visible PRs), forever.Fix — the "unobservable" variant
setGitHubCacheno longer schedules saves, and both the durable payload and the content hash omit the field (getDurableState()), so cache refreshes can never touchorca-data.jsonagain.flush()time (app quit, updater quit, window reload, agent-auth restart) it's snapshotted best-effort to a sidecarorca-github-cache.json(tmp+rename, dirty-gated, no backups, failures swallowed) and loaded opportunistically at startup — so PR/issue badges still paint instantly on the next launch. There is no user-observable behavior change short of a hard crash, and even then the cost is one cold badge paint of refetchable data.Result
orca-data.jsonwrites are now purely user/session-action-driven, and the file shrinks ~100KB. Renderer, web (localStorage-based), and mobile (meta.linkedPRfallback) consumers are untouched — verified by call-site audit.Review
Independent adversarial review verified six invariants (no durable writer can reinclude the key — including the offline CLI round-trip and pre-upgrade backup restores; hash/payload consistency; migration & ping-pong bounds; sidecar dirty-flag lifecycle across all flush call sites; consumer tolerance; type-safety through zod-failure/backup-recursion paths). Its one finding — sidecar validation accepted
null/arraypr/issueshapes, which could crash mobile PR grouping on a corrupt sidecar — is fixed in the second commit. 329 persistence tests pass (3 new: no-rewrite-on-refresh, flush-snapshot + restart seeding, legacy strip).Made with Orca 🐋