Private preview. Daggry is not publicly released.Roadmap
Skip to content

Gate expressions ​

Reference

A loop must stop on a fact, not on an agent's word. A gate is an expression in a loop's until that reads facts from sealed evidence, and this page defines its grammar, the contexts, every read form, the fact classes and the functions. Read it when you write a loop and need to know what until can read. For where until sits, see Workflow file. For the facts that validators emit, see Validators. For the steps, follow Add a loop.

The expressions on this page are illustrative. Where an example is refused, the page names the refusal.

Quick reference ​

A gate reads only derived facts: values that code computed from sealed inputs. The loader refuses a read of a claimed field, of a field with no class, and of a step that does not exist, before a run starts.

The loader accepts these reads.

text
verdict.all_covered
verdict.status == 'pass'
verdict.criteria_uncovered == 0
inputs.measurement.exit_code == 0
success()

The loader refuses these reads.

text
inputs.plan.criteria == 'x'
verdict.findings == 1
steps.zzz.measurement.exit_code == 0

Contexts ​

A gate reads from four contexts.

ContextReads
inputsThe artifacts handed to the loop, by kind.
needsThe artifacts of named previous work, by id.
stepsThe artifacts of a named step.
verdictThe verdict facts sealed so far.

A gate expression can use a name only from these four contexts. env.HOME is refused at parse time.

Read forms ​

The table lists the four read forms. <kind> is the kind's bare name, such as measurement, not evidence/measurement@1.

ReadFormNames after the contextHow the loader classifies it
stepssteps.<step id>.<kind>.<field>Exactly 3.The class of <field> in <kind>'s schema. <step id> must name a step of this workflow, top-level or inside a loop.
needsneeds.<id>.<kind>.<field>Exactly 3.As steps, but the id is not checked against the workflow.
inputsinputs.<kind>.<field>2 or more.The class of <field> in <kind>'s schema. Extra names leave the class unchanged. A read with fewer names has no class.
verdictverdict.<name>Exactly 1.If <name> is a property of the verdict schema, that property's class. Otherwise <name> is a fact name and takes the class of the verdict's facts: derived.

The loader checks every read in an until, in source order, and returns the first refusal. A read that the loader cannot classify is refused, the same as a claimed read. This is fail-closed.

A body field that is itself named meta is read as steps.<step id>.<kind>.meta.

Every envelope meta value is derived.

Fact classes ​

Every field has one of three classes or none.

ClassMeaningGate can read
claimedAn agent wrote it.No.
derivedCode computed it from sealed inputs.Yes.
judgedA model's verdict under a rubric a person approved for that criterion.Only once a person approves a rubric for that criterion. Until then the loader refuses a judged read.
noneThe schema gives the field no x-fact-class.No.

A schema marks a field's class with the keyword x-fact-class on the property.

Fact classes by kind and field ​

The table gives the class of every top-level body field of every kind.

KindFieldClass
evidence/plan@1criteriaclaimed
evidence/measurement@1label, criterion, exit_code, check, contract, outcome, findings, metrics, testsderived
revisionclaimed
evidence/verdict@1status, facts, and every fact namederived
validator, version, findingsnone
evidence/approval@1subject, path, digest, source_ref, cited_phrase, intent_read, authorderived
daggry/change@1frozenderived
revision, pathsclaimed
daggry/observation@1record, path, reason, step, attemptderived
daggry/run-lock@1validators, boundary_rules, image_digest, workflow_digestderived
daggry/work-item@1workspace, request, repository, issueclaimed

Only a top-level property of a body is readable. A fact value is a boolean, an integer or a string.

Verdict facts ​

A verdict.<name> read takes the value from the verdicts sealed for the run, newest first. Each verdict contributes status (a string) and each of its facts. A newer value of the same name replaces an older one, so verdict.status is the status of the latest verdict. The table lists the names the built-in validators give.

NameTypeFromMeaning
all_coveredbooleandaggry/criterion-coverageNo plan criterion is uncovered.
criteria_coveredintegerdaggry/criterion-coverageCriteria covered by a passing finding of the head measurement.
criteria_uncoveredintegerdaggry/criterion-coverageCriteria with no passing finding.
redbooleandaggry/baseline-proofThe proof step's check failed on the baseline with a non-zero exit.
findings_removedintegerdaggry/base-relativeFinding ids in base that are absent from head. Also emitted as tests_removed.
findings_newly_skippedintegerdaggry/base-relativeFinding ids that are skipped in head and not in base. Also emitted as tests_newly_skipped.
findings_fail, findings_error, findings_skipintegerdaggry/result-gateThe count of findings with that outcome in a measurement.
thresholds_missedintegerdaggry/result-gateThresholds on the measurement that do not hold.
statusstringany verdictpass, fail or inconclusive.

A native validator the tenant admits emits facts of its own under the same rules. The built-in validators are defined in Validators.

until does not depend on whether the iteration was green. When it holds at the end of a red iteration, the loop still ends.

Grammar ​

text
expr    = or
or      = and { "||" and }
and     = cmp { "&&" cmp }
cmp     = unary [ ("==" | "!=" | "<" | "<=" | ">" | ">=") unary ]
unary   = "!" unary | primary
primary = "true" | "false" | integer | 'string' | "(" expr ")" | call | field
call    = ("success" | "failure" | "always") "(" ")"
field   = ("inputs" | "needs" | "steps" | "verdict") { "." name }+

Lexical rules ​

The table lists the rule for each element of an expression.

ElementRule
WhitespaceIgnored between tokens.
Operators., (, ), &&, `
StringSingle-quoted, with no escape sequences. It runs to the next '. Double quotes are not accepted. An unterminated string is a syntax error at the opening quote.
IntegerA run of ASCII digits, read as a 64-bit signed integer. No minus sign and no float: -1 is a syntax error.
NameStarts with an ASCII letter or _. Continues with letters, digits, _ or -. So steps.build-all.exit is valid. A segment that starts with a digit or - cannot be written.
Booleantrue and false.
ComparisonNot chainable. a == b == c is a syntax error.
FieldNeeds at least one name after the context. inputs alone is a syntax error.
NestingParentheses and ! nest at most 32 deep.

Functions ​

The grammar has three functions.

FunctionValue
success()True when no step before this point failed.
failure()True when a step before this point failed.
always()True.

Functions take no arguments. success(1) is a syntax error. Any other call is an unknown function. A bare success without parentheses is an unknown context.

Evaluation rules ​

The table lists how an expression is evaluated.

RuleDetail
TypesBoolean, integer and string.
== and !=Two integers, two booleans or two strings.
<, <=, >, >=Integers only. Strings and booleans give a type mismatch.
Mixed typesA type mismatch.
!, &&, `
Short-circuitNone. Both sides of && and `
ResultThe whole expression must be a boolean. A bare boolean field such as verdict.all_covered is valid. A bare integer or string is not.

Errors ​

Parse errors ​

The parser reports one of four messages.

MessageCause
unknown context `<name>` The expression names a context other than the four.
unknown function `<name>` The expression calls a function other than the three.
syntax error at offset <at>The text does not parse. The offset counts characters. At the end of the input it equals the input's length.
expression nested too deeplyParentheses or ! nest more than 32 deep.

Evaluation errors ​

The evaluator reports one of four messages.

MessageCause
unknown field `<name>` The expression reads a field that does not exist.
field `<field>` is <class>, not derivedThe field is not derived.
operands of the wrong typeMixed types, or an ordering comparison of non-integers.
expression is not a booleanThe result is an integer or a string.

Loader errors ​

The loader refuses an until that does not parse, and one that reads a field that is not derived. See Workflow file.

Examples ​

Expressions that parse ​

text
success()
true == true
verdict.passed != false
'a' != 'b'
steps.build-all.exit == 0
failure()
always()
verdict.passed
!verdict.passed
inputs.count <= 3
verdict.coverage >= 80 && steps.verify.exit == 0
needs.plan.status == 'ok' || inputs.count > 9
(inputs.count < 3 || inputs.count != 3) && always()

These show the grammar. Whether each is readable in a workflow depends on the kinds and fields it names.

Expressions the parser refuses ​

The table is a representative set. Offsets count characters from the start of the expression.

ExpressionMessage
env.HOME == 1unknown context `env`
cancelled()unknown function `cancelled`
success(1)syntax error at offset 8
inputs.a ==syntax error at offset 11

Expressions that parse and fail to evaluate ​

Each expression in the table parses, and the evaluator refuses it.

ExpressionMessage
'a' < 'b', 'a' >= 'b', true < false, verdict.passed > false, true <= trueoperands of the wrong type
inputs.countexpression is not a boolean
steps.write.summary == 'done' where the field is claimedfield `<field>` is claimed, not derived
verdict.quality == 'good' where the field is judgedfield `<field>` is judged, not derived

Reads the loader accepts ​

The loader accepts each until in the table.

untilWhy
verdict.status == 'pass'status is a derived verdict property.
inputs.measurement.exit_code == 0exit_code is derived.
inputs.measurement.outcome == 'pass'outcome is derived.
verdict.all_covered && verdict.status == 'pass'Both reads are derived.
steps.v.measurement.exit_code == 0Step v exists.
needs.anything.measurement.exit_code == 0needs ids are not checked against the workflow.

Reads the loader refuses ​

The loader refuses each until in the table and names the class.

untilClass in the refusalCause
inputs.plan.criteria == 'x'claimedcriteria is claimed.
inputs.nope.x == 1noneNo kind nope.
steps.zzz.measurement.exit_code == 0noneNo step zzz in the workflow.

Sponsored by