The Drift Log · Governing agents that write code
Enforcing Pre-Commit Invariant Checks on Agent Write Intent
29 October 2026 · 3 min read · 545 words · inference

Gating agent file mutations on pre-commit Build Intent validation stops structural boundary violations before diffs hit code review.
An AI coding agent assigned to update an API endpoint often touches eight files: the route handler, the schema validation, three mock factories in test fixtures, a database migration, and a shared types file. The diff looks clean. The unit tests pass because the agent updated the test mocks to match its own new assumptions. The reviewer approves the pull request. Two weeks later, you discover the agent quietly introduced a circular dependency between your billing context and your notification domain.
Human review breaks down under wide, syntactically plausible diffs. When AI coding agents generate multi-file patches, they do not get tired, but the engineers reviewing their output do. Relying on standard code review automation or post-hoc CI pipelines to catch subtle architectural drift treats the symptom after the change has already reached your version control history.
The Failure of Post-Commit Verification
Most setups grant an agent raw filesystem tools: write_file, replace_file_content, or direct git commit permissions. The agent runs a loop of trial-and-error edits against disk, executes a local test suite, and opens a pull request when green.
This workflow creates two distinct problems for agent governance:
- Diff volume saturates review capacity. An agent can rewrite twenty call sites across three modules in seconds. Reviewers skim mechanical changes and miss structural boundary violations.
- Feedback happens too late. If your CI pipeline rejects a pull request on an invariant check, such as a dependency rule or forbidden import, the agent must consume an entire inference loop to understand why the commit failed and attempt a rewrite from scratch.
The correct posture is to register write intent before any filesystem mutation. The agent should first submit a build intent over the Build Intent protocol, where the proposal is recorded, invariants are resolved in code, and licensing is checked before the write is allowed to proceed. Only after that gate returns a terminal state should the filesystem change. That shifts governance from post-commit inspection to pre-commit validation.
The Build Intent Gate
The Build Intent gate is not a linter bolted onto the end of a patch. It is the protocol boundary for write operations. The agent proposes a change, the system records the intent, evaluates the invariants, resolves licensing, and returns a terminal state: approved, rejected, or blocked by contract.
That distinction matters. A failed CI job tells you that a patch is already in the repository and now needs repair. A failed Build Intent request tells the agent not to mutate the filesystem at all. The agent can revise the proposal before any artefact exists.
In practice, this is the difference between asking, “What broke after the fact?” and asking, “May this write happen at all?” The first is a debugging loop. The second is a control point.
Why This Matters for Agentic Change
The hard part is not writing code. It is keeping write authority aligned with the rules of the repository.
If an agent can edit files first and ask questions later, then every safeguard becomes reactive. If the agent must register intent and pass validation before mutation, then the repository can enforce architecture, dependency boundaries, and licensing constraints at the point where they still matter.
That is the posture worth taking. Not more review. Earlier control.
Keep reading
Next in the log
- Rejecting Agent PRs That Lack Upstream Source Attribution
Require automated coding agents to declare machine-checkable source provenance before generated pull requests reach human review queues.
- Resolving Build Intent Before AI Agents Commit Writes
Intercept agent writes in-memory to validate AST syntax, license compliance, and export invariants before disk mutation occurs.
- Separating Agent Decision Telemetry from Commit Authority
Decouple untrusted agent generation from git write authority by evaluating proposed diffs through a build intent gate before promotion.
The Strategic Master Library · written and reviewed under the house's own epistemic rules: nothing claimed that we cannot show.