mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 09:28:14 +00:00
fix(memory): core.New 漏接 rc.SetMediaStore,L0→L2 引用转移在生产从未生效
RelevanceContext.transferMediaRefs 依赖 c.mediaStore,而该字段只有 SetMediaStore() 能设置。搜遍全仓非测试代码,调用点为零——core.New() 里 没有,cmd/homed/main.go 里也没有。 上一层(f855893)把 AgentConfig.MediaStore 接到了 Agent.mediaStore, 漏了 rc 这一路。 后果是静默的:Prune 归档时 c.mediaStore 为 nil,transferMediaRefs 直接 return,而携带引用的 ContextEvent 已被归档删除 → 引用永久悬空在 context owner 上、计数永不归零 → 对应 blob 永远不会被 GC 回收。 ## 为什么测试没抓到 mediaref_test.go 里我手工调了 rc.SetMediaStore(ms) 才测转移逻辑。 **测试验证了函数正确,没验证它被接上了。** 与 findPluginPID 那次同一 个教训:测了一件不会自然发生的事。 ## 顺带全字段审计 写脚本比对 AgentConfig 的 32 个字段与 New() 函数体的引用情况, 确认无第二处漏接。
This commit is contained in:
@ -232,6 +232,12 @@ func New(cfg AgentConfig) *Agent {
|
||||
if cfg.IO != nil {
|
||||
rc.SetChannelDefLookup(cfg.IO.GetInputChannelDef)
|
||||
}
|
||||
// 必须把媒体存储也注给 RelevanceContext:L0→L2 归档(Prune)靠
|
||||
// rc.transferMediaRefs 把引用从 context owner 转给 document owner。
|
||||
// 漏了这一行的后果是静默的:rc.mediaStore 为 nil 时转移直接 return,
|
||||
// 而携带引用的 ContextEvent 已被归档删除 → 引用永久悬空在
|
||||
// context owner 上、计数永不归零 → 对应 blob 永远不会被 GC 回收。
|
||||
rc.SetMediaStore(cfg.MediaStore)
|
||||
|
||||
return &Agent{
|
||||
id: cfg.ID,
|
||||
|
||||
Reference in New Issue
Block a user