-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add TTL eviction to ProviderHealthTracker in-memory records #817
Description
Context
The ProviderHealthTracker (added in #773) uses an append-only in-memory list for ProviderHealthRecord entries. The get_summary() and get_all_summaries() methods filter to a 24-hour window, but old records are never evicted from the backing list.
This mirrors the existing CostTracker pattern, which has the same unbounded growth characteristic.
Problem
Over extended runtime (days/weeks), the _records list grows without bound. For a health tracker recording every provider call, this could accumulate millions of records and cause:
- Gradual memory growth
- Increasingly slow
_snapshot()calls (copies the entire list) - Eventually OOM
Proposed Solution
Add periodic eviction of records older than _HEALTH_WINDOW_HOURS during _snapshot() when the list exceeds a configurable threshold (e.g., 100,000 records). Apply the same pattern to CostTracker as well.
Found By
Pre-PR review agent (silent-failure-hunter) during #773 review.