Skip to content

fix(memory): archive every duplicate of an ID, not just the first - #8344

Open
chuiwenwei wants to merge 1 commit into
esengine:main-v2from
chuiwenwei:fix/archive-by-id-all-dirs
Open

fix(memory): archive every duplicate of an ID, not just the first#8344
chuiwenwei wants to merge 1 commit into
esengine:main-v2from
chuiwenwei:fix/archive-by-id-all-dirs

Conversation

@chuiwenwei

Copy link
Copy Markdown
Contributor

Summary

现状Store.Archiveforget 路径)注释承诺"archives from every directory the memory appears in(处理迁移重复)",但按 ID 引用时(ref == active.ID 分支)直接 return archiveMemoryInDir(filepath.Dir(path), ...)——只归档 findActive 找到的第一个目录。迁移遗留的跨目录同 ID 重复项用 ID 执行 forget 后,另一个副本仍会加载进下一会话,与"不再加载"的语义相悖。

本 PR:ID 命中时遍历所有目录,每目录先经 memoryIDInDirloadMemory 校验 ID 匹配)过滤再归档——同 ID 的迁移重复项全部清除,而同名但不同 ID 的 fact(合法的 scope 变体)保持不动(由既有测试 TestStoreV2ArchiveByIDOnlyArchivesMatchingIdentity 锁定该语义)。

Issues

(无关联 issue;整体代码审查产出,forget 语义修复)

Verification

  • 新增 TestStoreDeleteByIDRemovesFromAllDirs:双目录同 ID 副本(确定性 legacy ID)→ Delete(ID) → 修复前失败(global 副本残留),修复后两处都清除、Index() 为空
  • 既有 6 个 Delete/Archive 测试全过(含 TestStoreV2ArchiveByIDOnlyArchivesMatchingIdentity 同名不同 ID 不动)
  • go test ./internal/memory/ ./internal/control/ ./internal/tool/builtin/ 全绿
  • go test ./internal/boot/ -run TestGoldenBaseline 无漂移
  • gofmt -l 无输出;go vet ./internal/memory/ 通过

Documentation impact

Documentation-impact: none - forget 按 ID 删除的边界行为修复,无命令/配置/文档变化。

Cache impact

Cache-impact: none - 归档路径(forget 写侧)改动,不改变任何 provider 可见字节:系统提示词、记忆前缀、工具 schema、召回注入全部原样。
Cache-guard: go test ./internal/boot -run TestGoldenBaseline(前缀基线无漂移)+ 既有 memory 测试(TestStoreDelete* / TestStoreV2Archive*)。
System-prompt-review: esengine - 记忆 forget(Archive)按 ID 删除的边界语义修复,系统提示词/记忆前缀字节不变;需维护者确认后合并。

@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Aug 11, 2026
@chuiwenwei
chuiwenwei force-pushed the fix/archive-by-id-all-dirs branch from 8871e20 to 85e23bd Compare August 11, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant