Repository navigation
feat(context): add provenance metadata to injected memories - #422
Closed
Phototonic wants to merge 1 commit into
Closed
Phototonic wants to merge 1 commit into
Phototonic wants to merge 1 commit into
Conversation
7 tasks done
Contributor
Author
|
Pre-push review round (independent read-only reviewer over the full diff): APPROVE WITH COMMENTS — no blockers. Findings and disposition:
Reviewer validation: 46 targeted tests across six files + typecheck passed. Full suite rerun before push: 787 pass / 3 pre-existing Linux Supersedes #421 (same change, renamed branch). |
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
When the memory plugin injects remembered knowledge into a session, those memories used to be anonymous: the agent had no way to say which memory it was relying on, how old it was, or where it came from. This change gives every injected memory a visible identity — its id, creation date, and project — and tells the agent it may cite that id when leaning on a memory, so "I remember that we chose libSQL" can become "I remember that we chose libSQL (mem_1792183254076_wxsig8s9y, recorded 2026-10-16)". The same provenance is attached to the memories restored into a session after compaction, and the ids match what the Memory Explorer web UI shows, so a cited memory can be found and inspected later.
Details:
Provenance in the injected memory block, so agents can cite what they "remember":
Each
<memory>tag in the injected<memory_context>block now carriesid,created(UTCYYYY-MM-DD), andprojectattributes when present. Rows without provenance keep the exact previous tag shape.The block header tells agents they may cite a memory by its id when relying on it.
Compaction's
## Restored Session Memoryheadings gain the same provenance:### Memory N (mem_… · created YYYY-MM-DD · project), suffix omitted entirely when absent.Shared helpers live in a new pure module (
src/services/memory-provenance.ts). This keeps the mockedcontext.jsexport surface intact — several scenario testsmock.modulethat file with a minimal surface, sosrc/index.tsmust not import new exports from it.Session-title lookup was intentionally descoped per the issue (project name stands in).
Test plan
<memory relevance="100%" id="mem_…" created="2026-10-20" project="opencode-mem">plus the new header sentence (the issue's acceptance criterion)tests/memory-provenance.test.ts; three low-severity follow-ups from the pre-push review round are recorded in a comment belowChecklist
main(rebased onto 6289ac4; single commit)bun testpasses (787 pass / 3 fail — all three pre-existing on Linuxmain: plugin-bundle-boundary, user-profile-learning-confidence, config storagePath shape)bun run typecheckpassesbun run checkpasses (format + lint + typecheck)