pub struct MemoryConsolidator {
pub config: ConsolidationConfig,
}Expand description
The memory consolidation engine — responsible for keeping a fighter’s memory store lean and battle-ready.
Like a seasoned corner crew between rounds, the consolidator trims the fat, reinforces core muscle memory, and ensures the fighter enters the next bout at peak mental sharpness.
Fields§
§config: ConsolidationConfigThe consolidation training regimen.
Implementations§
Source§impl MemoryConsolidator
impl MemoryConsolidator
Sourcepub fn new(config: ConsolidationConfig) -> Self
pub fn new(config: ConsolidationConfig) -> Self
Create a new consolidator with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a consolidator with sensible default settings — a balanced training regimen suitable for most fighters.
Sourcepub async fn consolidate(
&self,
memory: &MemorySubstrate,
fighter_id: &FighterId,
) -> PunchResult<ConsolidationResult>
pub async fn consolidate( &self, memory: &MemorySubstrate, fighter_id: &FighterId, ) -> PunchResult<ConsolidationResult>
Run full memory consolidation for a fighter — the complete recovery session between bouts.
Steps:
- Apply confidence decay based on memory age
- Prune memories below the minimum confidence threshold
- Merge similar memories (by key similarity)
- If still over max capacity, prune lowest-confidence oldest memories
Sourcepub fn apply_decay(&self, confidence: f64, age_days: f64) -> f64
pub fn apply_decay(&self, confidence: f64, age_days: f64) -> f64
Compute decayed confidence based on age.
Muscle memory fades without practice — confidence erodes over time
at the configured decay rate: confidence * (1.0 - decay_rate) ^ age_days.
Sourcepub fn should_consolidate(&self, memory_count: usize) -> bool
pub fn should_consolidate(&self, memory_count: usize) -> bool
Check whether a fighter’s memory store needs consolidation — is the fighter carrying too much weight for their class?
Sourcepub fn keys_are_similar(a: &str, b: &str) -> bool
pub fn keys_are_similar(a: &str, b: &str) -> bool
Check if two memory keys are similar enough to merge.
Uses a normalized edit distance (Levenshtein-like). Two keys are considered similar if their normalized similarity score exceeds the configured threshold — like recognizing two punches as variations of the same combo.
Sourcepub fn merge_values(values: &[(&str, f64)]) -> (String, f64)
pub fn merge_values(values: &[(&str, f64)]) -> (String, f64)
Merge multiple memory values into a single consolidated entry.
Like combining footage from multiple training sessions: the best performance (highest confidence value) is kept, and the overall confidence is averaged across all observations.
Trait Implementations§
Source§impl Clone for MemoryConsolidator
impl Clone for MemoryConsolidator
Source§fn clone(&self) -> MemoryConsolidator
fn clone(&self) -> MemoryConsolidator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more