feat(search): optional time-decay re-ranking with durable exemption (#337) - #2157
Open
tuyenlethrive wants to merge 1 commit into
Open
feat(search): optional time-decay re-ranking with durable exemption (#337)#2157tuyenlethrive wants to merge 1 commit into
tuyenlethrive wants to merge 1 commit into
Conversation
…emPalace#337) Add opt-in Ebbinghaus recency decay to search_memories: multiply each hit's similarity by 0.5^(age/half_life) over the drawer's filed_at, re-rank, and truncate. Disabled by default (decay_half_life_days=0) so existing behavior is unchanged unless enabled via config. - searcher.py: _parse_filed_at / _decay_multiplier / _is_durable helpers; over-fetch + re-rank + truncate when decay is on. - config.py: decay.{enabled,half_life_days,durable_wings,durable_rooms}. - mcp_server.py: tool_search reads config and passes it through. Durable exemption keeps curated wings (memory/identity) or type=durable drawers at full score so canonical notes don't sink. Addresses roadmap MemPalace#337. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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
Implements optional time-decay re-ranking for search — roadmap item #337 ("recent memories surface before older ones").
When enabled,
search_memoriesmultiplies each hit's similarity by an Ebbinghaus half-life factor0.5 ^ (age_days / half_life)(age from the drawer'sfiled_at), re-ranks, and truncates. A slightly weaker-matching recent memory can now outrank a stale stronger match.Off by default
decay.enableddefaults to false — behavior is byte-identical unless turned on. All logic lives at the single retrieval choke point (search_memories), so the MCPsearchtool inherits it.Config (
~/.mempalace/config.json)Durable exemption
Drawers in
durable_wings/durable_rooms, or taggedtype: "durable"/"wisdom", skip decay (freshness forced to 1.0) so canonical notes don't sink. Exempting by wing is recommended over room, since room names are auto-assigned by the miner (a bulk import auto-labeledarchitectureshould not be treated as canonical).Caveats
n_results × 6, capped) — it reorders near-matches, it does not rescue an item far outside the similarity top-N.filed_at→ no decay (back-compat).Testing
Validated before/after on a ~8k-drawer palace: recent tickets lift, stale bulk content sinks, curated
memory/*notes stay put. Decay math + exemption covered by a self-check.Files:
mempalace/searcher.py,mempalace/config.py,mempalace/mcp_server.py(~90 lines).