小唯
6db0ffa7d4
fix(zhiyi-recall): recall 响应补 quality_score/v_value 直通 (t_631ab13d)
...
- 根因 (a) 显示漏:RecallResult 结构缺 quality_score/v_value 字段
⇒ JSON 序列化不带出 ⇒ 插件 r.get("quality_score",0) 恒得 0。
排序用库值(candidates[i].QualityScore, recall.go:236/321) 不受影响。
- Rust IPC Search 会把排序用 QualityScore 融合成 0.4*imp+0.6*raw(cap1.0),
非 LanceDB 原始列 ⇒ 新增 MemoryRecord.RawQualityScore(json:"-") 携带原值,
recall 响应展示原始库值(响应值==库值), 排序仍用融合值。
- AC2 实测 5 个 id 响应值==LanceDB 直读值(0.66/0.0/0.7/0.6/0.6)。
2026-10-11 22:41:26 +08:00
小唯
0e4fb59e1a
feat(zhiyi): t_689b6d38 注入入口加系统样板噪音闸门
...
被动注入入口不区分「真实用户消息」与「系统通知/提示样板」:近7天
[graph/notes] 通道 806 次注入里 543 次(67%) 入参是系统样板
("[IMPORTANT: You are running as a scheduled cron job..." /
"[IMPORTANT: Background process ..." / "[System note: ..."),
照常走完整实体拆解并返回 3 篇笔记 → 纯浪费 + 稀释信噪比。
改动(判定优先用结构化来源标记头,非纯长度启发式;白名单真实用户提问照常召回):
- 新增 routes/system_template.go: IsSystemTemplateInput(头子串 + 全文子串)
- /api/v1/graph/notes: 命中样板 → mode=none + notes=[] + skipped=system_template,不拆实体
- /api/v1/recall: 命中样板 → results=[] + skipped=system_template,不进语义召回
- plugins/hermes-zhiyi: prefetch/queue_prefetch 加同判据闸门(客户端侧前置拦截)
实测(改后): 样板入参 graph/notes notes_count=0 skipped=system_template;
真实提问 graph/notes mode=nl_extract notes_count=10 / recall count=3(无误杀)。
AC1 7天噪音率基线=543/806(67.4%),改后新日志以 [graph/notes] 拦截 行可判。
2026-10-11 22:19:39 +08:00
小唯
886c0c20e2
style(gofmt): 全仓 66 文件对齐 gofmt 1.25
...
gofmt -l 实测 66 文件不合规(历史遗留+gofmt 1.25 规范化:
单行 if/for/case 展开成块、Go1.19+ doc 注释 // 与段落 // 空行)。
本 commit 只含格式化,零逻辑改动:
- 66/66 文件「去注释+去空白+分号归一」后 token 流与 HEAD 完全一致
- go build ./... exit 0;go vet ./... exit 0(改前后一致)
- go test ./... 17 包全 ok(改前后一致)
验收: gofmt -l . 为空;git diff -w 非空系 gofmt 1.25 非纯空白特性,
非逻辑改动(等价性以 token 流 + test 兜底)。
2026-10-10 15:51:25 +08:00
xiaoyi
ba3ccd3e12
fix(conflict): 冲突预筛改用候选自身话题信号 —— 修 server.go:249 实体传参致预筛恒真
...
缺陷:调用方给每个候选都塞入「新内容的实体」(同一个切片),Scan 里 e1==e2 恒真
⇒ 实体预筛完全失效。实害:①预筛一条都没过滤;②每条候选跑 len(实体) 次冗余
IsContradiction(线上实测 4~12);③同一 (新内容,候选) 对产出多条重复 Conflict;
④Entity 字段恒记「新内容第一个实体」,与候选无关、事后无法定位共同话题。
更正归因:曾把 conflicts-false-positive 的 106 条假阳性归因于本 bug —— 实测不成立。
869 条真实样本(106 FP + 763 pending)在当前 IsContradiction 下判 true 的为 0,
那些误报的根因是 IsContradiction 自身旧启发式(阈值 0.3 + 单字否定),已于 09-20/09-21 修复。
修法:
- 新增 conflict_prefilter.go:sharesTopicWith 用**字符 bigram Jaccard**做话题交集判据
(不依赖分词/词表,中英改写都稳),阈值 0.15 由实测标定
(假阳性上界 0.118 / 真矛盾下界 0.400;误杀 0 对);
- Scan:候选侧改用自身正文判定,每条候选最多比对一次、最多产出一条 Conflict;
取不到信号时照常比较(宁可多算,不可静默漏检);
- 新增 governance.ExtractEntities:中英混排实体抽取(原有版本只认 ASCII 大写词,
对纯中文恒返回空,直接拿来当修法会让冲突检测整体静默失效);
- server.go:候选实体改为从其正文抽取。
验收:新增 conflict_prefilter_test.go(6 项,含真实生产样本 + 反证测试双向验证)。
基线对照:仅 2 项 alias 测试失败,与本次改动无关(HEAD 即失败)。
2026-10-09 11:54:14 +08:00
小唯
90af029c16
feat(memory): confidence 信任等级字段(Gap#2 来源加权 · 接线全通 · 加权默认关)
...
- schema: memories/episodes/tombstones +confidence(Float64,nullable) +confidence_source(Utf8,nullable)
- 迁移默认值改类型感知 + 一律可空(原 '' 字面量会把列标成 non-null,与 arrow_schema 冲突)
- 6 层接线全通:Rust schema/insert/scan/search → Go 解包/输出构造 → RecallResult
- recall.go: COALESCE(NULL→1.0) + 门控加权(ZHIYI_CONFIDENCE_LAMBDA 默认 0 = 首日 no-op)
- 新增 conf_e2e_test.go 端到端回归(未设 ZHIYI_CONF_SOCK 自动跳过)
- 验证:副本迁移 25→27 列行数不变;显式声明往返 0.5/authoritative;未声明读回 NULL
2026-10-08 20:39:29 +08:00
小唯
9bfe4c217f
fix(p1-1): forget path - counting test + purge-invalid endpoint (t_37ac8a45)
2026-10-08 15:44:04 +08:00
小唯
23388679b9
fix(health): /health 深检查 sidecar 可达性,故障返 503(防"假绿")
...
背景:2026-10-08 故障 —— sidecar 跑旧二进制时 /health 仍返回 200,
部署失败被静默数小时,只能靠 pgrep 才发现。
- HandleHealth 由静态 200 改为探测 IPC sidecar(consolidate.HealthCheck)
不可达时返回 503 + status=degraded + sidecar=unreachable + error 详情
- 探测函数做成可注入变量 sidecarHealthCheck,便于测试替换
- 新增回归项 TestHealthEndpoint_SidecarDown
- 顺带修复 provenance_observe_test.go 编译失败:provenanceMatch 已在
commit 4fa2e11 改名为 provenanceMeasure,测试未同步 ⇒ 该包自 09-30 起
编译不过、测试从未真正运行(同属"假绿")
2026-10-08 10:51:08 +08:00
小唯
ca45c96e32
fix(provenance): 落库 embedding_model/script_version 血缘字段 (t_7e3577c5)
...
根因: commit→distill→memory 管线从不在服务端持久化请求 metadata 里的
embedding_model/script_version, MemoryRecord 结构缺这两字段, 导致
zhiyi-vault-ingest.py 已发送的血缘被丢弃, 新写入恒 NULL。
修复:
- Go MemoryRecord + DistillInput 加两字段;
core.go commit handler 解析 metadata→AutoDistillTrigger 透传;
server.go 落库时 orDefault(embedding_model→bge-m3, script_version→unknown);
lancedb_ipc.go 记录 map 带上两字段。
- Rust MemoryRecord + arrow_schema() + insert_batch + 4 处 col_str 读取。
验证: commit 带 metadata → 蒸馏落地 19 行 bge-m3/vault-ingest-2.0.0 (原为 NULL)。
2026-10-08 03:57:30 +08:00
小唯
fc7b8e74bd
fix(distill): 修评分 echo 闸门失效 + 空 id 软删防御(P0-1/P0-2/P1-1)
...
P0-1 治本·去 echo 源
engine.go 的 5D 评分 prompt 曾把示例写成具体数字(0.8/0.7/0.6/0.9/0.7),
模型直接照抄 ⇒ 每条 overall 恒为 0.755(按 Weights 加权)⇒ 永久 ≥0.7 阈值
⇒ 评分闸门从未真正生效,实际只剩「文本长度」在扛质量,生产者于是学会拉长文本过关。
改为类型占位符 <小数>,并显式禁止沿用固定数值组合。
P0-2 治本·echo 检测 + 影子模式
新增 IsEchoScore(比对历史示例向量);闸门命中时默认只记 [SHADOW] would-drop,
不真丢(ZHIYI_SCORE_SHADOW=0 切回真拦)。原因:闸门修好后会首次开始真拦,
需先观察样本分布,避免一次性批量误杀。
P1-1 防御·空 id 软删
DB 存在 id/content 全空的垃圾行 → 命中 <30 字碎片快速道 → SoftDelete("")
→ Rust IPC 拒绝 "id required" → 调用方吞错照样 forgotten++ ⇒ 刷日志 + 计数虚高。
RustLanceDBClient.SoftDelete 入口拒绝空 id;admin.go/server.go 四处调用点
补 id != "" 守卫 + 失败不计数。
测试(均含阳性/阴性对照):
TestIsEchoScore_Positive / _Negative / TestEchoVectorMatchesWeightedOverall
/ TestPromptHasNoEchoLiterals(回归守卫,防示例数字被写回)
TestSoftDelete_RejectsEmptyID / _NonEmptyIDPassesGuard
2026-10-06 17:21:41 +08:00
xiaoxue
4fa2e11b78
feat(provenance): 阶段2 可溯源判据重定义 + 实测 lcs_len/prefix_hit60 入 jsonl (t_dc412532)
...
AC1 先量后判: jsonl 增记 lcs_len(最长公共子串) + prefix_hit60(前60字命中)。
AC2 判据重定义: 空原文(session 已压缩) -> unknown/source_not_available(不再误判
false/not_in_source); 摘要低 LCS -> unknown/derived_low_lcs(正常改写不可证伪);
命中 -> true(片段可溯源)。依据 24h 分布 true=1/false=8/unknown=193, 8条 false
全来自 session-compress(摘要器)=结构性误判。
AC3 unknown 处置=放行(fail-open): 94.6% unknown 为 writer 侧盲区(无 source),
非内容不可回证; 拒 unknown = 99.7% 拦 = 掐死织忆。
AC4 行为不变: 仍纯旁路观测, 不拒任何写入。
2026-09-30 19:36:09 +08:00
小唯
631241c50a
feat(provenance): commit 引用可复算旁路观测(t_3fbb6cbd 阶段1,只观测不拦截)
...
开关 ZHIYI_COMMIT_PROVENANCE_OBSERVE 默认关。开启时对 /api/v1/commit 做异步旁路观测:
(a) 有 source_uri+quote+quote_sha256 → 复算 sha256 比对(hash_mismatch)
(b) source==session-compress 且 session_id → 去 ~/.hermes/state.db 只读回证(前60字符命中或 LCS>=60)
(c) 其他 → observable=unknown/no_derivation
结果追加 ~/.hermes/logs/zhiyi-commit-provenance/YYYY-MM-DD.jsonl,不改响应/写入路径/拒写入。
AC1 关=零影响已验证;单元测试 TestProvenance*/TestLCS/TestDecideQuoteHash 通过。
2026-09-28 23:27:32 +08:00
小唯
66cb258979
perf(graph/navigate): 响应体积上限 maxNavigatePaths=200
...
实测 navigate("牧尘",2) 单次吐 34,465 条 path = 5.54MB,而全部调用点只读样本
(hermes 插件 paths[:50] / web-ui 只读 count / openclaw 已退役) ⇒ 全量无人消费。
与 /graph/notes 的 maxGraphPaths 同因同治;count 仍报真实总数,新增 returned/truncated 可观测。
2026-09-27 19:15:06 +08:00
小唯
f26126765c
graph: 跨层实体并集 + PathEnds 双键容错 + 邻域展开上限(修 CPU 打爆)
...
- entity_resolve.go: 新增 ResolveEntityIDs / MergePaths / PathEnds / ExtractEntities
- graph_sqlite.go: 新增 NodeIDsByName 精确同名查询(SearchNodes 是 name LIKE '%x%'
LIMIT 100,'织忆' 有 834 条子串命中会把精确同名挤出去 → 并集静默失效)
- graph_cache.go: 转发 NodeIDsByName(包装器不转发 → 类型断言失败 → 静默降级回 LIKE 路径)
- server.go: notes 路径接并集(union=1 opt-in / 0 关闭,响应带 union + entity_ids_used);
navigate 结果统一走 routes.PathEnds —— governance.Navigate 返回的是 from/to,
此前读 source/target 导致并集路径与「邻居进笔记匹配」被整条静默丢弃;
邻域进笔记匹配加 maxMatchEntities=24 上限(2026-09-27 事故:无上限邻域展开
→ 数千实体 × 全库笔记扫描 → CPU 159% / HTTP 超时)
- 单测 5 条,含 from/to 键容错回归
2026-09-27 09:23:03 +08:00
xiaoyi
c7235afcd5
perf(graph/notes): graph_paths 截断到 50 条(1.7MB → 5KB/次)
...
调用方核对:hermes 插件 data.get("notes")、openclaw client.ts r.data.notes、
hermes-zhiyi 旧副本 —— 3 处全只读 notes,无一处读 graph/notes 的 graph_paths
(读 paths 的是 /graph/navigate 那条线)。
实测 entity=织忆:响应 1775KB → 5.1KB,notes 仍 3 篇、score 不变;
paths_count 由 19266 → 50。max_hops/max_notes 语义不变。
2026-09-27 08:30:28 +08:00
xiaoyi
46eaf1a35d
feat(graph/notes): 整句→实体兜底拆解(EntityIndex)
...
问题:调用方(hermes 织忆插件)把整句用户提问直接当 entity 传给
/api/v1/graph/notes,NormalizeEntity 后整句匹配不到图谱节点 → 0 篇笔记,
Obsidian 笔记层在真实对话里几乎不生效。
改动(纯服务端,调用方无需改,也就无需重启 hermes 网关):
- 新增 routes.EntityIndex:节点名词表(PageRank,TTL 10min,后台 45s 预热)
+ 最长/权重匹配把整句拆成候选实体;候选需过 相对权重比(0.15) 与 图谱度数(>=3)
两道过滤,压掉通用词/自动切词噪声节点。
- /api/v1/graph/notes:entity 直查 0 篇笔记时自动兜底拆实体重查;
新增 query 参数;响应新增 mode(direct|nl_extract|none) 与 entities_used。
兜底路径 graph_paths 截断(单实体 20 条、合计 50 条)、参与匹配实体上限 8。
- 覆盖测试 10 个:真实句子拆解/大小写/包含冗余/权重比/度数过滤/TTL缓存与失败退避/nil 安全。
实测(生产 7821):单词实体 entity=织忆 仍 mode=direct 3 篇(回归不变);
整句 "织忆召回会不会给出obsidian实体所在的笔记位置呢" → mode=nl_extract
used=[Obsidian 织忆] 3 篇真路径 0.29s;无意义句 "完全不相干的一句话天气不错"
→ mode=none 0 篇(噪声已过滤)。
2026-09-27 02:19:13 +08:00
hermes
9d9b92df27
perf(recall): 向量重排 + 查询截断 —— 修掉 Hermes 记忆预取 8s 超时
...
根因(/api/v1/recall/debug 分阶段实测,2026-09-28):
query=60 字 → total 2268ms(encode 39 / ann 188 / rerank 2039 / mmr 0)
query=1200字 → total 9980ms(encode 1441 / ann 189 / rerank 8001 / mmr 347)
query=4000字 → encode 一步就 8000ms
rerank 占 90%+:旧实现(localCosineRerank)把 query + 50~100 条候选文档重新送进
int8 ONNX CPU 嵌入服务,而这些向量调用方本来就有(queryVec 来自 Step1,
LanceDB 返回的 MemoryRecord 自带 Vector)。
修复:
1. Reranker.RerankWithVectors —— 用已有向量直接算 cosine(向量不齐则回退文本路径);
recall 管线与 /recall/debug 同步改用。
2. Embedder.EncodeQuery —— query 侧向量化前按 512 字符截断(RECALL_QUERY_MAX_RUNES 可覆盖),
保护超长 query 的时延;关键词/BM25 路径仍用完整 query。
3. apiRerank 失败不再静默(log 出降级原因)。
实测(同机复验):60字 2268→235ms;1200字 9980→567ms;2000字 16571→547ms;4000字 8000+→502ms。
真实插件路径 prefetch:短 query 1.00s、3000 字长 query 1.25s(预算 8s,余量 6.4×)。
2026-09-27 00:57:39 +08:00
小唯
a76847b5d7
fix(commit): metadata 改 map[string]any —— 修 400 静默丢数据回归
...
2026-09-26 88f610a 为带上 source 把 metadata 写成 map[string]string,
而各写入端早就在 metadata 塞数字(hermes-zhiyi sync_turn 的 turn:int、
soulful 与 session-to-zhiyi 的 importance:number)⇒ json.Decode 整包失败
⇒ 400 invalid body ⇒ 这些写入端全部静默丢数据(客户端只打日志)。
实测:修前 A/B/C 三形状 400;修后全 201,且 metadata.source 仍被正确解析。
source 读取加类型断言,非字符串忽略(该字段是 metadata 里唯一被消费的键)。
验证:go build ok / go vet ok / go test ./internal/api/routes ok /
真实路径 HermesZhiYiMemoryProvider.sync_turn → _flush_queue 3 条全部落库。
2026-09-26 23:27:07 +08:00
小唯
db0395eb15
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)
2026-09-26 22:10:44 +08:00
小唯
88f610aa1e
feat(memory-source): 打通 commit→distill→memories.source→recall 全链(含 metadata.source 与 wiki:<路径> 标记)
...
- recall.go: RecallResult.Source = 记忆 source(此前只有 struct 字段没人填)
- distill/engine.go: DistillInput.Source(来源透传)
- auto_distill.go: AutoDistillTrigger 增加 source 参数并透传
- routes/core.go: /commit 请求体新增 source + metadata(此前缺失 → Go 静默丢弃 → 入库恒空)
- server.go: 蒸馏产物 Source = wiki:<路径>(有出处时),手动蒸馏端点也支持 source
- 清理 worker 误提交的 15MB 二进制(go/cmd/zhiyid/zhiyid-new)并加 .gitignore
2026-09-26 21:43:54 +08:00
xiaoyi
a7d6625aeb
test(distill): mock LLM 按 path 区分槽位探测与蒸馏调用
...
根因:19afe3b 引入 probeLLMSlots(GET /props 探本地 2B 槽位),而 mock LLM 的
handler 不检查 path、对任何请求都 calls++ ⇒ 断言「B 触发后恰好 base+1 次 LLM 调用」
被 flush 前后的两次探测撑成 base+3,TestCommitConflictGate_E2E 恒 FAIL。
修法:mock 对 /props 返回 {"total_slots":1} 且不计数 —— 探测不是「蒸馏 LLM 调用」。
不放松断言(判据本身是对的,是 mock 口径错了)。
验证:TestCommitConflictGate_E2E PASS;该包 go test 全绿。
2026-09-22 09:57:58 +08:00
小唯
2150e94cb8
fix(AC2): total_episodes 缓存兜底改名 episodes_cached(t_a838377a)
...
Rust sidecar 缺失 total_episodes 时的回退值原为 len(_local.episodes)
(进程内缓存,重启清零)却以 total_episodes 键名暴露 → 消费者误以为是真实总量。
现改为 episodes_cached 键名 + 各消费方 fallback 读取 episodes_cached + /api/v1/metrics 标注 episodes_source_cached=1。
生产验证:当前 Rust 返回 total_episodes=58284(count_rows 真实值),兜底分支不触发。
2026-09-21 23:30:59 +08:00
小唯
5450f29740
t_949840b1: 金标单一真相源收口 + candidates_scanned 名实相符 + 基线校准 diff=0
...
- 金标单一真相源:go/internal/api/routes/testdata/golden-set.json 为唯一数据文件;
Python 量具 golden-check.py 直接读仓库版(旧 ~/.hermes/scripts/tools/golden-set.json
副副本已归档到 .archive/20260921-golden-set-legacy-dup/)
- 基线校准:item4「牧尘喜欢什么样的工作方式」expected_ids 更新为当前稳定值
mem_1789834428978989104(旧基线 mem_1789837840173161705 已掉出 top-5)
- 两量具(Go TestEvalGolden_Live + Python golden-check.py)同批金标 14 条
分类差异 diff=0(独立复算确认)
- candidates_scanned 字段契约:RecallWithMeta 额外返回候选池真实大小
(ANN 粗检索池,非最终产出数),不再用 len(results) 覆盖
- 构建+测试:go build ./... 通过;go test ./internal/storage 通过;
routes 包 TestCommitConflictGate_E2E 在改动前后均挂(预存,非本次引入)
2026-09-21 22:55:03 +08:00
xiaoyi
3a3e019c03
feat(auth+zhiyid): 监听默认本机(ZHIYI_BIND) + 密钥强制(去硬编码回落) + /metrics 纳管 + 过渡期 legacy 兼容
...
卡 t_4fab32c1 的 AC1/AC2/AC3 实现 + 小怡 09-21 21:5x 过渡期补丁(legacy 行放行+限频告警)。
已部署并验收:127.0.0.1:7821 / 无key 401 / legacy 200 / 主密钥 200 / /metrics 无key 401 / /health 200 / LAN 不可达。
回滚点:~/.hermes/backups/zhiyid-sec-20260921/zhiyid-new.bin-2151
2026-09-21 21:56:47 +08:00
xiaoyi
e01181e40f
feat(auth): 绑定默认本机 + 密钥强制(无硬编码回落) + /metrics 纳管 + 过渡期 legacy 兼容
...
来源:卡 t_4fab32c1(AC1/AC2/AC3 代码)+ 小怡 09-21 21:5x 过渡期补丁。
过渡期补丁原因:hermes 记忆插件在 import 时读 ZHIYI_API_KEY(运行中的网关不重启不重读),
另有 8 个本地脚本持旧密钥 → 直接轮换会瞬间打断记忆读写。
故 key 文件支持多行:主密钥 + legacy: 行(放行并打 DEPRECATED 日志,限频 10min)。
收口条件:客户端迁移 + 网关重启后删除 legacy 行。
已部署(21:55,systemctl stop→replace→start):ss=127.0.0.1:7821、无key 401、legacy 200、
主密钥 200、/metrics 无key 401、/health 白名单 200、LAN IP 不可达。契约测试 TestParseKeysMultiLineFormat PASS。
2026-09-21 21:56:25 +08:00
小唯
ffaa3de14d
test(eval): CALIBRATED 结构化记录 + item4 已知漂移文档化 (t_a70b07e1)
...
- eval_test.go: TestEvalGolden_Live 逐条输出 CALIBRATED JSON 记录(i/query/top1/ids/kw_hit/id_hit/error),
供统一口径分类器(classify.py)复算 go/py 两量具分类差异。反证测试注释补 N=5 口径说明。
- golden-set.json: description 补 item4 已知漂移说明(基线 mem_1789837840173161705 漂移,
现稳定 top-5 成员 mem_1789834428978989104;两量具对该条可能差一级,待人工校准后 diff=0)。
2026-09-21 21:40:24 +08:00
小唯
5250eb1c2e
fix(eval+recall): 统一金标判据口径 N=5 + candidates_scanned 语义修订 (t_a70b07e1)
...
AC1: 两量具统一为「取 recall 返回前 N=5 条查关键词」——Go 量具(eval_test.go)原本就查 top-5,Python 量具(golden-check.py)原本只查 top-1,同批 14 条金标出现矛盾分类。N=5 写入 eval_test.go 注释 + golden-set.json 说明字段 + golden-check.py 头注释三方一致。
AC2: candidates_scanned 不再是 len(results) 的代理值——语义修订为「主路径(Pipeline.Recall/graph 兜底)产出候选数,在 E4.2/wiki 补充扩展之前捕获」,与最终 count 解耦。字段名保留(消费方兼容),全部消费方注释同步。keyword 路径恒 0。
- core.go: Recall 端点契约注释 + annScanned 捕获点注释(4 处)
- eval.go: checkKeywordRelevance/RunGolden 口径注释
- eval_test.go: liveRecallOnce/keywordHitAnywhere/TestEvalGolden_Live 口径注释 + CALIBRATED 结构化记录行(供分类器复算 go/py 差异=0)
- golden-set.json: description 说明字段补 N=5 口径
- golden-check.py: N_TOP=5 前 N 条口径 + CALIBRATED 记录行(仓外文件,另行提交)
2026-09-21 21:34:04 +08:00
小唯
e1985dfe32
test(eval): AC 验收 — 全量金标实跑 + 反证 + 空断言自守(t_d2380cd7)
...
eval_test.go(332 行,新增):
- TestEvalGolden_CounterEvidence(AC①反证):item[0] 故意改成
mem_0000000000000000000 → 该条必须 FAIL(判据非恒真)
- TestEvalGolden_Live:14 条全量实跑,一次 HTTP 同时拿 ids+contents,
每条 200ms 间隔;429 读 retry_after_s 退避;结尾打印真实数字
- 判据分层:ID 漂移但内容切题 → WARN;关键词未命中 → 硬 FAIL
- 校准基线:pass=11/14(fail=1 MMR;warn=2 ID 漂移)
2026-09-21 18:55:07 +08:00
小唯
5b4f7cd95a
fix(eval_test): uid→ids 构建错误(t_2d4e3b92 AC②④)
2026-09-21 18:48:38 +08:00
小唯
0b765ccc8b
fix(api): 统一错误体 schema — 失败返非 2xx + {"error":{code,message,retry_after_s"}} (t_2d4e3b92)
...
- recall 后端故障 502 recall_backend_error / keyword 编码失败 非 2xx(此前返 200 + 异形 body)
- 401 unauthorized / 429 rate_limit_exceeded 由扁平 error 字符串改为统一对象
- 成功体补 annScanned,区分「真无匹配」与「依赖故障」
- 新增 routes + middleware 两组形状契约测试(含反证:历史扁平/旧限流体必须被判错)
2026-09-21 18:34:21 +08:00
小唯
41e95aa36d
chore: 收工 eval.go gofmt + server.go 未提交杂项
2026-09-21 18:14:24 +08:00
小唯
5eccbaef03
chore(api): 收工未提交杂项 core.go/eval.go/testdata
2026-09-21 18:12:18 +08:00
小唯
c6be6a4cd5
fix(governance): DedupeActive 改为归档+审计,不物理删除 (t_0fdee22a)
2026-09-21 18:09:09 +08:00
小唯
d4d5db266a
feat(governance): 冲突队列保留策略+去重(t_4ce53193) - sha256去重键+7天保留期+归档审计+挂进t_consolidation触发器
2026-09-21 17:32:50 +08:00
小唯
1060e62066
fix(admin): /memories 与 /memories/export 改用全表扫描(Scan),弃零向量 ANN
...
病根:两个列表/导出端点一直用『零向量 ANN』冒充『列出全部』——零向量没有方向,
ANN 退化成本存储序前 N 行,再按 ns 客户端过滤 ⇒ 计数完全失真
(实测 export hermes-main 报 1 条,真实 139+;shared 报 0,真实 29)。
修复:
① Rust lancedb_ops: scan_for_forgetting 加 namespace 下推(only_if),limit 作用于过滤后结果集
② Go 接口 LanceDB 新增 Scan(limit, ns):
- RustLanceDBClient → lancedb_scan RPC
- SQLiteClient → SELECT ... WHERE is_deleted=0 [AND ns] ORDER BY created_at DESC LIMIT
- MemLanceClient → 内存 map 过滤 + created_at 倒序
③ 两个端点 ListMemories / ExportMemoriesMD 改用 aa.LanceDB.Scan(limit, ns)
④ 补 mock(zz_commit mockLance / write-buffer fakeLDB)+ 5 条新判据
(全表 3 / hermes-main 2 / shared 1 / limit 生效 / 不存在 ns 0)
2026-09-21 16:36:41 +08:00
小唯
1b937cc990
fix(recall/debug): 诊断端点 ns 解析与生产路径对齐(全库模式=单次空过滤检索 topK=200)
...
recall/debug 自带一套 nsList(["", "shared"])→ 与 RecallPipeline 的单次全库检索不一致,
诊断输出「2 namespaces」会误导排查。改为同一规则,保证 debug 如实反映生产召回。
2026-09-21 15:18:20 +08:00
小唯
266a85a5d2
fix(recall): 默认调用改全库跨命名空间召回(t_24eceed0 返修)
...
病根:纺忆写入侧按 agent/域把记忆分到 19 个命名空间(实测 300 采样:
hermes-main 139、wiki-curator-main 35、wiki 30、shared 29、soulful-xiaowei 27、
a06-main 11、domain:* 13…),而默认调用(无 namespace / 无 agent_id)
被推导成 default-main ⇒ 只搜 default-main+shared,全表 10172 条实测仅得 11 个候选,
99.9% 记忆在默认召回的盲区(t_24eceed0 worker 交付只改了推导来源,未解决跨 ns)。
修复:
① api/routes: 新增 resolveRecallNamespace() 纯函数 —— 显式 ns 原样、只有 agent_id 才推导、
两者都空返回 "" 表示全库;Recall 与 RecallDebug 共用同一函数(debug 如实反映 recall)
② storage/recall.go: namespace=="" → Search(..., 200, "") 全库单次检索(空过滤=不过滤),
候选池上限 50→100;显式 ns 路径完全不变([ns, shared])
③ 全库模式下关闭两段补丁式补搜(shared / wiki-curator-main),避免重复候选与白花 embedding
测试(8 条,含反证):
- routes: resolveRecallNamespace 5 用例(核心判据:空+空 必须返回 "")
- storage: 全库单次检索(记录 Search 实参)/ 显式 ns 保持 [ns shared] / shared 不重复搜
- 反证:还原旧行为 → 两组量具均 FAIL ✓("默认调用被解析成 hermes-main,又只能看到极小一片记忆")
踩坑记录:stub 用嵌入接口技巧时须一并覆写 Update(),否则后台 recall_count 回写 goroutine
落到 nil 接口 panic。
2026-09-21 15:15:07 +08:00
小唯
2d38d8d120
fix(api): recall 默认 namespace 用 classifyNamespace 推导(query 近似 content)+ shared 回退条件改为 (0, top_k)
...
来源: t_24eceed0 run790 worker 改动,小怡补部署 + 清理误建的根级 go.mod
- core.go: req.Namespace=='' 时由 deriveNamespace 改为 classifyNamespace('general', agentID, query)
→ 无 ns/无 agent_id 时按 content 关键词推导,技术类 query 归 shared,其余归 agent 私有 ns
- shared 回退: len(results)<3 改为 0<len(results)<topK 时补充搜 shared(避免有结果时重复补)
- 删除 worker 误建在仓库根的 go.mod(真实模块定义在 go/go.mod)
验收: go build OK + go test internal/api/routes 3.7s ok + /proc/exe 无 deleted + shared 不变量回归通过
2026-09-21 13:00:54 +08:00
小唯
3b8ecba48e
perf: 织忆内存/碎片双治本 — PageRank O(V+E) 重写 + 写入去抖 + 在线VACUUM
...
1. PageRank 三重循环 O(47k×374k×20≈3.5e11) → 入边表 O(V+E):
单次 full 整合 4h41m → 95.2s,内存峰值 3.8G → 237MB(实测)
2. 图谱修剪 merge 边 id 加 relation + INSERT OR REPLACE:
修复 09-18 起 UNIQUE constraint 静默失败 → 主库首次跑消 9.8万冗余边
3. LanceDB 写入去抖(server.go + validator.go):
被动验证只写 Confidence 实际变化的记录;原先每输入重写全库 6000 条
→ 版本快照 O(n²),每日 ~1.9万版本/十几G 膨胀的根因
4. 新增 scripts/lance_vacuum_online.py:在线 VACUUM(不停服务)+
24h 版本窗口(可回滚)+ 行数门禁(减少才报警);替代停服务版
每日 vacuum → cron 已改为在线版
实测:侧车 RSS 1.09G→69MB;memories 分片 5383→1;服务全程在线
2026-09-21 10:17:56 +08:00
小唯
daab83337b
feat(governance): 冲突持久化 + 禁止静默 dismiss(链路空转修复)
...
问题(2026-09-20 实测):
1) ConflictDetector.active 是纯内存 map,zhiyid 重启即清零
(17:17 重启后原先 pending 的 5 条冲突全部消失)
2) server.go 的 conflict_muchen 处理器把未匹配策略的冲突改写成 dismiss 再 Resolve,
且记成 RecordConflictResolved(true) —— 每条 pending 最多活 10 分钟即消失、
auto_resolve_rate 虚高、冲突从不进入任何人视野
(实测 17:19 建的冲突,同进程几分钟后 pending:0,未重启)
3) Conflict 不留两侧原文 ⇒ 事后无法核实真假矛盾(上一 commit 已加字段)
改动:
- governance:ConflictDetector 增 path + load/persistLocked(全量原子落盘 tmp+rename);
新增 NewPersistentConflictDetector(path);NewConflictDetector() 保持纯内存(测试安全)
- Scan/Resolve 变更后落盘
- server.go:检测器改用持久化构造(落盘失败降级内存 + 记日志)
- server.go:禁止无脑 dismiss —— 72h 内保留 pending 供人工处置,超期才 latest_wins
自动收敛(真裁决才记指标)
- 新增 conflict_persist_test.go:round-trip / resolve 落盘 / 纯内存不碰盘
未用 SQLite:冲突量级小,引 sqlite driver 需 cgo 新依赖(worker 曾在该方向崩溃
并留下锁重入死锁)。JSON 全量落盘零依赖、无锁重入。
2026-09-20 17:54:40 +08:00
小唯
cff87730b2
fix(api): check SoftDelete error returns at all 5 call sites
...
SoftDelete returns error but call sites discarded it, so a failed
soft-delete was silent — same class as the no-op implementations.
Now logged explicitly at:
- server.go: ephemeral_expired cleanup (x2)
- admin.go: auto_forget_fragment / auto_forget
- feedback.go: Deprecate endpoint
2026-09-20 11:51:57 +08:00
小唯
6e67f3e33f
fix(storage): fix all no-op/fake implementations in LanceDB interfaces
...
- IncrementUseful/IncrementNotUseful now return error and persist via
rc.Update() (Rust sidecar); all 4 implementations updated
- SoftDeleteBatch now delegates to SoftDelete() for real LanceDB write
- UpdateMemoryContent now persists content + version + version history
- Backup changed from return nil to explicit error (Rust sidecar unsupported)
- IncrementUseful/IncrementNotUseful signatures now include error return;
all 3 call sites (feedback.go, core.go) check the error
- Test mocks (mockLance, fakeLDB) updated to match new interface
Fixes the 'silent no-op' class of bugs discovered during dedup repair.
2026-09-20 09:53:00 +08:00
小唯
6c895618f9
test: fix mockGraph.AllEdges signature; add namespace classification probe
...
mockGraph declared AllEdges() []map[string]interface{} while
governance.GraphStore requires AllEdges(string) []governance.GraphEdge.
go build ./... stayed green because test files are not compiled by
build, so the routes test package could not be compiled at all and the
whole suite silently went unrun - which is why the earlier AllEdges
'compatibility fix' looked done without ever executing.
After fixing the signature the suite runs: all tests pass including
TestCommitConflictGate_E2E (end-to-end commit -> conflict -> distill
gate, 3.70s).
zz_ns_probe_test.go also gives positive evidence for the
classifyNamespace fix: human-side content now resolves to
soulful-xiaowei-main rather than a06-main.
'牧尘在招商局工作' -> soulful-xiaowei-main
'牧尘不在招商局工作' -> soulful-xiaowei-main
'画像规则: 牧尘在招商局工作' -> soulful-xiaowei-main
2026-09-20 08:40:41 +08:00
小唯
fd699151a8
fix(dedup): use SoftDelete path and flush buffer before responding
...
Two write-path fixes found while executing the dedup policy.
1. The endpoint wrote is_deleted via Update(). The system's canonical
path is SoftDelete(), which routes through SoftDeleteWriteBuffer
(5-minute window / 256-item threshold, single-transaction commit).
Update() writes one MVCC version per row, so this endpoint would
have created 411 versions in one run - the exact growth pattern the
vacuum script was written to clean up (table measured at 3.23G
before a 40M compaction).
2. The response was sent while soft deletes were still buffered. During
execution lance-vacuum (daily 03:30) stopped the service and ran
optimize(cleanup_older_than=0), discarding the unflushed writes: the
endpoint's deleted=34 never landed and is_deleted read back all
false, while the caller only saw curl exit=52 for the empty reply.
A new storage.FlushSoftDeleteBuffer() is now called before the
response, so reported counts equal what actually landed.
Demotions were unaffected in that incident because IncrementNotUseful
writes immediately (297 of 377 landed); they are now also correct
additive increments thanks to the earlier col+1 fix.
2026-09-20 03:34:59 +08:00
小唯
9188b9e5c9
fix(dedup): empty namespace means all namespaces; per-namespace breakdown
...
Passing namespace:'' silently scanned only hermes-main because of a
hardcoded default, and the response echoed back 'hermes-main' so the
missed scope was invisible - easy to mistake for a completed full sweep.
Empty now means all namespaces, and the response carries a by_namespace
breakdown (clusters/deleted/demoted) so a full run is auditable.
2026-09-20 03:10:22 +08:00
小唯
dd25457926
fix(demote): IncrementNotUseful was a no-op; implement A-policy dedup
...
Two fixes, both silent-failure class.
1. RustLanceDBClient.IncrementNotUseful was an empty function body.
Every demotion path was a false success: the HTTP endpoint returned
200, zhiyi-dedup.py reported '34 demoted, 0 failed', and
not_useful_count stayed 0 on all 32 dropped rows. Now delegates to
Update with $inc.
2. Update emulated $inc in Go using the _local.memories cache, which is
only populated on the Insert path (Search does not fill it). On a
cache miss getIncCachedValue returned 1, so an increment wrote the
absolute value 1 - resetting an existing count of e.g. 5 back to 1.
Now the column is sent to Rust as the expression 'col + 1'; Rust's
update() detects the arithmetic, reads the row's true current value
and computes the result, so the increment is genuinely additive.
Also implements 牧尘's chosen dedup policy (option A) in admin/dedup:
keep the NEWEST entry per cluster, then for every other member
- if it normalises to the same text (punctuation/whitespace/quote
differences only) it is a true duplicate -> soft delete
- otherwise it carries different information (different numbers,
subject, timestamps, versions) -> demote only, never delete
This satisfies 'newest wins' without discarding distinct facts.
2026-09-20 02:55:05 +08:00
小唯
cdf06312a4
feat(dedup): cluster-based keep-fullest policy in admin/dedup
...
Policy set by 牧尘 on 2026-09-20:
- existing duplicates -> keep the MOST COMPLETE entry
(longest content; ties broken by earliest)
- future writes -> newest wins (handled by the write-side gate
in commit/distill)
Two behavioural fixes over the previous pairwise loop:
1. Union-find clustering instead of pairwise marking. With chained
similarity (A~B, B~C, but A!~C below threshold) the pairwise loop
counted two pairs and left the cluster with multiple survivors, so
'keep the fullest' silently kept several entries. Measured: 220
clusters via closure vs 384 via pairwise - ~12% undercount.
2. Clustering is confined to a single namespace. Identical text in two
namespaces is two agents' own copies (e.g. domain:INSIGHT and
hermes-main), which is intended, not duplication. The early string
compare also keeps the full-table O(n^2) pass cheap.
Response now reports clusters/merged/deleted/policy, and an empty
namespace means 'all namespaces' rather than defaulting to hermes-main.
2026-09-20 02:50:22 +08:00
小唯
4af85fa093
fix(dedup): scan full table before namespace filter in Dedup endpoint
...
The endpoint passed the namespace straight into LanceDB.Search with
top_k=200. Rust ranks by distance to the zero vector globally and only
then applies the namespace filter, so a namespace's rows were mostly
never returned: soulful-xiaowei has 238 rows but only 9 came back,
hermes-main has 3387 but only 200 did. The endpoint therefore reported
merged=0 on every call - a false negative that made memory
deduplication look complete when a full cosine scan finds 404
redundant rows at the 0.98 threshold.
Now it pulls the whole table (top_k=1000000, no namespace filter) and
filters by namespace plus is_deleted in Go, so 'no duplicates' is a
claim the endpoint can actually support.
2026-09-20 00:43:50 +08:00
小唯
69602ddd08
fix(distill): semantic near-dedup gate on distill write path
...
Previously distill's direct-write path only skipped facts whose exact
content already existed (sim[0].Content == fact). This let semantically
equivalent facts - e.g. "牧尘在招商局工作" vs "牧尘在招商局工作。"
(trailing period) - slip through as separate memories, accounting for
most of the 404 redundant entries found by a full-vector cosine scan.
Now distill encodes each fact, searches 5 nearest neighbors in the same
namespace, and skips insertion if any neighbor has either identical
content OR cosine similarity >= 0.98. The same threshold is shared by
the commit path (routes/core.go), via a new api-level cosineSimilarity
helper.
This is preventative only: it does NOT merge existing duplicates.
Existing 404 redundant entries remain; they will be cleaned up by a
separate manual dedup run after the gate is live.
2026-09-20 00:37:25 +08:00
小唯
0d4add1fb2
test: add AllEdges mock for GraphStore interface compatibility
2026-09-20 00:25:00 +08:00
小唯
835b308df6
fix conflict scan: use real vector of new content instead of zero vector for retrieving existing memories
2026-09-20 00:10:03 +08:00