pub struct PromotionEngine { /* private fields */ }Expand description
Background engine that scans episodic memory and promotes recurring patterns to skills.
Runs off the hot path, typically queued to a JoinSet at turn boundary.
§Examples
use std::path::PathBuf;
use std::sync::Arc;
use zeph_memory::compression::promotion::{PromotionEngine, PromotionConfig};
let engine = PromotionEngine::new(
Arc::new(MockWriter),
PromotionConfig::default(),
PathBuf::from("/tmp/skills"),
);Implementations§
Source§impl PromotionEngine
impl PromotionEngine
Sourcepub fn new(
writer: Arc<dyn SkillWriter>,
config: PromotionConfig,
output_dir: PathBuf,
) -> Self
pub fn new( writer: Arc<dyn SkillWriter>, config: PromotionConfig, output_dir: PathBuf, ) -> Self
Create a new promotion engine.
writer is injected from zeph-core and encapsulates SkillGenerator +
optional SkillEvaluator. output_dir is where SKILL.md directories are created.
Sourcepub async fn scan(
&self,
window: &[PromotionInput],
) -> Result<Vec<PromotionCandidate>, MemoryError>
pub async fn scan( &self, window: &[PromotionInput], ) -> Result<Vec<PromotionCandidate>, MemoryError>
Scan a recent-episodic window and return clusters that qualify for promotion.
Clustering is greedy: each message is assigned to the first cluster whose centroid
has cosine similarity ≥ config.cluster_threshold; if no cluster matches, a new
cluster is created. A cluster qualifies when both min_occurrences and
min_sessions are satisfied.
Messages without embeddings (embedding == None) are silently skipped.
§Panics
Does not panic in practice — the unwrap on embedding is guarded by the
filter(|p| p.embedding.is_some()) step immediately above.
§Errors
Returns MemoryError::Promotion if embeddings have inconsistent dimensions.
Sourcepub async fn promote(
&self,
candidate: &PromotionCandidate,
) -> Result<(), MemoryError>
pub async fn promote( &self, candidate: &PromotionCandidate, ) -> Result<(), MemoryError>
Generate and persist a SKILL.md for candidate. Idempotent by signature.
On evaluator rejection the method returns Ok(()) — rejection is a normal outcome.
§Errors
Returns MemoryError::Promotion on generation, evaluator, or disk-write failure.
Auto Trait Implementations§
impl Freeze for PromotionEngine
impl !RefUnwindSafe for PromotionEngine
impl Send for PromotionEngine
impl Sync for PromotionEngine
impl Unpin for PromotionEngine
impl UnsafeUnpin for PromotionEngine
impl !UnwindSafe for PromotionEngine
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request