An architectural decision that exists only in a document is a request. The domain layer must not import the database adapter. The CI role must not be able to create IAM policies. The application’s database user must not own its tables. Each of those sentences is true in the wiki and optional in the repository, and the gap between the two is where the drift from Part 1 comes from.

The fix is to write the constraint down a second time, in a form that fails. Thoughtworks calls these fitness functions: measures of “how close an architecture is to achieving an architectural aim.” I prefer the plainer framing. A boundary is real when a test can fail because of it. Until then, your architecture is whatever the pipeline lets through.

Diagrams and decision records stay; they are the only place the why survives. The executable check records the what, in a form that does not care who, or what, authored the change.

Four layers worth testing

Most teams test one of these layers and trust convention for the other three. They are four different problems, with four different tools, running at four different times.

The first layer is code and dependency boundaries. Declare which modules may depend on which: the domain must not import infrastructure, one feature must not reach into another’s internals. Tools such as dependency-cruiser take a list of forbidden from and to paths; Nx has an ESLint rule that enforces the same thing through project tags. Either one fails a pull request the moment a prohibited import appears. This is the cheapest layer and the one most teams skip.

The second layer is infrastructure and identity policy. Terraform will tell you what it is about to do: terraform show -json turns a plan into a document, and OPA evaluates Rego policies against that document before anything is applied. The rule you want is simple to state and awkward to enforce by review: no routine engineering or CI role acquires an administrative capability, regardless of what the role is called. AWS’s IAM Access Analyzer adds a cloud-native version, including a check for whether an edited policy grants any new access compared to the version already deployed.

The third layer is runtime capability, and this is where most architecture-as-code efforts stop short. A policy test tells you what you asked for. Only the live system tells you what the identity can do. On PostgreSQL that means asking the catalog: which tables does the application role own, which roles is it a member of, does it carry BYPASSRLS, can it CREATE in the schema. Grants alone are misleading, because ownership and inheritance confer rights no GRANT statement records. Run these as read-only queries against production metadata and as negative tests (try the forbidden thing, expect a permission error) against an isolated database built with the same grants script.

The fourth layer is operational control. Can an everyday identity elevate itself? Does emergency access require the break-glass path, expire on its own, land in the audit log and page someone? Does the backup restore, and how long does that take? None of this fits in a pull request. All of it can be scheduled.

Where each check belongs

Not every architectural test can run in a three-minute PR pipeline, and forcing them there is how teams end up with none.

Dependency rules and policy-as-code run on every pull request; they are fast and deterministic. Plan inspection and capability tests against a provisioned environment run before deployment. Comparison of the deployed cloud identities and database privileges against the intended constraints runs continuously, as a drift check that alerts rather than blocks. Break-glass and restore drills run on a schedule, quarterly at least, with a named owner and a recorded result.

The cadence matters because each layer fails differently. A forbidden import is a mistake someone made this morning. A role with more than it should have is usually a mistake someone made eighteen months ago that nobody has looked at since.

The same wall for agents and engineers

This is where the exercise stops being about security and starts being about delivery. Teams adopting coding agents produce more change, faster, with less human attention per change. The usual responses are more review, which does not scale, or more trust, which Part 1 argued against.

The executable constraint is the third option. If the dependency rule, the policy check and the privilege test all run in the pipeline, then an agent’s pull request meets exactly the same wall an engineer’s does. You can accept agent-generated change at volume because the things that must never happen are enforced by something other than a reviewer’s attention. The checks do not need to know who wrote the diff.

That is also the honest answer to “how do we let the agent do more?” You let it do more when the boundaries it cannot cross are mechanical.

Ownership, exceptions and drift

A check with no owner becomes a check someone deletes the first time it blocks a release. Every constraint needs a person accountable for it, a one-line reason it exists, and a review date. Exceptions should be decisions with an expiry, recorded next to the check, rather than a // TODO in the config.

Leadership’s part is not to write the rules. It is to decide which boundaries are non-negotiable, assign the owner, and ask for the evidence. Five questions do most of the work:

Which architectural boundaries are non-negotiable for us? Which of those are enforced automatically today, and at what stage? Can you show me the evidence from the deployed system, rather than the policy document? Have we deliberately broken each important check to prove it detects a violation? Who is accountable for exceptions and for repairing drift when we find it?

The fourth question is the one most teams cannot answer. A check that has never failed is a hypothesis about a check. Part 3 is about breaking your own guardrails on purpose, with real SQL, Rego and dependency rules, so that you know.

If you would like help choosing the first three constraints to make executable, talk to jfsi.

Sources: Thoughtworks: Fitness function-driven development · dependency-cruiser · Nx: Enforce Module Boundaries · Open Policy Agent: Terraform · AWS: Validate policies with IAM Access Analyzer