Expand description
Read-mem cache resolution, published-config reads, and the install-to-cache side effect.
Every sealed-archive byte entering the cache goes through
validate_and_normalize_archive — the install path reads the
submitted archive, hands the bytes to the validator, and writes the
validator’s canonical_bytes via a temp-plus-atomic-rename so no
partial archive ever lands on disk. Steady-state loads (through
read_published_config or the entity loader) trust the cached
bytes: they were canonical at write time and re-validation on every
load would just pay for the same work twice.
The cache base path resolves via dirs::data_dir() so the same path
works on macOS (~/Library/Application Support/memstead/mems), Linux
($XDG_DATA_HOME/memstead/mems or ~/.local/share/memstead/mems), and
Windows (%APPDATA%\memstead\mems). For tests, MEMSTEAD_MEM_CACHE
overrides the base so temp dirs can stand in without touching the
user’s real data directory.
Structs§
- Cache
Install Outcome - Install a sealed mem archive into the global cache and register
it in a writable mem’s config. Accepts the
.memarchive format.
Enums§
- Install
Error - Mount
Registration - What happened on the mount-registration side of an install.
Constants§
- CACHE_
OVERRIDE_ ENV - Env var that overrides
<data_dir>/memstead/memsfor tests.
Functions§
- install_
to_ cache - Validate an archive and land it in the global content-addressed
cache — the cache-side half of
memstead install, with no config or mount side effects (the caller registers the returned archive as a workspace-level read-only mount). Shares the validator, the shadow-name gate, and the content-addressed atomic-rename write with the historical combined path. - mem_
cache_ dir - Resolve the global mem-cache directory.
- read_
published_ config - Read the whitelisted
.memstead/config.jsonfrom a cached archive. - register_
cached_ archive - Register a cached archive (the outcome of
install_to_cache) as a workspace-level read-only mount on the live engine — the shared back half ofmemstead installand the MCP server’s--read-memboot flag. Idempotent per content: an existing read-only mount under the same name is a no-op when it already points at this cache file, and an in-place refresh (unregister + re-register) when the content changed. The caller persists the mount state (engine.persist_state()) after aRegistered/Refreshedoutcome.