fix(review): circuit-break REES enrichment on a confirmed auth rejection - #4953
Merged
Merged
Conversation
…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.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
probeReesSecretAtStartupalready detects a REES shared-secret mismatch (401/403) at boot and logsrees_secret_mismatch, butbuildReviewEnrichmenthad no way to act on that signal — it kept calling/v1/enrichon every single PR review, each one failing the same way, for the whole process lifetime until a manual restart, with each failure also loggingreview_context_fetch_failed. This adds a module-level circuit breaker: once the startup probe confirms an auth rejection,buildReviewEnrichmentskips subsequent/v1/enrichcalls 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
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally, unsharded — full suite green (13910 passed, 0 failed);src/review/enrichment-wire.tsdiff 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:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateSafety
UI Evidencesection below with screenshots. — N/A, no UI touched.Notes
npm run test:cigate plusnpm audit --audit-level=moderatelocally, 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); aresetReesAuthRejectedForTests()export prevents it from leaking across unrelated tests sharing this module instance in the same test file.