Expand description
The StateStore trait and the in-memory reference implementation.
Structs§
- InMemory
Store - Single-node in-memory store: atomic counters behind a short transaction mutex that serializes check-and-spend so multi-key spends stay atomic.
- Refund
- One key/amount entry in an atomic multi-dimensional refund. Twin to
Spend. Introduced in R67 to close R66 F2: the previous shape issued 3 independentstore.refundcalls (total_calls, per-tool, payout), each its own Redis round-trip. Crash/reconnect between steps left partial refund state; concurrenttry_tool_callunderInMemoryStorecould observe partially-refunded state (freshtotal_callsheadroom but still-charged per-tool) — an ordering result impossible under a single-Lua refund and a cross-backend divergence withRedisStore(which has zero serialization between the 3 refunds). - Spend
- One key/amount/limit entry in an atomic multi-dimensional spend.
Enums§
- State
Error - State-layer errors.
- TrySpend
Outcome - Outcome of an atomic multi-dimensional spend. Carries the post- commit min-headroom across the spent keys on success — a value that CANNOT race with a concurrent spend/refund because it is computed inside the same atomic Lua (RedisStore) / mutex-critical section (InMemoryStore) that commits the spend.
Traits§
- State
Store - Atomic counter operations. Every mutation is atomic with respect to
concurrent callers;
try_spendis a single check-and-spend (never a read-then-write).