Rego Invariants•8 min read
Deterministic OPA Policy & Guardrails
Authoring declarative Open Policy Agent (OPA) rules in Rego to govern AI tool invocations, rate limits, and merge gates.
1. Why Declarative OPA Invariants?
Security rules in Kavach are written in Rego, the declarative query language designed for Open Policy Agent. Rego allows security teams to mathematically codify boundaries that cannot be hallucinated, coerced, or bypassed by adversarial prompt injection.
2. Production OPA Policy Example
The following policy enforces that AI agents cannot execute quarantine or remediation tools against production environments without an explicit human approval token:
