AI Governance, Part 2: Verify the Agent Built What You Asked For
Jose Ignacio ParisTL;DR: An agent builds whatever you ask, and often more, and the diff alone doesn’t tell you whether it built the right thing. Chainloop keeps the exact task, spec and skills behind every AI session and checks the pull request against them, one requirement at a time. The AI Session Score then grades each session on scope, alignment and tests, and the scores add up across your team to show whether spec-driven development is working.
This is part 2 of our series on AI governance. Part 1 followed one AI coding session from the prompt to production.
The context behind every AI change
An agent never works from the prompt alone. Before and during a session it reads a set of inputs, and those inputs decide what it builds:
- The task. The Linear or Jira ticket that says what to do and when it’s done.
- The spec. The design document that defines what to build.
- The skills. The instructions and scripts the agent loads during the session. A skill can change how the agent writes, tests and ships the code, so it shapes the result as much as the spec does.
- Anything else from outside the chat, such as an implementation plan written alongside the spec, a screenshot you pasted or a page the agent read.
Together they are the context of the session. Change one of them and you get different code.
The task, spec, plan and skills shape the pull request, but nothing records whether the session followed them.
The pull request shows what changed, and little about what the agent was asked to do. Teams do keep some of that context, with a ticket link in the description, a spec in the repository and sometimes the skills. But it’s scattered across tools, and nothing checks the change against it.
So it’s hard to tell whether a session followed its task, spec and skills, for one pull request or across a whole team.
Storing the exact version the agent read also makes the change reproducible, because a linked ticket or spec can change after the merge, as Miguel explained in Open Sourcing the AI Session Collector.
Measuring whether a session followed its inputs takes two steps:
- Capture the inputs with the session, in the exact version the agent read.
- Grade the change against them.
How chainloop trace captures the inputs
chainloop trace gathers the inputs automatically while the agent works. It keeps the content of every task, spec and plan the session uses, every skill the agent loads with its scripts, and anything else the agent reads from outside the chat, such as a linked page. The agent already reads those sources, so there are no Jira or Notion connectors to set up and no credentials to hand out.
I wrote this post with Claude Code and chainloop trace turned on, and before the agent wrote a single word, it had saved my Notion brief as the spec. This video walks through the same step in a real session:
On git push, chainloop trace stores the inputs in a signed attestation, together with the redacted transcript and session metadata such as cost and AI attribution, so editing a spec after the fact breaks the signature. Capture is part of the open source CLI, under Apache 2.0.
The context tab of one session in Chainloop Platform, with the task, the design spec for issue 3543 and the skill the agent loaded next to the transcript.
Grading the change against the spec
Once Chainloop stores the specs with the session, the AI Session Score in Chainloop Platform grades the pull request against them. It pulls the requirements out of the captured tasks, specs and plans, and reads the skills for context.
Then it finds the latest pull request that shares commits with the session, checks each requirement against the code change, and points to the lines of code behind each result. A requirement outside the task stays on the list, marked out of scope with the reason. The reviewer sees what’s missing or extra before reading a line of the diff.
To read the pull request, Chainloop needs the repository onboarded first. You connect GitHub or GitLab once for your organization, then link each repository to a Chainloop project. We walked through it in Changelog: Connect Your Repo, Secure on Day One.
Five of the six criteria in the score read the spec:
- Context & Planning gives credit when the session started from a spec that states the scope and the tests.
- Scope Discipline compares the diff with the spec and flags code nobody asked for.
- Alignment checks that what the agent said it did, and what the diff does, both match the spec. If the agent undoes a choice the user made, that counts as drift.
- Verification (tests) marks each test the spec asks for as added, run, missing or parked.
- Solution Quality checks the code against the design constraints in the spec.
On the session page, the Score & Policies tab lists the requested outcomes, the scope assessments and the verification checks, with how many passed and how many need attention. Click any assessment and the spec opens next to it at that requirement, so the reviewer sees the verdict and the source side by side. One score per session tells you which pull requests need a careful review.
A session graded against its captured ticket. Scope Discipline marks the runner URL changes and their regression tests as within scope, because the ticket asked for them.
When a developer changes course mid-session, the later instruction wins over the spec. Background material, such as a screenshot or a reference document, gives the score context, and the score doesn’t grade the change against it. If a session has no spec or no linked pull request, the score falls back to the conversation, and any criterion without enough evidence abstains and says so in the breakdown.
The score is advisory and never blocks a merge. The Chainloop AI Policies check on the same pull request is the one that blocks.
Measuring spec-driven development org-wide
One graded pull request tells a reviewer where to look. Hundreds of them tell you whether your team practices spec-driven development at all.
The AI Coding dashboard tracks each score criterion over time and breaks it down by contributor, model and coding agent. If the Context & Planning average drops, sessions are starting without a spec, and you find out from the data before a bad release tells you. A low Verification (tests) average means agents are skipping the tests your specs ask for.
With the specs stored and graded on every change, you can see whether spec-driven development pays off for your own team, from your own pull requests.
Next steps
Run chainloop trace init in a repository and your next session saves its specs. The AI Sessions quickstart covers the setup, and the trace guide lists which agents support skills and pasted images. To see the score and the dashboard on your own repositories, talk to us. Follow the Chainloop blog for the next part of this series.