pub struct MemoryConsolidation { /* private fields */ }Expand description
Memory consolidation controller.
Manages the two-layer memory system:
- MEMORY.md: Long-term facts (LLM-maintained)
- HISTORY.md: Timestamped log (append-only)
Implementations§
Source§impl MemoryConsolidation
impl MemoryConsolidation
Sourcepub fn new(config: ConsolidationConfig) -> Self
pub fn new(config: ConsolidationConfig) -> Self
Create a new consolidation controller.
Sourcepub fn should_consolidate(&self) -> bool
pub fn should_consolidate(&self) -> bool
Check if consolidation should be triggered.
Sourcepub fn record_message(&mut self)
pub fn record_message(&mut self)
Increment the message counter.
Sourcepub fn reset_counter(&mut self)
pub fn reset_counter(&mut self)
Reset the message counter after consolidation.
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Get the current message count.
Sourcepub fn append_history(
&self,
workspace: &Path,
entry: &str,
) -> Result<usize, String>
pub fn append_history( &self, workspace: &Path, entry: &str, ) -> Result<usize, String>
Save a history entry (append to HISTORY.md).
This is called by the save_memory tool to log timestamped entries.
Sourcepub fn update_memory(
&self,
workspace: &Path,
content: &str,
) -> Result<usize, String>
pub fn update_memory( &self, workspace: &Path, content: &str, ) -> Result<usize, String>
Update MEMORY.md (full replacement).
This is called by the save_memory tool with the LLM’s curated content.
Sourcepub fn read_memory(&self, workspace: &Path) -> Result<String, String>
pub fn read_memory(&self, workspace: &Path) -> Result<String, String>
Read current MEMORY.md content.
Sourcepub fn read_history(&self, workspace: &Path) -> Result<String, String>
pub fn read_history(&self, workspace: &Path) -> Result<String, String>
Read current HISTORY.md content.
Sourcepub fn search_history(
&self,
workspace: &Path,
pattern: &str,
max_results: usize,
) -> Result<Vec<HistoryEntry>, String>
pub fn search_history( &self, workspace: &Path, pattern: &str, max_results: usize, ) -> Result<Vec<HistoryEntry>, String>
Search HISTORY.md using grep-style pattern matching.
Sourcepub fn config(&self) -> &ConsolidationConfig
pub fn config(&self) -> &ConsolidationConfig
Get configuration reference.
Auto Trait Implementations§
impl Freeze for MemoryConsolidation
impl RefUnwindSafe for MemoryConsolidation
impl Send for MemoryConsolidation
impl Sync for MemoryConsolidation
impl Unpin for MemoryConsolidation
impl UnsafeUnpin for MemoryConsolidation
impl UnwindSafe for MemoryConsolidation
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
Mutably borrows from an owned value. Read more