fix(memory-source): 补上读回环 —— IPC Search 解包结构缺 source 字段导致 recall.source 恒空
- lancedb_ipc.go Search: raw 解包结构新增 Source 字段 + 构造 MemoryRecord 时带上 Source (写库早已带 source,但主读路径不解析 → recall 侧永远空,链路看着通实则断在这一环; 本地兜底路径 localSearch 一直有 Source,故只在 IPC 主路径上复现) - server.go/core.go: 加 [srcprobe] 诊断日志(commit 收到的 source / 蒸馏落库时的 mem.Source)
This commit is contained in:
@@ -105,6 +105,7 @@ func (a *API) Commit(w http.ResponseWriter, r *http.Request) {
|
||||
if src == "" && req.Metadata != nil {
|
||||
src = req.Metadata["source"]
|
||||
}
|
||||
log.Printf("[srcprobe] commit 收到 source=%q(顶层), metadata=%v → 解析后 src=%q", req.Source, req.Metadata, src)
|
||||
|
||||
// 1. 写入 episode(原始日志,总是写入)
|
||||
epID, err := a.LanceDB.InsertEpisode(req.AgentID, req.Namespace, req.Content, req.Category)
|
||||
|
||||
@@ -209,6 +209,7 @@ func NewServer() http.Handler {
|
||||
Freshness: "fresh",
|
||||
Source: srcOrLLMDistill(input.Source), // 2026-09-26:有笔记出处→"wiki:<路径>";否则沿用 llm_distill(2026-09-07 方案C provenance)
|
||||
}
|
||||
log.Printf("[srcprobe] 蒸馏落库 episode=%s input.Source=%q → mem.Source=%q", input.EpisodeID, input.Source, mem.Source)
|
||||
if err := ldb.InsertMemory(mem); err != nil {
|
||||
log.Printf("[distill] commit fact failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -187,6 +187,9 @@ func (rc *RustLanceDBClient) Search(table string, vector []float32, topK int, na
|
||||
VolatileFlag bool `json:"volatile_flag"`
|
||||
Tier string `json:"tier"`
|
||||
LastRecalledAt string `json:"last_recalled_at"`
|
||||
// 2026-09-26:出处(笔记路径)—— 此前**解包结构缺该字段** → IPC 主路径 Source 恒空
|
||||
// (本地兜底路径有 Source,主路径没有 → recall 永远拿不到出处,链路看似修好实则断在这一环)
|
||||
Source string `json:"source"`
|
||||
// vector 必须解析:近重复去重(commit near_dup / 蒸馏写入 gate /
|
||||
// admin/dedup 端点)全部依赖 records 携带向量做 cosine 比较。
|
||||
// 此前缺失该字段 → Vector 恒为空 → 所有 len(Vector)>0 判定失败 →
|
||||
@@ -264,6 +267,7 @@ func (rc *RustLanceDBClient) Search(table string, vector []float32, topK int, na
|
||||
QualityScore: finalQuality, Importance: r.Importance,
|
||||
RecallCount: int(r.RecallCount), VolatileFlag: r.VolatileFlag,
|
||||
Tier: r.Tier,
|
||||
Source: r.Source, // 2026-09-26:出处透出(缺此行 → recall.source 恒空)
|
||||
Vector: r.Vector, // 去重判据依赖,勿删
|
||||
})
|
||||
if len(out) >= topK {
|
||||
|
||||
Reference in New Issue
Block a user