Redis L2 shared-cache storage driver for Agent Assembly.
This crate implements three of the high-frequency [aa_storage] traits
against a Redis (or Valkey) instance so multiple Assembly processes can
coordinate through one shared cache instead of each hitting the L3 store:
- [
RedisSessionStore] —SessionStore - [
RedisRateLimitCounter] —RateLimitCounter - [
RedisPolicyStore] —PolicyStore, used as a read-through cache in front of the authoritative store
Build a [RedisBackend] from a [RedisStorageConfig] and hand out the
individual stores, or construct each store directly over a shared [Pool].
Key layout
Every key is namespaced under aa::
| Store | Key | Value |
|---|---|---|
| session | aa:session:<session_id> |
hash (agent_id, started_at_ns) |
| rate limit | aa:ratelimit:<key> |
integer counter |
| policy | aa:policy:<agent_id> |
JSON PolicyDocument |
<session_id> and <agent_id> are the lower-case hex encodings of the
16-byte ids.
TTL and invalidation semantics
- Sessions expire after [
SESSION_TTL_SECS] seconds. The TTL is re-armed on everysaveso an actively written session never lapses;deletedrops it immediately and is idempotent. - Rate-limit counters carry the window length supplied to
incrementas their TTL. The expiry is armed exactly once — on the first increment that creates the key — so the window is fixed: it starts at the first hit and is not pushed forward by later increments within the same window.resetdeletes the key. - Policies are cached with an explicit per-entry TTL via
[
RedisPolicyStore::cache_policy] ([DEFAULT_POLICY_CACHE_TTL_SECS] is the suggested default).invalidatedeletes the cached key so the next read misses and reloads from the authoritative store; it is idempotent.