Adds event sourcing to atomr actors with the Eventsourced trait, journals, snapshots, and multiple storage backends (SQL, Redis, MongoDB, Cassandra, DynamoDB, Azure).
Ships in atomr-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
atomr-persistence provides the plugin traits (Journal,
SnapshotStore, ReadJournal) and a high-level Eventsourced trait
that hides most of the recovery plumbing. Each backend ships as its
own crate so applications only pull in the drivers they actually use.
| Crate | Backend | Default feature |
|---|---|---|
atomr-persistence-sql | SQLite, Postgres, MySQL, MSSQL (via sqlx) | sqlite |
atomr-persistence-redis | Redis / KeyDB (via fred) | — |
atomr-persistence-mongodb | MongoDB | — |
atomr-persistence-cassandra | Cassandra / ScyllaDB | — |
atomr-persistence-aws | DynamoDB single-table | — |
atomr-persistence-azure | Azure Table Storage | — |
[dependencies]
atomr = { version = "0.2", features = ["persistence"] }
atomr-persistence-sql = { version = "0.1", default-features = false, features = ["postgres"] }
Every adapter is validated against atomr-persistence-tck's shared
conformance suite — if the suite passes, the adapter is interchangeable.
See docs/persistence-providers.md for the full provider matrix and
the integration-test environment variables (ATOMR_IT_REDIS_URL, etc.).
CI runs the integration matrix against Postgres, MySQL, Redis,
MongoDB, Cassandra, DynamoDB (local), Azurite (Azure Table emulator),
and redb on every PR — treat a green matrix as the bar for adapter
changes.
Eventsourced traitExpress a persistent entity as: state + commands → events + how events mutate state. The trait derives the recovery loop for you.
use async_trait::async_trait;
use atomr_persistence::{Eventsourced, EventsourcedError};
struct Counter { id: String }
#[async_trait]
impl Eventsourced for Counter {
type Command = CounterCmd;
type Event = CounterEvent;
type State = CounterState;
type Error = CounterErr;
fn persistence_id(&self) -> String { self.id.clone() }
fn command_to_events(
&self,
state: &Self::State,
cmd: Self::Command,
) -> Result<Vec<Self::Event>, Self::Error> { /* validate, emit events */ }
fn apply_event(state: &mut Self::State, e: &Self::Event) { /* mutate state */ }
fn encode_event(e: &Self::Event) -> Result<Vec<u8>, String> { /* ... */ }
fn decode_event(bytes: &[u8]) -> Result<Self::Event, String> { /* ... */ }
}
Rules:
apply_event must be pure and total. It runs both during command
handling AND during replay. Side effects belong in the actor's
command handler, not here.command_to_events is allowed to fail. Validation lives here —
reject invalid commands before any event is persisted.persistence_id is the entity's address in the journal. It must
be stable across restarts and must not collide with another entity's id.See examples/event-sourced-counter/ for the full pattern with
snapshots and bounded recovery.
Snapshots compress recovery. With a snapshot every N events, recovery
loads latest_snapshot + events_since_snapshot instead of replaying
the entire journal.
use atomr_persistence::{AsyncSnapshotter, SnapshotPolicy, InMemorySnapshotStore};
let snapshots = InMemorySnapshotStore::new();
let snapshotter = AsyncSnapshotter::new(snapshots, SnapshotPolicy::Periodic { every: 100 });
AsyncSnapshotter writes off the actor's hot path — the actor
doesn't block on snapshot persistence.
Tune every to your event size and recovery SLO. Smaller = faster
recovery + more snapshot writes. Larger = the opposite.
RecoveryPermitterWhen many entities recover concurrently (e.g. cold cluster start),
unbounded parallel replay can saturate the journal. RecoveryPermitter
caps the number of simultaneous recoveries:
let permits = RecoveryPermitter::new(64);
Wire it through your Eventsourced setup; it acts like a semaphore
around recovery.
persistence-queryFor projections, CQRS read models, or audit, enable persistence-query
and use ReadJournal to consume tagged events. Today this is supported
by the SQL adapter; others may follow. See
crates/atomr-persistence-query/.
InMemoryJournal and InMemorySnapshotStore are real implementations
of the journal/snapshot traits intended for tests and examples. They
satisfy the same conformance suite as the production adapters but lose
data on restart.
use atomr_persistence::{InMemoryJournal, InMemorySnapshotStore};
let journal = Arc::new(InMemoryJournal::default());
let snapshots = InMemorySnapshotStore::new();
Your backend must satisfy atomr-persistence-tck's suites:
journal_suite — append, read range, delete rangejournal_tag_suite — tagged stream replay (if implementing query)snapshot_suite — save, load latest, deleteA passing TCK run is the bar for "compatible with atomr-persistence".
examples/event-sourced-counter/ — Eventsourced + snapshotscrates/atomr-persistence/src/eventsourced.rs — trait definitioncrates/atomr-persistence/src/recovery_permitter.rs — bounded recoverycrates/atomr-persistence/src/async_snapshot.rs — AsyncSnapshottercrates/atomr-persistence-tck/ — conformance suitedocs/persistence-providers.md — provider matrix and env varsSpec parity tests cover the recovery and event-sourcing semantics:
look for EventsourcedSpec, RecoverySpec, PersistentFSMSpec, and
ALODSpec (at-least-once delivery) when verifying corner cases.
apply_event. They will run during replay too,
causing double-sends, duplicate writes, etc.apply_event. It won't be present
after recovery.bincode of structs you'll edit.Periodic { every: N } based on event size.persistence_id for a different entity type. The
journal will happily serve those events back to the wrong decoder.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
6 skills in this plugin
/atomr-actor-designUse when authoring or modifying an actor in a project that depends on atomr. Covers Msg type design, the Actor trait's lifecycle hooks, ask vs tell, supervision strategies, and FSM patterns. Triggers on writing or editing an `impl Actor`, choosing a Msg enum, picking a supervision strategy, or wiring `Props`/`ActorSystem`./atomr-clusterUse when bringing up clustering, sharding, singleton, distributed pub/sub, or distributed-data (CRDT) features in a project that depends on atomr. Covers feature flag selection, seed-node bootstrap, MessageExtractor design for sharding, and DistributedPubSub patterns. Triggers when adding cluster membership, ShardRegion, ShardCoordinator, ClusterSingleton, or Replicator usage./atomr-/atomr-ai-skills:atomr-persistencefrom atomr-ai-skills
npx claudepluginhub rustakka/atomr --plugin atomr-ai-skills