[Feature] Architecture: Scoped, freshness-aware memories for Git-aware RAG
Description
Attach Git state metadata (commit hash, branch name, file revision) to facts saved in the semantic memory/RAG system, allowing the agent to mechanically detect when a retrieved memory might be stale.
Use Case
Standard RAG systems fail in active codebases because they retrieve outdated facts. If the agent saves a memory about "how auth.ts handles tokens" on Monday, but the developer refactors auth.ts on Wednesday, retrieving that memory on Friday will cause the agent to hallucinate based on stale context.
Proposed Solution
- When a memory is stored, tag it with the current Git hash and the hashes of any files referenced in the memory.
- When the memory is retrieved via semantic search, the harness checks the current Git state.
- If the state has diverged, the harness injects the memory but wraps it in a warning:
[WARNING: This memory was recorded at commit 8c21. The file auth.ts has changed since then. Verify before trusting.]
Alternatives Considered
- Brute-force re-indexing the entire project on every commit (too slow/expensive).
- Standard keyword RAG (unreliable in fast-moving projects).
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
hey @akramcodez , i'd like to take this one, could you please assign it to me ?
plan -
when a memory is saved, i'll record the current commit, branch and a git hash-object hash of any tracked files it mentions. at recall, one batched hash-object call checks those files, and changed or deleted ones get wrapped in a [WARNING: recorded at 8c21a3f, auth.ts has changed since. Verify before trusting.] prefix, kept short to fit the Project Context token budget. old memories and non-git dirs work as before.
sure @karthikponna 👍