Runtime Host
KernelRuntime<S> wraps a Kernel with a MemoryStore.
It is the Rust host shape intended for daemons, gateways, embedded processes,
and future monad.ai integration. It owns the lifecycle:
- load a kernel,
- apply a write or
me://execution, - persist the snapshot,
- return the operation result,
- expose the runtime events generated by that operation.
Write-Through Runtime
use this_me::runtime::KernelRuntime;
use this_me::storage::JsonFileStore;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = JsonFileStore::new("/tmp/me-state.json");
let mut runtime = KernelRuntime::load(store)?;
runtime.write("profile.name", "Jabellae")?;
Ok(())
}
Receipts
Hosts normally want the result and the events together:
use this_me::runtime::{runtime_receipt_to_json, KernelRuntime};
use this_me::storage::JsonFileStore;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = JsonFileStore::new("/tmp/me-state.json");
let mut runtime = KernelRuntime::load(store)?;
let receipt = runtime.write_with_receipt(
"apps.fulltrailer.home.count",
3_u64,
)?;
let json = runtime_receipt_to_json(&receipt);
println!("{json}");
Ok(())
}
Receipt shape:
{
"result": "...",
"events": [
{
"path": ["apps", "fulltrailer", "home", "count"],
"operator": null,
"value": 3.0,
"memoryHash": "..."
}
]
}
write_with_receipt and execute_with_receipt drain only the events created by
that operation. Older pending events stay in the runtime queue.
Runtime events are not persisted in snapshots. Semantic memory persists; notification queues do not.