Areas we serve
Chapter 8

The Audit Trail

log, blame, show, and revert. The repository is the operation log.

Learning objectives

  • Answer who changed a line, when, and in which commit
  • Undo a bad agent merge without pretending it never happened
  • Explain why the repository is the source of agentic operations

If it is not in the log, it did not happen

Agentic operations are a series of actions: read the repo, edit files, run commands, commit, open a pull request, merge, deploy. Chat products remember some of that inside one session. They do not remember it in a way a second person, a host, or an auditor can replay. Git does. The commit chain is the operation log.

That is the strict reason this book exists. You can swap models. You can close Cursor and open a different agent next month. The new agent should start from origin/main, not from a folklore summary of “what we built.” The source of the work is the repository because every accepted action is a commit, and every commit is attributable.

Three commands that answer the morning questions

# What landed recently, and who signed it
git log --oneline -20

# Which commit last touched these lines
git blame app/reserve.php

# What that commit actually did
git show a1b2c3d

git blame is poorly named and extremely useful. It annotates each line with the commit that introduced it. When seats are wrong, you do not reread twelve chats. You blame the seat check, open that commit, and read the message and the diff. If the author is “Workshop Co. Agent,” you know a model wrote it, and the pull request link on GitHub is the review that let it through.

QuestionWhere the answer lives
What is production supposed to be?The commit origin/main points at, and the deploy that used it
What did the agent change last night?git show on that commit, or the pull request diff
Who approved it?The pull request review on GitHub, not the model’s “looks good”
How do we undo it?git revert, a new commit that puts the lines back, then review and deploy

Revert, do not rewrite

A bad waitlist is already on main and already deployed. The audit-friendly undo is revert: a new commit that applies the opposite of the bad one. History still shows the mistake and the repair. Customers of the log, including the next agent, can see both.

git switch main
git pull
git revert a1b2c3d
git push origin main

git reset --hard and git push --force erase commits from the branch tip. They feel like a cleaner story. They are how you lose the ability to explain Tuesday. Ban them for agent instructions. A revert message can say “Revert waitlist; seat counts dropped to zero in production.”

The agent reads this log too

The next session should be told: “Start from main. Do not repeat commit a1b2c3d; it zeroed seat counts and was reverted in b2c3d4e.” A repository with honest messages is a memory the model can be given on purpose. A repository with “wip” and “fix” is a memory that lies.

What you still keep outside Git

The repository is the source of code and of accepted change. It is not the source of live student records, passwords, or the production database. Those stay on the host, with backups, as Book 10 described. The audit split is: code and agent actions in GitHub, customer data and secrets on the server. Mixing them is how a public repository becomes a data breach.

Monday morning

Seat counts are zero. git log -5 --oneline shows a merge of “Add a waitlist” by Workshop Co. Agent at 01:12, then nothing else. What do you run to learn the lines, and what do you refuse to run to “make it like before”?

Answer

Run git show on the waitlist commit, or open the merged pull request, and read the seat-count lines. Fix forward with git revert of that commit, review the revert, push, and deploy. Refuse git reset --hard to an older night and refuse git push --force. Those delete the evidence instead of recording the repair.