Skip to content

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

@koala73

Description

@koala73

Problem

PERSISTENT_STALE_CEILING_MS in src/utils/circuit-breaker.ts:34 is a global 24h constant. Even after reducing risk scores localStorage staleness to 1h (PR #1320), the IndexedDB persistent cache can still serve 24h-old data as a last resort. For a conflict monitoring app, day-old CII risk scores are unacceptable.

Solution

Add an optional persistentStaleCeilingMs parameter to CircuitBreakerOptions. When provided, override the global PERSISTENT_STALE_CEILING_MS for that breaker. Risk scores would use 1h while other breakers keep the 24h default.

Files

  • src/utils/circuit-breaker.ts (line 34, options interface, persistent cache hydration)
  • src/services/cached-risk-scores.ts (line 171, breaker creation)

Context

Discovered during cache TTL audit (PR #1320). Plan explicitly deferred this as a separate task to avoid modifying a global constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: APIBackend API, sidecar, keysenhancementNew feature or requestperformancePerformance optimizationrefactorCode restructuring, architecture

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions