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§
- Bundle
Event Range - Inclusive positions in the exported event stream. A full-store snapshot starts at one; an empty snapshot has neither bound.
- Bundle
Header - First line of a bundle file: identity and integrity metadata for fail-fast import. Fields added in bundle format 2 default only so format-1 bundles remain readable; every format-2 field is validated before replay.
- Commit
Native Bundle - The committed head bundle paired with the machine store it protects.
- Embedded
Kernel - One opened embedded kernel: the composed service plus the store handle for operational tooling (replay, stats, compaction).
- Embedded
Kernel Store - Every kernel persistence port on one local store.
- Pending
Bundle Export - A marker intentionally has no cleanup in
Drop: unwinding, a killed process, or an ambiguous backend error are precisely the cases that must remain visible todoctor. - Store
Migration Receipt - What a migration did, kept in the store it produced.
Enums§
- Resolved
Data Dir - Where the data directory came from — logged at startup so the winning resolution rule is always visible.
- Storage
Engine - The engine behind a data directory’s
store/. Chosen once, when the directory is created; recorded as itsFORMAT_VERSION; never guessed.
Constants§
- BUNDLE_
FORMAT_ VERSION - 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.
- PENDING_
EXPORT_ DIR - 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§
- clear_
pending_ bundle_ exports - Clears markers after an operator has stopped other writers and explicitly acknowledged that a successful full export contains every committed write.
- 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.
- format_
version_ path - locate_
data_ dir_ from_ env - Resolves from the process environment and touches nothing.
- merge_
bundles - Merges only histories that have a deterministic answer: identical streams or one exact prefix of the other. Two branches that both appended at the same position are a semantic conflict, so KMP refuses to invent an order.
- migrate_
data_ dir - Migrates
source_dirintodestination_dir, returning what was moved. The destination is created with the default engine. - migrate_
data_ dir_ to migrate_data_dirwith 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_envfeeds it. - pending_
bundle_ exports - project_
bundle_ path - The conventional bundle path for the project
data_dirbelongs to. - read_
stamped_ version - The version stamped in
data_dir, without applying the gate. - resolve_
data_ dir - ADR-012 resolution: env override > project
.kernel/> per-user default. Pure function for testability;resolve_data_dir_from_envfeeds 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_ENGINEasks for, if it is set. Unset or empty means “no preference”: a fresh directory gets the default, an existing one opens as it is. - store_
file_ path_ for - Where
enginekeeps its store insidedata_dir. - user_
data_ home - Where user-scope memory lives:
$XDG_DATA_HOME, or~/.local/share. - verify_
bundle - Validates a bundle without opening or mutating a store. This is the recovery check: identity, range, about coverage and digest are all proved before an operator trusts a saved copy.
- write_
bundle_ atomically - Same-directory durable replacement, so a failed export leaves either the previous complete bundle or the next complete bundle, never half a JSONL stream. Unix rename replaces atomically; Windows keeps the previous file beside it until the new one has taken the canonical name.
- write_
bundle_ if_ absent - Publishes an immutable bundle without a check-then-replace race. The hard link is an atomic create-if-absent operation on the same filesystem: two snapshot creators can agree on existing content, but neither can replace the other’s recovery point.
Type Aliases§
- Embedded
Memory Service - 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_readyunconditionally true.