From 8a1d9bf910ae899aeae4b440dc616fd3e8801d1b Mon Sep 17 00:00:00 2001 From: Abhishek Divekar Date: Mon, 31 Aug 2026 04:09:42 +0530 Subject: [PATCH] feat(resilience): default the credential health check sweep to 60 minutes (#12138) Validado em worktree combinada com typecheck limpo, testes focados verdes, gates de file-size/complexity/cognitive-complexity/cycles OK. Obrigado! --- src/lib/credentialHealth/scheduler.ts | 4 ++-- src/lib/resilience/settings.ts | 7 ++++--- tests/unit/credential-health-sweep-interval.test.ts | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/lib/credentialHealth/scheduler.ts b/src/lib/credentialHealth/scheduler.ts index 8c2241bc92..d5922e87d2 100644 --- a/src/lib/credentialHealth/scheduler.ts +++ b/src/lib/credentialHealth/scheduler.ts @@ -129,7 +129,7 @@ export function resolveCredentialHealthSweepInterval( const parsed = parseInt(envVal, 10); if (!isNaN(parsed) && parsed >= 10_000) return parsed; } - return 300_000; // default 5 min + return 3_600_000; // default 60 min } /** @@ -142,7 +142,7 @@ function getSweepInterval(): number { const parsed = parseInt(envVal, 10); if (!isNaN(parsed) && parsed >= 10_000) return parsed; } - return 300_000; // default 5 min + return 3_600_000; // default 60 min } /** diff --git a/src/lib/resilience/settings.ts b/src/lib/resilience/settings.ts index e512b18f78..ddb67220a5 100644 --- a/src/lib/resilience/settings.ts +++ b/src/lib/resilience/settings.ts @@ -184,10 +184,11 @@ export const DEFAULT_RESILIENCE_SETTINGS: ResilienceSettings = { // default until an operator adds an override here. providerQuotaOverrides: {}, // Global default cadence for the background credential health check sweep. - // 5 minutes preserves the pre-setting scheduler default (300 000 ms); - // 0 disables the sweep entirely. Per-connection overrides always win. + // 60 minutes: the sweep makes a real upstream probe against EVERY active + // connection, so the previous 5-minute default cost 12 requests/hour per + // connection. 0 disables the sweep entirely. Per-connection overrides win. credentialHealthCheck: { - intervalMinutes: 5, + intervalMinutes: 60, }, }; diff --git a/tests/unit/credential-health-sweep-interval.test.ts b/tests/unit/credential-health-sweep-interval.test.ts index 135d25576f..e79a31dedc 100644 --- a/tests/unit/credential-health-sweep-interval.test.ts +++ b/tests/unit/credential-health-sweep-interval.test.ts @@ -20,13 +20,13 @@ function withEnv(value: string | undefined, fn: () => void) { } } -test("default resilience settings include a 5-minute credential health check cadence", () => { - assert.equal(DEFAULT_RESILIENCE_SETTINGS.credentialHealthCheck.intervalMinutes, 5); +test("default resilience settings include a 60-minute credential health check cadence", () => { + assert.equal(DEFAULT_RESILIENCE_SETTINGS.credentialHealthCheck.intervalMinutes, 60); }); test("resolveResilienceSettings returns the default interval when nothing is stored", () => { const resolved = resolveResilienceSettings({}); - assert.equal(resolved.credentialHealthCheck.intervalMinutes, 5); + assert.equal(resolved.credentialHealthCheck.intervalMinutes, 60); }); test("mergeResilienceSettings stores an operator interval and preserves other sections", () => { @@ -45,9 +45,9 @@ test("mergeResilienceSettings clamps the interval into the 0-1440 band", () => { assert.equal(high.credentialHealthCheck.intervalMinutes, 1440); }); -test("sweep interval: no operator setting and no env → built-in 5 min default", () => { +test("sweep interval: no operator setting and no env → built-in 60 min default", () => { withEnv(undefined, () => { - assert.equal(resolveCredentialHealthSweepInterval({}), 300_000); + assert.equal(resolveCredentialHealthSweepInterval({}), 60 * 60_000); }); }); @@ -87,6 +87,6 @@ test("sweep interval: non-numeric stored interval falls back to env/default", () const settings = { resilienceSettings: { credentialHealthCheck: { intervalMinutes: "abc" } }, }; - assert.equal(resolveCredentialHealthSweepInterval(settings), 300_000); + assert.equal(resolveCredentialHealthSweepInterval(settings), 60 * 60_000); }); });