Skip to content

Memory citations: store file:line evidence and verify before injecting - #495

Merged
currentbits merged 1 commit into
mainfrom
coder/memory-citations-store-file-line-evidenc-0f0b34
Aug 18, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/memory-citations-store-file-line-evidenc-0f0b34

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #395.

Offline curation of learned facts is a trap; what works is citations plus just-in-time verification. Every learned memory entry can now carry its evidence, and the agent that is about to apply it checks that evidence against the current worktree first.

Why

Shared memory rots when a fact outlives the code it described. A separate curation service does not fix that. This is GitHub's production lesson: store the citation, verify at use, write back on contradiction. Self-healing memory without a janitor.

Sharpens #299 (citation data the governance UI can later surface), #300 (drift at inject time, not a batch job), and #301 (contradiction cleanup no longer needs sleep-time consolidation).

What changed

Entries store an optional citations list:

  • file — path, line, and a short excerpt of the supporting code
  • thread — the thread id
  • commit — sha

When project is a live working directory (the cwd agents already pass), memory_bootstrap, memory_search, and memory_get verify file citations against that tree before returning the entry:

Worktree state What happens
Excerpt still at the cited line Inject as usual, mark verified
Excerpt moved inside the file Heal the stored line, then inject
File gone or excerpt gone Invalidate the entry and omit it
Slug-only project, or no file excerpt Skip verify (cannot prove a contradiction)

Uncited entries still inject, so existing memory is unchanged. The bootstrap protocol tells agents to cite learned facts.

Also:

  • MCP memory_store / memory_supersede accept citations
  • REST and the Memory tab round-trip them; cards show src/auth.ts:12 chips
  • Auto-recorded run outcomes cite the thread they came from

Tests

  • memory-server/test/citations.test.js — normalize, path safety, excerpt match

  • memory-server/test/citation-verify.test.js — store, heal, invalidate-on-contradiction, slug skip

  • REST, proxy, MemoryTab, and run-record coverage

  • tsc --noEmit clean

  • PR created by the Grok agent

Closes #395.

Learned memory entries can now carry file/thread/commit citations. When
project is a live worktree, bootstrap/search/get verify file excerpts
against that tree, heal drifted lines, and invalidate contradictions
instead of injecting stale facts.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 255bada into main Aug 18, 2026
2 of 6 checks passed
@currentbits
currentbits deleted the coder/memory-citations-store-file-line-evidenc-0f0b34 branch October 3, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory citations: store file:line evidence, verify before injecting

1 participant