Skip to main content

khive_db/
lib.rs

1//! SQLite storage backend for the khive knowledge graph runtime.
2//!
3//! Provides entity, note, event, edge, FTS5 text search, and optional
4//! `sqlite-vec` vector storage over a WAL-mode connection pool.
5
6/// Concrete storage backend providing capability-trait factories.
7pub mod backend;
8/// Periodic WAL checkpoint task.
9pub mod checkpoint;
10/// Read-only-by-intent database-integrity and WAL/checkpoint diagnostics.
11pub mod diagnostics;
12/// Error types for the SQLite layer.
13pub mod error;
14/// SQLite extension registration (sqlite-vec auto-extension).
15pub mod extension;
16/// Schema migration system (versioned migrations).
17pub mod migrations;
18/// WAL-mode connection pool: one writer, N concurrent readers.
19pub mod pool;
20mod read_cancellation;
21/// `SqlAccess` trait bridge to `ConnectionPool`.
22pub mod sql_bridge;
23/// Per-substrate store implementations (entity, note, graph, event, text, vectors, sparse).
24pub mod stores;
25/// Append-only NDJSON writer-timeout event sink (crate-internal).
26mod timeout_sink;
27/// Cross-process WAL-pin attribution sidecar (ADR-091 Amendment 2 Plank B).
28/// The sidecar write path (heartbeat/beacon) and identity primitives are
29/// portable; directory collection (`enumerate_live`/`housekeep_live`) is
30/// Unix-only — its only caller is the daemon's checkpoint task, and daemon
31/// mode itself requires Unix (see `khive-mcp/src/serve.rs`).
32pub mod walpin;
33/// Single-writer task and bounded write queue (ADR-067 Component A).
34pub mod writer_task;
35
36pub use backend::StorageBackend;
37pub use checkpoint::{
38    checkpoint_once, run_checkpoint_task, CheckpointConfig, CheckpointLifecycleOwner,
39    CheckpointTick,
40};
41pub use checkpoint::{run_session_sweep_task, SessionSweepConfig, SweepBackend};
42pub use error::SqliteError;
43pub use khive_storage::{
44    await_request_read_phase, effective_request_read_deadline, ensure_request_read_active,
45    inherit_request_read_cancellation, inherit_request_read_context, request_read_is_cancelled,
46    request_read_timeout_from_env, scope_request_read_cancellation, scope_request_read_deadline,
47    scope_request_read_deadline_at, wait_for_request_read_cancellation, RequestReadDeadline,
48    DEFAULT_REQUEST_READ_TIMEOUT_SECS,
49};
50pub use migrations::{
51    inspect_schema_is_current, inspect_schema_version, query_embedding_models, read_schema_version,
52    run_migrations, EmbeddingModelRegistryRecord, Migration, ServiceSchemaPlan, VersionedMigration,
53    MIGRATIONS,
54};
55pub use pool::{ConnectionPool, PoolConfig, ReaderGuard, WriterGuard};
56#[cfg(test)]
57pub use read_cancellation::scope_test_read_progress;
58pub use read_cancellation::{sqlite_interrupt_grace_from_env, DEFAULT_SQLITE_INTERRUPT_GRACE_MS};
59pub use sql_bridge::SqlBridge;
60pub use writer_task::WriterTaskHandle;