Class: Insika::CacheSeriesStore
- Inherits:
-
Object
- Object
- Insika::CacheSeriesStore
- Defined in:
- lib/insika/cache_series_store.rb
Overview
— per-AGENT cache-hit series (scope "cache_series"), for the Studio agent-detail plot. Sessions do not stamp their agent, so the per-session context trace cannot answer "cache-hit over time for THIS agent"; this capped list can. Entries are counts and a category name only — PII-free by construction. No retention hook: the cap bounds growth.
Constant Summary collapse
- SCOPE =
"cache_series"- MAX_PER_AGENT =
oldest dropped; one entry per turn, so 200 is a
200
Instance Method Summary collapse
-
#for_agent(agent) ⇒ Object
-> [Hash] the agent's series, chronological.
-
#initialize(store:) ⇒ CacheSeriesStore
constructor
rolling window, not a leak path.
-
#record(agent:, entry:) ⇒ Object
Appends a sanitized entry for the agent; caps.
Constructor Details
#initialize(store:) ⇒ CacheSeriesStore
rolling window, not a leak path
14 15 16 |
# File 'lib/insika/cache_series_store.rb', line 14 def initialize(store:) @store = store end |
Instance Method Details
#for_agent(agent) ⇒ Object
-> [Hash] the agent's series, chronological. [] if none.
30 |
# File 'lib/insika/cache_series_store.rb', line 30 def for_agent(agent) = @store.get(SCOPE, agent.to_s) || [] |
#record(agent:, entry:) ⇒ Object
Appends a sanitized entry for the agent; caps. Rescues everything — the series never breaks the turn.
20 21 22 23 24 25 26 27 |
# File 'lib/insika/cache_series_store.rb', line 20 def record(agent:, entry:) return if agent.to_s.empty? list = (@store.get(SCOPE, agent.to_s) || []) + [sanitize(entry)] @store.set(SCOPE, agent.to_s, list.last(MAX_PER_AGENT)) rescue StandardError nil end |