Skip to main content

Crate memstead_base

Crate memstead_base 

Source
Expand description

Backend-agnostic graph kernel for Memstead.

Hosts the parts of the engine that do not assume a git-backed storage: token-budget chunking, workspace-root utilities, the entity types and markdown pipeline (parse / generate / write), the in-memory store, graph queries and community detection, the mem router, the operation request/response types (including the gix-free read paths in ops::health / ops::search), the search index, validators, and rendering.

Consumers that need only graph operations against directory or archive storage depend on this crate alone — its dependency closure does not include gix. Code that needs git-backed mems depends on memstead-git-branch, which builds on memstead-base.

Re-exports§

pub use anchor::ANCHOR_SIDECAR_PATH;
pub use anchor::Anchor;
pub use anchor::AnchorGrain;
pub use anchor::AnchorHashStability;
pub use anchor::AnchorInput;
pub use anchor::AnchorProvenanceClass;
pub use anchor::AnchorSidecar;
pub use anchor::AnchorState;
pub use anchor::AnchorValidationError;
pub use anchor::AnchorVersion;
pub use anchor::ArtifactObservation;
pub use anchor::EntityAnchorComposition;
pub use anchor::INVALID_ANCHOR_CODE;
pub use anchor::compose_entity_anchors;
pub use anchor::resolve_anchor;
pub use backend::BackendError;
pub use backend::MemBackend;
pub use binding_migrate::BindingMigrateError;
pub use binding_migrate::LegacyBindingV1;
pub use binding_migrate::MigratedBinding;
pub use binding_migrate::check_all_consumed;
pub use binding_migrate::fold_v1_binding;
pub use binding_migrate::migrate_gen2_bindings;
pub use engine::BackendFactory;
pub use engine::BootError;
pub use engine::CreateEntityArgs;
pub use engine::CreateEntityOutcome;
pub use engine::DeleteEntityArgs;
pub use engine::DeleteEntityOutcome;
pub use engine::DeleteReferrers;
pub use engine::Engine;
pub use engine::EngineError;
pub use engine::EntityHistoryReport;
pub use engine::EntityTouch;
pub use engine::FromArchiveBytesError;
pub use engine::GitBranchBranchResetFn;
pub use engine::GitBranchChangesSinceFn;
pub use engine::GitBranchDiffFn;
pub use engine::GitBranchExportFn;
pub use engine::GitBranchExportToBytesFn;
pub use engine::GitBranchFetchFn;
pub use engine::GitBranchOps;
pub use engine::GitBranchPullFn;
pub use engine::GitBranchPushFn;
pub use engine::GitBranchReadTreeFn;
pub use engine::HISTORY_PAGE_DEFAULT;
pub use engine::HISTORY_PAGE_MAX;
pub use engine::INLINE_LIST_CAP;
pub use engine::MutationClock;
pub use engine::ReferrerInfo;
pub use engine::RelateAction;
pub use engine::RelateEntityArgs;
pub use engine::RelateEntityOutcome;
pub use engine::RenameEntityArgs;
pub use engine::RenameEntityOutcome;
pub use engine::ReviewMarkStatus;
pub use engine::SchemaSourceDiagnostic;
pub use engine::SchemaStaging;
pub use engine::SetReviewMarkOutcome;
pub use engine::StoryStart;
pub use engine::UpdateEntityArgs;
pub use engine::UpdateEntityOutcome;
pub use engine::format_inline_list_overflow;
pub use entity::id::ENTITY_ID_MAX_LEN;
pub use entity::id::SlugError;
pub use entity::id::TITLE_GRAMMAR_RULE;
pub use entity::Entity;
pub use entity::EntityId;
pub use entity::MetadataValue;
pub use entity::ParseResult;
pub use entity::Relationship;
pub use graph::ClusterInfo;
pub use graph::LouvainOutput;
pub use mem::MemOrigin;
pub use mem::MemRouterSnapshot;
pub use mem_management::CreateRuleSet;
pub use mem_management::DeleteRuleSet;
pub use mem_management::MatcherSet;
pub use mem_management::MatcherSetError;
pub use ops::BackendChanges;
pub use ops::BatchEntry;
pub use ops::BatchError;
pub use ops::BatchResult;
pub use ops::ChangeEnvelope;
pub use ops::ChangesReport;
pub use ops::ContextResult;
pub use ops::CreateArgs;
pub use ops::CreateResult;
pub use ops::DeleteResult;
pub use ops::EMPTY_TREE_SHA;
pub use ops::ExportResult;
pub use ops::Facets;
pub use ops::HealthReport;
pub use ops::HealthSummary;
pub use ops::ListResult;
pub use ops::MemExportResult;
pub use ops::ModifiedMetadata;
pub use ops::ModifiedSections;
pub use ops::Query;
pub use ops::RENAME_SIMILARITY_DEFAULT;
pub use ops::RENAME_SIMILARITY_MAX;
pub use ops::RENAME_SIMILARITY_MIN;
pub use ops::RelateArg;
pub use ops::RelateResult;
pub use ops::ReloadReport;
pub use ops::ReloadResult;
pub use ops::RenameResult;
pub use ops::SearchHit;
pub use ops::SearchResult;
pub use ops::SearchScope;
pub use ops::SetMemVersionOutcome;
pub use ops::UpdateArgs;
pub use ops::UpdateResult;
pub use ops::WarningHint;
pub use pipeline::Facet;
pub use pipeline::IngestTrigger;
pub use pipeline::Medium;
pub use pipeline::MediumType;
pub use pipeline::PatternEntry;
pub use pipeline::PatternMode;
pub use pipeline::Projection;
pub use pipeline_edit::PipelineEditError;
pub use pipeline_migrate::migrate_legacy_pipeline;
pub use pipeline_migrate::read_legacy_pipeline_configs;
pub use pipeline_store::BindingConfigs;
pub use pipeline_store::MemPipelineRecord;
pub use pipeline_store::PipelineConfigs;
pub use pipeline_store::PipelineRecord;
pub use pipeline_store::load_legacy_pipeline_configs;
pub use pipeline_store::load_pipeline_configs;
pub use provenance::Provenance;
pub use provenance::ProvenanceKind;
pub use store::Edge;
pub use store::EdgeSource;
pub use store::InEdge;
pub use store::Store;
pub use workspace::CreateRuleSetting;
pub use workspace::DeleteRuleSetting;
pub use workspace::Mount;
pub use workspace::MountCapability;
pub use workspace::MountLifecycle;
pub use workspace::MountStorage;
pub use workspace::SCHEMA_WILDCARD;
pub use workspace::Workspace;
pub use workspace::WorkspaceSettings;
pub use workspace_store::FileWorkspaceStore;
pub use workspace_store::InstantiateError;
pub use workspace_store::Layout;
pub use workspace_store::StoreError;
pub use workspace_store::WORKSPACE_STORE_DIR;
pub use workspace_store::WorkspaceStoreAdapter;
pub use workspace_store::detect_layout;
pub use workspace_store::instantiate_lean_backend;
pub use workspace_store::is_mem_repo_shaped;
pub use workspace_store::is_workspace_root;
pub use workspace_store::standalone_workspace;
pub use workspace_store::workspace_shape_label;

Modules§

anchor
Anchors — engine-owned durable provenance records tying an entity to the source artifacts it describes.
backend
MemBackend — uniform trait surface over folder, git-branch, and archive storage.
binding
Binding format v2 — one record per pipeline.
binding_migrate
Migration to binding v2 — the single-record pipeline format.
build_info
Build identity of the running binary.
check
Check records — the engine-recorded act of verification (agent-trust plan 14).
chunking
Token-budget chunking for large MCP responses.
derivation
Derivation baselines — “my source changed” computed, never stamped (agent-trust plan 12).
domain_authority_wire
Domain-authority publishing — the pure wire protocol shared by the signer (CLI) and the verifier (registry).
engine
Unified engine.
entity
Entity types and the markdown pipeline (parse, generate, write, load).
filesystem
filesystem-mem surfaces — single-mem, history-free, filesystem-backed workspaces.
friction
Friction ledger — the engine’s record of its own surface’s learnability (agent-trust plan 08).
graph
Graph algorithms — BFS traversal, community detection, neighborhood queries.
ingest
The deterministic ingest-orchestration surface.
mem
Multi-mem routing, visibility filtering, mem config.
mem_management
Compiled lifecycle-policy rule sets — first-match-wins glob lookup over the [[mem_management.create]] / [[mem_management.delete]] arrays surfaced in workspace.toml.
ops
Operation request/response types and the gix-free read paths (health, search).
overview
Shared overview composer used by both the memstead_overview MCP tool and the full CLI overview command.
pipeline
Pipeline primitives — the inline Source and the migrate-local legacy shapes.
pipeline_edit
Edit operations over the v2 single-record pipeline store.
pipeline_migrate
Migration from the legacy JSON-folder pipeline shape to the four-primitive workspace-store shape.
pipeline_store
File-adapter persistence for the pipeline configs.
provenance
Backend-neutral provenance record.
render
Markdown rendering of Engine result types.
runtime_validator
Runtime CRUD validators consumed by the unified crate::Engine — the single mutation engine, whatever storage backend (mem-repo git branch, plain folder, archive) sits behind a mount.
schema_source
SchemaSource — a storage backend’s schema-storage location.
search_index
Per-mem tantivy search indexes.
section_format
Section-body reduction — the markdown half of the section-format vocabulary (agent-toolbox plan 08).
storage
Mem write-side trait. The MemWriter surface is backend-neutral: it deals in mem-relative paths, raw bytes, and opaque CommitId strings. Two adapters live in the workspace today: the git-tree adapter in memstead_git_branch::storage::git_tree (mem-repo writes) and filesystem::FilesystemMemWriter in this crate (filesystem-only writes — no gix, no commit history).
store
In-memory graph store. Dumb data structure — no validation, no side effects. All mutations go through Engine methods.
validator
Strict ingress validator for sealed .mem archives.
vcs
Backend-agnostic VCS provenance types and trailer-block helpers.
workspace
Workspace concept — first-class in memstead-base after the workspace-store rebuild.
workspace_root
Workspace-root utilities. Today’s only consumer is the memstead_health OUTER_REPO_NOT_IGNORING_MEM_REPO warning surfaced by the MCP layer: when the workspace is embedded inside another git repository, the mem-repo-git directory must be excluded by the outer repo’s .gitignore to avoid the gitlink trap.
workspace_store
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.

Constants§

ENGINE_VERSION
The engine crate SEMVER of the running binary. Version-carrying surfaces — the per-mem mutation stamp (MemConfig.mutation_stamp), the boot-time ENGINE_VERSION_SKEW comparison, the overview’s _engine_version, CLI --version, MCP serverInfo.version — use build_info::full_version instead (semver plus the git build sha when present), so dev builds between releases stay distinguishable; this constant is the bare semver component.
MEM_META_DIR
The per-mem engine-internal directory under a folder mem’s root (<mem_root>/.memstead/config.json, changes.jsonl). Defined in memstead-schema (mem-config loading lives there); re-exported here as the mem-level home for the concept. The per-mem engine-internal directory under a folder mem’s root — <mem_root>/.memstead/ holds config.json and changes.jsonl. Defined here (rather than in memstead-base) because mem-config loading lives in this crate and memstead-base depends on it; memstead-base re-exports the constant for downstream consumers. Distinct from the workspace store directory (memstead_base::WORKSPACE_STORE_DIR) and from the in-zip member paths inside sealed archives (ARCHIVE_META_DIR), which are a separate on-disk format and never use this constant.

Functions§

engine_fallback_type
Engine-wide sentinel type. Used by ops that need a shared reference type at the Engine level (search, health, list) — always resolves to default@1.0.0::spec. Per-entity resolution still goes through type_by_name + schema lookup.
hex_lower
Lowercase hex encoding of a digest. Byte-identical to the {:x} formatting that sha2 < 0.11 digests carried; hash strings persisted under the old encoding must keep matching.