From e3dfe18811658343a7b03b981479b85a826842b9 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 26 Apr 2026 21:40:40 -0400 Subject: [PATCH] docs: search_memories docstring mentions SQL-side significance bias (T78) --- chat/state/memory.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/chat/state/memory.py b/chat/state/memory.py index 0eda418..5310965 100644 --- a/chat/state/memory.py +++ b/chat/state/memory.py @@ -125,6 +125,16 @@ def search_memories( so that stronger candidates yield smaller composite scores; the result is sorted ascending and truncated to ``k``. The unmodified ``fts_rank`` and a debug-friendly ``composite_score`` are kept on each returned dict. + + The result ordering applies TWO independent significance boosts: + + * **SQL-side** — ``ORDER BY (rank - significance * SIGNIFICANCE_RANK_BIAS)`` + pushes higher-significance memories ahead in the FTS5 candidate set so + the over-fetch already prefers them for tied / near-tied BM25 ranks + (T57, §11.1). + * **Python-side** — a composite re-rank with ``_SIGNIFICANCE_WEIGHT`` + reinforces the ordering after candidate retrieval, alongside the + recency boost above. """ if witness_role not in _VALID_WITNESS_ROLES: raise ValueError(