Rules language

Write Floodwall gate policies as data: syntax, fields, conditions, bundles and worked production guardrails.

A plane's gate enforces policies written as data, in a small declarative language. A rules file holds one or more policies; each is a named list of rules, and each rule rejects or defers the intents its condition holds for, with a reason. In the console they are the text on Policies; over the API, the rules field of the plane's settings.

rules
format 1

# Keep the fleet to the core services; anything else waits for a human.
policy "resource-allowlist" {
  defer "resource '{resource}' is not on the allowlist"
    when resource not in ["web", "api", "cache"]
}

policy "freeze-billing" {
  reject "billing is frozen until the audit closes"
    when resource matches "billing*" and kind != scale
  defer "{agent} may only scale billing during the audit"
    when resource matches "billing*" and kind == scale and agent != "autoscaler"
}

A file is checked when it is read: an unknown field, a value of the wrong type or anything else out of place is refused with its line and column, never kept as a rule that silently never matches.

Syntax#

A file starts with format 1. # starts a comment that runs to the end of the line; spaces, tabs and line breaks separate words and are otherwise ignored.

Policies#

policy "<name>" { <rules> }. A name is 1 to 64 lowercase letters, digits and -, starting with a letter; it is what the gate's breakdown and the ledger show. Names are unique within a file, and agent-signature and conflict-window (the plane's own checks) are reserved. A policy has at least one rule.

Rules#

reject "<reason>" when <condition> or defer "<reason>" when <condition>. A policy's verdict on an intent is the harshest of the rules whose conditions hold (reject over defer), with the reason of the first such rule; when none holds, it admits. Across policies the gate combines verdicts the same way: deny-overrides.

Reasons#

A reason may name the intent's fields in braces, filled in when the rule applies: {agent}, {kind}, {resource}, {manifest}, {replicas}, {priority}, {blast_radius}, and {action} (the action's summary, as in the ledger: scale web to 5). {{ and }} stand for literal braces. A reason may not be empty.

Conditions#

These fields of an intent can be tested:

FieldTypeTests
agentstring== != in matches
resourcestring== != in matches
manifeststring, for apply only== != in matches
kindapply, scale or destroy== != in
replicaswhole number, for scale only== != < <= > >= in
prioritybulk < normal < urgent < pager== != < <= > >= in
blast_radiuscell < service < region < global== != < <= > >= in
  • field in [v1, v2, ...] holds when the field equals one of the values; field not in [...] when it equals none of them.
  • field matches "pattern" holds when the whole string matches the pattern, in which * stands for any run of characters: "billing*" (starts with), "*-db" (ends with).
  • Strings are in double quotes, with \", \\, \n and \t as escapes. Enumerations (kind, priority, blast_radius) are bare words.
  • destructive holds for a destroy, or a scale to zero replicas. true and false are what they say.
  • Conditions combine with not, and and or, in that order of precedence, and with parentheses.

Bundles#

A file can declare itself a versioned policy bundle, right after its format line:

rules
format 1
bundle "production" revision "2026.10.28-1"

The name follows the rules for policy names; the revision is 1 to 64 letters, digits, ., _, -, + and : (a date, a version or a commit). Every decision made with the file then records, in the ledger, the bundle's name, its revision and the SHA-256 of the file, so the ledger says which revision of which rules decided each change. An auditor holding the file can check it with sha256sum. Release a change to the rules under a new revision.

Determinism#

A rule depends only on the intent: never on the time, other intents, or anything outside the file. A gate built from a rules file decides the same way every time it sees the same intent, which is what lets a plane be replayed from its ledger. Anything that needs the outside world (a change calendar, an incident flag) belongs in the rules file's next revision, or, on a self-hosted plane, in a policy written in Rust.

Examples#

The built-in policies#

policies/standard.rules is the crate's built-in policies, written as rules:

policies/standard.rules
format 1

# Never let an agent destroy something global without a human.
policy "no-global-destroy" {
  reject "destructive global change requires human sign-off"
    when blast_radius == global and destructive
}

# Wide changes must carry real urgency.
policy "blast-needs-priority" {
  reject "{blast_radius} blast radius needs priority >= urgent, got {priority}"
    when blast_radius >= region and priority < urgent
  reject "service blast radius needs priority >= normal, got {priority}"
    when blast_radius == service and priority < normal
}

# Only the core services; anything else waits for a human to extend the list.
policy "resource-allowlist" {
  defer "resource '{resource}' is not on the allowlist"
    when resource not in ["web", "api", "cache"]
}

Production guardrails#

policies/production.rules writes a platform team's production guardrails of the kind usually written in OPA/Rego: a trusted image registry, protected state, service ownership, scale bounds, change risk and chaos agents kept in staging. policies/README.md shows the Rego each one stands for, and the tests check the two decide alike on 24,576 intents.

policies/production.rules
format 1
bundle "production" revision "2026.10.28-1"

# Supply chain: deploy only images that CI built and pushed to the internal
# registry. The classic admission-control rule.
policy "trusted-registry" {
  reject "{agent} tried to deploy {manifest}, which is not from registry.internal"
    when kind == apply and not manifest matches "registry.internal/*"
}

# State: no agent tears down a database or a queue.
policy "protect-state" {
  reject "{resource} holds state, so no agent may take it to zero"
    when destructive and (resource matches "*-db" or resource matches "*-queue")
}

# Ownership: a team's services change only through its own agents, or the
# shared autoscaler.
policy "service-ownership" {
  reject "{agent} does not own {resource}"
    when resource matches "payments*" and agent not in ["payments-deployer", "autoscaler"]
  reject "{agent} does not own {resource}"
    when resource matches "search*" and agent not in ["search-deployer", "autoscaler"]
}

# Capacity: scaling past the usual bounds waits for a human.
policy "scale-bounds" {
  defer "scaling {resource} to {replicas} replicas needs a human"
    when replicas > 40
  defer "scaling {resource} to zero needs a human"
    when replicas == 0
}

# Risk: the wider a change can break things, the more urgency it needs.
policy "change-risk" {
  reject "a global {kind} needs priority pager, not {priority}"
    when blast_radius == global and priority < pager
  defer "a region-wide change at priority {priority} waits for a human"
    when blast_radius == region and priority < urgent
}

# Sandboxes: chaos agents stay in staging.
policy "chaos-in-staging" {
  reject "{agent} may only touch staging, not {resource}"
    when agent matches "chaos-*" and not resource matches "staging-*"
}

How it rules on a few intents:

IntentVerdictWhy
web-deployer apply api docker.io/library/api:latestrejecttrusted-registry
cleanup-bot destroy sessions-dbrejectprotect-state
web-deployer scale payments-api to 4rejectservice-ownership
autoscaler scale search to 60deferscale-bounds: held for a person
web-deployer apply web-edge (region, normal)deferchange-risk: held for a person
cdn-bot destroy cdn (global, urgent)rejectchange-risk: a global change needs pager
chaos-monkey destroy staging-webadmitnothing holds

From OPA/Rego#

OPA/RegoFloodwall rules
deny contains msg if { ... }reject "msg" when ...
a defer set, for changes that need a humandefer "msg" when ...
sprintf("%s ...", [input.agent])"{agent} ..."
startswith(s, "x"), endswith(s, "x")s matches "x*", s matches "*x"
x in {...}x in [...]
data, such as ownerswritten into the rules: a rule sees only the intent
time.now_ns()nothing like it: rules are deterministic

Test a change before saving it: the console's dry run replays the plane's recent intents through the new rules and lists every verdict that would change. The language's full definition is in src/rules.rs.