Skip to main content

khive_storage/
sparse.rs

1//! Sparse vector storage and lexical-semantic search capability (ADR-031).
2
3use async_trait::async_trait;
4use uuid::Uuid;
5
6use khive_types::SubstrateKind;
7
8use crate::types::{
9    BatchWriteSummary, SparseRecord, SparseSearchHit, SparseSearchRequest, SparseVector,
10    StorageResult,
11};
12
13#[async_trait]
14pub trait SparseStore: Send + Sync + 'static {
15    async fn insert_sparse(
16        &self,
17        subject_id: Uuid,
18        kind: SubstrateKind,
19        namespace: &str,
20        field: &str,
21        vector: SparseVector,
22    ) -> StorageResult<()>;
23
24    async fn insert_batch(&self, records: Vec<SparseRecord>) -> StorageResult<BatchWriteSummary>;
25
26    async fn delete(&self, subject_id: Uuid) -> StorageResult<bool>;
27
28    async fn search_sparse(
29        &self,
30        request: SparseSearchRequest,
31    ) -> StorageResult<Vec<SparseSearchHit>>;
32
33    async fn count(&self) -> StorageResult<u64>;
34}