kmp-embedded 0.18.0

In-process KMP composition root over a stamped local SQLite store
Documentation

kmp-embedded

KMP is local-first agent memory that preserves what happened, when and why. This crate is its in-process edition.

The composition root wires application services over a stamped local store with synchronous in-process projection and resolves the data directory. No transport, no infrastructure clients, no cluster — the same kernel semantics the deployed service exposes over gRPC, running inside your process.

use kmp_embedded::{
    EmbeddedKernel, default_engine_for_data_dir, resolve_data_dir_from_env,
};

// Data directory from KMP_MCP_DATA_DIR, or an explicit path.
let dir = resolve_data_dir_from_env()?;
let engine = default_engine_for_data_dir(dir.path());
let kernel = EmbeddedKernel::open_with_engine(dir.path(), engine)?;

Fresh stores always use shareable SQLite. The sqlite feature name remains as a compatibility alias for downstream manifests. An existing store opens from its FORMAT_VERSION; format-1 memory is rejected without being touched. Use KMP 0.3.2 to export that legacy store, then import the portable bundle with the current version. KMP never guesses or silently changes an engine.

Projection is synchronous on purpose: when a write returns, what it materialized is already readable. There is no queue to drain and no eventual window where memory disagrees with itself.

Each memory read pins one SQLite read-only snapshot for graph, bodies, sources, about selection and membership checks. The connection returns to its pool when the operation finishes or is cancelled. A later request opens a new snapshot; cursors still detect changes in the selected content. Projection mutations for one command use one transaction for both graph and details.

Custom application compositions can install a ReadSnapshotProvider on their QueryApplicationService. Configured provider errors propagate. Separate-store compositions without a provider retain their existing best-effort semantics; this is not a distributed-transaction guarantee.

SQLite stores support multiple agent processes. The viewer still mounts in-process so it shares the exact live kernel and adds no daemon, network hop or second read model.

For the consumer-facing surface, see kmp-memory-api. For an MCP server over this kernel, see kmp-mcp.

License

Apache-2.0.