A CEL Policy is defined using a YAML structure with the following top-level fields:
name (string): A system-specific identifier.description (string): A human-readable description.imports (list[string]): A list of aliases for simplifying type names.rule (object): The primary entry point for computations.
Rule Components
Variables
A rule can define an ordered list of variables. Variables are lazily evaluated and memoized. A variable must be declared before it is referenced.
variables:
- name: first_item
expression: "1"
- name: list_of_items
expression: "[variables.first_item, 2, 3, 4]"
Match and Condition
The match block contains a sequence of matches evaluated top-down.
condition: A CEL expression that must evaluate to a bool. If absent, it defaults to true.output: The result returned when the condition is met. All output expressions in a policy must have compatible types.
Nesting
You can nest a rule inside a match block to create scoped variables or fallback behavior (chaining). An unconditional nested rule (one without a condition) allows the engine to step back to the parent rule if no inner match is found.
rule:
match:
- condition: "outer == 'condition_a'"
rule:
match:
- condition: "inner == 'condition_a_1'"
output: "'outer_a_inner_1'"
- output: "'outer_a_inner_default'"
- output: "'outer_default'"