feat(memory): add expiry, supersession, and TTL support#84
Merged
Conversation
- Add Expire() and Supersede() methods to the memory Store interface - Expired entries excluded from Recall by default (IncludeExpired flag to override) - Superseded entries store a forward pointer to the replacement - StoreEntry accepts ExpiresAt for TTL-based auto-expiry at query time - Dedup skips expired entries so replacements are not silently merged - Stats now reports ExpiredCount and ActiveCount - EventExpired lifecycle event for cache boundary managers - REST endpoints: POST /v1/memory/expire, POST /v1/memory/supersede - MCP tools: memory_expire, memory_supersede - 12 new tests covering all expiry and supersession paths Closes #79 Co-authored-by: Ona <no-reply@ona.com>
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.
What
Adds the ability to mark memory entries as expired or superseded, with TTL support on write.
Why
Memory that can't be pruned becomes noise. When a decision is reversed or information becomes outdated, there was no way to mark it — stale entries degraded retrieval quality over time.
Changes
Core (
pkg/memory)Expire()— marks entries as expired; they remain in the store but are excluded fromRecallby defaultSupersede()— marks an entry as expired and stores a forward pointer to its replacementStoreEntry.ExpiresAt— optional TTL; entries past their expiry time are filtered at query timeRecallRequest.IncludeExpired— opt-in flag to retrieve expired entriesStatsnow reportsexpired_countandactive_countEventExpiredlifecycle event for cache boundary managersAPI
POST /v1/memory/expire— expire entries by IDPOST /v1/memory/supersede— supersede one entry with anotherMCP
memory_expiretoolmemory_supersedetoolTests
Usage
Closes #79