Rules
Rules
Rules define what is allowed, restricted, or blocked in your system and give you full control over how Averment behaves.
What is a rule?
A rule is a set of conditions that evaluate an action and influence the final decision. Each rule can increase or decrease risk, override decisions, or directly enforce an action (block, allow, etc.).
Rule structure

json

Rule anatomy
Each rule has three parts:
1. Condition (when)
Defines when the rule applies.

json

2. Effect (effect)
Controls risk scoring.
EffectMeaning
increaseIncrease risk
decreaseReduce risk
overrideOverride scoring
3. Decision Effect (decision_effect)
Directly controls enforcement.
ActionBehavior
allowExecute
cautionSoft gate; proceed with awareness
reviewRequire active attention
blockStop action
escalate_one_levelIncrease severity
deescalate_one_levelReduce severity
decision_effect overrides everything else when set.
Writing policies
Simple Rule (Recommended)

Full DSL (Advanced)

json

Supported operators
OperatorWhat it doesWorks withExample
eqequalsstring, number, booleancontext.role eq "admin"
neqnot equalstring, number, booleancontext.country neq "US"
gtgreater thannumbernumbers.requests gt 100
gtegreater than or equalnumbernumbers.age gte 18
ltless thannumbernumbers.score lt 50
lteless than or equalnumbernumbers.attempts lte 3
containstext includes valuestring / arraycontext.command contains "rm -rf"
starts_withstarts with valuestringcontext.email starts_with "admin"
ends_withends with valuestringcontext.email ends_with "@temp.com"
inmatches one of valuesarraycontext.role in ["admin","moderator"]
existsfield is presentanycontext.device exists
Available fields
Decision fields (system info)
FieldWhat it means
decision.typeType of action
decision.actionAction category
decision.summaryHuman-readable description
Context fields (your data)
The most flexible part. You pass this data when calling decide().

js

Then reference it in policies:

Typed fields (structured access)
TypePrefixExample
Numbersnumbers.*numbers.requests
Booleansbooleans.*booleans.is_external_api
Stringsstrings.*strings.email
Important notes
  1. Missing fields don't match: If a field isn't provided, the rule doesn't trigger.
  2. Use the right prefix: numbers use Numbers.*, booleans use booleans.*, everything else uses context.*.
  3. Context is your control layer: You decide what data to send, and more context means better decisions.
Priority & weight
Weight (0–100)
Controls how strongly a rule affects the decision. Higher weight = stronger influence.
Priority
Determines which rule runs first. Higher priority = executes first.
Next steps
Now that you understand policies, learn how to plug in your own LLM for semantic interpretation.
Bring Your Own LLM (BYOLLM)
Replace Averment's default semantic backend with your own LLM (OpenAI, Anthropic, Gemini, or any custom endpoint.)