pub struct SynthesisEngine { /* private fields */ }Expand description
Session-scoped online synthesis engine.
§Usage
use engram::intelligence::synthesis::{SynthesisConfig, SynthesisEngine, SynthesisStrategy};
let mut engine = SynthesisEngine::new(SynthesisConfig::default());
engine.add_to_buffer(1, "Rust ownership model uses borrow checker rules");
if let Some(synth) = engine.check_and_synthesize(
"Rust borrow checker enforces ownership rules at compile time",
SynthesisStrategy::Merge,
) {
println!("Synthesized: {}", synth.content);
}Implementations§
Source§impl SynthesisEngine
impl SynthesisEngine
Sourcepub fn new(config: SynthesisConfig) -> Self
pub fn new(config: SynthesisConfig) -> Self
Create a new engine with the given configuration.
Sourcepub fn tokenize(text: &str) -> Vec<String>
pub fn tokenize(text: &str) -> Vec<String>
Tokenise text: lowercase, split on whitespace and punctuation, strip
leading/trailing non-alphanumeric characters, filter empty tokens and
common English stopwords.
Sourcepub fn jaccard_similarity(a: &[String], b: &[String]) -> f32
pub fn jaccard_similarity(a: &[String], b: &[String]) -> f32
Jaccard similarity: |intersection| / |union| over token sets.
Returns 1.0 for two empty slices and 0.0 when the union is empty (degenerate case handled gracefully).
Sourcepub fn detect_overlap(&self, new_content: &str) -> Vec<OverlapResult>
pub fn detect_overlap(&self, new_content: &str) -> Vec<OverlapResult>
Check new_content against every entry in the buffer.
Returns all entries whose Jaccard score meets both the
overlap_threshold and min_overlap_tokens criteria, sorted by score
descending.
Sourcepub fn synthesize(
&self,
existing_content: &str,
existing_id: i64,
new_content: &str,
strategy: SynthesisStrategy,
) -> SynthesizedMemory
pub fn synthesize( &self, existing_content: &str, existing_id: i64, new_content: &str, strategy: SynthesisStrategy, ) -> SynthesizedMemory
Synthesise a new memory from existing_content (id existing_id) and
new_content using the chosen strategy.
The overlap_score is embedded in the result for caller transparency.
Sourcepub fn add_to_buffer(&mut self, id: i64, content: &str)
pub fn add_to_buffer(&mut self, id: i64, content: &str)
Add a memory to the sliding buffer, evicting the oldest entry when the buffer is at capacity.
Sourcepub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Current number of entries in the buffer.
Sourcepub fn check_and_synthesize(
&self,
new_content: &str,
strategy: SynthesisStrategy,
) -> Option<SynthesizedMemory>
pub fn check_and_synthesize( &self, new_content: &str, strategy: SynthesisStrategy, ) -> Option<SynthesizedMemory>
Convenience method: detect overlap and, if found, synthesise using the best-scoring buffer entry.
Returns None when no buffer entry meets the overlap criteria.
Auto Trait Implementations§
impl Freeze for SynthesisEngine
impl RefUnwindSafe for SynthesisEngine
impl Send for SynthesisEngine
impl Sync for SynthesisEngine
impl Unpin for SynthesisEngine
impl UnsafeUnpin for SynthesisEngine
impl UnwindSafe for SynthesisEngine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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