Expand description
Decision cache for policy evaluation results.
Provides an LRU-based cache that stores Verdict results keyed by
Action identity (tool, function, paths, domains) and optional
agent identity. Cached verdicts are invalidated when the policy
generation counter is bumped (e.g., on policy reload).
§Security
- Context-dependent results are NOT cached. When the
EvaluationContextcarries session-dependent state (call counts, previous actions, time windows, call chains, capability tokens, session state), the result depends on mutable session state and must be evaluated fresh every time. - Fail-closed on lock poisoning. If the internal
RwLockis poisoned,getreturnsNone(cache miss) andinsertis a no-op. This ensures a poisoned cache never serves stale Allow verdicts. - Bounded memory. The cache enforces
MAX_CACHE_ENTRIESand evicts the least-recently-used entry when at capacity. - Counters use
fetch_add. Hit/miss/eviction counters useu64atomics, which cannot practically overflow (584-year wraparound at 1 GHz increment rate). The LRU access counter usesSeqCstordering.
Structs§
- Cache
Stats - Aggregate cache performance statistics.
- Decision
Cache - LRU decision cache for policy evaluation results.
Constants§
- MAX_
CACHE_ ENTRIES - Absolute upper bound on cache entries to prevent memory exhaustion.
- MAX_
TTL_ SECS - Maximum allowed TTL in seconds (1 hour).
- MIN_
TTL_ SECS - Minimum allowed TTL in seconds.