pub fn install_read_mem(
archive_path: &Path,
target: TargetMem<'_>,
ctx: &CommitContext<'_>,
commit_message: &str,
writable_mem_names: &[&str],
) -> Result<InstallOutcome, InstallError>Expand description
Install a sealed mem archive into the global cache and register
it in a writable mem’s config. Accepts the .mem archive format.
Two independent side effects, both idempotent:
- If the content-addressed cache file does not exist: run the submitted bytes
through
validate_and_normalize_archiveand write the validator’scanonical_bytesvia a.tmpsibling + atomic rename. A mid-write crash leaves the temp file behind, never a partial cache file. Existing cache files are left untouched — overwrite-on-newer-version is an app-level update flow, not a CLI install semantic. Users who want to force-replace can delete the cache file first. - If the target mem’s config does not already list this mem
under
readMems, add an entry withsource: { type: "local" }. Existing entries are left untouched so re-running install never clobbers atype: "url"(etc.) source the user configured by hand.
The target parameter selects where the registration lands:
TargetMem::Disk(mem_dir)writes the updated config back to<mem_dir>/.memstead/config.json(legacy disk shape).TargetMem::MemRepo { workspace_root, mem_name }commits the updatedconfigs/<mem_name>.jsontomem-repo-git:main(post- cutover shape).
ctx and commit_message are used only by the MemRepo arm —
the disk arm rewrites the file via the existing config-update path
which has its own (file-mtime-based) provenance trail.
Returns an InstallOutcome describing which effects fired. The
authoritative mem name comes from the validator’s approved
config, not from the submitted filename or caller argument.