feat(store): record memory provenance the model cannot write
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start by tracing how observations and prompts are stored and queried, including the UserPromptSubmit hook and mem_save_prompt paths; the issue does not name files or tests. The requested change spans runtime and model metadata, prompt provenance, observation-to-prompt links, and search and export filters. Done means stored data can distinguish hook-captured user prompts from tool-saved prompts and identify observation runtime, model when available, and matching prompt.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Existing Issue Search
- I searched existing issues and will add evidence to a canonical tracker when applicable.
(Searched for "provenance", "mem_save_prompt", "prompt source" and "observation provenance agent". The closest are #1817 and #1833, which are about consolidation provenance, and #2211, which is about the project a prompt is filed under. None of them covers who authored a memory.)
🔍 Observed Consequence
When an agent saves a memory, the only record of who the information came from (the user, the agent's own inference, a web page, a tool) is whatever the model writes in the content. If a prompt injection is planted in a web page or in a tool's output, it can make the agent write "the user said X". The memory is then stored and recalled in later sessions as if the user had said it.
Engram already records some provenance outside the model: the session, the timestamp, tool_name = subagent-stop for subagent captures, and marked_by_* on relation judgments. Two gaps remain:
- An observation has no field set by the runtime, rather than by the model, that says which runtime saved it, with which model, and whether the turn that produced it had a user prompt captured by the hook.
- Prompts captured by the
UserPromptSubmithook and prompts saved throughmem_save_promptare stored the same way. So when an external check compares a memory that claims "the user said X" against the session's stored prompts, it cannot tell a prompt the user really typed from one the agent wrote.
Measured on my store (engram 3.7.2, 2026-11-27):
- All 2,418 rows in
user_promptshave an emptysource_inbox_id. capture_project_provenancehas no rows for prompts (0 of the 794 prompts from the last 14 days).- No column distinguishes the hook path from the tool path.
- In the last 14 days, 382 of 383 observations saved from an agent session and 211 of 211 subagent captures have user prompts in the same session, so a cross-check is possible for most memories. The 147 observations saved with
engram save --projectfrom the CLI have none.
💡 Desired Outcome
Using only the stored data, without trusting the model's text, I can tell for each observation:
- which runtime saved it (Claude Code, Codex, OpenCode, …);
- which model saved it, when the runtime exposes that;
- whether it was written in a turn that had a user prompt captured by the hook, and which prompt that was.
For each stored prompt, I can also tell whether it came from the hook (the user typed it) or from a tool call (the agent wrote it).
Search and export can filter on these fields.
📦 Affected Area
Store (database, queries)
Release Context
engram 3.7.2 (Homebrew) on Linux, Claude Code with the engram plugin 0.1.6. OpenCode writes to the same store.
🔄 Workarounds and Constraints
My current plan has two parts. Each new memory gets a line in its content naming the agent and the source class (said by the user, inferred by the agent, taken from the web or from a tool). An external check then compares each "said by the user" against the session's stored prompts and flags the ones it cannot match.
Neither part is independent of the model: the content line is written by the model, and so is any prompt saved through mem_save_prompt. Memories saved from the CLI into another project also have no session prompts to compare against.
📎 Additional Context
- Microsoft Security Blog, "Guarding AI memory" (2026-06-22): "Establish intent and provenance before persistence" and "Enforce boundaries outside the model".
- TMA-NM, arXiv 2606.24322 (preprint, single author): the agent's own summarization is the first channel that launders provenance. In the author's tests, provenance fixed at write time, combined with independent corroboration, blocked the attacks.
- Lenguaje dominante
- Go
- Estrellas
- 7.1k
- Forks
- 729
- Merge medio
- 2 h 19 min
- PR fusionados (30 d)
- 167
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Gentleman-Programming/engram
-
status:needs-review type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Gentleman-Programming/engram#2512 ·
Los mantenedores suelen responder en 1 día
-
status:needs-review
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Gentleman-Programming/engram#2502 ·
Los mantenedores suelen responder en 1 día
-
status:needs-review type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Gentleman-Programming/engram#2501 ·
Los mantenedores suelen responder en 1 día
-
status:needs-review type:feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Gentleman-Programming/engram#2416 ·
Los mantenedores suelen responder en 1 día
-
status:needs-review type:bug
Dificultad 4/5 3-5 días Aptitud para principiantes 57/100
Gentleman-Programming/engram#2513 ·
Los mantenedores suelen responder en 1 día
Todos los issues de Gentleman-Programming/engram
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AvengeMedia/DankMaterialShell#4490 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
stefanpejcic/OpenPanel#1415 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100