Your First Policy
A policy in Actra defines when an action should be allowed or blocked before execution.
Let’s break down a simple rule.
Example Policy
version: 1
rules:
- id: block_large_refund
scope:
action: refund
when:
subject:
domain: action
field: amount
operator: greater_than
value:
literal: 1000
effect: block
Rule Anatomy
This rule reads as:
Block the
refundaction whenamount > 1000
Every rule is made of 5 important parts.
1) Rule ID
id: block_large_refund
A unique identifier for the rule.
This is returned in policy errors and debugging output.
2) Scope
scope:
action: refund
Scope limits the rule to a specific action.
This rule applies only when the protected function is admitted as:
runtime.admit("refund", fn)
3) Condition
when:
subject:
domain: action
field: amount
This tells Actra:
inspect the
amountfield from the action input.
4) Operator + Value
operator: greater_than
value:
literal: 1000
This compares:
action.amount > 1000
5) Effect
effect: block
If the condition matches, the function execution is blocked.
Mental Model
Think of a rule as:
For this action,
if this condition is true,
apply this effect.
That simple model scales to:
- workflow approvals
- AI tool safety
- deployment controls
- runtime governance
Next Steps
- Learn the full Schema DSL
- Explore Actor and Snapshot
- Write multi-rule policies