Files
HomeAgent/internal/memory
JianFeeeee 6067f85c03 fix(memory): graph_centroid 建表归位到 schemas —— 新库不再每轮回退
问题(WSL2 真机诊断报告问题 5):新库上每轮召回都打
  `[graph] recall blocks: reading centroid failed, falling back to raw vectors:
   graph: load centroid: no such table: graph_centroid`
417KB 日志里占相当比例,并回退到全量 raw vectors 扫描(生产库 3178 块)。

根因不是"迁移脚本漏了",而是**建表根本没在初始化里**:
graph_centroid 只定义在 centroid_store.go,且只由 SaveCentroid 内部的
ensureCentroidSchema 创建。新建的库在存过第一个中心向量之前**从不**
调 SaveCentroid ⇒ 建表语句一次没跑过;而召回走的是 LoadCentroid。

修法:把 ddlCentroid 加进 graph.go 的 schemas 列表(复用同一个常量,
避免两处 DDL 漂移)。

判据(centroid_store_test.go,2 条,均经变异验证):
· TestGraphCentroidTableExistsOnNewDB —— 新建库后表必须已存在
· TestLoadCentroidOnNewDBDoesNotFail —— 空库 LoadCentroid 返回
  (nil,false,nil) 而不是 error(贴真实故障路径)
变异:删掉 schemas 里那行 ddlCentroid ⇒ 两条全红,报错文案与真机一致。
2026-10-25 20:15:43 +08:00
..