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 note::{FilterOp, Note, NoteFilter, NoteStore, NoteVisibility, SortDir};
46pub use request_context::{
47    await_request_read_phase, capture_request_read_context, effective_request_read_deadline,
48    ensure_request_read_active, inherit_request_read_cancellation, inherit_request_read_context,
49    request_read_is_cancelled, request_read_timeout_from_env, scope_request_read_cancellation,
50    scope_request_read_deadline, scope_request_read_deadline_at,
51    wait_for_request_read_cancellation, RequestReadContext, RequestReadDeadline,
52    RequestReadStopReason, DEFAULT_REQUEST_READ_TIMEOUT_SECS,
53};
54pub use sparse::SparseStore;
55pub use sql::{AtomicUnitOp, BoxFuture, SqlAccess, SqlReader, SqlWriter, TopLevelMaintenance};
56pub use telemetry::{
57    ChannelBackoffArmedPayload, ChannelBackoffResetPayload, ChannelHeartbeatPersistFailedPayload,
58    ChannelPollFailedPayload, ChannelPollStartedPayload, ChannelPollSucceededPayload,
59    CheckpointOutcomeRecordedPayload, ConfigLockedPayload, LifecycleEvent, PhaseCancelledPayload,
60    PhaseCompletedPayload, PhaseStartedPayload,
61};
62pub use text::TextSearch;
63pub use types::StorageResult;
64pub use vectors::VectorStore;
65
66pub use types::{
67    BatchWriteError, BatchWriteErrorClass, BatchWriteErrorCount, BatchWriteRetryability,
68    BatchWriteSummary, BoundedCount, DeleteMode, DirectedNeighborHit, Direction, Edge, EdgeFilter,
69    EdgeSeekPage, EdgeSortField, EdgeUpsertDisposition, EdgeUpsertRefusal, EdgeUpsertRequest,
70    EdgeUpsertResult, GraphPath, GuardedBatchOutcome, GuardedBatchRefusal, GuardedEdgeBatchRefusal,
71    GuardedEdgeBatchUpsertOutcome, GuardedEdgeUpsertOutcome, GuardedWriteOutcome,
72    IndexRebuildScope, LimitReport, LinkId, MissingEndpoints, NeighborCursor, NeighborHit,
73    NeighborQuery, OrphanSweepConfig, OrphanSweepResult, Page, PageRequest, PathNode,
74    PropertyFilter, PropertyOp, SeekCursor, SeekPage, SortDirection, SortOrder, SparseRecord,
75    SparseSearchHit, SparseSearchRequest, SparseVector, SqlRow, SqlStatement, SqlValue,
76    TextDocument, TextFilter, TextGatherMode, TextIndexStats, TextQueryMode, TextSearchHit,
77    TextSearchOptions, TextSearchRequest, TextTermStats, TextTermStatsRequest, TimeRange,
78    TraversalExecutionBudget, TraversalOptions, TraversalRequest, VectorIndexKind,
79    VectorMetadataFilter, VectorRecord, VectorSearchHit, VectorSearchRequest,
80    VectorStoreCapabilities, VectorStoreInfo, DEFAULT_TRAVERSAL_LIMIT,
81    MAX_BATCH_WRITE_ERROR_DETAILS, MAX_BATCH_WRITE_ERROR_MESSAGE_CHARS, MAX_SPARSE_SEARCH_TOP_K,
82    MAX_TRAVERSAL_DEPTH, MAX_TRAVERSAL_LIMIT, MAX_TRAVERSAL_MILLIS, MAX_TRAVERSAL_ROOTS,
83    MAX_TRAVERSAL_WORK,
84};
85
86pub use khive_types::{
87    AgentRecord, AgentState, EdgeCategory, EdgeRelation, EventOutcome, SubstrateKind,
88    TerminalReason,
89};
90
91/// The current time as microseconds since the Unix epoch, the unit stored
92/// rows use for their timestamps.
93pub fn now_micros() -> i64 {
94    chrono::Utc::now().timestamp_micros()
95}