Code provenance over the durable agent event log: "git blame for the agent's mind".
Every agent file edit is already persisted as a :file_edit_proposed event
carrying the file path, the full before/after content, and the originating
tool_call_id/session. The agent's reasoning for that edit (the user request
that prompted it, plus the thinking and assistant text of that turn) is
persisted in the same per-session, append-only log.
So provenance is a read-only projection, not new captured state. We never reconstruct or summarise "why" after the fact: we point at the reasoning that was recorded live when the edit happened.
for_line/3answers "why is this line like this?" by content-matching the line against theafter_contentof past edits (most recent wins).for_file/2answers "what did the agent do to this file?" as a chronological list of edit-turns.
Both return Entry structs. Lines/files the agent never wrote return nil / [].
Known limitations (v1)
Provenance is keyed on the file path recorded at edit time, matched exactly.
If a file is renamed or moved after the agent edited it, lookups miss and the
file reads as "no history" even though the edits exist under the old path.
Bridging renames would require consulting git (blame/log --follow); that
is deliberately out of scope for v1. Coverage is also bounded by the event
log's retention window.
Summary
Functions
Returns the file's agent edit-turns, most recent first, one per {session, tool_call}.
Returns the most recent agent edit-turn whose after_content contains needle, or nil.
Types
@type opt() :: {:db, MingaAgent.EventLog.Store.db()} | {:db_dir, String.t()} | {:limit, pos_integer()}
Read options. :db injects an open connection (caller owns it); otherwise one is opened.
Functions
@spec for_file(String.t(), [opt()]) :: {:ok, [MingaAgent.Autobiography.Entry.t()]} | {:error, term()}
Returns the file's agent edit-turns, most recent first, one per {session, tool_call}.
@spec for_line(String.t(), String.t(), [opt()]) :: {:ok, MingaAgent.Autobiography.Entry.t() | nil} | {:error, term()}
Returns the most recent agent edit-turn whose after_content contains needle, or nil.
Prefers the edit that introduced the text (present after, absent before); falls back to the most recent edit that merely contains it.