Skip to main content

Crate allen_store_sqlite

Crate allen_store_sqlite 

Source
Expand description

Implements allen_store::AgentStore on local SQLite through a single-owner Tokio actor that enforces BEGIN IMMEDIATE, PRAGMA synchronous = FULL, and SHA-256 checksummed startup migrations.

§Architecture & Layer Role

Within the Allen Open Agent Infrastructure Standard, allen-store-sqlite is the single-node Layer 1 persistence backend. Local binaries (the host authority daemon, allen, and standalone CLI consumers) pair it with allen-runtime for durable sessions, fenced run leases, effect journals, command deduplication receipts, and checked integer spend tracking without an external database service. It satisfies the same allen_store::conformance invariants as allen_store::InMemoryStore and external custom backends.

§Quick Start

Pass ":memory:" for an isolated in-memory SQLite database (useful in tests) or a filesystem path for durable on-disk storage:

use allen_store::{CommandStore, LeaseStore, OwnerId, SessionStore, StepCommit};
use allen_store_sqlite::{JournalMode, SqliteAgentStore, SqliteStoreConfig};
use allen_types::ids::{SessionId, SessionRevision, TenantId};
use std::time::Duration;

let cfg = SqliteStoreConfig::try_new(":memory:")
    .unwrap()
    .with_journal_mode(JournalMode::Wal);
let store = SqliteAgentStore::connect_and_migrate(cfg).await.unwrap();

let tenant = TenantId::try_new("org:local").unwrap();
let session = SessionId::try_new("sess:1").unwrap();
let owner = OwnerId::try_new("node-1").unwrap();

store.create_session(&tenant, &session, None).await.unwrap();
let lease = store
    .acquire_session_lease(&tenant, &session, &owner, Duration::from_secs(30))
    .await
    .unwrap();
let committed = store
    .commit_step(&lease, StepCommit::empty(SessionRevision::INITIAL))
    .await
    .unwrap();
assert_eq!(committed.new_revision, SessionRevision::from_u64(1));

§API Guide

§Durability & Concurrency Invariants

Modules§

durabledurable
Unified durable session persistence backed by crate::SqliteAgentStore.

Structs§

SqliteAgentStore
Cloneable handle to the single-owner SQLite Tokio actor implementing allen_store::AgentStore.
SqliteStoreConfig
Validated connection configuration for SqliteAgentStore::connect_and_migrate.

Enums§

JournalMode
SQLite journal mode configured on the actor’s database connection.