Expand description
Persistence adapter — reads / writes the Workspace from disk
(or other backing stores) so crate::Engine::from_mounts can
consume an in-memory mount list without owning the disk format.
§Two-layer file adapter (default)
FileWorkspaceStore is the default adapter. It splits the
workspace’s persisted state across two files under
<workspace>/.memstead/:
workspace.toml— operator-edited. Carries the persistence- adapter declaration plus (in later sessions) cross-mem permissions, workspace-level policy, plugin hooks. The engine never writes to this file.state/mounts.json— engine-managed. Carries the mount list (per-mount mem name, schema pin, capability, lifecycle, cross-linkable flag, and the backend-specific storage reference — folder path, gitdir+branch pair, or archive path). The operator does not edit this file during normal operation.
The split mirrors the natural authorship: the operator edits rules that change rarely; the engine writes mount-list entries that change often (planning mems, ingest scratch mems, …). Sharing one file would force two authors with different update frequencies through the same merge surface.
§Adapter trait
WorkspaceStoreAdapter is the seam. Future adapters (SQLite,
remote, in-memory test fixture) implement it without changing the
engine API.
The adapter is selected at startup via the persistence-adapter
declaration in workspace.toml — the file adapter is the only
built-in V1.
§Backend instantiation
The adapter produces a Workspace (mount list + operator
policy). Turning each Mount’s MountStorage into a
Box<dyn MemBackend> is a separate concern — handled by
instantiate_lean_backend for folder + archive variants. The
git-branch backend lives in the memstead-git-branch crate behind the
mem-repo Cargo feature; consumers in the lean flavour cannot
materialise a MountStorage::GitBranch mount and surface
InstantiateError::GitBranchRequiresMemRepoFeature.
Structs§
- File
Workspace Store - Two-layer file adapter — the default. Reads
.memstead/workspace.toml(operator) +.memstead/state/mounts.json(engine). Constructed without arguments; everything is keyed off the workspace root passed per-call.
Enums§
- Instantiate
Error - Errors surfaced by
instantiate_lean_backend. - Layout
- On-disk layout the workspace root carries today.
- Store
Error - Errors surfaced by
WorkspaceStoreAdapter::loadandWorkspaceStoreAdapter::save_state. Backend-specific failures surface asStoreError::Otherwith a string message; structured per-adapter errors can extend the enum later.
Constants§
- WORKSPACE_
STORE_ DIR - The engine-managed workspace store directory under the workspace
root —
<workspace_root>/.memstead/holdsworkspace.toml,state/mounts.json, and the tier-3 install cache. Distinct from the per-mem meta directory (memstead_schema::MEM_META_DIR, re-exported ascrate::mem::MEM_META_DIR) and from the literal".memstead/..."member paths inside sealed archives, which are a separate on-disk format and never use this constant.
Traits§
- Workspace
Store Adapter - Adapter trait — the seam between the engine and the persisted
workspace state. Implementations decide where the mount list
lives (two files under
.memstead/, a SQLite database, a remote service, an in-memory test fixture); the engine consumes the producedWorkspaceuniformly.
Functions§
- detect_
layout - Detect the on-disk layout at
workspace_root. The returnedLayoutdiscriminator is total: every workspace falls into exactly one variant. - instantiate_
lean_ backend - Materialise a
MemBackendformountusing the lean-flavour backends (folder + archive). Returns an error for the git-branch variant — full consumers handle that with a feature-gated counterpart inmemstead-git-branch. - is_
mem_ repo_ shaped - True when the workspace root carries
mem-repo/.git/— the multi-mem, git-backed shape. False for the single-mem, history-free filesystem-mem shape. The.memstead/workspace.tomlmarker is shape-neutral, so this directory probe is what distinguishes the two. - is_
workspace_ root - True when
diris a workspace root: it carries.memstead/workspace.toml. The shared recognition primitive for every workspace walk-up (MCP boot, CLI setup, per-command walkers) — keep them all on this helper so workspaces resolve uniformly. - parse_
workspace_ settings - Parse the operator-edited
.memstead/workspace.tomlatworkspace_rootinto a freshWorkspaceSettings. Exposed so MCP- and CLI-driven policy-mutation tools (theworkspace_config_edit::{grant,revoke}_*family) can refresh the engine’s in-memory settings after writing to disk — closing the stale-cache footgun where the next call into the engine after a successful policy mutation still saw the pre-mutation policy. - standalone_
workspace - Synthesize a one-mount
Workspacefrom a bare standalone folder mem — a directory carrying.memstead/config.jsonbut no.memstead/workspace.toml. The mem root is the workspace root (the collapsed single-mem form), so the lone mount is a folder backend pointed atworkspace_rootitself. - workspace_
shape_ label - The one spelling of a workspace’s shape, for any surface that names
it to a human or an agent:
"mem-repo"or"filesystem-mem". Both spellings match the vocabulary the refusals use (UNSUPPORTED_WORKSPACE_SHAPE) and the commands that create each shape (memstead mem-repo init/memstead quickstart).