Skip to content

fix(review): circuit-break REES enrichment on a confirmed auth rejection - #4953

Merged
JSONbored merged 1 commit into
mainfrom
fix/rees-enrichment-auth-circuit-breaker
Jul 11, 2026
Merged

fix(review): circuit-break REES enrichment on a confirmed auth rejection#4953
JSONbored merged 1 commit into
mainfrom
fix/rees-enrichment-auth-circuit-breaker

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • probeReesSecretAtStartup already detects a REES shared-secret mismatch (401/403) at boot and logs rees_secret_mismatch, but buildReviewEnrichment had no way to act on that signal — it kept calling /v1/enrich on every single PR review, each one failing the same way, for the whole process lifetime until a manual restart, with each failure also logging review_context_fetch_failed. This adds a module-level circuit breaker: once the startup probe confirms an auth rejection, buildReviewEnrichment skips subsequent /v1/enrich calls for the rest of the process (with logging capped at 3 occurrences so the skip itself doesn't spam logs). A non-auth probe failure (e.g. a 500) does not trip the breaker, since that isn't a confirmed secret mismatch. Mirrors the approach from the closed PR fix(review): circuit-break REES enrichment on auth rejection #3738.

Closes #4952

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 a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally, unsharded — full suite green (13910 passed, 0 failed); src/review/enrichment-wire.ts diff is 100% line coverage, and the only branch/function gaps reported for the file are in a pre-existing, unrelated function (resolveEnrichmentAnalyzerSelection) not touched by this change.
  • 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 — 4 new tests: default-closed (proceeds normally), trips-and-skips on a confirmed 401 without even attempting the doomed fetch, log volume capped at exactly 3 occurrences across 5 calls, and a non-auth failure (500) does not trip the breaker.

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. — the 401/403-vs-500 distinction tests above are exactly this negative-path coverage for the auth-rejection path.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A, no API/OpenAPI/MCP surface touched (internal REES enrichment wiring only).
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, no UI touched.
  • Visible UI changes include a UI Evidence section below with screenshots. — N/A, no UI touched.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

Notes

  • Owner PR (JSONbored); ran the full npm run test:ci gate plus npm audit --audit-level=moderate locally, both fully green. The module-level circuit-breaker state is process-lifetime by design (cleared only by the restart that fixing the secret mismatch already requires); a resetReesAuthRejectedForTests() export prevents it from leaking across unrelated tests sharing this module instance in the same test file.

…ion (#4952)

probeReesSecretAtStartup already detects a REES shared-secret mismatch
(401/403) at boot, but buildReviewEnrichment had no way to act on it -- it
kept calling /v1/enrich on every PR review, each one failing the same way,
for the whole process lifetime. Once the probe confirms rejection, skip
subsequent calls (with capped logging) instead of repeating a call that's
confirmed doomed. A non-auth failure (e.g. 500) does not trip the breaker.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 11, 2026
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.24%. Comparing base (6954202) to head (fb371d0).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4953   +/-   ##
=======================================
  Coverage   94.24%   94.24%           
=======================================
  Files         445      445           
  Lines       38869    38880   +11     
  Branches    14157    14160    +3     
=======================================
+ Hits        36633    36644   +11     
  Misses       1577     1577           
  Partials      659      659           
Flag Coverage Δ
shard-1 46.46% <27.27%> (-0.30%) ⬇️
shard-2 33.56% <27.27%> (+0.26%) ⬆️
shard-3 31.56% <27.27%> (+0.14%) ⬆️
shard-4 32.52% <27.27%> (-0.49%) ⬇️
shard-5 34.41% <100.00%> (+0.94%) ⬆️
shard-6 45.46% <27.27%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/review/enrichment-wire.ts 98.26% <100.00%> (+0.11%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 11, 2026
@loopover-orb

loopover-orb Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Important

🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪

🔍 Gittensory is reviewing…

AI analysis is in progress. This comment will update when the review is complete.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing

@JSONbored
JSONbored merged commit d6d5a02 into main Jul 11, 2026
18 checks passed
@JSONbored
JSONbored deleted the fix/rees-enrichment-auth-circuit-breaker branch July 11, 2026 02:47
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

review: REES enrichment keeps retrying /v1/enrich after a confirmed auth rejection

1 participant