mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1250] [Issue]: LTM recall scoring: bounded per-lane normalization (BM25 boost, keyword lane, threshold) #639
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#639
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Promansis on GitHub (Oct 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1250
Originally assigned to: @Promansis on GitHub.
Summary
Recall ranking is not bounded per lane. The raw BM25 score is added to the fused score unbounded, which overrides rank fusion and the lane weights. The keyword lane is normalized against its own top hit, so a false positive gets full relevance. The threshold means different things per style, lane and vault size.
Affected package
long-term-memory (
packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/ranking.ts,retrieval.ts,keyword-index.ts)Expected behavior
Actual behavior
ranking.ts:46,58):rawScoreBoost = rawScore * 0.001 * lane.weight. Non-bm25 raws are <= 1, so the boost is a tie-breaker. BM25 raw is an unbounded idf sum (10-40 for multi-message queries), while the whole RRF term is <= 1/61 ~ 0.0164, so the boost dominates. Probe ofreciprocalRankFusewith balanced weights (semantic 0.6, lexical 0.3): vector rank 1 (cosine 0.85) fused 0.00887 / relevance 0.510; bm25 rank 10 (raw 18) fused 0.00946 / relevance 0.284. All ten bm25 hits outrank the best semantic hit. On real debug-log recalls the boost is 49-63% (median) of the fused score. Source extraction's existing-note lookup uses the whole source text as the query (source-extraction.ts:311-321), so it is hit hardest.retrieval.ts:167,173:rawScore = hit.score / keywords[0].score), and fuzzy matching is a bare substring check (keyword-index.ts:96,98,103,110).searchLtmKeywordIndex({byKeyword:{king:[...]}}, "I was looking for the map")returns{"score":1.6136,"reasons":["keyword:fuzzy:king"]}. With no exact hit, that false positive normalizes to 1.0, sorelevanceScore = keywordWeight(0.8 underexact) and every chunk of the note passes any threshold up to 0.8. The threshold help text (locales/en.json:310) says it is not "a score relative to the top result", but this lane is exactly that.ranking.ts:43,60,constants.ts:284-314,graph.ts:92,runtime-settings.ts:117-119): a lane's maximum relevance is weight x its own ceiling (graph <= 0.5w; bm25x/(x+1)< w and grows with corpus size and query length; vector cosine x w, <= 0.15 underexact). A threshold of 0.3 tuned underbroadremoves all semantic recall underexactand all bm25, keyword and graph recall underbalanced. Real BM25 normalizes to 0.94-0.98 for every hit, and balanced's selected relevance sits in a 0.285-0.295 band, so any threshold change acts as a cliff.Steps to reproduce
reciprocalRankFuse(ranking.ts) with balanced weights, one vector hit at rank 1 (cosine 0.85) and ten bm25 hits with raw scores up to 18.searchLtmKeywordIndexwith a keywordkingagainst the query "I was looking for the map" and observe the fuzzy hit and its normalization to 1.0 inretrieval.ts.Environment
staging)src/)Logs, screenshots, or video
Probe output above. Full write-up: audit findings LTM-SCORE-02, 03 and 07 (local
scratch/audits/ltm-recall-scoring.md, not tracked).Additional context
Proposed fix: one bounded per-lane normalization pass in
ranking.tsandretrieval.ts.normalizedRawScore, or remove the additive term.reciprocalRankFuseunit test: a deep high-raw bm25 hit vs. the top vector hit across styles, an invariant that the raw boost cannot invert lane weights, and keyword negative cases (substring-only match must not reach relevance = keywordWeight).Related: #1246 (separate settings-validation bug).
Template check