Repository navigation
feat(cli): import --from <store|bundle> --about into the live store (#903) - #907
Merged
Merged
Conversation
…ng (#903) EmbeddedKernelStore::import_abouts compares each (about, role) stream of a verified bundle with the destination log and, in one SQLite write transaction, replays absent streams, leaves identical ones alone, extends exact prefixes with the missing tail, and refuses divergence, a destination ahead, reused idempotency keys and relations that would dangle. EmbeddedKernelStore::open_read_only reads another store through read-only SQLite connections without stamping, migrating or adopting it.
tgarciai
merged commit Oct 4, 2026
8c756eb
into
integration/903-workspace-memory
35 of 36 checks passed
4 tasks done
tgarciai
added a commit
that referenced
this pull request
Oct 4, 2026
…d about import (#903) (#905) S1 projects beat the saved selection; an existing .kernel marks a project; git worktrees share the main checkout store (#904). S2 every session names the store it opened, in initialize and on every kmp_wake (#906). S3 kmp-mcp memories: one inventory of every store, its reach and its abouts; memories register (#908). S4 kmp-mcp import --from <store|bundle> --about: incorporate exact abouts into a live store, all or nothing, idempotent (#907).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice S4 of #903 (decision D4, option A): use memory from another workspace by incorporating exact abouts into the live store.
Behaviour
Into the store
kmp-mcpresolves here (KMP_MCP_DATA_DIR/ project / saved / user), opened exactly as plainimportopens it.--aboutis required with--fromand vice versa; abouts are opaque and matched exactly. A requested about the source lacks is refused before anything is written.EmbeddedKernelStore::open_read_only— read-only SQLite connections (SQLITE_OPEN_READ_ONLY+query_only), nocreate_dir, no FORMAT_VERSION stamp/upgrade, no card adoption, no journal-mode switch, no writer lock; schema andquick_checkstill verified. Exported through the existing filtered export path (export_bundle_for_abouts). A workspace path is accepted for its.kernel/. A source whose legacy cards were never adopted into its event log is refused (exporting it would drop them).(about, role)event stream (the store's aggregate key):BEGIN IMMEDIATE), so no other writer commits in between and a refusal writes nothing. A second run reports every aboutunchangedand writes nothing.{"abouts":[...],"aggregates":{"<about>":"imported|unchanged|extended"},"data_dir":...,"events_imported":N,"from":...,"mutations_applied":M}; refusals exit 2 with the reason on stderr.kmp-mcp import [file](empty-store replay) is unchanged. No new MCP tool (16).Decisions
Prefix → extend (not refuse). Appending revision
n+1to a stream at headnis exactly the live write path (append_in_transactionrequirescurrent == expectedand assignscurrent + 1); projections are applied per event in the same transaction, asappend_projecteddoes. Imported events land at the end of the log, so a full rebuild reproduces the same projections —kmp-embedded/tests/import_abouts.rsasserts wake (nodes and relationships) is identical to the source's and unchanged byrebuild_projections. The lexical sidecar follows the log by position/tail, so it picks the new events up on its next catch-up.Relations → refuse. The projection silently materialises a missing relation endpoint as an
UNMATERIALIZEDplaceholder node, and the write path only allows a cross-about relation to a ref verified to exist. So an appended relation whose endpoint is produced by no event of the requested abouts (whole source stream) and does not exist as a non-placeholder node here is refused, naming the relation and the missing node and suggesting the extra--about. Measured first on a copy of a real 474-event user store: each of its 20 abouts imported alone into an empty store with zero refusals, so the rule does not reject ordinary memory. Strictness to be aware of: a relation already dangling in the source is refused too.Verification
about_import_plan), 10 adapter tests (kmp-adapter-embedded/tests/about_import.rs: imported + idempotent rerun, prefix extended to the source's exact digest, divergence refused with event count and digest unchanged and a valid sibling about not written, destination ahead, missing/near-miss about, dangling relation refused then accepted with its owner, relation to an existing destination node, idempotency-key collision, source store byte-identical + writes refused through the read-only handle, non-store dir refused and not created), 1 kernel test (kmp-embedded/tests/import_abouts.rs: live source read while open, imported then extended, wake parity, rebuild parity, about stays writable), 3 binary tests on a hermetic machine (kmp-mcp/tests/import_from_cli.rs: store source imported/unchanged/document, source tree byte-identical, bundle source divergence refused with digest unchanged, missing about, argument rules without preparing the store).cargo test --locked -p kmp-mcp -p kmp-embedded -p kmp-adapter-embedded: 1516 passed, 0 failed, 3 ignored;kmp-releasetests green.cargo fmt --all,cargo clippy --locked --workspace --all-targets -- -D warnings,scripts/ci/kmp-mcp-architecture-gate.sh(0 debt),scripts/ci/mcp-registry.sh(16 tools),scripts/ci/kmp-capability-contract.py: pass.help.txt,import.txt); guide entryadvanced:import-aboutsadded toeditorial.jsonand assets regenerated; CHANGELOG[Unreleased]entry.KMP_MCP_DATA_DIR: every about of a copied user store, and the copiedmy-ships-gamestore (46 events → imported, then unchanged;documentrenders; missing about refused).Not done / notes
import; SQLite's write lock is what serialises against live sessions..kmp/memory.jsonlis not refreshed after import (same as plainimport); the nextexport/kmp:saveshows the diff.known-stores.jsonlis not touched (S3's inventory).-wal/-shmmay leave those (empty) SQLite sidecars behind; the database file and everything else stay byte-identical (tested).serveholds the destination open (singleBEGIN IMMEDIATEwith the 10 s busy timeout should wait it out; untested). Not run: an all-abouts import of the real-store copy compared by digest against its full export.crates/kmp-mcp/src/cli/mod.rshelp text andfixtures/contract/cli/help.txt; whoever merges second re-blesses.