Expand description
Git-based reconciliation for session close.
Backstop layer of the trust-fabric file-capture stack:
- (highest trust) specialized event types (
agent.wrote_file) - (medium) promoted from generic
agent.called_tool - (this module) shell out to
gitat session close and pick up anything an agent edited outside any captured tool channel
Why this matters: the trust-fabric bar is “if a file changed, it
must appear in the receipt.” Hooks and MCP cover most paths but
not all – an agent that ran sed -i inside a Bash command, a
build tool that modified files, or any other untracked side
effect would otherwise vanish silently. Running git diff and
git ls-files --others at close catches the rest.
Fail-open by design: if the working dir isn’t a git repo, if the git binary is missing, or if any git command errors, returns an empty list. The receipt is still produced; reconciliation is a best-effort enhancement, never a gate.
Structs§
- GitChange
- One file change observed via git that wasn’t already captured by a
tool channel. Mapped 1:1 into a synthetic
AgentWroteFileevent at session close so it flows through the normal aggregator and receipt composition path.
Functions§
- current_
head_ sha - Capture the current HEAD commit SHA so it can be stored in the session manifest at session start. The session close pass uses it as the diff base for committed-during-session changes. Returns None when not in a git repo or no commits exist yet.
- reconcile_
changes - Collect every file change in
repo_dirworth surfacing in a session receipt: working-tree modifications (staged or not), committed-since-since_shachanges (when provided), and untracked files.