Skip to main content

memstead_base/
lib.rs

1//! Backend-agnostic graph kernel for Memstead.
2//!
3//! Hosts the parts of the engine that do not assume a git-backed
4//! storage: token-budget chunking, workspace-root utilities, the
5//! entity types and markdown pipeline (parse / generate / write), the
6//! in-memory store, graph queries and community detection, the mem
7//! router, the operation request/response types (including the
8//! gix-free read paths in `ops::health` / `ops::search`), the search
9//! index, validators, and rendering.
10//!
11//! Consumers that need only graph operations against directory or
12//! archive storage depend on this crate alone — its dependency closure
13//! does not include `gix`. Code that needs git-backed mems depends on
14//! `memstead-git-branch`, which builds on `memstead-base`.
15
16pub mod backend;
17pub mod chunking;
18pub mod domain_authority_wire;
19pub mod engine;
20pub mod entity;
21pub mod filesystem;
22pub mod graph;
23pub mod mem;
24pub mod mem_management;
25pub mod ops;
26pub mod pipeline;
27pub mod pipeline_edit;
28pub mod pipeline_migrate;
29pub mod pipeline_store;
30pub mod provenance;
31pub mod render;
32pub mod runtime_validator;
33pub mod schema_source;
34#[cfg(not(target_arch = "wasm32"))]
35pub mod search_index;
36pub mod storage;
37pub mod store;
38pub mod validator;
39pub mod vcs;
40pub mod workspace;
41pub mod workspace_root;
42pub mod workspace_store;
43
44use std::sync::Arc;
45
46use memstead_schema::{TypeDefinition, type_by_name};
47
48pub use backend::{BackendError, MemBackend};
49pub use engine::{
50    BackendFactory, BootError, CreateEntityArgs, CreateEntityOutcome, DeleteEntityArgs,
51    DeleteEntityOutcome, DeleteReferrers, Engine, EngineError, FromArchiveBytesError,
52    GitBranchBranchResetFn, GitBranchChangesSinceFn, GitBranchDiffFn, GitBranchExportFn,
53    GitBranchExportToBytesFn, GitBranchFetchFn, GitBranchOps, GitBranchPullFn, GitBranchPushFn,
54    GitBranchReadTreeFn, INLINE_LIST_CAP, ReferrerInfo, RelateAction, RelateEntityArgs,
55    RelateEntityOutcome, RenameEntityArgs, RenameEntityOutcome, SchemaSourceDiagnostic,
56    UpdateEntityArgs, UpdateEntityOutcome, format_inline_list_overflow,
57};
58pub use entity::id::{ENTITY_ID_MAX_LEN, SlugError};
59pub use entity::{Entity, EntityId, MetadataValue, ParseResult, Relationship};
60pub use graph::{ClusterInfo, LouvainOutput};
61pub use mem::{MEM_META_DIR, MemOrigin, MemRouterSnapshot};
62pub use mem_management::{CreateRuleSet, DeleteRuleSet, MatcherSet, MatcherSetError};
63pub use ops::{
64    BackendChanges, BatchEntry, BatchError, BatchResult, ChangeEnvelope, ChangesReport,
65    ContextResult, CreateArgs, CreateResult, DeleteResult, EMPTY_TREE_SHA, ExportResult, Facets,
66    HealthReport, HealthSummary, ListResult, MemExportResult, ModifiedMetadata, ModifiedSections,
67    Query, RENAME_SIMILARITY_DEFAULT, RENAME_SIMILARITY_MAX, RENAME_SIMILARITY_MIN, RelateArg,
68    RelateResult, ReloadReport, ReloadResult, RenameResult, SearchHit, SearchResult, SearchScope,
69    SetMemVersionOutcome, UpdateArgs, UpdateResult, WarningHint,
70};
71pub use pipeline::{
72    Facet, Ingest, IngestMode, IngestTrigger, Medium, MediumType, PatternEntry, PatternMode,
73    Projection,
74};
75pub use pipeline_edit::PipelineEditError;
76pub use pipeline_migrate::{migrate_legacy_pipeline, read_legacy_pipeline_configs};
77pub use pipeline_store::{
78    MemPipelineRecord, PipelineConfigs, PipelineRecord, load_pipeline_configs,
79};
80pub use provenance::{Provenance, ProvenanceKind};
81pub use store::{Edge, EdgeSource, InEdge, Store};
82pub use workspace::{
83    CreateRuleSetting, DeleteRuleSetting, Mount, MountCapability, MountLifecycle, MountStorage,
84    SCHEMA_WILDCARD, Workspace, WorkspaceSettings,
85};
86pub use workspace_store::{
87    FileWorkspaceStore, InstantiateError, Layout, StoreError, WORKSPACE_STORE_DIR,
88    WorkspaceStoreAdapter, detect_layout, instantiate_lean_backend, is_workspace_root,
89    standalone_workspace,
90};
91
92/// Engine-wide sentinel type. Used by ops that need a shared reference
93/// type at the Engine level (search, health, list) — always resolves to
94/// `default@1.0.0::spec`. Per-entity resolution still goes through
95/// `type_by_name` + schema lookup.
96pub fn engine_fallback_type() -> Arc<TypeDefinition> {
97    type_by_name("spec").expect("spec type must exist in the default builtin schema")
98}