Skip to main content

KnowledgeBase

Trait KnowledgeBase 

Source
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§

Source

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.

Source

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.

Source

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.

Implementors§