pub struct Engine { /* private fields */ }Implementations§
Source§impl Engine
impl Engine
Sourcepub fn distill(
&mut self,
space: &ScopedSpace,
limit: usize,
) -> Result<DistillReport>
pub fn distill( &mut self, space: &ScopedSpace, limit: usize, ) -> Result<DistillReport>
Drain up to limit pending episodes of this space through the LLM.
Failures are recorded on the queue row (attempts, last_error) and
never delete anything (memory/bugs.md P-2); after 3 attempts the row
parks as failed and stops being retried implicitly.
Sourcepub fn add_entity_alias(&mut self, alias: &str, canonical: &str) -> Result<()>
pub fn add_entity_alias(&mut self, alias: &str, canonical: &str) -> Result<()>
Register alias as another name for canonical (both canonicalized).
Sourcepub fn apply_facts(
&mut self,
space: &ScopedSpace,
episode_id: i64,
facts: &[ExtractedFact],
) -> Result<ApplyReport>
pub fn apply_facts( &mut self, space: &ScopedSpace, episode_id: i64, facts: &[ExtractedFact], ) -> Result<ApplyReport>
Apply extracted facts from one episode, in one transaction.
Source§impl Engine
impl Engine
Sourcepub fn facts_list(
&self,
space: &ScopedSpace,
all: bool,
) -> Result<Vec<FactItem>>
pub fn facts_list( &self, space: &ScopedSpace, all: bool, ) -> Result<Vec<FactItem>>
Facts of a space; active only unless all (closed/expired included).
Sourcepub fn facts_why(
&self,
space: &ScopedSpace,
fact_id: i64,
) -> Result<Vec<ProvenanceItem>>
pub fn facts_why( &self, space: &ScopedSpace, fact_id: i64, ) -> Result<Vec<ProvenanceItem>>
The episodes that taught us this fact (invariant I4 guarantees ≥1).
Sourcepub fn facts_close(
&mut self,
space: &ScopedSpace,
fact_id: i64,
reason: &str,
) -> Result<()>
pub fn facts_close( &mut self, space: &ScopedSpace, fact_id: i64, reason: &str, ) -> Result<()>
Close a fact by hand, with a reason (interval close, never delete).
Source§impl Engine
impl Engine
Sourcepub fn facts_about(
&self,
space: &ScopedSpace,
entity: &str,
) -> Result<Vec<FactItem>>
pub fn facts_about( &self, space: &ScopedSpace, entity: &str, ) -> Result<Vec<FactItem>>
Active facts whose subject is entity (canonicalized, aliases
honored), scoped to one space.
Source§impl Engine
impl Engine
Sourcepub fn decay_facts(
&mut self,
space: &ScopedSpace,
max_idle_days: u32,
) -> Result<usize>
pub fn decay_facts( &mut self, space: &ScopedSpace, max_idle_days: u32, ) -> Result<usize>
Decay (spec §5): expire active facts that are old, unaccessed, and low-confidence. Expiry is an interval close with a recorded reason (adopted from the predecessor’s forgetReason, rationales.md R-3) — never a delete. Recalled facts are reinforced (access_count, last_accessed) and therefore immune. Returns how many expired.
Source§impl Engine
impl Engine
Sourcepub fn pending_episodes(
&self,
space: &ScopedSpace,
limit: usize,
) -> Result<Vec<(i64, String, String)>>
pub fn pending_episodes( &self, space: &ScopedSpace, limit: usize, ) -> Result<Vec<(i64, String, String)>>
Episodes awaiting distillation, for agent-driven extraction (subscription-native path: the host agent is the model).
Sourcepub fn complete_distillation(
&mut self,
space: &ScopedSpace,
episode_id: i64,
facts: &[ExtractedFact],
) -> Result<ApplyReport>
pub fn complete_distillation( &mut self, space: &ScopedSpace, episode_id: i64, facts: &[ExtractedFact], ) -> Result<ApplyReport>
Apply agent-extracted facts for one pending episode and mark its queue row done. The engine enforces the invariants; the agent only proposes.
Source§impl Engine
impl Engine
pub fn ingest( &mut self, space: &ScopedSpace, input: IngestInput, ) -> Result<IngestOutcome>
Sourcepub fn import_episode(
&mut self,
space: &ScopedSpace,
kind: &str,
content: &str,
source: Option<&str>,
created_at: Option<&str>,
) -> Result<(i64, bool)>
pub fn import_episode( &mut self, space: &ScopedSpace, kind: &str, content: &str, source: Option<&str>, created_at: Option<&str>, ) -> Result<(i64, bool)>
Import-grade ingest: explicit kind/source/created_at, same pipeline. Returns the episode id and whether it was freshly stored. Public for importers and harnesses that must preserve original timestamps — temporal scoring is only as real as created_at.
Source§impl Engine
impl Engine
Sourcepub fn ingest_directory(
&mut self,
space: &ScopedSpace,
dir: &Path,
max_file_bytes: u64,
) -> Result<ScanReport>
pub fn ingest_directory( &mut self, space: &ScopedSpace, dir: &Path, max_file_bytes: u64, ) -> Result<ScanReport>
Recursively ingest text files under dir. Hidden entries and
dependency/build directories are skipped; binary and oversized
files are counted in skipped, never silently dropped (spec §10).
Content-hash dedup makes rescans cheap and edits append-only.
Sourcepub fn ingest_directory_tagged(
&mut self,
space: &ScopedSpace,
dir: &Path,
max_file_bytes: u64,
tags: &[&str],
) -> Result<ScanReport>
pub fn ingest_directory_tagged( &mut self, space: &ScopedSpace, dir: &Path, max_file_bytes: u64, tags: &[&str], ) -> Result<ScanReport>
Directory scan with curation tags: every ingested (or re-seen) file gets the given tags plus its lowercase extension as a source tag.
Source§impl Engine
impl Engine
Sourcepub fn export_jsonl(&self, space: &ScopedSpace) -> Result<String>
pub fn export_jsonl(&self, space: &ScopedSpace) -> Result<String>
Export one space as JSONL: episodes, entity aliases, then facts (with full interval history and hash-based provenance).
Sourcepub fn import_jsonl(
&mut self,
space: &ScopedSpace,
data: &str,
) -> Result<ImportReport>
pub fn import_jsonl( &mut self, space: &ScopedSpace, data: &str, ) -> Result<ImportReport>
Import JSONL produced by Engine::export_jsonl. Idempotent.
Source§impl Engine
impl Engine
pub fn recall( &mut self, space: &ScopedSpace, query: &str, opts: &RecallOpts, ) -> Result<ContextPack>
Source§impl Engine
impl Engine
Sourcepub fn tag_episode(
&mut self,
space: &ScopedSpace,
episode_id: i64,
names: &[&str],
) -> Result<()>
pub fn tag_episode( &mut self, space: &ScopedSpace, episode_id: i64, names: &[&str], ) -> Result<()>
Attach tags to an episode (idempotent; names normalized lowercase).
Tags of a space with episode counts, most-used first.
Source§impl Engine
impl Engine
Sourcepub fn open(
data_dir: &Path,
embedder: Box<dyn EmbeddingProvider>,
) -> Result<Engine>
pub fn open( data_dir: &Path, embedder: Box<dyn EmbeddingProvider>, ) -> Result<Engine>
Open (creating if needed) the engine rooted at data_dir.
Refuses to open when the store was embedded with a different
provider (spec §9): switching embedders is an explicit
doctor --rebuild, never a silent re-index.
Sourcepub fn open_for_repair(
data_dir: &Path,
embedder: Box<dyn EmbeddingProvider>,
) -> Result<Engine>
pub fn open_for_repair( data_dir: &Path, embedder: Box<dyn EmbeddingProvider>, ) -> Result<Engine>
Open bypassing the embedder pin, for doctor --rebuild only.
Sourcepub fn set_chunk_target(&mut self, bytes: usize)
pub fn set_chunk_target(&mut self, bytes: usize)
Set the chunking granularity (bytes) for future ingests.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
True when another scone process holds the index write lock: search works from committed state; ingest/distill/doctor are refused with typed errors until the other process exits.
Sourcepub fn set_llm(&mut self, llm: Option<Box<dyn LlmProvider>>)
pub fn set_llm(&mut self, llm: Option<Box<dyn LlmProvider>>)
Attach or detach the semantic lane’s LLM. None pauses lane 2
loudly; the episodic engine is unaffected (spec §9).
pub fn has_llm(&self) -> bool
Sourcepub fn set_reranker(&mut self, reranker: Option<Box<dyn Reranker>>)
pub fn set_reranker(&mut self, reranker: Option<Box<dyn Reranker>>)
Attach or detach a cross-encoder reranker for recall precision.
Sourcepub fn llm_answer(&self, question: &str, context: &str) -> Result<String>
pub fn llm_answer(&self, question: &str, context: &str) -> Result<String>
Answer a question from rendered context via the configured LLM.
Sourcepub fn llm_answer_with_system(
&self,
system: &str,
question: &str,
context: &str,
) -> Result<String>
pub fn llm_answer_with_system( &self, system: &str, question: &str, context: &str, ) -> Result<String>
Answer with an explicit system prompt (for prompt A/B harnesses).
Sourcepub fn doctor_rebuild(&mut self) -> Result<DoctorReport>
pub fn doctor_rebuild(&mut self) -> Result<DoctorReport>
Rebuild every derived index from SQLite truth, re-embedding chunks whose stored vectors no longer match the active embedder.
pub fn space_revision(&self, space: &ScopedSpace) -> Result<i64>
Sourcepub fn status(&self) -> Result<StatusReport>
pub fn status(&self) -> Result<StatusReport>
Administrative overview of the whole store (single-user surface; multi-user servers must scope what they expose of it).
Sourcepub fn episode_content(&self, episode_id: i64) -> Result<(String, String)>
pub fn episode_content(&self, episode_id: i64) -> Result<(String, String)>
Content and kind of one episode, straight from truth.
pub fn data_dir(&self) -> &Path
pub fn schema_version(&self) -> Result<i64>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl !Sync for Engine
impl !UnwindSafe for Engine
impl Send for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
impl<T> Fruit for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more