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

Gate expressions ​

Reference

A gate is the expression in a loop's until. It decides when the loop ends, and it reads sealed records only, never what an agent says. This page lists what a gate can read, the grammar and the errors. Read it when you write a loop. For where until sits, see Workflow file. For the steps, follow Add a loop.

A gate seals nothing. It reads the verdicts that a verify step sealed, so every decision to end a loop can be traced to records in the evidence trail.

claimedAn agent wrote it
  • inputs.plan.criteria
  • steps.work.change.paths
a gate cannot read it
derivedCode computed it from sealed records
  • verdict.all_covered
  • verdict.outcome
  • inputs.measurement.exit_code
a gate can read it
judgedA rubric judge answered
  • verdict.rubric_pass
only once a person approves the rubric
What a gate can read. A claimed field is something an agent wrote, and a gate cannot read it. A derived field is something code computed from sealed records, and a gate can read it. A judged field is a rubric judge's answer, and a gate can read it only once a person approves the rubric.

The diagram shows the three classes of field and which of them a gate can read.

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

Quick reference ​

A gate reads derived facts: values that code computed from sealed inputs. It reads a judged fact only once a person approves the rubric behind it. 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.outcome == '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 five 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.
runFacts that code computes from every sealed record of the run. See Run facts.

A gate expression can use a name only from these five 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 that fact in the verdict: derived, or judged for a rubric judge's.

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.
judgedThe answer of a rubric judge: a bounded model's pass or fail under a rubric a person approved, with citations that code confirmed.Only once a person approves the rubric. 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.

The class of every field of every kind is in Fact classes by kind. Only a top-level field of a record's 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 outcome (a string) and each of its facts. A newer value of the same name replaces an older one, so verdict.outcome is the outcome of the latest verdict. Every fact name and the judge that emits it is in Facts a judge emits.

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

Run facts ​

An auto_when expression decides whether an effect runs with no person. It reads facts about the whole run. The table lists them.

FactTypeMeaning
run.changed_filesintegerThe paths the sealed changes of the run changed.
run.changed_linesintegerThe lines those changes added and removed.
run.within.<area>booleanEvery changed path is inside the area of that name in the project config.
run.verdicts_failedintegerThe verdicts of the latest verify step that are not pass.
run.protected_touchedintegerThe times Daggry put back a protected or frozen path in this run.

All are derived. When an auto_when holds, Daggry seals the expression and the value of each fact it read. See Autonomy.

Grammar ​

The grammar is small: comparisons, !, &&, ||, parentheses and three functions.

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" | "run") { "." name }+
Lexical rules, functions and evaluation

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 five.
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 a gate cannot read. See Load errors.

More examples

Expressions that parse

text
success()
true == true
verdict.covered != false
'a' != 'b'
steps.build-all.exit == 0
failure()
always()
verdict.covered
!verdict.covered
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.covered > 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.outcome == 'pass'outcome is a derived verdict property.
inputs.measurement.exit_code == 0exit_code is derived.
inputs.measurement.outcome == 'pass'outcome is derived.
verdict.all_covered && verdict.outcome == '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