Skip to main content

Module mem_management

Module mem_management 

Source
Expand description

Mem-lifecycle orchestrator — full home for the multi-mem create and delete pipelines. The matcher primitives (memstead_base::CreateRuleSet, memstead_base::DeleteRuleSet, memstead_base::MatcherSet) stay in lean because the lean engine’s cross_mem_link_allowed synthesises a memstead_base::CreateRuleSet on multi-folder workspaces. Only the lifecycle orchestrators — create_mem, delete_mem, their param/response types, the shared NOTE_MAX_LEN cap, and the validate_mem_path helper — live here.

Functions take &mut memstead_base::Engine directly rather than going through a FullEngine wrapper struct: the lean engine is a single polymorphic Engine parameterised by Box<dyn MemBackend> and already carries every state field the orchestrators need (mem_router, settings, backend_factory, workspace_root, git_branch_ops). Full contributes lifecycle as free functions over that engine; no separate engine type, no policy-provider trait.

Return type is Result<_, crate::FullEngineError>. Lean-side failures (InvalidInput, UnknownMem, SchemaResolverInit, SchemaNotFound, MemNameCollision, Mem(_), Backend(_)) propagate verbatim through FullEngineError::Lean(_) via the #[from] memstead_base::EngineError conversion — the ? operator on engine.persist_state()? and similar lean calls does the wrap automatically. The four lifecycle-only variants (MemPathNotAllowed, MemReferencedByPolicy, MemSchemaNotAllowed, ConfigAlreadyExists) are constructed as FullEngineError::* directly; they no longer live in memstead_base::EngineError.

Structs§

AllowlistEntryRemoved
One scrubbed .memstead/workspace.toml entry surfaced on MemDeleteResponse::allowlist_entries_removed. Only dangling [cross_mem_links] grants are scrubbed, so table is always "cross_mem_links" and from / to name the directionality the grant established (from is the table key, to is the array element or wildcard). The pattern field is retained on the stable response shape but is no longer populated — the [[mem_management.*]] allowlist rules are preserved across a delete and therefore never reported here.
MemCreateParams
Parameters for create_mem. Mirrors the memstead_mem_create MCP tool’s wire shape 1:1.
MemCreateResponse
Response shape from create_mem.
MemDeleteParams
Parameters for delete_mem. Mirrors the memstead_mem_delete MCP tool’s wire shape 1:1, plus a transport-side operator_mode flag the wire shape does not expose.
MemDeleteResponse
Response shape from delete_mem.
MemRenameParams
Parameters for rename_mem.
MemRenameResponse
Response of rename_mem.

Enums§

StorageKind
Explicit storage-backend override for create_mem. The default (MemCreateParams.storage: None) keeps the workspace-shape heuristic: git-branch when <workspace_root>/mem-repo/.git/ exists, folder otherwise. Passing Some(_) pins the backend regardless of workspace shape — the mount loader and runtime already handle mixed-backend workspaces (per-mount backend dispatch), so a folder mem can live beside git-branch mems.

Constants§

NOTE_MAX_LEN
Note-length cap shared with memstead_create / memstead_update / full’s lifecycle orchestrators. Mirrors memstead_git_branch::NOTE_MAX_LEN.

Functions§

create_mem
Create a new writable mem at runtime. Unified counterpart to full’s memstead_git_branch::mem_management::create_mem. Routes through the engine’s installed memstead_base::BackendFactory so the same call site materialises folder, archive, or git-branch backends transparently — production full consumers install memstead_git_branch::storage::instantiate_full_backend at boot via engine_from_workspace_root.
delete_mem
Unregister a writable mem at runtime. The unified-engine counterpart to full’s memstead_git_branch::mem_management::delete_mem.
rename_mem
Rename a mem: oldnew, complete across every surface that carries the name.