Skip to main content

plugmem_host/
lib.rs

1#![doc = include_str!("../README.md")]
2//! Native host layer for the plugmem engine: file-backed storage with
3//! exclusive locking, a thread-safe database handle with a maintenance
4//! policy, and embedding providers.
5//!
6//! This crate is the "point it at a file and go" Rust experience:
7//!
8//! ```no_run
9//! use plugmem_host::{Config, Database, RecallQuery, RememberInput};
10//!
11//! let (db, _report) = Database::open("agent.plugmem", Config::default())?;
12//! db.remember(RememberInput::text(1_784_000_000_000, "prefers tokio"))?;
13//! let out = db.recall(RecallQuery::text(1_784_000_100_000, "runtime?"))?;
14//! println!("{}", out.rendered);
15//! # Ok::<(), plugmem_host::HostError>(())
16//! ```
17//!
18//! Concurrency model: one local database has one owning process —
19//! a second open is refused with [`HostError::Locked`]; within the
20//! process, clone the [`Database`] handle across threads and agents;
21//! different files are fully independent. Embedding calls run outside
22//! the database lock.
23//!
24//! With the default `config` feature, the host also accepts the shared
25//! `config.toml` format through [`Settings::load`] and [`read_config`]. The
26//! `SETTINGS.md` file is the reference documentation for that format, not an
27//! input file. Disable the feature with `default-features = false` when a
28//! caller wants only programmatic [`Config`] construction.
29
30mod db;
31mod embedder;
32mod error;
33mod paths;
34mod readonly;
35#[cfg(feature = "config")]
36mod settings;
37#[cfg(feature = "config")]
38mod settings_help;
39mod storage;
40mod workspace;
41
42pub use db::{Database, DatabaseBuilder, ExportPage, ExportedFact, FactSnapshot, RecoverReport};
43pub use embedder::{Embedder, NullEmbedder, OpenAiCompatEmbedder, SharedEmbedder};
44pub use error::HostError;
45pub use paths::{default_config_dir, default_config_path, default_data_dir, default_database_path};
46pub use readonly::{ReadOnlyDatabase, Scrub};
47#[cfg(feature = "config")]
48pub use settings::{Settings, SettingsError, WorkspaceSettings, read_config};
49#[cfg(feature = "config")]
50pub use settings_help::{SettingDoc, SettingScope, SettingWarning, SettingsHelp, settings_help};
51pub use storage::{FileScratch, FileStorage, FsyncPolicy};
52pub use workspace::{
53    ARCHIVED_TAG, DEFAULT_IDLE_TIMEOUT_MS, DEFAULT_MAX_OPEN, DbEntry, DbName, Description,
54    ENTRY_TAG, IfMissing, MAX_DB_NAME, MAX_OPEN_CEILING, NameProblem, Opener, ReindexReport,
55    SELF_ENTITY, Workspace, WorkspaceError, WorkspaceIssue, WorkspaceLayout, WorkspaceLimits,
56};
57
58// The engine types a host caller works with, re-exported so simple
59// embedders need only this crate.
60pub use plugmem_core::snapshot::{DEFAULT_SCRUB_BUDGET, ScrubProgress};
61pub use plugmem_core::{
62    Config, EdgeId, EntityId, Error, FactId, FactRecord, LinkInput, MaintainReport,
63    MaintenanceMode, MaintenanceOptions, OpenReport, RecallQuery, RecallResult, RecallScratch,
64    RecalledEdge, RecalledFact, RememberInput, RememberOutcome, ShardLayout, Similar,
65    SimilarReason, Stats, UnlinkInput, VALID_TO_OPEN, fact_flags,
66};
67pub use plugmem_core::{MemScratch, Scratch};