Repository navigation
Description
Motivation
Currently all notes/entities are weighted equally in search results. A stale observation from three weeks ago ranks the same as a correction that saved 30 minutes yesterday. As knowledge bases grow, retrieval quality degrades because there's no signal for which memories are actually useful.
Inspired by memelord's approach (Turso blog), which combines cosine similarity with time decay and usage weighting:
ORDER BY (1.0 - vector_distance_cos(embedding, vector32(?)))
* POWER(0.995, julianday('now') - julianday(created_at))Proposed Changes
Phase 1: Time-decay scoring (low effort, high impact)
- Add a time-decay factor to search result ranking
- Recent notes score higher than old ones at equal similarity
- Configurable decay rate (default ~0.995/day means half-life of ~138 days)
- This is purely a scoring change — no schema or storage changes needed
Phase 2: Usage-weighted scoring (medium effort)
- Track when a note/entity is retrieved via search or build_context
- Track when retrieved notes are actually used in the conversation (accessed via read_note after appearing in search results)
- Boost frequently-useful notes, decay ignored ones
- Could be as simple as a
last_accessed_at+access_counton entities
Phase 3: Feedback loop (higher effort, ties into SPEC-28)
- Allow agents to explicitly rate memory usefulness (upvote/downvote)
- Automatic contradiction detection — when an agent stores a correction, the corrected memory gets downweighted
- Self-cleaning: memories below a weight threshold get flagged for review/archival
Why This Matters
BM's differentiator is human-readable plain text. But search ranking doesn't have to be naive just because storage is simple. We can have sophisticated retrieval on top of transparent storage.
The memelord approach validates this — they use SQLite + vector search + weighted scoring. We already have the first two. Adding weighted scoring closes the gap while keeping our plain-text advantage.
References
- Turso/memelord blog: https://turso.tech/blog/giving-openclaw-a-memory-that-actually-works
- memelord repo: https://github.com/glommer/memelord
- Letta sleep-time compute (similar concept): memory consolidation + re-ranking during idle time
- Our memory-reflect skill already does manual consolidation — this would automate the ranking part
Activity
claude commentedon Feb 25, 2026
Claude finished @bm-clawd's task in 1m 32s —— View job
Issue Triage
Triage Summary
Type: Enhancement / Feature Request
Priority: Medium
Component: Database (search), MCP tools
Complexity: Complex (multi-phase)
Labels applied:
enhancementAnalysis
No duplicate issues found.
What the issue proposes: Three phases of smarter search ranking:
created_at/updated_at. The issue calls this "low effort, high impact" since no schema changes are needed.last_accessed_at+access_countto entities and boost frequently-retrieved notes.Current search implementation: Looking at
sqlite_search_repository.py:819, the FTS query currently usesbm25(search_index) as scorewith no temporal weighting. The entity model already hascreated_atandupdated_atfields with indexes (ix_entity_created_at,ix_entity_updated_at). The search index also hascreated_atandupdated_atcolumns, making Phase 1 feasible without schema changes.Phase 1 feasibility: Essentially straightforward — the search SQL at line 802-825 could incorporate a decay multiplier like the Turso blog example:
The tricky part is:
Phase 2 feasibility: Requires schema changes — adding
last_accessed_atandaccess_countcolumns to the entity or search_index table, plus Alembic migrations. Medium effort, touches MCP tools (search, read_note, build_context all need to update these counters).Phase 3 feasibility: High complexity — requires explicit agent APIs, contradiction detection logic, and memory consolidation. Should be a separate issue/SPEC.
Recommendations
0.999).The Turso/memelord approach validates the pattern. BM25 note: SQLite FTS5's
bm25()returns negative values where more negative = better match, so the decay formula needs to account for the sign when combining with time decay. A rank normalization step would be needed for a clean multiplicative combination.bm-clawd commentedon Feb 25, 2026
Config note: Time-decay scoring should be opt-in via project config, not default behavior. Some use cases (research archives, documentation, permanent knowledge bases) need stable ranking regardless of age. Others (agent memory, daily workflows, conversation context) benefit from recency bias.
Proposed config shape:
Could also support per-note opt-out via frontmatter (e.g.
pinned: trueordecay: false) for notes that should never fade regardless of project setting.alexanderbering commentedon Oct 30, 2026
A single 0.995 per day gives every note the same 138-day half-life: generous for yesterday's standup, stingy for the schema decision someone looks up every week. That is the objection in #616, and the per-note
decay: falseabove works around it by hand.Memory research puts the rate on the item and lets each retrieval change it. ACT-R's base-level activation sums a power-law decay over an item's past retrievals, B = ln Σ t_j^-0.5 (power law after Anderson & Schooler, 1991). A note that keeps being read stays strong without a pin, an untouched one fades, and Phase 1 and Phase 2 become one term. No need to keep every timestamp: Petrov's (2006) hybrid approximation with one exact lag uses the count, the time since the last retrieval and the age, i.e. the
access_countandlast_accessed_atfrom Phase 2 pluscreated_at.Phase 2's line between retrieved and used carries the weight. If every hit counts, the ranking feeds itself and a superseded fact grows stronger with each search; SPEC-82's valid-time qualifiers are the better signal for that.