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