The CEL dialect of loop conditions and prompt interpolation, the item and repo variables for each trigger, and the functions and macros available.
Loops use CEL for selection, conditional approval, queue priority, and task interpolation. Conditions return booleans; priorities return integers; each {{ ... }} in a task returns a scalar. Edit expressions in the loop form or with usine config edit loop <project>/<loop>.
Before saving a revision, usine type-checks every expression against its stream’s variables. An unknown field, a type mismatch, or a wrong result type rejects the edit or complete import; the stored configuration stays unchanged. Evaluation happens later, against each item’s payload or tick.
Expressions can use repo and item. Their types come from the payload slice for each stream. GitHub supplies item values with its GraphQL field names; the orchestrator supplies repository and tick values. These fields have no configurable defaults, shown as — in the tables.
The full target branch commit SHA. Null for stored payloads polled before this field was available. Test with item.baseRefOid != null.
headRefName
string
—
The source branch.
headRefOid
string
—
The head commit SHA. Attempts of pr loops start from this commit.
additions
int
—
Added lines in the diff.
deletions
int
—
Removed lines in the diff.
changedFiles
int
—
Changed files in the diff.
reviewDecision
string
—
yes
APPROVED, CHANGES_REQUESTED, or REVIEW_REQUIRED. Null if the branch requires no review.
mergeable
string
—
MERGEABLE, CONFLICTING, or UNKNOWN. GitHub computes it lazily, so the first poll after the base branch changes can return UNKNOWN.
mergeStateStatus
string
—
GitHub’s merge state, such as CLEAN, BLOCKED, BEHIND, or DIRTY.
statusCheckRollup.state
string
—
statusCheckRollup
The combined check state, such as SUCCESS, FAILURE, or PENDING. statusCheckRollup is null if the head commit has no checks.
labels.totalCount
int
—
Number of labels.
labels.nodes[].name
string
—
All current labels. Polling completes a truncated label connection.
labelEvents
map
—
The last label-addition event for each current label with available history, indexed by label name. See Label actors.
labelEvents["name"].actor.login
string
—
actor
The GitHub actor’s login. For a GitHub App, this is the App slug without [bot].
labelEvents["name"].actor.type
string
—
actor
GitHub’s actor type, such as Bot or User.
labelEvents["name"].createdAt
string
—
ISO 8601 UTC time of the last LabeledEvent.
reviewRequests.totalCount
int
—
Number of review requests.
reviewRequests.nodes[].requestedReviewer.login
string
—
see below
The first 10 review requests.
reviews.totalCount
int
—
Number of reviews.
reviews.nodes[]
list
—
The last 20 reviews: author.login (author nullable), state, body, submittedAt (nullable), commit.oid (commit nullable).
reviewThreads.totalCount
int
—
Number of review threads.
reviewThreads.nodes[]
list
—
The first 50 threads: isResolved, isOutdated, path, and comments with totalCount and the first 10 nodes, each with author.login (author nullable) and body.
comments.totalCount
int
—
Number of comments.
comments.nodes[]
list
—
The last 20 comments: author.login (author nullable), body, createdAt.
closingIssuesReferences.totalCount
int
—
Number of closing issue references.
closingIssuesReferences.nodes[]
list
—
The first 10 issues that the pull request closes: number, state.
requestedReviewer is null if the reviewer is a deleted account. A team review request has no login, so login reads as null.
Issue and pull request expressions can read item.labelEvents["ready-for-agent"].
Only current labels appear in the map. Removing and reapplying a label replaces its
entry with the latest addition’s actor and time. A deleted actor is null; a label
with no available history has no entry. Check membership with
"ready-for-agent" in item.labelEvents before indexing, then check actor != null
before reading its fields.
Polling fetches the last 100 LabeledEvent entries in the snapshot query. It reads
older pages only while current labels lack an event, up to ten pages in total. If
that limit prevents completing the map, the snapshot keeps the events found and
omits labels whose history is unavailable. The map’s actor fields affect event
deduplication; timestamps do not.
The actor identifies the GitHub account that applied the label. An operator action
through the board uses the App’s identity too.
The fields marked nullable above are nullable in the CEL environment. When such a field is null:
Comparing it with a value gives false: item.reviewDecision == "APPROVED" is false if the branch requires no review.
Comparing it with null, in either order, tests for a value: item.milestone != null, null == item.author.
Reading a field of a null object fails the evaluation: item.milestone.title == "v1" fails with No such key: title on an issue without a milestone. Test the object first: item.milestone != null && item.milestone.title == "v1". CEL’s && returns false if either side is false, even if the other side fails.
Selecting a field of a null object with .? gives an empty optional instead of failing: item.?milestone.?title.orValue("none") is "none" on an issue without a milestone. The null field itself counts as present, so item.?reviewDecision.orValue("NONE") is null if the branch requires no review. See Optional values.
has(item.milestone.title) is false, but has(item.milestone) is true, because the field exists. Test the value with != null.
Fields of a nullable object keep their types, so a misspelled item.milestone.titel still rejects the edit or import. Field names after .? aren’t checked.
In the body, {{ item.milestone != null ? item.milestone.title : "no milestone" }} and {{ item.?milestone.?title.orValue("no milestone") }} both render on every issue. A null value renders as null.
An evaluation failure leaves the stored loop definition unchanged:
if of an issue or pr loop. usine opens no run for that loop on that item and leaves the item’s queued runs as they are. Other loops, other items, and the poll cursor continue. Needs attention shows the failure with the loop and the item while it lasts, and usine logs it once per loop, item, and content hash. The first poll after a restart or an applied revision fetches failing items again, so a fixed loop evaluates them without waiting for a change.
if of a schedule loop. The tick fails for that repository, and usine evaluates it again at the next wake.
The recheck before a queued run opens. usine logs a warning, and the run opens as if the check had passed.
An approval condition. The run requires approval and logs a warning. The saved decision explains the evaluation failure.
Comparison: ==, !=, <, <=, >, >=. You can compare an int with a double.
Logic: &&, ||, !, and the conditional condition ? a : b.
Arithmetic: +, -, *, /, %. + also concatenates strings and lists.
Membership: value in list.
Literals: integers, doubles, strings in "..." or '...', true, false, null, lists [...], and maps {...}. A list or map literal must contain values of one type.
Parts of a timestamp, in UTC or in the time zone passed as an argument. getMonth and getDayOfMonth start at 0, getDate at 1, and getDayOfWeek is 0 on Sunday.
Subtracting two timestamps gives a duration, and durations compare. No function returns the current time. A schedule loop can use item.tick.scheduledAt.
.? and [?] select a value that might be missing. Instead of failing, they give an optional, which contains a value or is empty. Every selection after a .? in the same chain also gives an optional.
Syntax
Result
object.?field
The field’s value, or an empty optional if object is null or has no such field.
map.?key, map[?key]
The value at key, or an empty optional if the key is absent.
list[?index]
The element at index, or an empty optional if the index is out of range: item.labels.nodes[?0].?name.orValue("none").
o.orValue(fallback)
The value of o, or fallback if o is empty. fallback must have the value’s type.
o.or(other)
o if it contains a value, otherwise the optional other.
o.hasValue()
true if o contains a value.
o.value()
The value of o. Evaluation fails if o is empty.
optional.of(x), optional.none()
An optional that contains x, and an empty optional.
An if must still produce a bool, and an interpolation a scalar, so end the chain with orValue or hasValue(). {{ item.?milestone.?title }} fails validation with Expected a scalar value, got optional<string>.
cel-js doesn’t check field names after .?, so item.?milestone.?titel.orValue("none") == "v1" loads and is always false. In an interpolation, the same typo fails validation with Expected a scalar value, got dyn. In an if, prefer the != null form, which keeps field names checked.
When an instance loads, usine collects the string literals that a loop’s if compares with a label name under item.labels, through ==, !=, in, and the exists, all, exists_one, filter, and map macros. For each literal that the stored configuration doesn’t declare under labels, it logs Loop trigger references an undeclared GitHub label. The loop still loads.
The approval expression returns false for a User actor and true for other
actor types. Missing history or a null actor causes an evaluation error, which
requires approval and logs a warning. A board move uses the App identity and
requires approval under this condition. Use on: pr for the same policy on pull
requests. The loop’s max_cycles limit still applies.
A pull request is ready for review, and no outcome label is present:
Pull request {{ item.number }} is marked `ready-to-merge` but GitHub reports its branch `{{ item.headRefName }}` as conflicting with `{{ item.baseRefName }}`.
The scheduler evaluates priority against the saved event snapshot when the run requests a worker slot. Higher values go first; equal values use lane rank and then event arrival. The default is 0. Evaluation errors, including results outside the safe integer range, use 0 and produce a warning. The editor checks the result type and previews the value for each stored match.