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;
16mod fts_maintenance;
17/// Schema migration system (versioned migrations).
18pub mod migrations;
19/// What a live store's schema says about `namespace` (ADR-189).
20pub mod namespace_census;
21/// Moving records between namespaces (ADR-189).
22pub mod namespace_move;
23/// A store fixture reproducing the namespace split, for the move's own arms.
24#[cfg(any(test, feature = "test-support"))]
25pub mod namespace_move_fixture;
26/// WAL-mode connection pool: one writer, N concurrent readers.
27pub mod pool;
28mod read_cancellation;
29/// `SqlAccess` trait bridge to `ConnectionPool`.
30pub mod sql_bridge;
31/// Per-substrate store implementations (entity, note, graph, event, text, vectors, sparse).
32pub mod stores;
33/// Append-only NDJSON writer-timeout event sink (crate-internal).
34mod timeout_sink;
35/// Cross-process WAL-pin attribution sidecar (ADR-091 Amendment 2 Plank B).
36/// The sidecar write path (heartbeat/beacon) and identity primitives are
37/// portable; directory collection (`enumerate_live`/`housekeep_live`) is
38/// Unix-only — its only caller is the daemon's checkpoint task, and daemon
39/// mode itself requires Unix (see `khive-mcp/src/serve.rs`).
40pub mod walpin;
41/// Single-writer task and bounded write queue (ADR-067 Component A).
42pub mod writer_task;
43
44pub use backend::StorageBackend;
45pub use checkpoint::{
46    checkpoint_once, run_checkpoint_task, CheckpointConfig, CheckpointLifecycleOwner,
47    CheckpointTick,
48};
49pub use checkpoint::{run_session_sweep_task, SessionSweepConfig, SweepBackend};
50pub use error::SqliteError;
51pub use fts_maintenance::{
52    fts_maintenance_counters, FtsIndexStructure, FtsLevelStructure, FtsMaintenanceCounters,
53    FtsSegmentDiagnostics,
54};
55pub use khive_storage::{
56    await_request_read_phase, effective_request_read_deadline, ensure_request_read_active,
57    inherit_request_read_cancellation, inherit_request_read_context, request_read_is_cancelled,
58    request_read_timeout_from_env, scope_request_read_cancellation, scope_request_read_deadline,
59    scope_request_read_deadline_at, wait_for_request_read_cancellation, RequestReadDeadline,
60    DEFAULT_REQUEST_READ_TIMEOUT_SECS,
61};
62pub use migrations::{
63    inspect_schema_is_current, inspect_schema_version, query_embedding_models, read_schema_version,
64    run_migrations, EmbeddingModelRegistryRecord, Migration, ServiceSchemaPlan, VersionedMigration,
65    MIGRATIONS,
66};
67pub use pool::{ConnectionPool, PoolConfig, ReaderGuard, ReaderRow, WriterGuard};
68#[cfg(any(test, feature = "test-support"))]
69pub use read_cancellation::scope_test_read_progress;
70pub use read_cancellation::{sqlite_interrupt_grace_from_env, DEFAULT_SQLITE_INTERRUPT_GRACE_MS};
71pub use sql_bridge::SqlBridge;
72pub use writer_task::WriterTaskHandle;
73
74#[cfg(test)]
75mod namespace_move_fixture_tests;
76#[cfg(test)]
77mod stream_schema_tests;
78
79#[cfg(test)]
80mod reader_lease_tests;