feat(memory): implement tier decay, importance evaluation, and reinforced ranking - #25
Merged
Conversation
…rced ranking - Add tier/importance_score/last_accessed_at/access_count/decay_rate columns - EvaluateImportance: rule-based scoring (length + punctuation + keywords) - CalcRetention: Ebbinghaus decay R = e^(-t / 24S) in MatchMemories re-ranking - RouteTier: auto-assign working/short-term/long-term on write - PromoteTier: access-count-based tier promotion on recall - CalcReinforce: R_new = min(1, R + F*(1-R)) on recall hit - ForgottenMultiplier: x0.1 penalty for memories below threshold - Fix: delete corpus_vector_400 row on memory_forget - Add tier filter to memory_list, tier field to memory_recall output - Configurable thresholds via env vars (MEMORY_LONG_TERM_THRESHOLD etc.)
- Replace direct field assignment with MemorySet + SetWith so dbUpdate detects changed columns (last_accessed_at, access_count, tier, decay_rate) - Remove dead CalcReinforce call: retention is derived from timestamp, resetting last_accessed_at to now() already achieves full reinforcement - Remove redundant CalcRetention pre-computation in reinforce path - Update plan doc to document the clock-reset reinforcement strategy
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
Three-tier memory lifecycle (working / short-term / long-term) with Ebbinghaus decay re-ranking, rule-based importance evaluation on write, and access-count-driven tier promotion on
recall.
Why
Vector similarity alone can't distinguish important preferences from stale chatter —
memory_recallquality degrades as memories accumulate.Changes
tier,importance_score,last_accessed_at,access_count,decay_ratetoconvo_memoryEvaluateImportancescores content by rule (length + punctuation + keywords),RouteTierassigns tier + decay rate. Upserts preserve tierMatchMemoriescomputesFinalScore = Similarity × R × ForgottenMultiplier(EbbinghausR = e^(-t/(24×S))), re-ranks by composite scorelast_accessed_at(clock-reset → next R ≈ 1.0), incrementaccess_count, promote tier at configurable thresholds (default: 3 → short-term, 10 →long-term). Uses
MemorySet+SetWithfor correct ORM change trackingmemory_recallreturnstier,memory_listsupportstierfilter,memory_forgetcleans up vector rowMEMORY_{LONG_TERM,SHORT_TERM,FORGET}_THRESHOLD,MEMORY_PROMOTE_{W2S,S2L}Key decisions
CalcReinforce: retention is derived from timestamps, resettinglast_accessed_atachieves full reinforcement without needing a persistence target forR_new