Expand description
Unified engine.
One Engine type, three storage backends: the engine sits
above MemBackend and routes reads / writes to the backend
named by each mount’s mem. Consumers reach the engine through
Engine::from_workspace_root (folder + archive backends) or
memstead_git_branch::engine_from_workspace_root (adds git-branch).
§Routing
Each mount holds one mem. Lookup is by mem name: the first
mount whose mem field equals the requested name wins. One mount
per mem is enforced — duplicates are a configuration bug, not a
feature, and the constructor rejects them.
Re-exports§
pub use archive::FromArchiveBytesError;pub use error::BootError;pub use error::EngineError;pub use error::INLINE_LIST_CAP;pub use error::MissingWikiLink;pub use error::ReferrerInfo;pub use error::SchemaSourceDiagnostic;pub use error::StaleCause;pub use error::format_inline_list_overflow;pub use events::DEFAULT_BROADCAST_CAPACITY;pub use events::EventCallback;pub use events::MemChangedEvent;pub use events::SubscriptionHandle;pub use history::EntityHistoryReport;pub use history::EntityTouch;pub use history::HISTORY_PAGE_DEFAULT;pub use history::HISTORY_PAGE_MAX;pub use history::StoryStart;pub use mutation::delete::DeleteReferrers;pub use mutation::PATCH_OLD_NOT_FOUND_CONTENT_CAP;pub use mutation::RELATIONSHIP_CYCLE_PATH_CAP;pub use outcomes::CreateEntityArgs;pub use outcomes::CreateEntityOutcome;pub use outcomes::DeleteEntityArgs;pub use outcomes::DeleteEntityOutcome;pub use outcomes::ExpectedHash;pub use outcomes::HashOverride;pub use outcomes::RelateAction;pub use outcomes::RelateEntityArgs;pub use outcomes::RelateEntityOutcome;pub use outcomes::RenameEntityArgs;pub use outcomes::RenameEntityOutcome;pub use outcomes::RetypeEdge;pub use outcomes::RetypeEdgeDirection;pub use outcomes::RetypeEntityArgs;pub use outcomes::RetypeEntityOutcome;pub use outcomes::RetypeProblem;pub use outcomes::SetSchemaOutcome;pub use outcomes::SetSchemaResult;pub use outcomes::UpdateEntityArgs;pub use outcomes::UpdateEntityOutcome;pub use review::ReviewMarkStatus;pub use review::SetReviewMarkOutcome;pub use boot::SchemaResolver;pub use boot::load_workspace_schemas;pub use boot::resolve_builtin_schema_pin_pub;pub use lifecycle::SchemaStaging;
Modules§
- apply_
commit - Apply a
CommitEnvelopeto the in-memory store. - archive
- Byte-based snapshot API: hydrate an engine from sealed
.memarchive bytes, and export a mem’s current state back to archive bytes. - boot
- Engine construction —
from_mounts*andfrom_workspace_root. - check_
ops - The check operation and derived check state.
- checks_
transport - The check ledger’s transport between machines.
- conflicts
- Merge-conflict resolution for folder mems.
- drift
- Drift detection and per-mem change synthesis.
- due
- The due-brief: a schema declares its
deadline axis (
memstead_schema::DueAxis), the engine renders “what is due next” as one deterministic markdown brief. - error
- Engine error envelopes.
- events
- Mem-change events: runtime-agnostic callback-based subscribe API.
- export_
html export --format html: one self-contained HTML file per mem — the read surface for non-operators. A file you hand to a person: no server, no account, no installed anything.- export_
llms_ txt - Render one mem as a single agent-readable Markdown document — the
/llms-full.txtshape, shared by the served endpoint andmemstead export --format llms-txt. - gates
- The gates brief — the engine-rendered standing of every declared
gated transition:
transition_requires_checks(the related entities’ checks) andtransition_requires_self_check(the entity’s own check). - history
- Per-entity history — the narrative query behind an inspector’s “how did this entity get this way”.
- independence
- The author≠checker independence reading, derived from provenance.
- lifecycle
- Engine lifecycle — settings/workspace-root setters, runtime mem add/remove, reload, and export.
- mutation
- Engine mutation entrypoints — split per mutation kind.
- outcomes
- Argument/outcome shapes for the mutation entrypoints
(
Engine::create_entity,update_entity,delete_entity,relate_entity,rename_entity). The MCP wire envelopes and CLI command output formatters branch on these shapes; their field layouts are part of the engine’s public surface. - proposal
Engine::proposal_brief: the three-way review of a fork against its source mem. Types and the markdown renderer live incrate::ops::proposal; this module reads.- query
- Engine read paths — accessors and queries.
- review
- Review marks — one per-mem pointer to the last human-approved state (the operator’s review model: diffs accumulate against it, approving moves it, ignoring it entirely is first-class).
- roster
- Mem membership follows reload-before-operation.
- write_
lock - Cross-process write serialisation per mem.
Structs§
- Derived
Key - The validity key for derived-structure memos:
the store generation (bumped by every store mutation, carried by
Store::cloneso batch rollback restores it) plus the schemas epoch (bumped by every change to the engine’s schema map). A memo is current exactly while both halves still match. - Engine
- Unified engine. Holds a list of mounted backends and routes mem-named operations to the right one.
- GitBranch
Ops - Bundle of git-branch-specific op dispatchers. Installed on the
engine at full boot. Each field is one ops-method that previously
lived on the
MemBackendtrait; moving them off the trait keeps the bytes-level primitive surface clean. - Quarantined
Mem - One quarantined mem: the mem-level boot failure that took it out of
service, and the retained mount record
reloaduses to re-attempt the attach after a repair. The reason code/message are typed material — the message’s final clause names the repair command, so the roster entry is actionable as-is. - Unmounted
MemStorage - Discovered storage for a mem that has NO mount record — the unmounted half of the write-time cross-mem target verification. The workspace layer owns the discovery convention (the mem-repo’s branch registry, which memstead-base cannot see without inverting the crate dependency) and hands back a transient backend to ask plus the mem’s schema pin when its config declares one, so the cross-schema edge routing can keep its authority without a mount.
Enums§
- Disjoint
Merge - What a
GitBranchMergeDisjointFncame to. - RefPrevious
- The precondition of a
GitBranchUpdateRefFnmove.
Type Aliases§
- Backend
Factory - Backend factory function pointer. Both crates’ existing
instantiate_*_backendfunctions match this signature, so the type alias is what bridges the dependency direction (memstead-base can’t depend on memstead-git-branch) without an extra trait. Stateless,Send + Sync + Copy. - GitBranch
Branch Reset Fn Engine::branch_resetdispatch for git-branch mounts. Returns the outcome on success; surfacesBackendError::Othercarrying an in-band marker (UNKNOWN_REF:<raw>orPUSHED_COMMITS_PROTECTED:<sha,sha,...>) the engine layer un-marshals into typedEngineErrors.- GitBranch
Changes Since Fn Engine::changes_sincedispatch for git-branch mounts.- GitBranch
Collect Schema Source Fn - Collect one pinned schema’s raw source files (manifest, sealed
format marker, type definitions) from the workspace’s
__MEMSTEAD:schemas/<name>@<version>/ref — the treememstead schema installwrites on the git-branch backend.Ok(None)when the workspace has no mem-repo, the ref, or the package. Read-only; the consumer is the FOLDER-mount export path: a folder mem living in a mem-repo workspace pins a schema the installer sealed on the ref, so the archive assembler must read the same store the loader resolves from, or the mem loads but cannot export. - GitBranch
Create Branch AtFn fork_memdispatch: createrefs/heads/<branch_full_path>atsha, a full commit id already in the object store, in one ref-edit that refuses when the ref exists. The branch is the fork’s lineage claim: its first commit is the source’s, never a fresh seed.- GitBranch
Diff Fn Engine::diffdispatch for git-branch mounts. Walks the two refs inside the workspace’s mem-repo gitdir, produces a per-entitycrate::ops::Diff. Refs are arbitrarygix::rev_parse_singleinputs — branch names, commit SHAs, tag names. Resolves each independently so cross-branch (cross-mem) diffs work uniformly.branchis the mount’s declared branch; a bareHEADtoken in either ref re-anchors onto it.- GitBranch
Export Fn Engine::export_memdispatch for git-branch mounts.- GitBranch
Export ToBytes Fn Engine::export_mem_to_bytesdispatch for git-branch mounts.- GitBranch
Fetch Fn Engine::fetchdispatch for git-branch mounts.- GitBranch
IsAncestor Fn Engine::remote_statusdispatch: whetherancestoris reachable fromdescendantin the gitdir’s history (git merge-base --is-ancestor). Read-only; tells local-ahead from behind from forked without moving a ref.- GitBranch
IsEmpty Root Fn Engine::pull_alldispatch: whether the commitshais a root commit (no parent) over the empty tree, the shape of a freshly bootstrapped schema-and-config ref that carries no state yet. Read-only.- GitBranch
LsRemote Fn Engine::push_alldispatch, first half: the remote’s ref table in one round-trip (git ls-remote --heads), as(full ref name, sha)pairs. Lets the engine tell a lagging ref from one already in sync before it sends anything.- GitBranch
Merge Base Fn - The nearest common ancestor of two commits (
git merge-base);Nonewhen they share no history. Read-only. The adopt form ofmem forkreads the ancestor of a fork branch that arrived on a remote off it. - GitBranch
Merge Disjoint Fn - Merge two commits’ trees path by path from their merge base, when no
path changed on both sides: the paths only
theirschanged are applied ontoours’s tree, and a commit with both parents (oursfirst) is written withmessage. No ref moves; the caller moves it. A path changed on both sides is a content decision the merge does not make: the answer names every such path and writes nothing. - GitBranch
Namespace Conflicts Fn - Ref-namespace probe: the local branches a new
refs/heads/<branch_full_path>could not coexist with, because one is a path prefix of the other (git keeps refs as files in directories).create_memasks before it writes anything. - GitBranch
Prune Config Blob Fn - Config-only prune: drop the mem’s blobs on
__MEMSTEADand leave every content branch alone.create_memrolls a failed seed commit back through it so no config outlives the mem it was written for;delete_memremoves a config left behind that way. Idempotent. - GitBranch
Prune Residue Fn - Residue-prune dispatch for git-branch mounts.
The
create_memorchestrator calls this whenRecoveryAction::ForceOverwriteis selected against pre-existing storage residue. Dropsrefs/heads/<branch_full_path>and the__MEMSTEAD:mems/<branch_full_path>/config.jsonblob in one ref-edit transaction (the same call theMemBackend::delete_artifactsimpl wraps for delete-files flows). Surfaces as a function pointer socrate::mem_managementcan drive a prune against an unmounted gitdir without depending onmemstead-git-branch. - GitBranch
Pull Fn Engine::pulldispatch for git-branch mounts.branchis the mount’s declared branch — the single source of truth for both the local ref and the remote-tracking ref;memlabels the outcome only.- GitBranch
Push Fn Engine::pushdispatch for git-branch mounts.branchis the mount’s declared branch (seeGitBranchPullFn);memlabels the outcome only.- GitBranch
Read Config AtRef Fn fork_memdispatch for the remote form: one mem’s config blob (mems/<mem>/config.json) from the__MEMSTEADtree atref_name, the remote-tracking ref a fetch just placed (refs/remotes/<remote>/__MEMSTEAD), never the localrefs/heads/__MEMSTEAD.Ok(None)when the ref or the blob is absent. Read-only.- GitBranch
Read RefSchemas Fn - Re-read every schema sealed on the workspace’s
__MEMSTEAD:schemas/ref (empty when the ref or subtree is absent). Read-only;Engine::full_refreshis the consumer — the warm-server path that makes an out-of-bandmemstead schema installresolvable without a process restart. - GitBranch
Read Schema File Fn - Read one file from a sealed schema package on the workspace’s
__MEMSTEAD:schemas/<name>@<version>/ref.Ok(None)when the ref, package, or file is absent — absence is a normal state (the install-provenance stamp only exists for path-sourced installs). Read-only; the authoring-drift health axis is the consumer. - GitBranch
Read Tree Fn - Read every
.mdblob atref_nameingitdir, returning(relative_path, utf8_content)pairs. Skips.memstead/engine-internal entries and non-blob nodes. Used by the pre-merge schema-validation passEngine::pullandEngine::pushrun before they advance the branch pointer / push to the remote. - GitBranch
Remote AddFn Engine::remote_adddispatch — configures a named remote on the mem-repo gitdir (upsert: add, or set-url when it already exists).- GitBranch
Rename MemStorage Fn rename_memdispatch for the git-branch backend: move the mem’s content branchrefs/heads/<old>torefs/heads/<new>at the same tip (history preserved) and relocate the__MEMSTEAD:mems/<old>/config blob tomems/<new>/, all in one ref-edit transaction. Refuses (no mutation) when the source branch is missing or the target branch already exists.- GitBranch
Resolve RefFn Engine::push_alldispatch, second half: resolve one local ref to its SHA.Ok(None)when the ref does not exist (a fresh mem-repo legitimately has no__MEMSTEADyet).- GitBranch
Update RefFn - Point
ref_nameatsha, under the preconditionpreviousnames. A move that decided on an observed tip pins it withRefPrevious::At(orRefPrevious::Absentfor a ref it saw missing), so a commit that lands between the decision and the move makes the move fail instead of being dropped.RefPrevious::Anyis for a ref the engine derives and owns outright (the check-ledger transport ref, re-derived from the workspace ledger before every publish). - GitBranch
Write Schema Fn Engine::install_schemadispatch for the git-branch backend: write a schema package ((relative-path, bytes)pairs) onto the workspace’s unified__MEMSTEAD:schemas/<name>@<version>/ref and return the resulting commit sha. Mirrorsmemstead_git_branch::storage_memstead::write_schema_to_memstead_ref.- Mutation
Clock - Clock the engine reads when stamping mutation timestamps.
Arc’d closure rather than a trait so a test can pin a constant with one line:engine.set_mutation_clock(Arc::new(|| some_time)). - Unmounted
Storage Prober - Discovery hook: mem name → its storage, when the workspace layer
can find any (
None= no discoverable storage; the forward-reference mechanic governs, exactly as before). Boxed closure rather than a function pointer because discovery needs the workspace root and gitdir captured at boot.