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