Skip to content

feat(cache): per-breaker persistent stale ceiling#1699

Open
NewCoder3294 wants to merge 1 commit intokoala73:mainfrom
NewCoder3294:feat/per-breaker-persistent-stale-ceiling
Open

feat(cache): per-breaker persistent stale ceiling#1699
NewCoder3294 wants to merge 1 commit intokoala73:mainfrom
NewCoder3294:feat/per-breaker-persistent-stale-ceiling

Conversation

@NewCoder3294
Copy link
Collaborator

Summary

  • Adds optional persistentStaleCeilingMs to CircuitBreakerOptions so individual breakers can override the global 24h PERSISTENT_STALE_CEILING_MS during IndexedDB hydration
  • Risk Scores breaker now uses LS_MAX_STALENESS_MS (1h) to align the persistent ceiling with the localStorage staleness limit from PR fix(cache): align CDN and client TTLs with freshness thresholds #1320
  • Backwards compatible — omitting the option defaults to existing 24h behavior

Changes

  • src/utils/circuit-breaker.ts — new option field, private instance field, used in hydratePersistentCache()
  • src/services/cached-risk-scores.ts — passes persistentStaleCeilingMs: LS_MAX_STALENESS_MS
  • tests/circuit-breaker-persistent-stale-ceiling.test.mts — 39 tests (static analysis, behavioral, edge cases, concurrency, encapsulation)

Test plan

  • 39 new tests covering static analysis, behavioral, boundary conditions (> vs >=), exotic values (NaN, Infinity, -Infinity), interaction with cacheTtlMs=0 and persistCache=false, multi-breaker isolation, concurrent execution, and encapsulation
  • All 1491 existing tests pass (0 failures)
  • TypeScript typecheck clean
  • Biome lint clean on changed files

Closes #1326

🤖 Generated with Claude Code

The global PERSISTENT_STALE_CEILING_MS (24h) is too permissive for
time-sensitive data like CII risk scores. This adds an optional
persistentStaleCeilingMs to CircuitBreakerOptions so individual
breakers can override the global default during persistent cache
hydration.

Risk Scores breaker now uses LS_MAX_STALENESS_MS (1h) to align
the IndexedDB persistent ceiling with the existing localStorage
staleness limit from PR koala73#1320.

Closes koala73#1326

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 15, 2026

@NewCoder3294 is attempting to deploy a commit to the Elie Team on Vercel.

A member of the Team first needs to authorize it.

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.

feat(cache): per-breaker persistent stale ceiling

1 participant