Skip to main content

Crate kmp_embedded

Crate kmp_embedded 

Source
Expand description

Embedded edition composition root (ADR-013): wires the application services over the local store with synchronous in-process projection, and resolves the data directory per the ADR-012 contract and the storage engine per ADR-018. No transport, no infrastructure clients.

Structs§

EmbeddedKernel
One opened embedded kernel: the composed service plus the store handle for operational tooling (replay, stats, compaction).
EmbeddedKernelStore
Every kernel persistence port on one local store.
StoreMigrationReceipt
What a migration did, kept in the store it produced.

Enums§

ResolvedDataDir
Where the data directory came from — logged at startup so the winning resolution rule is always visible.
StorageEngine
The engine behind a data directory’s store/. Chosen once, when the directory is created; recorded as its FORMAT_VERSION; never guessed.

Constants§

DATA_DIR_ENV
Explicit data directory override (ADR-012 rule 1).
ENGINE_ENV
Explicit engine override for a fresh data directory. Without it, the user-facing binary chooses SQLite when compiled and redb otherwise; existing directories always open from their stamp.
PROJECT_BUNDLE_PATH
Where a project keeps the committed copy of its memory, relative to the project root.
SUPPORTED_FORMAT_VERSION
The layout this binary creates for a fresh data directory, and the one it has always created: redb (ADR-009).

Functions§

default_engine_for_data_dir
Implicit engine choice for a data directory when no operator override is present. Existing stores defer to their stamp; fresh stores prefer the shareable engine when this build carries it.
ensure_data_dir_skeleton
Creates the non-store part of a KMP data directory.
migrate_data_dir
Migrates source_dir into destination_dir, returning what was moved. The destination is created with the default engine.
migrate_data_dir_to
migrate_data_dir with the destination engine chosen — how a store changes engines (ADR-018). A redb store becomes a SQLite one that two agent hosts can share by replaying its history into a fresh directory; the source stays as it was and the receipt records both layouts.
open_or_migrate_data_dir
Migrate once, reopen afterwards. Safe on every start: a destination that already holds a store is opened as it is, and the returned receipt says whether this call was the one that migrated it.
parse_engine
Parses an engine name the way the environment variable and the CLI spell it. Pure, for testing; resolve_engine_from_env feeds it.
project_bundle_path
The conventional bundle path for the project data_dir belongs to.
resolve_data_dir
ADR-012 resolution: env override > project .kernel/ > per-user default. Pure function for testability; resolve_data_dir_from_env feeds it from the process environment.
resolve_data_dir_from_env
Resolves from the process environment and prepares the directory. Every data directory gets the same safety skeleton, regardless of whether it was discovered from a project, supplied explicitly, or created by migration.
resolve_engine_for_data_dir_from_env
Resolves the engine for a particular data directory.
resolve_engine_from_env
The engine KMP_MCP_ENGINE asks for, if it is set. Unset or empty means “no preference”: a fresh directory gets the default, an existing one opens as it is.

Type Aliases§

EmbeddedMemoryService
The KMP memory facade composed over the embedded store: every port is the same single-file redb store, and ingest projects synchronously in-process, which is what makes read_after_write_ready unconditionally true.