Skip to content

feat(credential-health): per-connection sweep interval via healthCheckInterval (#8443) - #10687

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.50from
maxmad64bis:feat/8443-credential-health-per-connection-interval
Aug 20, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.50from
maxmad64bis:feat/8443-credential-health-per-connection-interval

Conversation

@maxmad64bis

@maxmad64bis maxmad64bis commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The credential health scheduler tests every active provider connection on a single global cadence (CREDENTIAL_HEALTH_CHECK_INTERVAL, default 5 min). There is no way to pace heavy or low-value connections individually, and no per-connection opt-out. Issue #8443 reports the probe volume this generates (~6 000 probe requests/day for ~20 providers, as corrected in the thread).

Fix

  • The sweep reads provider_connections.healthCheckInterval (minutes) per connection: > 0 overrides the global cadence, <= 0 excludes the connection from the sweep (opt-out), absent falls back to the env default. The column already exists (the token-refresh scheduler uses it) — no migration, no API or UI change (the field is already editable per connection).
  • On success the scheduler keeps the per-connection timing (nextAttemptAt = lastAttemptAt + interval) instead of clearing it, so a healthy connection is retested on its own schedule, not every sweep.
  • Failure backoff (5 min → 10 → 30 → 2 h) is unchanged and takes priority.
  • Removed dead code in the same file: OAUTH_INTERVAL_MULTIPLIER (never used — the inert multiplier called out in the issue thread; the header comment claiming OAuth is tested 2x less often was false), getMaxFailuresAcrossConnections (never called), and a leftover interval variable in sweep().

Note on the shared column: a value set for token-refresh purposes also paces credential tests (and 0 disables both) — one knob, two schedulers. A per-connection interval shorter than the global sweep cadence is capped by it (the sweep timer itself is unchanged).

⚠️ base-red inherited: #9985

Verification

The sweep predicates are replicated in the unit tests, following the existing house pattern for this file (the scheduler auto-initializes on import); the replica and the implementation were aligned line by line.

$ node --import tsx/esm --test tests/unit/credential-health-interval.test.ts

# tests 6
# pass 6
# fail 0

$ node --import tsx/esm --test tests/unit/credential-health-backoff-retry.test.ts

# tests 6
# pass 6
# fail 0

The full credential-health family (5 files: active-connections-9180, backoff-retry, boot-wiring, interval, search-providers) passes, 0 fail; the three pre-existing files are unchanged and pass as at base.

$ npx eslint tests/unit/credential-health-interval.test.ts tests/unit/credential-health-backoff-retry.test.ts src/lib/credentialHealth/scheduler.ts

/home/.../src/lib/credentialHealth/scheduler.ts
  21:1  error  '@/lib/localDb' import is restricted ...  no-restricted-imports

✖ 1 problem (1 error, 0 warnings)

The full npm run lint is red on the base branch (25 errors in untouched test files, byte-identical to upstream/release/v3.8.50); the one error above (no-restricted-imports on the @/lib/localDb import) also exists at base. This branch introduces no new lint error.

Tests added/modified: tests/unit/credential-health-interval.test.ts (new), tests/unit/credential-health-backoff-retry.test.ts (adapted: success now spaces the next sweep by the per-connection interval instead of clearing the timing).

…kInterval, opt-out at 0 (cheaper-inference#8443)

The sweep reads provider_connections.healthCheckInterval (minutes) per
connection: > 0 overrides the global cadence, <= 0 excludes the connection
from the sweep (opt-out), absent falls back to CREDENTIAL_HEALTH_CHECK_INTERVAL.
On success the scheduler keeps the per-connection timing
(nextAttemptAt = lastAttemptAt + interval) instead of clearing it, so a healthy
connection is retested on its own schedule. Failure backoff (5min -> 10min ->
30min -> 2h) is unchanged.

Also removes dead code in the same file: OAUTH_INTERVAL_MULTIPLIER (never used,
header comment claiming OAuth is tested 2x less often was false),
getMaxFailuresAcrossConnections (never called), and a leftover interval
variable in sweep().

Tests: new credential-health-interval.test.ts (6 cases, replicated predicates
per the existing house pattern), backoff-retry adapted to the new success
behavior; changelog fragment for cheaper-inference#8443.
@maxmad64bis
maxmad64bis marked this pull request as draft August 18, 2026 18:11
@maxmad64bis
maxmad64bis force-pushed the feat/8443-credential-health-per-connection-interval branch from a659143 to c5faf19 Compare August 18, 2026 18:12
@maxmad64bis
maxmad64bis marked this pull request as ready for review August 18, 2026 18:24
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Solid, focused feature: per-connection sweep cadence via the already-existing provider_connections.healthCheckInterval column, with <=0 as an opt-out and absent falling back to the env default. Correctly reuses the existing column (no migration/API/UI change), removes genuinely dead code (OAUTH_INTERVAL_MULTIPLIER was never used; getMaxFailuresAcrossConnections never called), and ships real unit tests that pass (I verified the full credential-health family green: 6+6+8). Cleanup observations only, none blocking: (1) the isOAuth parameter on testConnection is now fully unused after removing OAUTH_INTERVAL_MULTIPLIER — worth dropping to avoid confusion; (2) the sweep predicates are replicated in the tests rather than imported (documented house pattern because the scheduler auto-inits on import) — keep the replica/implementation aligned as you have been; (3) note the shared-column coupling is real and worth an explicit callout in the release notes: a healthCheckInterval set for token refresh also paces credential health, and 0 disables both (the EditConnectionModal defaults to 60, so configured OAuth connections will now be credential-checked at 60min instead of ~10min — aligned with the probe-volume goal of #8443, but a deliberate behavior change). No new lint errors vs base; the single no-restricted-imports on the @/lib/localDb import predates this PR. ready to merge.

…ction, call out interval coupling in release notes
@maxmad64bis

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Both optional cleanups are in (commit e2160f7): dropped the unused isOAuth param on testConnection, and added the release-notes callout about the shared healthCheckInterval column (60min default for OAuth connections, 0 disables both). Typecheck and tests are clean — only the known omniglyph base-red remains. Ready to merge whenever.

@diegosouzapw
diegosouzapw merged commit 0bfaaa4 into cheaper-inference:release/v3.8.50 Aug 20, 2026
5 checks passed
@maxmad64bis
maxmad64bis deleted the feat/8443-credential-health-per-connection-interval branch September 24, 2026 21:11
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…kInterval (cheaper-inference#8443) (cheaper-inference#10687)

Merged — validated together with a batch of related maxmad64bis PRs in one combined worktree (typecheck:core clean, complexity/cognitive-complexity/file-size/changelog gates green, focused tests passing). Thanks for the contribution!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants