fix(memory): deduplicate episodic/event_log on re-memorize and add foresight expiry cleanup#129
Open
dugubuyan wants to merge 1 commit intoEverMind-AI:mainfrom
Open
Conversation
…foresight expiry cleanup
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.
Description
The memory write pipeline was append-only across all three stores (MongoDB, Elasticsearch, Milvus). This PR fixes two data quality issues that result from that behaviour.
Type of Change
Related Issues
Fixes #95
Relates to #
Changes Made
episodic_memoryandevent_log: when the same MemCell is re-processed, old records are removed from all three stores before the new ones are written. Deduplication key is(parent_id, user_id)to correctly handle group vs personal episodes from the same source.cleanup_expired_foresights()insrc/biz_layer/mem_cleanup.py: deletes foresight records whoseend_timehas passed from Milvus → Elasticsearch → MongoDB in that order.delete_by_parent_idtoEpisodicMemoryRawRepository,EpisodicMemoryEsRepository, andEpisodicMemoryMilvusRepository.delete_by_parent_idtoEventLogEsRepository.delete_expiredtoForesightRecordRawRepositoryandForesightEsRepository.Testing
Test Configuration:
Test Results:
Checklist
Screenshots (if applicable)
Additional Notes
cleanup_expired_foresights()is provided as a standalone async function intended to be wired into a scheduled task (e.g. via the existingcore/asynctasks/framework or ARQ). The deletion order (Milvus → ES → MongoDB) ensures that even if a later step fails, the record is no longer returned by search.Breaking Changes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.