Skip to content

feat(memory): kit memory search --fresh — recency-aware RRF ranking - #369

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a
Jul 19, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

@sandstream sandstream commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner

What

Recency-aware recall for kit memory search, borrowed from the Cerebras knowledge-base ranking stack (see the kit-research note) but kept on-charter: deterministic, zero-LLM. kit has one lexical retriever (FTS5 bm25, which already does IDF) plus a recency signal — no embeddings, no reranker model — so the honest borrow is fusing kit's two incommensurable signals (relevance + recency) by rank, not cargo-culting a multi-retriever/RRF+reranker pipeline.

  • fuseByRrf(lists, keyOf, k=60) — a pure Reciprocal Rank Fusion primitive. Merges ranked lists by rank, not score, so signals with incompatible scales combine with no normalization; k=60 (standard) makes cross-list consensus outweigh a single list's Governance harvest: code-review lenses, preflight gates, secrets runbooks #1. Deterministic tiebreak by key. Reusable for future multi-signal fusion (e.g. provenance from feat(memory): decision-lifecycle capture — idea/abandoned kinds + provenance #362).
  • searchMessages gains opts.recencyBoost — off by default, so the relevance-first order is unchanged. When on, it fetches a larger candidate pool and RRF-fuses bm25-relevance with recency, so a fresh, still-relevant hit can outrank a marginally-more-relevant stale one ("when relevance is otherwise equal, the newer answer wins"). Relevance still dominates the top; recency breaks the lower ranks.
  • kit memory search --fresh wires the flag; memory search help + OpenCLI contract updated.

Why opt-in (no false green)

Making recency-fusion the default would change recall ordering that existing behavior/tests rely on (a 2-item RRF is a symmetric tie), and I can't prove universal improvement for decision-memory. --fresh delivers the value for "what did we recently say about X" without silently regressing the relevance-first default.

Tests

🤖 Generated with Claude Code

Borrows the Cerebras knowledge-base ranking insight, kept on-charter (deterministic, zero-LLM;
kit has one lexical retriever + recency, no embeddings/reranker).

- fuseByRrf<T>(lists, keyOf, k=60): pure Reciprocal Rank Fusion — merges ranked lists by RANK,
  not score, so incommensurable signals combine without normalization. Deterministic tiebreak
  by key. Reusable primitive for future multi-signal fusion (e.g. provenance).
- searchMessages gains opts.recencyBoost (default off → relevance-first order UNCHANGED). When
  on, it fetches a larger candidate pool and RRF-fuses bm25-relevance with recency, so a fresh
  still-relevant hit can outrank a marginally-more-relevant stale one; relevance still dominates.
- kit memory search --fresh wires it; help/opencli contract updated.

Tests: fuseByRrf (consensus > single #1, single-list identity, dedup, deterministic tiebreak);
searchMessages --fresh promotes a fresh-but-weaker hit above a stale mid one while the strongest
relevance match still leads. Full suite green (3013 pass / 0 fail).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit cb58e9c into main Jul 19, 2026
18 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch July 19, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants