feat: implement Memory v2 - #15
Merged
Merged
Conversation
- remove dead allowedTopicIds param, unused exports, and write-only fields (job.cwd, result.generation, trace.filtered, attachmentId, topic path, section ids, indexed fact metadata) - extract shared utils: atomic-file, file-lock (unifies extractor and writer locks), estimateTextTokens, truncateUtf8, memoryContentHash - reuse the shared frontmatter parser via a new blockLists mode - centralize shared regexes and merge duplicate selector call sites into MemoryService.runSelector and generateStructuredObject - collapse repeated root-agent memory guards in agentLoop
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
This PR replaces the sparse legacy auto-memory path with Memory v2: a global, Markdown-first user memory system with durable post-turn extraction and hybrid retrieval.
agentLoopfinishes normally, using only that turn's bounded projection.memory/topics/*.md; derives the compactMEMORY.mdcore profile from those topics.Why
The previous extractor sampled a short transcript tail and appended a small number of facts to
auto.md. In practice, it was easy to miss durable product, technology-stack, collaboration, and cross-repository context. It also lacked a reliable queue and a precise retrieval layer.Memory v2 separates the two concerns:
Implementation
Reliable post-turn capture
Markdown-first global store
userXcodeDir()/memory, shared across repositories.topics/*.mdas the only memory source of truth.MEMORY.mddeterministically.Hybrid recall
memorySearchtool for explicit, scoped history lookup.CLI and operations
MemoryServiceand keeps sub-agents isolated from memory writing/search./memory,/memory status,/memory search,/memory explain, and/memory reloadflows./memory reloador CLI restart; invalid topics are isolated instead of served from stale in-memory content.Compatibility and legacy data
memory/auto.mdfiles are ignored: they are not read, validated, moved, rewritten, or deleted.AutoMemory,getAutoMemory, andinitMemoriesruntime APIs are removed and the public export snapshot is updated.memory.enabledif an operational rollback is needed.Correctness and safety coverage
Automated tests cover:
memorySearchbehavior;auto.mdremains untouched.Validation
pnpm run cigit diff --checkpassedManual verification checklist
MEMORY.md, search, and recall./memory reloadand restart behavior.