Back to Delivery
deliveryL3 SystematicGovernance & Compliance

Policy-as-code

Policy-as-code means expressing compliance rules as executable code that runs automatically in the CI/CD pipeline, rather than as documents that developers are expected to read and follow manually.

  • ·Minimum viable audit trail is captured per AI-assisted change: model identifier, timestamp, context description, human approver
  • ·Policy-as-code enforces compliance rules in CI (OPA or equivalent)
  • ·Compliance gates run on every PR to in-scope repositories
  • ·Audit trail fields are validated by CI (missing fields fail the build)
  • ·Policy exceptions are logged and require follow-up within 48 hours

Evidence

  • ·Sample commit or PR metadata showing model, timestamp, context, approver fields
  • ·OPA policy configuration in CI pipeline
  • ·Compliance gate pass/fail logs

What It Is

Policy-as-code means expressing compliance rules as executable code that runs automatically in the CI/CD pipeline, rather than as documents that developers are expected to read and follow manually. Instead of a policy document that says "all AI-generated code must have a human reviewer," a policy-as-code implementation is a CI check that fails if the PR lacks a human approval record from a non-author account. The policy is enforced, not hoped for.

The technical foundation for policy-as-code in most organizations is Open Policy Agent (OPA), a general-purpose policy engine that evaluates structured inputs (JSON representing commit metadata, PR attributes, security scan results) against Rego policy rules and returns a decision: allow or deny. OPA integrates with CI systems (GitHub Actions, GitLab CI, Jenkins), Kubernetes admission controllers, API gateways, and infrastructure provisioning tools. A single OPA policy can enforce the same rule across all of these integration points simultaneously.

At L3 (Systematic), policy-as-code applies to the delivery pipeline specifically: CI checks that enforce AI disclosure requirements, block merges that lack required audit trail fields, verify that AI-generated code in high-risk repositories was reviewed by a human with specific permissions, and confirm that model versions used are on the approved list. The policy lives in the repository alongside the code it governs, goes through code review when it changes, and its enforcement decisions are logged and auditable.

The shift from document-based policy to policy-as-code has a profound effect on compliance reliability. Document-based policies have adoption rates that peak at launch and decay over time - developers skip steps under deadline pressure, new developers don't find the policy document, policy updates don't reach developers who were already past onboarding. Policy-as-code has adoption rates that are mechanically enforced: every merge request, every deployment, every time. The compliance evidence is the CI run log, not a survey about whether people read the policy.

Why It Matters

  • Compliance is mechanically enforced, not behaviorally dependent - policy-as-code eliminates the failure mode where developers know the policy but don't follow it under pressure; the pipeline either passes or fails, regardless of deadline urgency
  • Policy changes go through code review - when a compliance rule changes, the change to the policy code goes through the same review process as application code, creating an auditable history of what was required when
  • Audit evidence is the CI log - instead of collecting attestations from developers or doing periodic audits, the compliance evidence is the automated check results that run on every merge; this is a much stronger evidence base for SOC2 and ISO 27001
  • Scales automatically with team growth - adding a new team or repository to the policy scope requires adding it to the OPA policy config, not training new developers on a document they may not find
  • Enables proactive policy testing - policy rules can be unit-tested like application code; you can verify that a rule correctly rejects a non-compliant commit before it ever runs in production CI

Getting Started

6 steps to get from here to the next level

Common Pitfalls

Mistakes teams actually make at this stage - and how to avoid them

How Different Roles See It

B
BobHead of Engineering

Bob has been managing AI governance through policy documents and PR template fields for six months. The compliance rate on PR disclosures is 75% - good, but not auditable at the level his SOC2 auditors expect. They want evidence that the policy is enforced, not just documented. Bob needs to close the gap between "we have a policy" and "we enforce our policy."

What Bob should do - role-specific action plan

S
SarahProductivity Lead

Sarah has been manually reviewing PR disclosure data every month to check compliance rates. The process takes two hours per review cycle and the data is often incomplete because some PRs lack disclosures and she has to chase down the developers who submitted them.

What Sarah should do - role-specific action plan

V
VictorStaff Engineer - AI Champion

Victor has been informally advocating for policy-as-code for months and has already written prototype OPA rules for the AI audit trail requirements. He wants to get the organization to adopt them but has been waiting for the right moment.

What Victor should do - role-specific action plan