Skip to content

feat(context): add provenance metadata to injected memories - #421

Closed
Phototonic wants to merge 1 commit into
tickernelz:mainfrom
Phototonic:issue-VOX-271-provenance-memory
Closed

Phototonic wants to merge 1 commit into
tickernelz:mainfrom
Phototonic:issue-VOX-271-provenance-memory

Conversation

@Phototonic

@Phototonic Phototonic commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Provenance in the injected memory block, so agents can cite what they "remember":

  • Each <memory> tag in the injected <memory_context> block now carries id, created (UTC YYYY-MM-DD), and project attributes 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 Memory headings 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 mocked context.js export surface intact — several scenario tests mock.module that file with a minimal surface, so src/index.ts must not import new exports from it.

Session-title lookup was intentionally descoped per the issue (project name stands in).

Test plan

  • Exercised the change locally — a live session quoted its injected block verbatim: <memory relevance="100%" id="mem_…" created="2026-10-20" project="opencode-mem"> plus the new header sentence (the issue's acceptance criterion)
  • Noted any follow-up or known limitations — exact-format unit tests for both blocks in tests/memory-provenance.test.ts; three low-severity follow-ups from the pre-push review round are recorded in a comment below

Checklist

  • Branch is based on main (rebased onto 6289ac4; single commit)
  • bun test passes (787 pass / 3 fail — all three pre-existing on Linux main: plugin-bundle-boundary, user-profile-learning-confidence, config storagePath shape)
  • bun run typecheck passes
  • bun run check passes (format + lint + typecheck)
  • Docs / README updated — N/A: the injected block format is not documented in README, so no doc surface changes

@Phototonic

Phototonic commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Pre-push review round (independent read-only reviewer over the full diff): APPROVE WITH COMMENTS — no blockers. Findings and disposition:

  1. Low — formatMemoryCreatedDate accepts timezone-free strings (2026-10-20T00:30:00 parses relative to local TZ; 2026-02-30 normalizes to Mar 2). Not reachable from current callers — they supply epoch-ms or Z-suffixed ISO (safeToISOString / raw created_at). Follow-up candidate: treat unzoned input as UTC + focused tests.
  2. Low — the compaction suffix renders id/projectName verbatim, so a project name containing embedded newlines could disturb the Markdown heading. IDs are plugin-generated (no newlines) and memory bodies already enter these prompts verbatim, so this is formatting hardening only. Follow-up candidate: collapse control whitespace in display metadata.
  3. Low — header wording states every memory carries an id/date while legacy rows intentionally omit them. Kept as originally proposed; happy to soften to "when available…" if maintainers prefer.

Reviewer validation: 46 targeted tests across six files + typecheck passed. Full suite rerun before push: 787 pass / 3 pre-existing Linux main failures (plugin-bundle-boundary, user-profile-learning-confidence, config storagePath shape).

@Phototonic Phototonic closed this Oct 20, 2026
@Phototonic
Phototonic deleted the issue-VOX-271-provenance-memory branch October 20, 2026 04:15
@Phototonic

Copy link
Copy Markdown
Contributor Author

Reopened as #422 (identical change, renamed branch). Closing this one since the original branch name referenced a private tracker.

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.

1 participant