← Back to Pull requests

fix: fall back to last successful OIDC discovery when refetch fails #10020

Merged
KR-Ravindra merged 3 files (434 lines) on Nov 05, 2026 03:15 UTC
View on GitHub
KR-Ravindra KR-Ravindra commented on Sep 13, 2026 08:22 UTC
Author

What this PR does / why we need it:

OIDC discovery runs on every translation with a cache that is re-created each time. If /.well-known/openid-configuration is unreachable or non-2xx during a reconciliation, the SecurityPolicy fails and every route it protects answers 500 until a later reconciliation succeeds.

This keeps the last successfully discovered OpenIDConfig per issuer in a process-wide, mutex-guarded LRU cache (128 entries) and falls back to it, logging the error, when discovery fails. Discovery is still retried every translation; an issuer that never succeeded still fails, and local issuer/TLS configuration errors are never masked. Follows the guidance on #9239 (size cap + LRU, no TTL).

Tests: fallback, none without prior success or on a local TLS config error, LRU eviction, concurrency under -race.

Which issue(s) this PR fixes:
Fixes #9235

---

PR Checklist

  • Authorship & ownership

  • DCO

  • API agreed first: N/A

  • Required checks pass: gofmt, go vet and go test -race ./internal/gatewayapi/ pass locally

  • Tests added/updated

  • Docs: N/A

  • Release notes: release-notes/current/bug_fixes/9235-oidc-discovery-fallback.md

  • Generated files committed: N/A

  • Scope & compatibility

  • Codex review: requested; findings addressed (local TLS config errors, token endpoint validation before retaining)

  • Copilot review: not yet requested
  • Experimented and verified with an AI agent.

    Diff: 434 lines (+424 / -10) across 3 files Reviewer: zirain Review duration: 76013m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.42) × (1 − Review Confidence (0.79)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 434 lines diff across 3 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.72 · 5 substantive comment(s)
    0.72
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    79%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Real PR Conversation Timeline
    41 items
    netlify[bot] netlify[bot] commented on Sep 13, 2026 08:22 UTC
    Bot

    <span aria-hidden="true">✅</span> Deploy Preview for cerulean-figolla-1f9435 ready!

    | Name | Link |
    |:-:|------------------------|
    |<span aria-hidden="true">🔨</span> Latest commit | 88e846fb5c996399a56c17bfc4925fe222aa49e2 |
    |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6aeb08b8fa9df580771a3471 |
    |<span aria-hidden="true">😎</span> Deploy Preview | https://deploy-preview-10020--cerulean-figolla-1f9435.netlify.app |
    |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />!QR Code<br /><br />_Use your smartphone camera to open QR code link._</details> |
    ---
    <!-- cerulean-figolla-1f9435 Preview -->
    _To edit notification comments on pull requests, go to your Netlify project configuration._

    sadovnikov sadovnikov commented on Oct 21, 2026 11:24 UTC
    Contributor

    @KR-Ravindra, can you submit this PR for review?

    KR-Ravindra KR-Ravindra commented on Oct 21, 2026 13:30 UTC
    Author

    @sadovnikov rebased on current main in 5fdc4c6 and marked ready for review. (Experimented and verified with an AI agent.)

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 21, 2026 13:30 UTC
    Bot

    <!-- codex-pull-request-review-summary -->
    <!-- codex-review-state:v1 {"code_review":{"commit_sha":"88e846fb5c996399a56c17bfc4925fe222aa49e2","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->

    Codex Review Summary

    This comment shows the latest Codex review activity on this pull request.

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-04T10:33:30.736443Z">2026-11-04T10:33:30.736443Z</relative-time> | 88e846f | New commits |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Oct 21, 2026 13:36 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2622,10 +2626,19 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		if fallback, ok := oidcDiscoveryFallback.Get(issuerURL); ok {

    <sub><sub>!P2 Badge</sub></sub> Do not mask local TLS configuration errors

    When an issuer was discovered successfully before and its Backend/EnvoyProxy client-certificate configuration is later changed to an invalid PEM/key pair, discoverEndpointsFromIssuer returns the local providerTLS.ToTLSConfig() error before sending any request. This branch nevertheless returns the issuer-only fallback as a success, so the SecurityPolicy continues translating with unusable TLS settings instead of surfacing the configuration error; restrict fallback to remote fetch/response failures or otherwise distinguish HTTP-client construction errors.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 21, 2026 13:36 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 5fdc4c6c8f

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    KR-Ravindra KR-Ravindra commented on Oct 21, 2026 15:43 UTC
    Author

    Addressed the finding in 8a5ecb0: issuer-URL and TLS client construction errors are now typed as local configuration errors and never fall back to the retained discovery result, with a test for the invalid client-certificate case. @codex review (Experimented and verified with an AI agent.)

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 21, 2026 16:00 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 8a5ecb0856

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Oct 21, 2026 16:00 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2622,10 +2626,23 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		// Errors in the local issuer or TLS configuration are surfaced instead of being masked.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL); ok {

    <sub><sub>!P2 Badge</sub></sub> Bind fallback entries to the TLS settings used

    When an existing policy's Backend/EnvoyProxy TLS settings change to a valid-but-nontrusting CA or SNI, HTTP client construction succeeds and the resulting TLS handshake error is returned from client.Get as an ordinary transport error, so this condition still selects the old discovery document. The new invalid-key-pair test only exercises constructor failure; malformed CA PEM is also silently accepted because TLSUpstreamConfig.ToTLSConfig ignores AppendCertsFromPEM's result at internal/ir/xds.go:4160. The SecurityPolicy therefore remains translated even though its current token-endpoint TLS configuration cannot connect; retain a fingerprint of providerTLS with each cache entry and only fall back when it matches.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    sadovnikov sadovnikov commented on Oct 21, 2026 16:31 UTC
    Contributor

    Thank you, @KR-Ravindra 👍

    KR-Ravindra KR-Ravindra commented on Oct 21, 2026 17:57 UTC
    Author

    @sadovnikov thanks. Codex raised one more point after that push, addressed in 0f3cbbc: each retained discovery result now carries a fingerprint of the TLS settings it was fetched with and is only reused while those match, with a test for the changed-settings case. @codex review (Experimented and verified with an AI agent.)

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 21, 2026 18:02 UTC
    Bot

    <!-- codex-review-receipt:v1 -->

    Codex Review: Didn't find any major issues. :rocket:

    Reviewed commit: 0f3cbbcf5d

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    KR-Ravindra KR-Ravindra commented on Nov 02, 2026 14:42 UTC
    Author

    Rebased on main and switched the two ptr.To calls in the test to new() for the forbidigo rule in 3b19a88. The coverage-test failure on the rerun was TestProvider/gateway_scheduled_status in internal/provider/kubernetes, which this PR does not touch, and osv-scan reports the same go-jose finding on main.

    (Experimented and verified with an AI agent.)

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 02, 2026 14:47 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2611,12 +2616,27 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     		return config, nil
     	}
     
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		// Errors in the local issuer or TLS configuration are surfaced instead of being masked,
    +		// and a result obtained with different TLS settings is not reused.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL, tlsFingerprint); ok {
    +				t.Logger.Error(err, "OIDC discovery failed, using the last successfully discovered configuration",
    +					"issuer", issuerURL)
    +				t.oidcDiscoveryCache.Set(issuerURL, fallback, nil)

    <sub><sub>!P2 Badge</sub></sub> Include TLS settings in the per-translation cache key

    When two SecurityPolicies in one translation share an issuer but use different TLS settings, the first fallback stored here is returned to the second by the issuer-only Get before tlsFingerprint is computed. During an issuer outage, TLS B can therefore reuse a document retained under TLS A even when B's CA or SNI cannot connect. Fresh evidence after the fingerprint fix is that the newly added fallback is inserted into the old issuer-only per-translation cache; key that cache by both issuer and fingerprint (or recheck the fingerprint on lookup).

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 02, 2026 14:47 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2611,12 +2616,27 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     		return config, nil
     	}
     
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		// Errors in the local issuer or TLS configuration are surfaced instead of being masked,
    +		// and a result obtained with different TLS settings is not reused.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL, tlsFingerprint); ok {
    +				t.Logger.Error(err, "OIDC discovery failed, using the last successfully discovered configuration",
    +					"issuer", issuerURL)
    +				t.oidcDiscoveryCache.Set(issuerURL, fallback, nil)
    +				return fallback, nil
    +			}
    +		}
     		t.oidcDiscoveryCache.Set(issuerURL, nil, err)
     		return nil, err
     	}
     
    +	oidcDiscoveryFallback.Set(issuerURL, config, tlsFingerprint)

    <sub><sub>!P2 Badge</sub></sub> Validate discovered endpoints before replacing the fallback

    When a previously valid issuer next returns HTTP 200 metadata with a nonempty token URL that validateTokenEndpoint rejects (for example, an IP-literal URL), discoverEndpointsFromIssuer reports success because OpenIDConfig.validate only checks for empty fields, so this call replaces the usable fallback before buildOIDCProvider rejects the endpoint. A subsequent 503 then retrieves the invalid entry and the protected routes continue returning 500 instead of falling back to the last usable configuration; validate the discovered endpoint before calling Set, or preserve the old entry when downstream validation fails.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 02, 2026 14:47 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 3b19a88fa2

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    KR-Ravindra KR-Ravindra commented on Nov 02, 2026 16:58 UTC
    Author

    Pushed 6c70f5a: a discovery result whose token endpoint fails validateTokenEndpoint is no longer stored as the fallback (second Codex thread), with a test. The first thread is about the per-translation cache being keyed by issuer only, which is main's existing behaviour and unchanged here; the TLS fingerprint guards the cross-translation fallback.

    (Experimented and verified with an AI agent.)

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 02, 2026 17:01 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 6c70f5a666

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 02, 2026 17:02 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2611,12 +2616,31 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     		return config, nil
     	}
     
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		// Errors in the local issuer or TLS configuration are surfaced instead of being masked,
    +		// and a result obtained with different TLS settings is not reused.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL, tlsFingerprint); ok {
    +				t.Logger.Error(err, "OIDC discovery failed, using the last successfully discovered configuration",
    +					"issuer", issuerURL)
    +				t.oidcDiscoveryCache.Set(issuerURL, fallback, nil)
    +				return fallback, nil
    +			}
    +		}
     		t.oidcDiscoveryCache.Set(issuerURL, nil, err)
     		return nil, err
     	}
     
    +	// Only retain a result whose token endpoint passes the validation applied when the provider
    +	// is built, so that an unusable discovery result never replaces a usable fallback.
    +	if validateTokenEndpoint(config.TokenEndpoint) == nil {

    <sub><sub>!P2 Badge</sub></sub> Retain discoveries usable with explicit token endpoints

    When a SecurityPolicy explicitly sets provider.tokenEndpoint but leaves authorizationEndpoint to discovery, buildOIDCProvider replaces the discovered token URL and validates only the explicit URL. If the discovery document has a nonempty token URL that this helper rejects (for example, an IP literal), the current translation succeeds using the explicit endpoint, but this gate does not retain the discovered authorization endpoint. A later issuer outage therefore has no fallback (or uses an older authorization endpoint) and returns the protected route to HTTP 500 even though the last resolved provider was usable; retention needs to account for the final selected endpoints or which fields the policy overrides.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    codecov[bot] codecov[bot] commented on Nov 02, 2026 18:33 UTC
    Bot

    Codecov Report


    :x: Patch coverage is 92.30769% with 3 lines in your changes missing coverage. Please review.
    :white_check_mark: Project coverage is 82.67%. Comparing base (c267eaa) to head (88e846f).
    :warning: Report is 10 commits behind head on main.

    | Files with missing lines | Patch % | Lines |
    |---|---|---|
    | internal/gatewayapi/securitypolicy.go | 92.30% | 3 Missing :warning: |

    <details><summary>Additional details and impacted files</summary>

    @@            Coverage Diff             @@
    ##             main   #10020      +/-   ##
    ==========================================
    + Coverage   82.53%   82.67%   +0.13%     
    ==========================================
      Files         277      277              
      Lines       44270    44328      +58     
    ==========================================
    + Hits        36540    36649     +109     
    + Misses       7729     7678      -51     
      Partials        1        1              
    

    </details>

    :umbrella: View full report in Codecov by Harness.
    :loudspeaker: Have feedback on the report? Share it here.
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    zhaohuabing zhaohuabing commented on code on Nov 03, 2026 01:22 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -103,6 +106,8 @@ func (t *Translator) ProcessSecurityPolicies(
     ) []*egv1a1.SecurityPolicy {
     	// Cache is only reused during one translation across multiple routes and gateways.
     	// The failed fetches will be retried in the next translation when the provider resources are reconciled again.
    +	// The last successful discovery result per issuer is retained across translations in
    +	// oidcDiscoveryFallback and used when a later discovery attempt fails.
     	t.oidcDiscoveryCache = newOIDCDiscoveryCache()

    Non-blocking, fine as a follow-up: the per-translation cache is still keyed by issuer only, so when two policies share an issuer, the second one gets the first one's fallback without its own TLS fingerprint check. Adding the fingerprint to that cache key would fix it.

    zhaohuabing zhaohuabing commented on code on Nov 03, 2026 01:29 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2611,12 +2616,31 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     		return config, nil
     	}
     
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		// Errors in the local issuer or TLS configuration are surfaced instead of being masked,
    +		// and a result obtained with different TLS settings is not reused.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL, tlsFingerprint); ok {
    +				t.Logger.Error(err, "OIDC discovery failed, using the last successfully discovered configuration",
    +					"issuer", issuerURL)
    +				t.oidcDiscoveryCache.Set(issuerURL, fallback, nil)
    +				return fallback, nil
    +			}
    +		}
     		t.oidcDiscoveryCache.Set(issuerURL, nil, err)
     		return nil, err
     	}
     
    +	// Only retain a result whose token endpoint passes the validation applied when the provider
    +	// is built, so that an unusable discovery result never replaces a usable fallback.
    +	if validateTokenEndpoint(config.TokenEndpoint) == nil {

    Should we only check the discovered token endpoint when the policy doesn't set its own tokenEndpoint?

    Fine as a follow-up since this is an edge case.

    zhaohuabing zhaohuabing commented on code on Nov 03, 2026 01:35 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2611,12 +2616,31 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     		return config, nil
     	}
     
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		// Errors in the local issuer or TLS configuration are surfaced instead of being masked,
    +		// and a result obtained with different TLS settings is not reused.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL, tlsFingerprint); ok {
    +				t.Logger.Error(err, "OIDC discovery failed, using the last successfully discovered configuration",

    Non-blocking: Could we add a warning condition to make that visible? It's fine as a follow-up.

    KR-Ravindra KR-Ravindra commented on Nov 03, 2026 01:37 UTC
    Author

    @zhaohuabing done in bc353f7: the per-translation cache is now keyed by issuer plus the TLS fingerprint, and the discovered token endpoint is only checked before retaining the result when the policy does not set its own tokenEndpoint (buildOIDCProvider passes the override through). Tests for both are included. Could you take another look?

    (Experimented and verified with an AI agent.)

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 03, 2026 01:43 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2613,11 +2621,30 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    -		t.oidcDiscoveryCache.Set(issuerURL, nil, err)
    +		// Fall back to the last successfully discovered configuration for this issuer, if any,
    +		// so that a transient discovery failure does not break every route protected by it.
    +		// Errors in the local issuer or TLS configuration are surfaced instead of being masked,
    +		// and a result obtained with different TLS settings is not reused.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL, tlsFingerprint); ok {
    +				t.Logger.Error(err, "OIDC discovery failed, using the last successfully discovered configuration",
    +					"issuer", issuerURL)
    +				t.oidcDiscoveryCache.Set(issuerURL, tlsFingerprint, fallback, nil)
    +				return fallback, nil
    +			}
    +		}
    +		t.oidcDiscoveryCache.Set(issuerURL, tlsFingerprint, nil, err)
     		return nil, err
     	}
     
    -	t.oidcDiscoveryCache.Set(issuerURL, config, nil)
    +	// Only retain a result whose token endpoint passes the validation applied when the provider
    +	// is built, so that an unusable discovery result never replaces a usable fallback. The check
    +	// is skipped when the policy overrides the token endpoint, since the discovered one is unused.
    +	if tokenEndpointOverridden || validateTokenEndpoint(config.TokenEndpoint) == nil {
    +		oidcDiscoveryFallback.Set(issuerURL, config, tlsFingerprint)

    <sub><sub>!P2 Badge</sub></sub> Separate override-only discovery fallbacks

    Fresh evidence after adding override-sensitive retention is that this branch still writes an override-only document into the issuer/TLS-wide fallback. If two policies share those settings, a previously valid fallback can be replaced when the issuer advertises an IP-literal token URL and the policy being translated supplies its own valid token endpoint; on the next issuer outage, a policy without an override receives that retained IP URL, fails validateTokenEndpoint in buildOIDCProvider, and returns its protected routes to 500. Keep override-only discoveries separate from fallback entries usable by non-overriding policies.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 03, 2026 01:43 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2603,8 +2608,11 @@ func (o *OpenIDConfig) validate() error {
     	return nil
     }
     
    -func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig) (*OpenIDConfig, error) {
    -	if config, cachedErr, ok := t.oidcDiscoveryCache.Get(issuerURL); ok {
    +// fetchEndpointsFromIssuer discovers the OpenID configuration of the issuer. tokenEndpointOverridden
    +// reports that the policy sets its own token endpoint, so the discovered one is not used.
    +func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig, tokenEndpointOverridden bool) (*OpenIDConfig, error) {
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)
    +	if config, cachedErr, ok := t.oidcDiscoveryCache.Get(issuerURL, tlsFingerprint); ok {
     		if cachedErr != nil {
     			return nil, cachedErr
     		}

    <sub><sub>!P2 Badge</sub></sub> Apply override retention on translation-cache hits

    Fresh evidence after making retention depend on tokenEndpointOverridden is that a per-translation hit returns before that decision. If a non-overriding policy first fetches a document with an IP-literal token URL, it caches the document here but correctly does not retain it globally; a later policy sharing issuer/TLS but supplying a valid token override succeeds from this cache hit without retaining the discovered authorization endpoint, so its next reconciliation during an issuer outage has no fallback and its protected routes return 500. Reapply retention on cached successes or include override mode in this cache key.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 03, 2026 01:43 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: bc353f7012

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    zhaohuabing zhaohuabing commented on code on Nov 03, 2026 01:44 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2800,34 +2845,133 @@ type cachedOIDCEntry struct {
     
     func newOIDCDiscoveryCache() *oidcDiscoveryCache {
     	return &oidcDiscoveryCache{
    -		entries: make(map[string]cachedOIDCEntry),
    +		entries: make(map[oidcDiscoveryCacheKey]cachedOIDCEntry),
     	}
     }
     
    -func (c *oidcDiscoveryCache) Get(issuer string) (*OpenIDConfig, error, bool) {
    +func (c *oidcDiscoveryCache) Get(issuer, tlsFingerprint string) (*OpenIDConfig, error, bool) {
     	if c == nil {
     		return nil, nil, false
     	}
     
    -	entry, ok := c.entries[issuer]
    +	entry, ok := c.entries[oidcDiscoveryCacheKey{issuer: issuer, tlsFingerprint: tlsFingerprint}]
     	if !ok {
     		return nil, nil, false
     	}
     
     	return entry.config, entry.err, true
     }
     
    -func (c *oidcDiscoveryCache) Set(issuer string, cfg *OpenIDConfig, err error) {
    +func (c *oidcDiscoveryCache) Set(issuer, tlsFingerprint string, cfg *OpenIDConfig, err error) {
     	if c == nil {
     		return
     	}
     
    -	c.entries[issuer] = cachedOIDCEntry{
    +	c.entries[oidcDiscoveryCacheKey{issuer: issuer, tlsFingerprint: tlsFingerprint}] = cachedOIDCEntry{
     		config: cfg,
     		err:    err,
     	}
     }
     
    +// maxOIDCDiscoveryFallbackEntries caps the number of issuers whose last successful discovery
    +// result is retained across translations. The number of OIDC providers used by a cluster is
    +// typically small, so a small bound with LRU eviction is sufficient.
    +const maxOIDCDiscoveryFallbackEntries = 128
    +
    +// oidcDiscoveryFallback retains the last successfully discovered OpenID configuration per issuer
    +// for the lifetime of the process. It is shared by all translations and consulted when discovery
    +// fails, so that a transient IdP outage does not result in a 500 response on every route
    +// protected by that issuer.
    +var oidcDiscoveryFallback = newOIDCDiscoveryFallbackCache(maxOIDCDiscoveryFallbackEntries)
    +
    +// oidcDiscoveryFallbackCache is a size-capped LRU cache of OpenID configurations keyed by issuer.
    +// It is safe for concurrent use.
    +type oidcDiscoveryFallbackCache struct {
    +	mu         sync.Mutex
    +	maxEntries int
    +	entries    map[string]*list.Element

    The fallback cache is keyed by issuer only, so with the per-translation cache now split by TLS settings, policies that share an issuer overwrite each other's fallback and only the last one is covered during an outage. Keying the fallback by issuer plus fingerprint as well would fix it.

    KR-Ravindra KR-Ravindra commented on Nov 03, 2026 06:06 UTC
    Author

    @zhaohuabing done in f81e6ca: the fallback cache is now keyed by issuer plus the TLS fingerprint as well, so policies sharing an issuer each keep their own entry (the TLS-change test now checks both are retained), and the unparam lint failure is fixed. I've left the warning condition for a follow-up as you suggested. Could you take another look?

    (Experimented and verified with an AI agent.)

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 03, 2026 12:50 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2739,11 +2746,30 @@ func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.
     
     	config, err := discoverEndpointsFromIssuer(issuerURL, providerTLS)
     	if err != nil {
    -		t.oidcDiscoveryCache.Set(issuerURL, nil, err)
    +		// Fall back to the last configuration successfully discovered for this issuer with the
    +		// same TLS settings, if any, so that a transient discovery failure does not break every
    +		// route protected by it. Errors in the local issuer or TLS configuration are surfaced
    +		// instead of being masked.
    +		var configErr *oidcDiscoveryConfigError
    +		if !errors.As(err, &configErr) {
    +			if fallback, ok := oidcDiscoveryFallback.Get(issuerURL, tlsFingerprint); ok {
    +				t.Logger.Error(err, "OIDC discovery failed, using the last successfully discovered configuration",
    +					"issuer", issuerURL)
    +				t.oidcDiscoveryCache.Set(issuerURL, tlsFingerprint, fallback, nil)
    +				return fallback, nil
    +			}
    +		}
    +		t.oidcDiscoveryCache.Set(issuerURL, tlsFingerprint, nil, err)
     		return nil, err
     	}
     
    -	t.oidcDiscoveryCache.Set(issuerURL, config, nil)
    +	// Only retain a result whose token endpoint passes the validation applied when the provider
    +	// is built, so that an unusable discovery result never replaces a usable fallback. The check
    +	// is skipped when the policy overrides the token endpoint, since the discovered one is unused.
    +	if tokenEndpointOverridden || validateTokenEndpoint(config.TokenEndpoint) == nil {

    <sub><sub>!P2 Badge</sub></sub> Reject token ports that downstream translation cannot encode

    Fresh evidence after adding this validation gate is that, on 64-bit builds and for a policy with neither a token override nor provider BackendRefs, a discovered URL such as https://idp.example.com:4294967296/token passes validateTokenEndpoint because strconv.Atoi accepts the port, so this branch replaces the last usable fallback. url2Cluster then rejects that same port via ParseUint(..., 32) (internal/xds/translator/utils.go:60-63), and a later discovery outage reuses the invalid entry instead of restoring the working document; validate against the downstream port range before Set.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 03, 2026 12:50 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2926,34 +2970,127 @@ type cachedOIDCEntry struct {
     
     func newOIDCDiscoveryCache() *oidcDiscoveryCache {
     	return &oidcDiscoveryCache{
    -		entries: make(map[string]cachedOIDCEntry),
    +		entries: make(map[oidcDiscoveryCacheKey]cachedOIDCEntry),
     	}
     }
     
    -func (c *oidcDiscoveryCache) Get(issuer string) (*OpenIDConfig, error, bool) {
    +func (c *oidcDiscoveryCache) Get(issuer, tlsFingerprint string) (*OpenIDConfig, error, bool) {
     	if c == nil {
     		return nil, nil, false
     	}
     
    -	entry, ok := c.entries[issuer]
    +	entry, ok := c.entries[oidcDiscoveryCacheKey{issuer: issuer, tlsFingerprint: tlsFingerprint}]
     	if !ok {
     		return nil, nil, false
     	}
     
     	return entry.config, entry.err, true
     }
     
    -func (c *oidcDiscoveryCache) Set(issuer string, cfg *OpenIDConfig, err error) {
    +func (c *oidcDiscoveryCache) Set(issuer, tlsFingerprint string, cfg *OpenIDConfig, err error) {
     	if c == nil {
     		return
     	}
     
    -	c.entries[issuer] = cachedOIDCEntry{
    +	c.entries[oidcDiscoveryCacheKey{issuer: issuer, tlsFingerprint: tlsFingerprint}] = cachedOIDCEntry{
     		config: cfg,
     		err:    err,
     	}
     }
     
    +// maxOIDCDiscoveryFallbackEntries caps the number of issuers whose last successful discovery
    +// result is retained across translations. The number of OIDC providers used by a cluster is
    +// typically small, so a small bound with LRU eviction is sufficient.
    +const maxOIDCDiscoveryFallbackEntries = 128
    +
    +// oidcDiscoveryFallback retains the last successfully discovered OpenID configuration per issuer
    +// and TLS settings for the lifetime of the process. It is shared by all translations and consulted
    +// when discovery fails, so that a transient IdP outage does not result in a 500 response on every
    +// route protected by that issuer.
    +var oidcDiscoveryFallback = newOIDCDiscoveryFallbackCache(maxOIDCDiscoveryFallbackEntries)
    +
    +// oidcDiscoveryFallbackCache is a size-capped LRU cache of OpenID configurations keyed by issuer
    +// and the TLS settings the configuration was discovered with, so that policies sharing an issuer
    +// with different TLS settings do not overwrite each other's entry. It is safe for concurrent use.
    +type oidcDiscoveryFallbackCache struct {
    +	mu         sync.Mutex
    +	maxEntries int
    +	entries    map[oidcDiscoveryCacheKey]*list.Element
    +	// order holds *oidcDiscoveryFallbackEntry values, most recently used first.
    +	order *list.List
    +}
    +
    +type oidcDiscoveryFallbackEntry struct {
    +	key    oidcDiscoveryCacheKey
    +	config *OpenIDConfig
    +}
    +
    +// oidcDiscoveryTLSFingerprint returns a stable identifier for the TLS settings used to contact
    +// the issuer, so that a retained discovery result is only reused while those settings are unchanged.
    +func oidcDiscoveryTLSFingerprint(providerTLS *ir.TLSUpstreamConfig) string {
    +	if providerTLS == nil {
    +		return ""
    +	}
    +	b, err := json.Marshal(providerTLS)
    +	if err != nil {
    +		// Not expected for the IR types; a non-matching value disables the fallback for this call.
    +		return fmt.Sprintf("unmarshalable:%p", providerTLS)
    +	}
    +	return fmt.Sprintf("%x", sha256.Sum256(b))
    +}
    +
    +func newOIDCDiscoveryFallbackCache(maxEntries int) *oidcDiscoveryFallbackCache {
    +	return &oidcDiscoveryFallbackCache{
    +		maxEntries: maxEntries,
    +		entries:    make(map[oidcDiscoveryCacheKey]*list.Element),
    +		order:      list.New(),
    +	}
    +}
    +
    +// Get returns the last configuration successfully discovered for the issuer with the given TLS
    +// settings, if any, and marks it as the most recently used entry.
    +func (c *oidcDiscoveryFallbackCache) Get(issuer, tlsFingerprint string) (*OpenIDConfig, bool) {
    +	c.mu.Lock()
    +	defer c.mu.Unlock()
    +
    +	elem, ok := c.entries[oidcDiscoveryCacheKey{issuer: issuer, tlsFingerprint: tlsFingerprint}]
    +	if !ok {
    +		return nil, false
    +	}
    +	c.order.MoveToFront(elem)
    +
    +	return elem.Value.(*oidcDiscoveryFallbackEntry).config, true
    +}
    +
    +// Set stores the configuration discovered for the issuer with the given TLS settings as the most
    +// recently used entry, evicting the least recently used entries beyond the cap.
    +func (c *oidcDiscoveryFallbackCache) Set(issuer string, cfg *OpenIDConfig, tlsFingerprint string) {
    +	c.mu.Lock()
    +	defer c.mu.Unlock()
    +
    +	key := oidcDiscoveryCacheKey{issuer: issuer, tlsFingerprint: tlsFingerprint}
    +	if elem, ok := c.entries[key]; ok {
    +		elem.Value.(*oidcDiscoveryFallbackEntry).config = cfg
    +		c.order.MoveToFront(elem)
    +		return
    +	}
    +
    +	c.entries[key] = c.order.PushFront(&oidcDiscoveryFallbackEntry{key: key, config: cfg})

    <sub><sub>!P2 Badge</sub></sub> Bound the fallback cache by retained byte size

    When an issuer returns very large strings in the decoded token, authorization, or end-session fields, this line retains those bytes process-wide, while the 128-entry limit bounds only count and the decoder at securitypolicy.go:2934 has no body-size limit. Cycling through 128 such issuers can therefore retain gigabytes even after their policies are removed, whereas the prior translation cache was collectible after each run; reject oversized discovery responses or make eviction account for retained bytes.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 03, 2026 12:50 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: cc657cfde3

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    zhaohuabing zhaohuabing commented on Nov 04, 2026 05:18 UTC
    Reviewer

    LGTM thanks!

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 04, 2026 06:15 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 5ebd886202

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 04, 2026 06:15 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2729,8 +2733,11 @@ func (o *OpenIDConfig) validate() error {
     	return nil
     }
     
    -func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig) (*OpenIDConfig, error) {
    -	if config, cachedErr, ok := t.oidcDiscoveryCache.Get(issuerURL); ok {
    +// fetchEndpointsFromIssuer discovers the OpenID configuration of the issuer. tokenEndpointOverridden
    +// reports that the policy sets its own token endpoint, so the discovered one is not used.
    +func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig, tokenEndpointOverridden bool) (*OpenIDConfig, error) {
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)

    <sub><sub>!P2 Badge</sub></sub> Memoize TLS fingerprints across route targets

    When an OIDC SecurityPolicy with an inline CA or client certificate is applied through a selector to many routes, buildOIDCProvider invokes this path for every target; although all but the first lookup are served from oidcDiscoveryCache, this line first JSON-marshals and SHA-256-hashes the entire TLS config on every call. A 1 MiB bundle and 1,000 matched routes therefore add roughly a gigabyte of serialization and allocation to each reconciliation, so cache the fingerprint per translated TLS source/config rather than recomputing it before every per-route cache lookup.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    zhaohuabing zhaohuabing commented on code on Nov 04, 2026 09:00 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2729,8 +2733,11 @@ func (o *OpenIDConfig) validate() error {
     	return nil
     }
     
    -func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig) (*OpenIDConfig, error) {
    -	if config, cachedErr, ok := t.oidcDiscoveryCache.Get(issuerURL); ok {
    +// fetchEndpointsFromIssuer discovers the OpenID configuration of the issuer. tokenEndpointOverridden
    +// reports that the policy sets its own token endpoint, so the discovered one is not used.
    +func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig, tokenEndpointOverridden bool) (*OpenIDConfig, error) {
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)

    Thinking about this more, I'd drop the TLS fingerprint from both caches. The discovery document depends only on the issuer, not on the TLS settings used to fetch it, so one entry per issuer is enough. cc @KR-Ravindra

    KR-Ravindra KR-Ravindra commented on code on Nov 04, 2026 10:28 UTC
    Code Review
    internal/gatewayapi/securitypolicy.go:1
    @@ -2729,8 +2733,11 @@ func (o *OpenIDConfig) validate() error {
     	return nil
     }
     
    -func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig) (*OpenIDConfig, error) {
    -	if config, cachedErr, ok := t.oidcDiscoveryCache.Get(issuerURL); ok {
    +// fetchEndpointsFromIssuer discovers the OpenID configuration of the issuer. tokenEndpointOverridden
    +// reports that the policy sets its own token endpoint, so the discovered one is not used.
    +func (t *Translator) fetchEndpointsFromIssuer(issuerURL string, providerTLS *ir.TLSUpstreamConfig, tokenEndpointOverridden bool) (*OpenIDConfig, error) {
    +	tlsFingerprint := oidcDiscoveryTLSFingerprint(providerTLS)

    @zhaohuabing done in 88e846f: dropped the TLS fingerprint from both caches, so they are keyed by issuer only again, and removed the two tests that covered the per-TLS entries. Could you take another look?

    (Experimented and verified with an AI agent.)

    zirain zirain approved these changes on Nov 05, 2026 01:34 UTC
    Approved Reviewer

    Approved these changes.

    zhaohuabing zhaohuabing approved these changes on Nov 05, 2026 01:40 UTC
    Approved Reviewer

    Approved these changes.

    sadovnikov sadovnikov commented on Nov 05, 2026 07:41 UTC
    Contributor

    Thank you, @KR-Ravindra and @zhaohuabing

    Reviewers
    Assignees
    KR-Ravindra KR-Ravindra
    Labels
    risk: low confidence: 79.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 79.3% · Lower = rushed or shallow review
    79.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.8% · Safe to merge
    8.8%