Skip to content

Commit 24436d1

Browse files
l46kokcopybara-github
authored andcommitted
Implement custom policy invariants verification
Enables policy authors to declare custom logical invariants (`assume` preconditions and `assert` clauses) on `CelPolicy` definitions, mathematically verifying that properties hold across all possible input states. PiperOrigin-RevId: 915170572
1 parent 4c2c2fd commit 24436d1

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ A policy source document supports the following top-level keys:
8282
- `imports` *(list[object], optional)*: A list of type name aliases to simplify
8383
object and protobuf references within the expressions.
8484
- `rule` *(object, required)*: The entry point for the policy execution.
85+
- `verification` *(object, optional)*: Formal safety properties (`invariants`)
86+
verified against the policy.
8587

8688
---
8789

@@ -171,6 +173,43 @@ For more details on CEL optionals, refer to the [CEL optional proposal](https://
171173

172174
---
173175

176+
### Formal Verification (`verification`)
177+
178+
The `verification` block allows policy authors to declare custom safety
179+
properties that can be statically and mathematically verified using the CEL
180+
Verifier engine.
181+
182+
Currently, it supports defining custom **invariants**:
183+
184+
- `invariants` *(list[object], optional)*: A list of invariant declarations.
185+
186+
Each invariant item contains:
187+
188+
- `id` *(string, required)*: A unique identifier for the invariant.
189+
- `description` *(string, optional)*: Human-readable rationale for the
190+
invariant.
191+
- `assume` *(list[string], optional)*: A list of CEL expressions evaluating to
192+
`bool` that defines the preconditions constraining the input state space. All
193+
conditions must be true. Defaults to `true` if omitted.
194+
- `assert` *(list[string], required)*: A list of CEL expressions evaluating to
195+
`bool` asserting the safety condition. It can reference the reserved
196+
identifier `rule.result`, which represents the evaluated return value of the
197+
policy's `rule` graph.
198+
199+
```yaml
200+
verification:
201+
invariants:
202+
- id: secure_port_required
203+
description: "If external access is permitted, port must be 443"
204+
assume:
205+
- "request.external == true"
206+
- "rule.result == 'ALLOW'"
207+
assert:
208+
- "port == 443"
209+
```
210+
211+
---
212+
174213
### Type Imports (`imports`)
175214

176215
The top-level `imports` list defines type alias references. These aliases

0 commit comments

Comments
 (0)