Skip to main content

Crate aidaemon_store_sqlite

Crate aidaemon_store_sqlite 

Source
Expand description

§aidaemon-store-sqlite

A SQLite implementation of aidaemon_core::RunStore: an append-only event journal (run_events) plus the latest RunState snapshot per run (run_states), with versioned migrations.

Beyond the trait, SqliteStore offers query helpers an application needs after a restart: SqliteStore::interrupted_runs (waiting on a human decision, settle with Agent::resume) and SqliteStore::in_flight_runs (stopped mid tool batch, continue with Agent::run_from).

With the channels feature, [SqliteApprovalStore] keeps a ChannelRunner’s open approvals in the same database, so they survive a restart (it is the crate that depends on aidaemon-channels, not the other way round, so channels stay free of SQL).

With the client-events feature, [SqliteClientEventLog] is the Client Gateway’s durable event log (resume by seq) and its remembered command replies, in the same database.

maintenance keeps a long-lived database healthy: planner statistics (maintenance::optimize) and consistent live copies (maintenance::snapshot). Write transactions on a shared database should begin with BEGIN IMMEDIATE (pool.begin_with("BEGIN IMMEDIATE")): under WAL a deferred one that reads first fails when another connection commits before it writes.

use std::sync::Arc;
use aidaemon_store_sqlite::SqliteStore;

let store = Arc::new(SqliteStore::open("runs.db").await?);
for state in store.in_flight_runs().await? {
    // agent.run_from(state, CancellationToken::new()).await
}

Modules§

maintenance
Upkeep for a long-lived SQLite database: query-planner statistics and consistent snapshots.

Structs§

Migration
One schema step.
SqliteStore
SQLite-backed RunStore. Cheap to clone (wraps a pool).
StoredEvent
One journal row as stored.

Enums§

Error
Errors from this crate. Converted to StoreError at the trait boundary.

Constants§

MIGRATIONS
Every migration this build knows, in order.

Functions§

erase_session_in_tx
Erase every run of one session from the journal and the checkpoints, in the caller’s transaction (a /wipe deletes conversation text atomically).
latest_version
The newest schema version this build understands.