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 anchor;
17pub mod backend;
18pub mod binding;
19pub mod binding_migrate;
20pub mod chunking;
21pub mod domain_authority_wire;
22pub mod engine;
23pub mod entity;
24pub mod filesystem;
25pub mod graph;
26pub mod ingest;
27pub mod mem;
28pub mod mem_management;
29pub mod ops;
30pub mod overview;
31pub mod pipeline;
32pub mod pipeline_edit;
33pub mod pipeline_migrate;
34pub mod pipeline_store;
35pub mod provenance;
36pub mod render;
37pub mod runtime_validator;
38pub mod schema_source;
39#[cfg(not(target_arch = "wasm32"))]
40pub mod search_index;
41pub mod storage;
42pub mod store;
43pub mod validator;
44pub mod vcs;
45pub mod workspace;
46pub mod workspace_root;
47pub mod workspace_store;
48
49use std::sync::Arc;
50
51use memstead_schema::{TypeDefinition, type_by_name};
52
53pub use anchor::{
54    ANCHOR_SIDECAR_PATH, Anchor, AnchorGrain, AnchorHashStability, AnchorInput,
55    AnchorProvenanceClass, AnchorSidecar, AnchorState, AnchorValidationError, AnchorVersion,
56    ArtifactObservation, EntityAnchorComposition, INVALID_ANCHOR_CODE, compose_entity_anchors,
57    resolve_anchor,
58};
59pub use backend::{BackendError, MemBackend};
60pub use binding_migrate::{
61    BindingMigrateError, MigratedBinding, migrate_gen2_bindings, resolve_migrated_binding,
62};
63pub use engine::{
64    BackendFactory, BootError, CreateEntityArgs, CreateEntityOutcome, DeleteEntityArgs,
65    DeleteEntityOutcome, DeleteReferrers, Engine, EngineError, FromArchiveBytesError,
66    GitBranchBranchResetFn, GitBranchChangesSinceFn, GitBranchDiffFn, GitBranchExportFn,
67    GitBranchExportToBytesFn, GitBranchFetchFn, GitBranchOps, GitBranchPullFn, GitBranchPushFn,
68    GitBranchReadTreeFn, INLINE_LIST_CAP, ReferrerInfo, RelateAction, RelateEntityArgs,
69    RelateEntityOutcome, RenameEntityArgs, RenameEntityOutcome, SchemaSourceDiagnostic,
70    UpdateEntityArgs, UpdateEntityOutcome, format_inline_list_overflow,
71};
72pub use entity::id::{ENTITY_ID_MAX_LEN, SlugError};
73pub use entity::{Entity, EntityId, MetadataValue, ParseResult, Relationship};
74pub use graph::{ClusterInfo, LouvainOutput};
75pub use mem::{MEM_META_DIR, MemOrigin, MemRouterSnapshot};
76pub use mem_management::{CreateRuleSet, DeleteRuleSet, MatcherSet, MatcherSetError};
77pub use ops::{
78    BackendChanges, BatchEntry, BatchError, BatchResult, ChangeEnvelope, ChangesReport,
79    ContextResult, CreateArgs, CreateResult, DeleteResult, EMPTY_TREE_SHA, ExportResult, Facets,
80    HealthReport, HealthSummary, ListResult, MemExportResult, ModifiedMetadata, ModifiedSections,
81    Query, RENAME_SIMILARITY_DEFAULT, RENAME_SIMILARITY_MAX, RENAME_SIMILARITY_MIN, RelateArg,
82    RelateResult, ReloadReport, ReloadResult, RenameResult, SearchHit, SearchResult, SearchScope,
83    SetMemVersionOutcome, UpdateArgs, UpdateResult, WarningHint,
84};
85pub use pipeline::{
86    Facet, IngestTrigger, Medium, MediumType, PatternEntry, PatternMode, Projection,
87};
88pub use pipeline_edit::PipelineEditError;
89pub use pipeline_migrate::{migrate_legacy_pipeline, read_legacy_pipeline_configs};
90pub use pipeline_store::{
91    BindingConfigs, MemPipelineRecord, PipelineConfigs, PipelineRecord,
92    load_legacy_pipeline_configs, load_pipeline_configs,
93};
94pub use provenance::{Provenance, ProvenanceKind};
95pub use store::{Edge, EdgeSource, InEdge, Store};
96pub use workspace::{
97    CreateRuleSetting, DeleteRuleSetting, Mount, MountCapability, MountLifecycle, MountStorage,
98    SCHEMA_WILDCARD, Workspace, WorkspaceSettings,
99};
100pub use workspace_store::{
101    FileWorkspaceStore, InstantiateError, Layout, StoreError, WORKSPACE_STORE_DIR,
102    WorkspaceStoreAdapter, detect_layout, instantiate_lean_backend, is_workspace_root,
103    standalone_workspace,
104};
105
106/// Engine-wide sentinel type. Used by ops that need a shared reference
107/// type at the Engine level (search, health, list) — always resolves to
108/// `default@1.0.0::spec`. Per-entity resolution still goes through
109/// `type_by_name` + schema lookup.
110pub fn engine_fallback_type() -> Arc<TypeDefinition> {
111    type_by_name("spec").expect("spec type must exist in the default builtin schema")
112}