feat(memory): episodic memory consolidation pipeline#49
Merged
Conversation
New module memory/consolidation.py with MemoryConsolidator that runs three-step consolidation: archive resolved episodes older than retention_days, LLM-summarize clusters of archived episodes into lesson notes grouped by shared entity, and promote episodes referenced by 3+ other episodes to permanent vault notes. Add ARCHIVED status to OutcomeStatus enum. EpisodeStore gains archive_old_resolved(), query_archived(), and count_entity_references() methods. Add ConsolidationConfig (disabled by default, monthly schedule).
14 tests across 5 classes: archive old resolved episodes (4), query archived (2), count entity references (1), full consolidation with archive/summarize/promote (5), ConsolidationConfig defaults and Settings integration (2).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a memory consolidation pipeline for episodic memory lifecycle management, inspired by memora-lab/memory-service-public's observation lifecycle patterns. Episodes now have a complete lifecycle: created → resolved → archived → summarized into lesson notes → promoted to permanent vault notes. This is the final PR (#49) in the memora-inspired enhancement plan.
Three-Step Consolidation
Episode Lifecycle (Complete)
Changes
New Files
src/vaultmind/memory/consolidation.py(241 lines) —MemoryConsolidatorclass withconsolidate()orchestrator,_archive_old_episodes(),_summarize_clusters()(groups by shared entity, LLM synthesis, writes lesson notes),_promote_referenced()(cross-reference counting, writes permanent notes).ConsolidationReportdataclass tracks counts and errorstests/test_consolidation.py(230 lines) — 14 tests across 5 classesModified Files
src/vaultmind/memory/models.py— AddedARCHIVED = "archived"toOutcomeStatusenum, enabling the archive lifecycle statesrc/vaultmind/memory/store.py— Three new methods:archive_old_resolved(age_days=365)— UPDATE resolved episodes older than threshold to "archived" status. Skips pending and already-archived. Returns countquery_archived(limit=100)— retrieve archived episodes ordered by created desccount_entity_references(entity)— count episodes mentioning a given entity (for promotion threshold)src/vaultmind/config.py— AddedConsolidationConfigclass withenabled(defaultFalse),retention_days(365),min_references_for_promotion(3),schedule("0 0 1 * *"— monthly). Addedconsolidationfield toSettingsconfig/default.toml— Added[consolidation]section with all config entriesBackward Compatibility
ConsolidationConfig.enableddefaults toFalse— zero behavior change for existing usersARCHIVEDstatus is additive to OutcomeStatus enum — existing statuses unaffected_meta/lessons/and_meta/episodes/— isolated from user contentOutput Examples
Lesson note (
_meta/lessons/lesson-kubernetes-20260326.md):Promoted note (
_meta/episodes/episode-api-decision-20260326.md):Test plan
test_consolidation.pyacross 5 classes:ruff check— cleanmypy --ignore-missing-imports— clean