Skip to content

fix(selfhost): wire GITHUB_CACHE_TTL_SECONDS or remove the dead config - #2573

Merged
JSONbored merged 1 commit into
mainfrom
fix/github-cache-ttl-seconds-dead-config
Jul 2, 2026
Merged

fix(selfhost): wire GITHUB_CACHE_TTL_SECONDS or remove the dead config#2573
JSONbored merged 1 commit into
mainfrom
fix/github-cache-ttl-seconds-dead-config

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • GITHUB_CACHE_TTL_SECONDS (threaded into createRedisResponseCache as the fallback ttlSeconds) was dead beyond its >0/=0 enable/disable gate: every real call site into GitHubResponseCache.set() (src/github/client.ts, src/github/graphql-cache.ts) already resolves its own per-class TTL env var (GITHUB_BRANCH_PROTECTION_CACHE_TTL_SECONDS, GITHUB_COMMIT_CACHE_TTL_SECONDS, GITHUB_METADATA_CACHE_TTL_SECONDS, GITHUB_GRAPHQL_CACHE_TTL_SECONDS) and always passes it explicitly, so ttlOverrideSeconds ?? ttlSeconds never fell through to the configured value. An operator setting GITHUB_CACHE_TTL_SECONDS=5 or =120 (per .env.example's own "short default Redis TTL" documentation) got no change in actual cache freshness — only the gate had any effect. A stale server.ts comment ("Default 20s") reinforced the false impression.
  • Chose removal over wiring it in as an actual fallback default: the per-class TTLs default to 10–20 minutes, but docker-compose.yml already sets GITHUB_CACHE_TTL_SECONDS=20 unconditionally in every self-host deployment's environment — wiring it in as a fallback would silently collapse every existing deployment's caching from 10–20 minutes down to 20 seconds on upgrade, a surprising regression for what should read as a docs/dead-code fix.
  • Made ttlSeconds a required parameter on GitHubResponseCache.set() and createRedisResponseCache() instead of an optional one with a dead fallback (every real caller already supplies it), and corrected the misleading .env.example/docker-compose.yml/server.ts documentation to describe the actual enable/disable-gate behavior.
  • Rewrote test/unit/selfhost-redis-response-cache.test.ts for the new required-argument signature (100% coverage retained on the changed file).

Closes #2505.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate. (redis-response-cache.ts is 100% on the changed lines; client.ts's two changed lines land in client.ts's existing, unrelated uncovered ranges — unchanged by this diff.)
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A, internal cache interface only.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, no UI changes.
  • Visible UI changes include a UI Evidence section below — N/A, no UI changes.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

Notes

GITHUB_CACHE_TTL_SECONDS (threaded into createRedisResponseCache as the
fallback ttlSeconds) was dead beyond its >0/=0 enable/disable gate:
every real call site into GitHubResponseCache.set() (client.ts,
graphql-cache.ts) already resolves its own per-class TTL env var
(GITHUB_BRANCH_PROTECTION_CACHE_TTL_SECONDS,
GITHUB_COMMIT_CACHE_TTL_SECONDS, GITHUB_METADATA_CACHE_TTL_SECONDS,
GITHUB_GRAPHQL_CACHE_TTL_SECONDS) and always passes it explicitly, so
ttlOverrideSeconds ?? ttlSeconds never fell through to the configured
value. An operator setting GITHUB_CACHE_TTL_SECONDS=5 or =120 (per
.env.example's own "short default Redis TTL" documentation) got no
change in actual cache freshness -- only the gate had any effect.

Chose removal over wiring it in as an actual fallback default: the
per-class TTLs default to 10-20 minutes, but docker-compose.yml already
sets GITHUB_CACHE_TTL_SECONDS=20 unconditionally in every self-host
deployment's environment -- wiring it in as a fallback would silently
collapse every existing deployment's caching from 10-20 minutes down to
20 seconds on upgrade, a surprising regression for a "fix the docs"
change.

Make ttlSeconds a required parameter on GitHubResponseCache.set() and
createRedisResponseCache() instead of an optional one with a dead
fallback, and correct the misleading .env.example/docker-compose.yml/
server.ts documentation to describe the actual enable/disable-gate
behavior.
@dosubot dosubot Bot added the size:S label Jul 2, 2026
@loopover-orb

loopover-orb Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-02 09:24:35 UTC

6 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
The change correctly removes the dead cache-wide TTL fallback and documents `GITHUB_CACHE_TTL_SECONDS` as an enable/disable gate while keeping per-entry TTLs supplied by GitHub client callers. The Redis cache implementation now has a cleaner contract: construction only needs Redis, and `set()` always receives the caller-resolved TTL before flooring it to 1 second. The visible tests are updated against that contract and still cover round-trip, malformed cache entries, TTL flooring, and Redis error metrics.

Nits — 5 non-blocking
  • nit: `src/server.ts` still parses the gate with `Number(...)`, so a malformed positive-looking value disables the cache silently; consider documenting or validating invalid values if operator feedback matters.
  • nit: `.env.example` says the numeric value is otherwise unused, but `src/server.ts` still requires it to be parseable and `>0`; tightening that wording to “only its parsed >0/0 state is used” would avoid ambiguity.
  • In `src/server.ts`, consider logging both `githubResponseCacheEnabled` and the parsed gate value so operators can diagnose unexpected disablement from `GITHUB_CACHE_TTL_SECONDS=0` or an invalid value.
  • In `.env.example`, mirror the exact server behavior by saying the parsed numeric value only controls enabled-vs-disabled, not cache entry duration.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2505
Related work ⚠️ 2 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (size label size:S; 1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 65 registered-repo PR(s), 55 merged, 553 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 65 PR(s), 553 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Review top overlaps.
  • Add a concise scope and risk note.
  • No action.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.98%. Comparing base (92fba2f) to head (0335605).
⚠️ Report is 30 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2573      +/-   ##
==========================================
+ Coverage   95.95%   95.98%   +0.02%     
==========================================
  Files         226      229       +3     
  Lines       25425    25813     +388     
  Branches     9244     9390     +146     
==========================================
+ Hits        24397    24777     +380     
- Misses        417      425       +8     
  Partials      611      611              
Files with missing lines Coverage Δ
src/github/client.ts 100.00% <ø> (ø)
src/selfhost/redis-response-cache.ts 100.00% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 32be1ba into main Jul 2, 2026
13 checks passed
@JSONbored
JSONbored deleted the fix/github-cache-ttl-seconds-dead-config branch July 2, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Development

Successfully merging this pull request may close these issues.

fix(selfhost): wire GITHUB_CACHE_TTL_SECONDS or remove the dead config

1 participant