Skip to main content

av_state/
lib.rs

1//! Session/agent state: atomic counters, token-velocity windows, rate limits,
2//! and action budgets (brief Modules B/D and the §8 "In-Memory State" layer).
3//!
4//! The core abstraction is [`StateStore`]: check-and-spend operations that are
5//! atomic even under concurrent tool calls from parallel sub-agents
6//! (silent-error class D13.9 — a budget must never over-spend by racing).
7//! `InMemoryStore` is the single-node reference; a Redis Cluster backend
8//! compiles behind the `redis` feature for multi-node deployments and is
9//! contract-tested against a live server when `AV_REDIS_URL` is set.
10//!
11//! All arithmetic here is checked — budget/monetary code must fail loudly,
12//! never wrap.
13
14pub mod budget;
15pub mod store;
16pub mod velocity;
17
18pub use budget::{ActionBudget, BudgetDecision, BudgetSpec};
19pub use store::{InMemoryStore, Spend, StateError, StateStore};
20pub use velocity::TokenVelocity;
21
22#[cfg(feature = "redis")]
23pub mod redis_store;