Skip to main content

khive_storage/
lib.rs

1//! Storage capability traits: `SqlAccess`, `VectorStore`, `TextSearch`,
2//! `GraphStore`, `NoteStore`, `EntityStore`, `EventStore`, `SparseStore`,
3//! `BlobStore`, and `AttachmentStore`.
4
5pub mod agent;
6pub mod attachment;
7pub mod blob;
8pub mod capability;
9pub mod embedding_space;
10pub mod entity;
11mod env;
12pub mod error;
13pub mod event;
14pub mod graph;
15pub mod note;
16pub mod operation_context;
17pub mod request_context;
18pub mod secret_scan;
19pub mod sparse;
20pub mod sql;
21pub mod telemetry;
22#[cfg(feature = "test-support")]
23pub mod test_support;
24pub mod text;
25pub mod tx_registry;
26pub mod types;
27pub mod usage;
28pub mod vectors;
29
30pub use agent::AgentStore;
31pub use attachment::{
32    Attachment, AttachmentReadReport, AttachmentStore, AttachmentSubstrate, NewAttachment,
33};
34pub use blob::{
35    BlobOrphanSweepConfig, BlobOrphanSweepResult, BlobStore, ContentRef, UploadId,
36    MAX_BLOB_WHOLE_BYTES,
37};
38pub use capability::StorageCapability;
39pub use embedding_space::{EmbeddingSpaceIdentity, EmbeddingSpaceIdentityError, EmbeddingSpaceKey};
40pub use entity::{Entity, EntityFilter, EntityStore};
41pub use env::read_env_number;
42pub use error::{CapacityUnavailablePhase, StorageError, WriterTaskRequestState};
43
44pub use event::{
45    Event, EventFilter, EventObservation, EventStore, EventView, ObservationRole, ReferentKind,
46};
47pub use graph::{
48    EdgeInsertIfAbsentOutcome, GraphGuardValueKind, GraphStatementGuard,
49    GraphStatementGuardFailure, GraphStatementGuardFailureReason, GraphStore,
50};
51pub use khive_types::vector::{
52    decode_f32_le, decode_f32_native, encode_f32_le, encode_f32_native, VectorCodecError,
53};
54pub use note::{FilterOp, Note, NoteFilter, NoteStore, NoteVisibility, SortDir};
55pub use request_context::{
56    await_request_read_phase, capture_request_read_context, current_request_correlation,
57    effective_request_read_deadline, ensure_request_read_active, inherit_request_read_cancellation,
58    inherit_request_read_context, request_read_is_cancelled, request_read_timeout_from_env,
59    scope_request_correlation, scope_request_read_cancellation, scope_request_read_deadline,
60    scope_request_read_deadline_at, wait_for_request_read_cancellation, RequestReadContext,
61    RequestReadDeadline, RequestReadStopReason, DEFAULT_REQUEST_READ_TIMEOUT_SECS,
62};
63pub use sparse::{SparseStore, SparseStoreFactory};
64pub use sql::{
65    AtomicUnitOp, BoxFuture, SqlAccess, SqlReader, SqlRowConsumer, SqlWriter, TopLevelMaintenance,
66};
67pub use telemetry::{
68    ChannelBackoffArmedPayload, ChannelBackoffResetPayload, ChannelHeartbeatPersistFailedPayload,
69    ChannelPollFailedPayload, ChannelPollStartedPayload, ChannelPollSucceededPayload,
70    CheckpointOutcomeRecordedPayload, ConfigLockedPayload, LifecycleEvent, PhaseCancelledPayload,
71    PhaseCompletedPayload, PhaseStartedPayload,
72};
73pub use text::{TextSearch, TextSearchFactory};
74pub use types::StorageResult;
75pub use vectors::{VectorStore, VectorStoreFactory};
76
77pub use types::{
78    BatchWriteError, BatchWriteErrorClass, BatchWriteErrorCount, BatchWriteRetryability,
79    BatchWriteSummary, BoundedCount, DeleteMode, DirectedNeighborHit, Direction, Edge, EdgeFilter,
80    EdgeSeekPage, EdgeSortField, EdgeUpsertDisposition, EdgeUpsertRefusal, EdgeUpsertRequest,
81    EdgeUpsertResult, GraphPath, GuardedBatchOutcome, GuardedBatchRefusal, GuardedEdgeBatchRefusal,
82    GuardedEdgeBatchUpsertOutcome, GuardedEdgeUpsertOutcome, GuardedWriteOutcome,
83    IndexRebuildScope, LimitReport, LinkId, MissingEndpoints, NeighborCursor, NeighborHit,
84    NeighborQuery, OrphanSweepConfig, OrphanSweepResult, Page, PageRequest, PathNode,
85    PropertyFilter, PropertyOp, SeekCursor, SeekPage, SortDirection, SortOrder, SparseRecord,
86    SparseSearchHit, SparseSearchRequest, SparseVector, SqlRow, SqlStatement, SqlValue,
87    TextDocument, TextFilter, TextGatherMode, TextIndexStats, TextQueryMode, TextSearchHit,
88    TextSearchOptions, TextSearchRequest, TextTermStats, TextTermStatsRequest, TimeRange,
89    TraversalExecutionBudget, TraversalOptions, TraversalRequest, VectorIndexKind,
90    VectorMetadataFilter, VectorRecord, VectorScanEntry, VectorScanPage, VectorScanRequest,
91    VectorSearchHit, VectorSearchRequest, VectorStoreCapabilities, VectorStoreInfo,
92    DEFAULT_TRAVERSAL_LIMIT, MAX_BATCH_WRITE_ERROR_DETAILS, MAX_BATCH_WRITE_ERROR_MESSAGE_CHARS,
93    MAX_SPARSE_SEARCH_TOP_K, MAX_TRAVERSAL_DEPTH, MAX_TRAVERSAL_LIMIT, MAX_TRAVERSAL_MILLIS,
94    MAX_TRAVERSAL_ROOTS, MAX_TRAVERSAL_WORK,
95};
96
97pub use khive_types::{
98    AgentRecord, AgentState, EdgeCategory, EdgeRelation, EventOutcome, SubstrateKind,
99    TerminalReason,
100};
101
102/// The current time as microseconds since the Unix epoch, the unit stored
103/// rows use for their timestamps.
104pub fn now_micros() -> i64 {
105    chrono::Utc::now().timestamp_micros()
106}