fix(memory): archive every duplicate of an ID, not just the first - #8344
Open
chuiwenwei wants to merge 1 commit into
Open
fix(memory): archive every duplicate of an ID, not just the first#8344chuiwenwei wants to merge 1 commit into
chuiwenwei wants to merge 1 commit into
Conversation
chuiwenwei
force-pushed
the
fix/archive-by-id-all-dirs
branch
from
August 11, 2026 12:49
8871e20 to
85e23bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
现状:
Store.Archive(forget路径)注释承诺"archives from every directory the memory appears in(处理迁移重复)",但按 ID 引用时(ref == active.ID分支)直接return archiveMemoryInDir(filepath.Dir(path), ...)——只归档findActive找到的第一个目录。迁移遗留的跨目录同 ID 重复项用 ID 执行forget后,另一个副本仍会加载进下一会话,与"不再加载"的语义相悖。本 PR:ID 命中时遍历所有目录,每目录先经
memoryIDInDir(loadMemory校验 ID 匹配)过滤再归档——同 ID 的迁移重复项全部清除,而同名但不同 ID 的 fact(合法的 scope 变体)保持不动(由既有测试TestStoreV2ArchiveByIDOnlyArchivesMatchingIdentity锁定该语义)。Issues
(无关联 issue;整体代码审查产出,forget 语义修复)
Verification
TestStoreDeleteByIDRemovesFromAllDirs:双目录同 ID 副本(确定性 legacy ID)→Delete(ID)→ 修复前失败(global 副本残留),修复后两处都清除、Index()为空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 删除的边界语义修复,系统提示词/记忆前缀字节不变;需维护者确认后合并。