Problem Statement: Guardrails That Move at the Speed of Deploys
Frames the policy engine as a distributed evaluation fabric with four enforcement planes, not as a linter.
Problem statement
Design an automated security policy engine that checks every infrastructure and code change against a library of security guardrails—open security groups, unencrypted storage, public buckets, over-privileged IAM, missing TLS, privileged containers, missing audit logging—and either blocks the change or raises an alert before the change can cause harm. The engine must integrate with CI so a violating pull request cannot merge, with infrastructure-as-code pipelines so a violating Terraform plan cannot apply, with cluster admission so a violating workload cannot run, and with the live cloud so configuration drift is detected and reconciled continuously.
The reason this question exists is that the naive answer—“we do manual security reviews”—collapses under real change velocity. Our assumed organization ships 25,000 commits per day across 1,500 repositories and performs roughly 1,200 infrastructure deploys per day . A human review board examining even 1% of that volume becomes the critical path and then gets bypassed. The design therefore has to make the secure path the fast path: evaluation must be cheaper and faster than the review it replaces, and it must be correct enough that engineers trust the block rather than route around it.
Why this is a distributed-systems problem, not a linting problem
A linter runs once, on one input, and prints a message. A policy engine is a decision fabric with four very different enforcement planes:
- Shift-left (pre-merge): static analysis of code and IaC in the pull request. Inputs are diffs and manifests. Latency budget is tens of seconds. Failure means a noisy check, not an outage.
- Plan gate (pre-apply): evaluation of a rendered infrastructure plan (for example Terraform's plan JSON) before anything is created. This is the last cheap moment to stop a real resource from existing.
- Admission control (runtime create): a validating webhook inside each cluster intercepts create/update requests before the API server persists them. Latency budget is hundreds of milliseconds. Failure semantics—fail-open or fail-closed—are a production decision, not a footnote.
- Runtime drift (continuous): the live cloud is compared against the desired baseline using provider change feeds and periodic snapshots, because resources get modified outside pipelines, consoles get used, and accounts get inherited.
Each plane has a different input format, latency budget, failure consequence, and consistency requirement, but all four must evaluate the same policy library and reach the same decision for the same input. If CI says “pass” and admission says “block,” engineers learn that the CI signal is decorative and the whole system loses legitimacy. That cross-plane determinism requirement is what elevates this from a tool to a platform.
The two products inside one engine
The engine is really two products sharing one compiler. The first is an evaluation service : fast, deterministic, stateless decisions over normalized inputs. The second is a governance workflow : policy authoring, testing, dry-run promotion, exemptions with expiry, compliance mapping, and audit evidence. Interviews that only design the first product produce a fast service nobody can safely operate; interviews that only design the second produce a portal with no enforcement. A strong answer builds both and keeps the boundary crisp: governance writes signed policy artifacts, enforcement consumes them and reports signed decision events.
Public operating baseline versus design assumptions
The category is operationally real and well documented. Open Policy Agent (OPA) is a graduated project of the Cloud Native Computing Foundation, and its published case studies describe firms enforcing policy across hundreds of clusters and global service meshes. Capital One created Cloud Custodian in 2016 and donated it to the Cloud Native Computing Foundation; it remains one of the most widely cited engines for cloud-runtime guardrails with serverless remediation. Microsoft documents that Azure Policy uses the Gatekeeper admission engine for AKS clusters. These are cited public facts used for context. Every scale number, SLO, and retention value in this answer that is not explicitly attributed is a stated design assumption for a fictional organization, not a claim about any company's private production system.
The four architectural planes
- Policy plane: authoring, versioning, testing, signing, bundling, distribution.
- Enforcement plane: CI scanners, plan gates, admission webhooks, drift detectors.
- Evidence plane: evaluation events, violations, waivers, audit trail, compliance projections.
- Operations plane: dashboards, alerting, false-positive tuning, incident response for the engine itself.
The rest of this answer designs each plane, then stresses them: what happens when a bad policy ships, when the webhook fleet dies, when the drift feed lags, and when an exemption becomes a hole.
Key Highlights
- •Manual review collapses at 25,000 commits/day; the engine must make the secure path the fast path.
- •Four enforcement planes—shift-left, plan gate, admission, runtime drift—share one policy library and must agree.
- •Cross-plane determinism is the core correctness property: same policy version plus same input yields the same decision.
- •The engine is two products: a stateless evaluation service and a governance workflow that emits signed artifacts.
- •All uncited scale and SLO values in this answer are explicit design assumptions, labeled as such.
Section Rescue Kit
Buzzwords to use:
Safe statements:
- "Let me separate the evaluation service from the governance workflow before choosing any storage."
- "The interesting constraint is not detecting violations; it is making four different enforcement points agree on what a violation is."