pub struct KnowledgeBase {
pub storage: Storage,
/* private fields */
}Fields§
§storage: StorageImplementations§
Source§impl KnowledgeBase
impl KnowledgeBase
pub fn appraise(&self, params: AppraiseParams<'_>) -> Result<Verdict>
Source§impl KnowledgeBase
impl KnowledgeBase
Source§impl KnowledgeBase
impl KnowledgeBase
pub fn add( &self, content: &str, kind: &str, trigger_desc: Option<&str>, anti_trigger_desc: Option<&str>, source: &str, skill_name: Option<&str>, ) -> Result<String>
Sourcepub fn add_with_deps(
&self,
content: &str,
kind: &str,
trigger_desc: Option<&str>,
anti_trigger_desc: Option<&str>,
source: &str,
skill_name: Option<&str>,
deps: &[(String, String)],
) -> Result<String>
pub fn add_with_deps( &self, content: &str, kind: &str, trigger_desc: Option<&str>, anti_trigger_desc: Option<&str>, source: &str, skill_name: Option<&str>, deps: &[(String, String)], ) -> Result<String>
Full-form writer: persist a chunk, its vectors, and all declared
dependencies in a single transaction. Each dep is (dst_chunk_id, kind); kind ∈ {soft,hard}. Dependency targets are validated to
exist inside the transaction, so a bad dependency rolls back the whole
write — the chunk is never persisted on its own.
Sourcepub fn add_dependency(&self, src: &str, dst: &str, kind: &str) -> Result<()>
pub fn add_dependency(&self, src: &str, dst: &str, kind: &str) -> Result<()>
Declare that chunk src depends on chunk dst.
kind is "hard" (fail-closed: if dst is unavailable or archived at
recall time the whole seed is dropped) or "soft" (a recall-time
ranking bonus). Both chunks must exist. Idempotent — re-declaring the
same edge is a no-op (INSERT OR IGNORE).
pub fn spark( &self, content: &str, trigger_desc: Option<&str>, anti_trigger_desc: Option<&str>, ) -> Result<String>
pub fn mature_spark(&self, spark_id: &str, to: &str) -> Result<()>
pub fn promote_spark(&self, spark_id: &str, to: &str) -> Result<String>
pub fn drop_spark(&self, spark_id: &str, reason: &str) -> Result<()>
pub fn approve(&self, chunk_id: &str) -> Result<()>
pub fn archive(&self, chunk_id: &str, reason: &str) -> Result<()>
pub fn invalidate(&self, chunk_id: &str, reason: &str) -> Result<()>
pub fn restore(&self, chunk_id: &str) -> Result<()>
Source§impl KnowledgeBase
impl KnowledgeBase
pub fn recall(&self, params: RecallParams<'_>) -> Result<RecallResult>
Source§impl KnowledgeBase
impl KnowledgeBase
pub fn record(&self, params: RecordParams<'_>) -> Result<()>
Source§impl KnowledgeBase
impl KnowledgeBase
Sourcepub fn repair_traces(&self, dry_run: bool) -> Result<TraceRepairReport>
pub fn repair_traces(&self, dry_run: bool) -> Result<TraceRepairReport>
One-shot data repair for trace pollution that predates the strict
selected = “entered the model context” semantics (Priority 1).
Before the fix, the daemon recalled on every session start, discarded the
knowledge, and kept only the trace_id — yet recall() had already
written per-chunk selected/retrieved events and an open episodic
log. That inflated selected_count (which feeds the curate archive
heuristic selected_count >= N AND used_count = 0) and stuffed the open
pool that drives trace-completion stats. Empty hook recalls did the same.
This repair, in one transaction:
- deletes daemon-sourced
selected/retrievedusage events; - recomputes
selected_countfrom the cleaned facts (curate’s formula); - retires orphaned
openlogs (daemon session traces + no-answer recalls whose snapshot selected nothing) todiscarded/known_none.
Idempotent: a second run deletes nothing and recomputes the same counts.
With dry_run the transaction is rolled back and the report reflects what
would change.
Source§impl KnowledgeBase
impl KnowledgeBase
pub fn open(db_path: impl AsRef<Path>) -> Result<Self>
pub fn open_with( db_path: impl AsRef<Path>, embedding: Option<Arc<dyn EmbeddingProvider>>, refiner: Option<Arc<dyn Refiner>>, distiller: Option<Arc<dyn Distiller>>, curator: Option<Arc<dyn Curator>>, sanitizer: Option<Arc<dyn Sanitizer>>, ) -> Result<Self>
Sourcepub fn with_reranker(self, reranker: Arc<dyn Reranker>) -> Self
pub fn with_reranker(self, reranker: Arc<dyn Reranker>) -> Self
Install an opt-in offline reranker (part d). Used by open_kb when an LLM is
configured; recall only invokes it when a caller passes rerank=true, so the
default hook path stays no-LLM regardless.