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 a context object. The available fields differ depending on whether the stage is part of a UI-configured pipeline or a YAML playbook.

UI pipeline stages

FieldTypeDescription
exit_codeintegerProcess exit code (0 = success)
cost_usdnumberTotal cost in USD (currently reported as 0 — result doc parsing not yet wired in UI path)
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

YAML playbook stages

Playbook stages evaluate rules against the result document directly using dot-path notation:

FieldTypeDescription
verdictstringResult document verdict: pass, fail, blocked
timing.duration_secnumberStage duration in seconds
run.attemptintegerAttempt number (1 = first try, 2 = first retry, etc.)
meta.input_tokensintegerInput token count
meta.output_tokensintegerOutput token count
meta.cost_usdnumberCost in USD

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 implementation stage takes longer than 2 hours, and warn if it uses more than 100k input tokens:

rules:
- field: timing.duration_sec
operator: less_than
value: 7200
severity: block
onFail: hold
label: "2 hour cap"
- field: tokens.input
operator: less_than
value: 100000
severity: warn
onFail: proceed
label: "Token budget warning"