feat(selfhost): cache stable GitHub GraphQL reads#1880
Conversation
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-01 16:15:18 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 7 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
JSONbored
left a comment
There was a problem hiding this comment.
This touches an important area, so i'm holding this temporarily while I confirm whether or not it conflicts with the direction i'm currently taking the cache.
Leave the PR as-is and I'll review it after I'm done implementing outstanding cache changes, please.
If for whatever reason I decide not to use this direction, I'll allow a one-time rewrite of this PR to focus on something else.
Thanks for working on this.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1880 +/- ##
==========================================
+ Coverage 95.69% 95.71% +0.01%
==========================================
Files 222 223 +1
Lines 24584 24663 +79
Branches 8923 8942 +19
==========================================
+ Hits 23526 23605 +79
Misses 433 433
Partials 625 625
🚀 New features to boost your workflow:
|
cb2a22d to
2d511bc
Compare
Summary
#1842 added an auth-aware shared response cache for stable GitHub REST GETs used by Octokit and raw backfill reads. Self-host backfill and hydration still POST to
https://api.github.com/graphqlon every segment sweep with no shared cache, even for idempotent repository totals and contributor-activity queries that repeat across webhook bursts, re-gate sweeps, and concurrent segment workers.This extends the same cache boundary to allowlisted stable GraphQL operations — reducing duplicate quota burn without caching mutable PR/issue/review-thread subresources that gate scoring and review decisions.
What this adds
src/github/client.ts/src/selfhost/redis-response-cache.ts, keyed by auth hash + normalized query signature (operation name + stable variables).GittensoryRepoTotalsandGittensoryContributorActivity; bypass live PR detail, review-thread, review-decision, open-issue supplement, and open-PR supplement queries.gittensory_github_graphql_cache_total), and fail-open behavior on Redis errors — mirroring the REST cache semantics from feat(selfhost): cache stable GitHub GET reads #1842.githubGraphQlinsrc/github/backfill.tsthrough the shared cache path; skip rate-limit observation writes for cache replays.Purely operational — no scoring, review, gate, or MCP behavior change.
Files touched (estimated)
src/github/client.tssrc/github/graphql-cache.tssrc/github/backfill.tsgithubGraphQlthrough shared cache; preserve existing error/rate-limit pathssrc/selfhost/redis-response-cache.tsgh:resp:withgql:namespace)src/server.tstest/unit/github-graphql-cache.test.tstest/unit/backfill.test.tsGITHUB_GRAPHQL_CACHE_TTL_SECONDS)Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coverage— aim for 100% statements/branches on new/changed lines insrc/github/graphql-cache.tsand cache wiringnpm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateTargeted test run:
Notes
Analogues to imitate end-to-end: REST cache in
src/github/client.ts,createRedisResponseCacheinsrc/selfhost/redis-response-cache.ts, and backfill rate-limit deferral insrc/github/backfill.tsshouldWaitForGitHubRateLimit.