From 6cbc49ca0eb14faf17768434b75a842e996ef796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=94=AF?= Date: Sat, 7 Nov 2026 06:05:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(recall):=20E4.2=20=E8=B7=A8ns=E5=85=B1?= =?UTF-8?q?=E4=BA=AB=E5=85=9C=E5=BA=95=E8=A1=A5=20ghost-ns=20=E5=88=A4?= =?UTF-8?q?=E6=8D=AE=20=E2=80=94=20=E4=BF=AE=E5=A4=8D=E4=BC=A0=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=20ns=20=E4=BB=8D=E7=BB=8F=20shared?= =?UTF-8?q?=20=E8=A1=A5=E5=85=85=E6=90=9C=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit t_a243aefa 终审在**生产部署后实测**发现:传 ghost ns 仍返回 1 条 channel=shared 记忆 (mem_1793118290141936234, score=0.5 固定值)。根因 = core.go:724 E4.2「结果数 <3 时 补搜 shared」这一段没有 nsHasRows 判据 —— t_15d82af7 只修了 recall.go 的 namespaces 列表和 FTS 尾通道两处,漏了路由层这第三处。 判据与另两处对齐:storage.NamespaceHasRowsFor(与 recall.go 同一个函数,带 60s TTL 缓存)。 ghost ns ⇒ 不补搜;真实 ns ⇒ 行为逐位不变(回归测试 + go test 两包全绿)。 --- go/internal/api/routes/core.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/go/internal/api/routes/core.go b/go/internal/api/routes/core.go index b1f8573..2c9f019 100644 --- a/go/internal/api/routes/core.go +++ b/go/internal/api/routes/core.go @@ -722,7 +722,12 @@ func (a *API) Recall(w http.ResponseWriter, r *http.Request) { } // E4.2: 跨 agent 知识共享 — recall 结果在 (0, top_k) 时,补充搜索 "shared" namespace - if len(results) > 0 && len(results) < 3 && req.Namespace != "shared" && req.Namespace != "" { + // t_a243aefa 终审补漏(2026-11-07 部署后实测):ghost ns(全表无该 ns 行)时**不得**补搜 shared。 + // t_15d82af7 已给 coarse search 的 namespaces 列表和 FTS 尾通道加了同口径判据,唯独漏了本处 ⇒ + // 传不存在的 ns 仍会经 E4.2 捞出 shared 记忆(实测泄漏 mem_1793118290141936234, channel=shared, score=0.5)。 + // 现与另两处对齐:nsHasRows=false ⇒ 不补搜。判据函数与 recall.go 同一个(带 60s TTL 缓存)。 + if len(results) > 0 && len(results) < 3 && req.Namespace != "shared" && req.Namespace != "" && + storage.NamespaceHasRowsFor(a.LanceDB, req.Namespace) { vec, encErr := a.Embedder.EncodeQuery(req.Query) if encErr == nil { var shared []models.MemoryRecord