From f5aaa255efdc277e191c2bb165dea8f13b1ec758 Mon Sep 17 00:00:00 2001 From: kami Date: Tue, 21 Jul 2026 18:42:56 +0400 Subject: [PATCH] =?UTF-8?q?fix(l3):=20raise=20repo-map=20similarity=20floo?= =?UTF-8?q?r=200.5=E2=86=920.6=20(stopgap)=20(#305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit L3 semantic retrieval does a bad job on the repo map: docs embed a terse symbol-list descriptor while queries embed prose intent, an asymmetric comparison that collapses all scores into a ~0.5 noise band (session 459: junk hits at 0.53/0.54, real relevance never reached). At 0.5 the noise-winners cleared the bar and suppressed the deterministic repo-map floor. 0.6 sits above the noise ceiling (~0.55) and below the real-signal floor (0.68) so noise → empty → fall back to the repo map. Band-aid, not a fix — the real remedy is a prose-shaped repo-file descriptor so query and document share a representation space. Calibration knob, retune if the embedder changes. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01HMbPmZZjcXhR2crU82zZ8S --- .../apps/server/memory/L3RepoKnowledgeRetriever.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/server/src/main/kotlin/com/correx/apps/server/memory/L3RepoKnowledgeRetriever.kt b/apps/server/src/main/kotlin/com/correx/apps/server/memory/L3RepoKnowledgeRetriever.kt index 3e50044a..5ee22283 100644 --- a/apps/server/src/main/kotlin/com/correx/apps/server/memory/L3RepoKnowledgeRetriever.kt +++ b/apps/server/src/main/kotlin/com/correx/apps/server/memory/L3RepoKnowledgeRetriever.kt @@ -24,7 +24,15 @@ private const val RETRIEVAL_OVERSAMPLE_FACTOR = 4 // live grounding); below this floor a hit is just the nearest thing in a small corpus, not // actually related to the query — rendering it as "relevant" is the same poisoning failure // mode as the markdown-in-L3 bug, just via low-signal cosine similarity instead of topic drift. -private const val MIN_SIMILARITY_SCORE = 0.5f +// +// ponytail: 0.5 was too low. Docs embed a terse *symbol-list* descriptor ("path: module X; +// symbols: a,b") while queries embed *prose* intent — an asymmetric prose↔symbols comparison +// that collapses ALL scores into a ~0.5 noise band (2026-07-21 session 459: top junk hits at +// 0.54/0.53, real relevance never reached). At 0.5 those noise-winners cleared the bar and +// SUPPRESSED the deterministic repo-map floor (repoEntriesOrMapFloor). 0.6 sits above the +// observed noise ceiling (~0.55) and below the real-signal floor (0.68): noise → empty → +// fall back to the repo map. Calibration knob — retune if the embedder model changes. +private const val MIN_SIMILARITY_SCORE = 0.6f class L3RepoKnowledgeRetriever( private val embedder: Embedder,