pub trait KnowledgeBase: Send + Sync {
// Required methods
fn index(
&self,
scope: &TenantScope,
chunk: Chunk,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
fn search(
&self,
scope: &TenantScope,
query: KnowledgeQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, Error>> + Send + '_>>;
fn chunk_count(
&self,
scope: &TenantScope,
) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + '_>>;
}Expand description
Trait for knowledge base implementations.
Uses Pin<Box<dyn Future>> for dyn-compatibility, matching Tool, Memory,
and Blackboard traits.
SECURITY (F-KB-1): every method takes a &TenantScope. Implementations
MUST stamp chunk.tenant_id = scope.tenant_id on index and filter
search/chunk_count by it. A shared Arc<dyn KnowledgeBase> across
tenants would otherwise leak documents cross-tenant via knowledge_search.
Required Methods§
Sourcefn index(
&self,
scope: &TenantScope,
chunk: Chunk,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
fn index( &self, scope: &TenantScope, chunk: Chunk, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
Index a chunk into the knowledge base under the given tenant scope.
Sourcefn search(
&self,
scope: &TenantScope,
query: KnowledgeQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, Error>> + Send + '_>>
fn search( &self, scope: &TenantScope, query: KnowledgeQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, Error>> + Send + '_>>
Search the knowledge base, filtered by tenant scope.
Sourcefn chunk_count(
&self,
scope: &TenantScope,
) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + '_>>
fn chunk_count( &self, scope: &TenantScope, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + '_>>
Return the number of indexed chunks for the given tenant scope.