xiaoyi
2a8fc6494e
test(recall): 修 TestRecallWriteBufferTickerFlush 竞态 —— 它等的是中间态而非断言对象
...
现象:该用例偶发假红(实测 5 次里 1 次),报「窗口到点应 flush 1 次,实际 batchCalls=0」,
而同期日志里 flush 其实已发生([recall-buffer] flush: 合并 1 条记忆 → 落盘 1 行, 单事务=true)。
根因:Flush() 是「先清 b.pending、再调 BatchUpdate」;用例等 len(pending)==0 就断言,
会抢在 batchCalls++ 之前 ⇒ 读到 0。同文件 TestRecallWriteBufferThresholdFlush 用的才是正确
写法(直接等 batchCalls>0)—— 本次统一成后者。
验证:修正后连跑 20 次 20/20 绿;反证(把等待条件改回中间态)连跑 20 次红 4 次 ⇒ 竞态真实存在。
全仓 go test ./... -count=1:失败包 0 / 失败测试 0 / 通过包 9。
本提交仅改测试文件,不改变构建产物。
2026-10-09 13:20:36 +08:00
xiaoyi
fe8126dd85
fix(recall): 缓存键补 topK/diversity + 失效改前缀寻址,修 main 上 3 个长期红用例
...
一、3 个 recall 命名空间测试长期红灯(真因:测试对全局缓存不设防)
RecallWithMeta 命中缓存即提前返回,而 SearchCacheInstance 是带 Redis L2 的包级单例
(跨 test 运行持久)⇒ 一旦缓存里有同 (query,namespace) 条目,Search 永不被调用。
用例断言「Search 被调用几次」,于是恒红。修:用例内隔离该全局(存值→置 nil→Cleanup 还原),
并补一条反证用例 TestRecallCachedPathSkipsSearch 固证「命中缓存就不查库」这一机制。
(三次反证均确认有鉴别力:撤掉隔离后两次都假红。)
二、缓存键缺 topK/diversity(真实缺陷,非测试问题)
键原为 (query,namespace),但召回结果随 topK 变化(rerank/MMR 取 topK*2、最终按 topK 截断),
而调用方 topK 各异(eval 用 3 / 5,HTTP 用客户端 Limit)⇒ 不同调用方串用同一条缓存、
拿到条数不对的结果(金标集评分会被静默少算;客户端要 50 条可能只拿到 5 条)。
修:键布局改为 <namespace>\x00<queryHash>\x00<topK>\x00<diversity>,可前缀寻址;
RecallWithMeta 在查缓存前先归一 topK(否则 topK<=0 的调用永远命中不了自己写的条目)。
三、Invalidate(namespace) 是静默空操作(真实缺陷)
旧实现把 entry.Results 反序列化成 map 再读 ["namespace"],而 Set 存的是 []RecallResult
(JSON 数组)⇒ 反序列化恒失败 ⇒ 一个键都删不掉。后果:记忆写入后调用方以为缓存已刷新,
实际最长 1h TTL 内持续返回陈旧召回。修:改为按键前缀匹配 + L2 DelPrefix(RedisCache.DelPrefix
用 SCAN 游标 + 批量 DEL,不用会阻塞 Redis 的 KEYS)。
验证:main 上 `go test ./... -count=1` 失败包 2→0、失败测试 5→0、通过包 7→9;
新增 8 条回归用例;反证 A(键退回不含 topK)、B(失效退回 payload 解析)、C(撤掉缓存隔离)
均确认会让对应用例变红。
2026-10-09 12:59:37 +08:00
xiaoyi
e98565f0c9
fix(recall): 来源加权 λ 移到 MMR 之前 —— 原实现只改展示分不改选择
...
λ 原加在 Step 4 之后的展示分上,候选取舍已由 rerank+MMR 定死,
故 λ 无论多大都不改变结果集合(实测 λ=0.1 vs 0:14 条 query 全部
cache-miss 下 top-10 集合与 legacy 占比 33.57% 完全一致,而逐条分数
位移与理论吻合 legacy -0.0277 / conf1.0 +0.0294)。
现移到 MMR 之前,使选择与展示共用同一套分数;λ=0 时循环不执行,
与旧行为逐字节等价。
2026-10-09 08:46:43 +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
小唯
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
小唯
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
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
小唯
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
小唯
8026142a08
feat(memory-source): commit→distill→memories.source→recall 打通来源(集合笔记路径)
2026-09-26 21:35:29 +08:00
xiaoyi
7c0affde65
recall: RecallResult 带 namespace/agent_id 来源(全库召回可分辨归属域)
...
背景:09-22 把 daemon 召回作用域放开到全库(金标 ID 命中 8/14 → 12/14),
但 recall 返回体只有 id/content/category/score/timestamp,调用方无法分辨
某条记忆属于哪个域,会把分身的私有记忆当成自己的用。
改动:
- models.RecallResult 加 Namespace / AgentID(json omitempty,旧调用方无感)
- recall.go 主路径构造点带上 c.Namespace / c.AgentID(MemoryRecord 本就有这两个字段)
图谱扩展路径(graph_*.go)无 ns 概念,留空由调用方处理。
验证:go build ./... OK / go vet OK / internal/storage 测试 OK。
注:internal/api/routes 的 TestCommitConflictGate_E2E 为既有失败(改动前同样 FAIL,已用 git stash 证伪)。
2026-09-22 09:32:44 +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
小唯
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
小唯
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
小唯
b5f59703ab
fix(storage): check error returns from MemLanceClient in SQLiteMemClient
...
SQLiteMemClient.IncrementUseful/IncrementNotUseful were discarding the
error return of MemLanceClient.IncrementUseful/IncrementNotUseful.
Since the latter now return real errors (6e67f3e ), dropping them
re-introduces the silent-failure class of bug we just fixed across
the Rust path. Also propagate persistMemory errors.
2026-09-20 11:39:30 +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
小唯
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
小唯
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
小唯
ec17c836a1
fix(dedup): parse vector field in Rust IPC Search results
...
RustLanceDBClient.Search decoded the Rust IPC response into a struct
that had no vector field, so every MemoryRecord returned to Go had an
empty Vector. Consequence chain:
len(results[i].Vector) > 0 && len(results[j].Vector) > 0
always false → the cosine branch was skipped in:
- commit path near_dup (core.go:634)
- distill direct-write dedup gate (server.go:179) <-- the fix I just
deployed this round was silently a no-op
- admin/dedup endpoint (core.go:634) <-- merged≈0 false
negative
Without this, no near-duplicate detection in the whole system works —
it silently fell back to exact string comparison only.
Retained: the vector is forwarded from the raw IPC JSON; if Rust stops
returning it, the degenerate behaviour is exact-string comparison
(which still works), rather than a crash.
2026-09-20 01:07:27 +08:00
小唯
962489f20c
fix: Search must forward namespaceFilter to Rust IPC (was hardcoded empty)
2026-09-19 22:16:14 +08:00
小唯
dbe6c278c5
deep-think integration: conflict-detector fix, GraphRAG recall fusion, Louvain community discovery, deep-think endpoint
2026-09-19 19:12:49 +08:00
小唯
ee50ef0d59
fix(rust): 恢复缺失的 LanceDBStats/stats() 和 helper 函数 (t_3fb41049); storage: 添加软删除累积延迟缓冲 (t_384f785b)
2026-09-14 22:14:52 +08:00
小唯
68ce2c9678
feat(distill): 限制 prompt ≤8k token 保护本地 2B 单槽; storage: 添加 SoftDeleteBatch 及 Rust 端批量软删除优化 (t_3fb41049)
2026-09-14 22:09:44 +08:00
小唯
41230ccb0a
docs+test(recall): 修正批量更新注释(delta 分组,非 CASE WHEN)+ 补 IPC 只读校验用例 (t_8496e8b6)
...
- recall_write_buffer.go / lancedb_ipc.go: 注释与实现对齐 —— lance 不支持 CASE WHEN,
Rust 侧按 delta 分组、每组一次 update 提交;整批版本数 = 不同 delta 的个数(通常 1 个)
- batch_ipc_integration_test.go: +TestBatchIPCScanReadOnly(只读扫 socket 校验 recall_count 真落盘)
实测(临时 sidecar,/tmp/mw-verify-180517):
VERSION_ACCOUNTING: 批量3条 → 1 个版本 | 逐条3次 → 3 个版本
BATCH_IPC_OK id=ep_1786982837511335732 recall_count 0 → 3
SCAN_READONLY: 总 1814 条, recall_count>0 的 742 条, 最大 828
2026-09-12 18:07:30 +08:00
小怡
f2362150d1
perf(recall): 累积延迟更新治理写放大 — 读路径零逐条写 + 单事务批量落盘 (t_8496e8b6)
...
根因: recall 读路径对每条结果同步 lancedb.Update,LanceDB MVCC 每次提交=1 版本
实测 15 版本/分钟 / _versions 17.7G(真实数据 22M)
改动:
- Go: 新增 RecallWriteBuffer(窗口合并+阈值触发+优雅退出落盘);recall.go 读路径改 Record();RustLanceDBClient.UpdateRecallBatch
- Rust: lancedb_update_batch IPC — 按 delta 分组,每组一次 update(`recall_count + delta` + id IN (...)) 提交
- 单测 6 个 + IPC 端到端版本计数测试;bench_test.go 修 NewReranker 签名失配(阻塞包测试)
实测: 批量 3 条 → 1 个版本;逐条 3 次 → 3 个版本 (lance 不支持 CASE WHEN,已按 delta 分组规避)
2026-09-12 17:57:31 +08:00
小唯
310a98da4e
fix(graph-cleanup): CleanupNoiseNodes NULL-id panic + 新增 scoped 卫安/A03/A04 测试污染清理端点 (t_1dfaaa4a)
...
- graph_sqlite.go CleanupNoiseNodes: row[id] 为 NULL(daemon-distill pattern 模板行)时直接
.(string) panic → HTTP 连接被关(HTTP=000);改为 nil 安全跳过
- 新增 CleanupScopedNodes(dryRun, namespaces, nameContains):namespace+名称子串精确圈定,
清理 2026-06 多 agent 测试污染(openclaw-main/a06-main/hermes-main 的 A03/A04/卫安 节点)
- graph_cache.go: cachedGraphStore 透传(inner 可选接口断言,非 SQLite 后端静默 0)
- server.go: GET/POST /api/v1/graph/cleanup/scoped?dry_run=&namespace=&name=
实际执行后 InvalidateAll 保证 graph_cache 一致性 —— 禁外部 SQL 的官方通道
2026-09-08 09:02:35 +08:00
xiaowei
4a245b6262
fix(forgetting): P2 候选源升级 — Rust scan 全表替代纯缓存遍历
...
GetCandidatesForForgetting 原实现只遍历进程内 _local.memories 缓存
(commit/recall/search 才触碰), 重启后缓存空 → decay scanned=3 扫不全,
9-25 到期记忆若不在缓存则永远无法被遗忘(闭环断)。
安全版 scan_for_forgetting (防 febc2c9 风暴复发):
- 强制 limit (IPC 钳制硬上限 5000, decay 侧 2000)
- 不读 vector 列 (1024维×3000条≈12MB+, IPC JSON 会卡)
- 真读 last_recalled_at 列 (scan_all 旧实现 String::new() 恒空 → 遗忘判定失真)
- 消费方截断护栏已就位 (merge 桶500 / conflict 500 / sanity 1000)
- IPC 失败/空 → fallback 缓存遍历 (保持可用)
验证: [decay] scanned=3 → 2000 (重启即扫全表), CPU 0%, 无 panic
2026-09-06 02:32:58 +08:00
xiaowei
d4343b1c47
fix(recall): Embedder http client 8s 超时 + decay 分批 AC-1 日志
...
- Embedder http.Client{} 无超时 → 远端 bge 半开 TCP 时 recall 永久挂起
(gateway 10s 断 → 织忆异常误报)。加 8s 超时快速失败降级。
- decay 每 tick 限量 2000 条(最久未访问优先) + scanned/forgotten 日志
(AC-1 验收证据)
2026-09-06 01:08:42 +08:00
xiaowei
e6b1e0417c
fix(forgetting): P1 防风暴 - 限长/分桶/抽样下推/decay分批
...
febc2c9 全表扫描 O(n²) 风暴的根治防护(生产基线 ba44e20+ 之上,不含 febc2c9 扫描代码):
1. mergeSimilar 按 category 分桶 + 单桶 maxMergePerBucket=500 截断
- 原双层循环全量 O(n²),全表时触发 620% CPU
- 分桶后 O(Σ桶²) << O(n²),语义不变(原 catI!=catJ continue 等价分桶)
2. scanConflicts 显式 created_at 倒序取最近 500 条
- 原注释'最近100条'实际全量 O(n·50)
3. checkTimestampSanity 先截断 maxSanitySample=1000 再均匀抽样
- 原全量拉取仅为 5% 抽样
4. decay 每 tick 限量 maxDecayBatch=2000,按最久未访问优先
5. 存储层输出契约统一 RFC3339 string + 补 category/created_at
- lancedb_ipc: last_recalled_at 此前直接放 time.Time → server.go .(string)
断言恒失败 → lastAccessed 永远默认30天前 → 遗忘判定失真(本 bug + 数据
年龄未到 = 遗忘从不触发的双根因之一)
- sqlite: 补 category/created_at + LIMIT 100→200(对齐 lancedb 契约)
- 新增 memoryTimeVal/fmtTimeRFC3339 helper 兼容多类型
测试: go build ./... 全绿;gofmt 仅历史文件遗留(未全文件重排,保持最小 diff)
2026-09-06 00:56:06 +08:00
小唯
736d407e68
fix(softdelete): 单独应用 SoftDelete 持久化修复(ba44e20+SoftDelete only, 不含 lancedb_scan 风暴代码)
...
从 febc2c9 提取仅 SoftDelete 部分: updateField 提升包级 + SoftDelete 调
lancedb_update 持久化 is_deleted=true。跳过 GetCandidatesForForgetting 全表
扫描改动(有 620% CPU 风暴 bug, 待修复后另部署)。
验证: DELETE scratch2-1788616361067 → [ipc]SoftDelete persisted → 查询0条
→ 重启后仍0条(持久化成功)。
2026-09-06 00:23:23 +08:00
xiaowei
2a350cf781
fix(distill): max_tokens 800→1200 — Agnes推理token预算不足
...
Agnes 2.0-flash是推理模型,推理token占大量预算。
800仍不够→JSON截断(parse error: unexpected end of JSON input)。
1200确保推理+正文都够用。
2026-08-20 01:13:06 +08:00