Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }

Implementations§

Source§

impl Engine

Source

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.

Source

pub fn add_entity_alias(&mut self, alias: &str, canonical: &str) -> Result<()>

Register alias as another name for canonical (both canonicalized).

Source

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

Source

pub fn facts_list( &self, space: &ScopedSpace, all: bool, ) -> Result<Vec<FactItem>>

Facts of a space; active only unless all (closed/expired included).

Source

pub fn facts_why( &self, space: &ScopedSpace, fact_id: i64, ) -> Result<Vec<ProvenanceItem>>

The episodes that taught us this fact (invariant I4 guarantees ≥1).

Source

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

Source

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

Source

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

Source

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).

Source

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

Source

pub fn ingest( &mut self, space: &ScopedSpace, input: IngestInput, ) -> Result<IngestOutcome>

Source

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

Source

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.

Source

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

Source

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).

Source

pub fn import_jsonl( &mut self, space: &ScopedSpace, data: &str, ) -> Result<ImportReport>

Import JSONL produced by Engine::export_jsonl. Idempotent.

Source§

impl Engine

Source

pub fn profile(&mut self, space: &ScopedSpace, limit: usize) -> Result<Profile>

Source§

impl Engine

Source

pub fn recall( &mut self, space: &ScopedSpace, query: &str, opts: &RecallOpts, ) -> Result<ContextPack>

Source§

impl Engine

Source

pub fn tag_episode( &mut self, space: &ScopedSpace, episode_id: i64, names: &[&str], ) -> Result<()>

Attach tags to an episode (idempotent; names normalized lowercase).

Source

pub fn tags_list(&self, space: &ScopedSpace) -> Result<Vec<(String, i64)>>

Tags of a space with episode counts, most-used first.

Source§

impl Engine

Source

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.

Source

pub fn open_for_repair( data_dir: &Path, embedder: Box<dyn EmbeddingProvider>, ) -> Result<Engine>

Open bypassing the embedder pin, for doctor --rebuild only.

Source

pub fn set_chunk_target(&mut self, bytes: usize)

Set the chunking granularity (bytes) for future ingests.

Source

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.

Source

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).

Source

pub fn has_llm(&self) -> bool

Source

pub fn set_reranker(&mut self, reranker: Option<Box<dyn Reranker>>)

Attach or detach a cross-encoder reranker for recall precision.

Source

pub fn llm_answer(&self, question: &str, context: &str) -> Result<String>

Answer a question from rendered context via the configured LLM.

Source

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).

Source

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.

Source

pub fn space_revision(&self, space: &ScopedSpace) -> Result<i64>

Source

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).

Source

pub fn episode_content(&self, episode_id: i64) -> Result<(String, String)>

Content and kind of one episode, straight from truth.

Source

pub fn data_dir(&self) -> &Path

Source

pub fn schema_version(&self) -> Result<i64>

Trait Implementations§

Source§

impl Debug for Engine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Engine

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Fruit for T
where T: Send + Downcast,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V