Skip to main content

Gate Rules

Gate rules define conditions that must pass before a stage proceeds. They're evaluated by the gate engine after a stage completes and produce a verdict that routes the pipeline.

Rule structure

Each rule has five fields:

FieldTypePurpose
fieldstringWhat to check (see fields table below)
operatorstringHow to compare (see operators table below)
valueanyThe threshold to compare against
severitystringHow bad a failure is (warn, required, block)
onFailstringWhat to do when the rule fails
labelstringHuman-readable description shown in the UI

Available fields

Gate rules evaluate against the stage-run context produced by the database-backed pipeline executor.

FieldTypeDescription
exit_codeintegerProcess exit code (0 = success)
cost_usdnumberTotal cost in USD (currently reported as 0 — result doc parsing is not wired into the DB-stage gate context yet)
tokens_inintegerInput token count (currently 0 — same limitation)
tokens_outintegerOutput token count (currently 0 — same limitation)
providerstringProvider name reported by the driver
modelstringModel identifier reported by the driver
driverstringDriver name

Operators

OperatorMeaning
equalsExact match
not_equalsNot equal
less_thanStrictly less than
greater_thanStrictly greater than
containsString or array contains value
matchesRegex match
inValue is in a list
existsField is present and non-null

Severity levels

SeverityMeaning
warnRule failure is logged and shown in the UI but does not affect routing
requiredRule failure triggers onFail action
blockSame as required but displayed prominently as a blocker

onFail actions

ActionEffect
proceedIgnore the failure; continue
holdPause the run for manual decision
reworkRoute to onFail stage
abortStop the pipeline; mark the run failed
notifyLog the failure (no routing change)
escalateEscalate for attention (no routing change)

Verdict resolution

When multiple rules fail, the gate engine takes the worst onFail action across all failed rules (severity order: abort > rework > hold > proceed). That worst action becomes the gate verdict.

Example

Hold if the stage process exits non-zero, and warn if it ran on a non-preferred provider:

rules:
- field: exit_code
operator: equals
value: 0
severity: block
onFail: hold
label: "Stage process exited successfully"
- field: provider
operator: equals
value: anthropic
severity: warn
onFail: proceed
label: "Preferred provider warning"