Rule DSL reference

Rules are YAML: when X, then Y. They are evaluated in order and the most severe action wins (block > hold > note > allow). Actions: allow, note, hold, block, alert.

version: 1
defaults:
  mode: inherit      # inherit the agent's mode
  fail: open         # open | closed if Keeprun itself errors
rules:
  - id: hold-big-refunds
    when: { tool.risk_class: refund, amount: { gt: 2000, currency: INR } }
    then: hold
    approvers: [owner, approver]
    expire: 30m
    fail: closed

Predicates include:

  • tool.risk_class, tool.name, tool.irreversible
  • amount with gt, gte, lt, between, currency
  • check: <id> matches when a check fired
  • expr a sandboxed expression with a 5 ms budget and whitelisted lookup()
  • duplicate, count (velocity), payee/recipient.not_in_history
  • time windows, matches / output_or_input_matches (RE2-safe regex)

Currency conversion uses a static daily table and is labelled approximate.