Expressions
Expressions compute values from a device’s data. Nexigon Hub evaluates them to decide whether a device has taken the revision of a profile rollout. With fleet operations, a preview feature, they also select the target devices, decide whether a step runs, and decide when a step has finished waiting. For example, this expression checks whether a device’s update integration reports a completed system update:
properties["dev.nexigon.ota.status"].value.state == "completed"
The language is a subset of the
Common Expression Language (CEL) with one addition, the
version() function. Every Nexigon expression parses as CEL. Where
the CEL specification defines the value of an expression, Nexigon evaluates it
to the same value or reports an error.
Differences from CEL lists the cases where Nexigon
reports an error.
Evaluation Model
An expression reads variables that its context provides, such as properties,
which holds the device’s properties by name,
each with its value as value. It computes a value from them and has no side
effects. The result is either a value of any type or an error.
An error results from any operation that cannot produce a value, such as reading a property that the device has not reported, comparing a string with a number, or dividing by zero. Errors propagate: an operation that receives an error as an operand produces that error. No construct turns an error back into a value.
Because reading absent data is an error, an expression never holds by accident
for a device that has not reported the data it depends on. For example, this
expression produces an error for a device without dev.nexigon.ota.status, so
the device cannot pass as healthy:
properties["dev.nexigon.ota.status"].value.state != "failed"
Handle absent data explicitly where you expect it. Use in to test whether a
property or map key exists, and optional access to read
values that may be absent. This expression treats a device without a status as
idle, so it is true for that device:
properties[?"dev.nexigon.ota.status"].?value.?state.orValue("idle") != "failed"
The remaining examples on this page assume that an application publishes the
property com.example.app with a value such as this:
{
"enabled": true,
"version": "1.8.2",
"startedAt": "2026-10-22T08:00:00Z",
"features": { "beta": false },
"services": [{ "name": "api", "healthy": true }]
}
Variables
| Variable | Type | Value |
|---|---|---|
properties | map | All contexts. The device’s properties by name. |
now | timestamp | All contexts. The time of evaluation. It has the same value throughout one evaluation. |
rollout | map | Profile rollout expressions only. The rollout’s effect on the device. |
operation | map | Fleet operation steps only. The operation’s effect on the device. |
Each entry of properties has these members:
| Member | Type | Value |
|---|---|---|
value | any | The property’s value, converted as described in Property Values. |
version | int | The property’s version. |
rollout and operation have the member writes, a map of the properties
that the rollout or the operation’s earlier steps wrote on the device. Each
entry has the member version, the
property version that the
write created. Properties that were not written on the device are absent.
Contexts
Every context requires a bool result. Any other result is an error. Each
context decides how to handle errors:
| Context | On error |
|---|---|
| Profile rollout expressions | The expression counts as false; the other expression can still complete or fail the device. |
| Target selectors | The device is not selected. The error is recorded as a selection error. |
| Step conditions | The step fails. |
| Wait expressions | The step keeps waiting and shows the latest error. |
Validation
Nexigon Hub checks an expression when it is saved and rejects:
- Syntax errors, including invalid literals and duplicate keys in map literals.
- Variables, functions, or methods that the context does not provide.
- Calls with the wrong number of arguments.
- Literal arguments that can never be valid, such as
timestamp("yesterday"),version("v1"), or an invalid regular expression inmatches().
Nexigon Hub does not check types. All other errors, such as 1 + 1.0, occur
during evaluation.
Limits
The syntax tree of an expression may be up to 64 levels deep. Each operator,
call, field selection, and index adds a level, and so does each operator in a
chain such as a + b + c. Use in with a list instead of long chains of ||.
Evaluating an expression for one device may cost up to 100,000 units. Each evaluated part of an expression costs one unit, and operations additionally cost the length of the strings, lists, and maps they process. An evaluation that exceeds the limit is an error. The limit only affects expressions that iterate over large data or nest macros.
Syntax
Literals
| Type | Examples |
|---|---|
null | null |
bool | true, false |
int | 0, 42, -7 |
double | 3.14, .5, 1e6, 2.5e-3 |
string | "text", 'text', r"^v[0-9]+$" |
list | [], [1, 2, 3], ["a", "b"] |
map | {}, {"ring": "canary", "weight": 2} |
An int literal consists of an optional - and decimal digits, and must lie
within the int range. A double literal has a fractional part, an exponent,
or both, and must be finite. 5. is not a valid literal.
Strings use double or single quotes and support the escapes \\, \", \',
\n, \r, \t, \uXXXX, and \UXXXXXXXX. Escapes must denote Unicode scalar
values, so surrogate code points are invalid. Strings cannot contain line
breaks. A raw string, prefixed with r or R, does not process escapes, which
keeps regular expressions readable. To include the quote character in a raw
string, quote it with the other one, such as r'say "hi"'.
Map literals must have string keys, and each key may appear only once. List and
map literals may end with a trailing comma, such as [1, 2,]. Call arguments
may not.
Identifiers
An identifier starts with a letter or _, followed by letters, digits, or _.
The keywords true, false, null, and in and the following reserved words
are not identifiers: as, break, const, continue, else, for,
function, if, import, let, loop, package, namespace, return,
var, void, and while.
Operators
Operators in order of precedence, from highest to lowest:
| Operators | Description |
|---|---|
a.f, a[k], a.f(...) | Field selection, indexing, and method calls |
!a, -a | Logical negation and numeric negation |
*, /, % | Multiplication, division, and remainder |
+, - | Addition and subtraction |
==, !=, <, <=, >, >=, in | Equality, ordering, and membership |
&& | Logical and |
|| | Logical or |
c ? a : b | Conditional |
Binary operators associate to the left. ?: associates to the right, so
a ? b : c ? d : e means a ? b : (c ? d : e). Parentheses group
subexpressions. // starts a comment that runs to the end of the line.
Field Selection and Indexing
m.f and m["f"] both read the member f of a map. Use the index form for
member names that are not identifiers, such as property names with dots or
reserved words:
properties["dev.nexigon.ota.status"].value.currentVersion
l[i] reads the element at index i of a list, starting at 0. List indexes
must be int and map keys must be string.
Reading an absent member or an index outside the list, including a negative index, is an error. So is selecting a field of a value that is not a map, or indexing a value that is not a list or map.
Types
| Type | Values |
|---|---|
null | The JSON null value. |
bool | true and false. |
int | 64-bit signed integers. |
double | 64-bit IEEE 754 floating-point numbers. |
string | Unicode strings. |
list | Ordered sequences of values. |
map | Maps from strings to values. |
timestamp | Points in time, created by timestamp(). |
duration | Signed time spans, created by duration(). |
version | Software versions, created by version(). |
optional | A value or nothing, created by optional access. |
Property Values
Property values are JSON values. They convert to types as follows:
| JSON value | Type |
|---|---|
null | null |
true, false | bool |
| Number | int if written without fraction or exponent, other than -0, and between -2^63 and 2^63-1, otherwise double |
| String | string |
| Array | list |
| Object | map |
The type of a number depends on how the device writes it: 1 becomes an int
and 1.0 a double. Arithmetic does not mix the two, so convert reported
numbers with int() or double() before calculating with them.
Timestamps and versions in JSON are strings. Convert them with
timestamp() and version() to compare them as such.
Arithmetic
+, -, *, and / require two int or two double operands. % requires
two int operands.
int division truncates toward zero, and the remainder has the sign of the
dividend. Results outside the int range are errors, including
-(-9223372036854775808) and -9223372036854775808 / -1. int division or
remainder by zero is an error. double arithmetic follows IEEE 754, so
1.0 / 0.0 is positive infinity.
+ also concatenates two strings or two lists. Time values support the
arithmetic listed under Time.
Equality
== and != compare two values of the same type:
- Numbers compare by value across
intanddouble, so1 == 1.0istrue. nullcompares with any value and equals onlynull.- Lists are unequal if their lengths differ. Otherwise, their elements are compared in order.
- Maps are unequal if their keys differ. Otherwise, their values are compared in ascending key order.
- Timestamps, durations, and versions compare by value. Versions ignore build metadata.
Comparing values of other differing types is an error. The elements of lists
with equal lengths and the values of maps with equal keys follow the same rule,
so [1] == ["1"] is an error. This catches mistakes like comparing a reported
number with a string. Comparing optionals is an error.
Ordering
<, <=, >, and >= compare two numbers, two strings, two timestamps, two
durations, or two versions. Numbers compare by value across int and double.
Strings compare by Unicode code points. Other combinations are errors.
Membership
x in l tests whether a list contains an element equal to x, using the rules
of ==. k in m tests whether a map contains the string key k. It is false
for an absent key and an error if k is not a string.
Evaluation Order
Every operation evaluates its operands from left to right. When an operand is an error, the operation produces that error without evaluating the remaining operands.
Logical operators and the conditional operator evaluate only the operands they need:
| Expression | Result |
|---|---|
a && b | An error if a is an error or not a bool, false if a is false, otherwise b, which must be a bool. |
a || b | An error if a is an error or not a bool, true if a is true, otherwise b, which must be a bool. |
c ? a : b | An error if c is an error or not a bool, a if c is true, otherwise b. |
The operand of ! must also be a bool.
Operand order therefore decides whether a check protects the operands after it.
This expression is false for a device without com.example.app, because in
is evaluated first:
"com.example.app" in properties && properties["com.example.app"].value.enabled
With the operands swapped, the expression is an error for the same device. Because evaluation stops early, an error in a later operand only appears for devices whose data lets evaluation reach it. An expression can therefore work on test devices and fail on others.
Optional Values
Optional access reads a value that may be absent without producing an error.
m.?f and m[?k] on a map, and l[?i] on a list, return an optional. It
holds the value if it exists and is empty otherwise. These methods turn an
optional back into a value:
| Method | Result |
|---|---|
o.orValue(x) | The held value, or x if the optional is empty. x is only evaluated if the optional is empty. |
o.hasValue() | Whether the optional holds a value. |
o.value() | The held value. An error if the optional is empty. |
Continue a chain of optional accesses with .? or [?] at each step:
properties[?"com.example.app"].?value.?features.?beta.orValue(false)
This is false for a device without the property and for one whose property
lacks features or beta. Plain selection or indexing on an optional, as in
m.?a.b, is an error.
Optional access handles only absence: on a value that is not a map or list,
including null, it is an error.
Functions
Functions that create or convert a value are called as functions, such as
int(x). Functions that operate on a value are called as methods, such as
s.size().
Strings and Collections
| Function | Result |
|---|---|
x.size() | The number of elements of a list, entries of a map, or code points of a string. |
s.contains(t) | Whether string s contains t. |
s.startsWith(t) | Whether string s starts with t. |
s.endsWith(t) | Whether string s ends with t. |
s.matches(re) | Whether a part of s matches the regular expression re (RE2 syntax). Use ^ and $ to match all of s. |
The pattern of matches() must be a string literal. As in RE2, the Perl classes
\d, \w, and \s and the word boundaries \b and \B match ASCII
characters only, and the product of nested repetition counts is limited to 1000.
Nexigon additionally supports only these features of RE2:
- The flags
i,m,s, andU. - Unicode general categories by their abbreviation, such as
\pLor\p{Lu}. Scripts such as\p{Greek}are not supported. - Patterns that compile to at most 256 KiB, which rules out large repetitions of
Unicode classes, such as
\pL{1000}.
Conversions
| Function | Accepts |
|---|---|
int(x) | An int; a double, truncated toward zero; or a string of decimal digits with an optional leading -. |
double(x) | A double; an int; or a string in the syntax of a number literal with an optional leading -. |
string(x) | A string; an int; a bool; a timestamp, formatted in RFC 3339 in UTC, such as "2026-10-22T08:00:00.5Z"; or a duration, formatted in seconds, such as "60.001s". Timestamps and durations get as many fractional digits as needed. |
Arguments of other types, unparsable strings, and results outside the target
range are errors. This includes int() of NaN or an infinity, and double() of
strings such as "1e400" or "NaN".
Time
timestamp(s) parses an RFC 3339 string, such as "2026-10-22T08:00:00Z" or
"2026-10-22T10:00:00+02:00". It requires uppercase T and Z, allows up to
nine fractional digits, and accepts timestamps from 0001-01-01T00:00
duration(s) parses an optional sign followed by one or more numbers, each with
a unit, such as "1h30m", "-2.5s", or "48h". The units are h, m, s,
ms, us, and ns. "0" is the zero duration. A fraction must amount to a
whole number of nanoseconds, so "1.5us" is valid and "1.5ns" is not.
Durations are limited to the range of 64-bit nanoseconds, about 292 years in
either direction.
Unparsable strings and results outside these ranges are errors. Time values support this arithmetic:
| Expression | Result |
|---|---|
timestamp - timestamp | duration |
timestamp + duration | timestamp |
timestamp - duration | timestamp |
duration + duration | duration |
duration - duration | duration |
Versions
version(s) parses a version string. A version consists of dot-separated
numeric release components, an optional prerelease suffix after -, and
optional build metadata after +. Examples are 5, 2.1.0, 2026.01.15, and
2.1.0-rc.1+build.7. This covers semantic versions, calendar versions, and
single integers such as build numbers.
The prerelease and the build metadata consist of dot-separated identifiers of
ASCII letters, digits, and hyphens. No component or identifier may be empty, and
numbers must fit into 64 bits. Surrounding whitespace is ignored. Strings that
do not follow this format, such as v2.1.0 or build-20260401120000-abc1234,
are errors. The language has no functions to remove such prefixes, so report
versions in a separate property or member if your version strings carry them.
Versions compare as follows:
- Release components compare numerically from left to right. Leading zeros and
trailing zero components are ignored, so
version("5") == version("5.0.0")andversion("2026.01") == version("2026.1"). - A version with a prerelease sorts before the same release without one.
- Prereleases compare their dot-separated identifiers from left to right. Numeric identifiers compare numerically, ignoring leading zeros, and sort before other identifiers, which compare in ASCII order. If all identifiers of one prerelease match the start of the other, the shorter one sorts first.
- Build metadata does not affect comparisons.
Combine comparisons to express a range:
version(properties["com.example.app"].value.version) >= version("1.8")
&& version(properties["com.example.app"].value.version) < version("2")
This range includes prereleases of 2, such as 2.0.0-rc.1, because they sort
before 2. To exclude them, compare with version("2-0"), the lowest possible
prerelease of 2.
Macros
Macros bind each element of a list, or each key of a map, to the name x and
evaluate the expression p for it:
| Macro | Result |
|---|---|
c.all(x, p) | Whether p is true for every element. |
c.exists(x, p) | Whether p is true for at least one element. |
Lists are processed in order and map keys in ascending order of Unicode code
points. Processing stops at the first element that decides the result or at the
first error. p must be a bool; other values are errors. all is true and
exists is false for an empty list or map.
x must be an identifier that is neither a variable of the context nor
__result__, which CEL reserves. Macros can be nested.
properties["com.example.app"].value.services.all(s, s.healthy)
Examples
Target selector that matches devices with the beta feature enabled:
properties[?"com.example.app"].?value.?features.?beta.orValue(false)
Target selector that matches devices running a version of the application older than 2:
version(properties["com.example.app"].value.version) < version("2")
Wait step that finishes once all services of the application are healthy:
properties["com.example.app"].value.services.all(s, s.healthy)
Wait step that finishes once the application has run for two hours:
now - timestamp(properties["com.example.app"].value.startedAt) >= duration("2h")
Completion expression of a profile rollout that completes a device once its
update integration has acted on the rollout’s change to dev.nexigon.ota.config
and completed the update:
properties["dev.nexigon.ota.status"].value.configVersion
>= rollout.writes["dev.nexigon.ota.config"].version
&& properties["dev.nexigon.ota.status"].value.state == "completed"
The update integration reports the version of dev.nexigon.ota.config that it
last read as configVersion, in the same write as the state that results from
that configuration. A value of at least the version of the rollout’s write
therefore means that state reflects the rollout’s change. Until the device
reports such a status, the expression is false, or an error if no status
exists. In both cases, the device stays active.
Differences from CEL
The comparison with CEL assumes a CEL environment with the optional types
extension and the variables of the context, with property values converted as in
Property Values. CEL’s standard JSON conversion differs: it
turns every number into a double. In that environment, where the CEL
specification defines the value of an expression, Nexigon returns the same value
or an error.
The specification leaves some results open, and Nexigon defines them: the exact
format of string() for timestamps and durations, and the order in which macros
iterate over map keys. CEL implementations may produce other results in these
cases.
Nexigon reports an error where the specification defines a value in these cases:
- Logical operators evaluate left to right and produce the first error. CEL
ignores an error if the other operand decides the result, so
<error> && falseisfalsein CEL. - Macros stop at the first error. CEL’s
existsistrueif any element matches, even if another element produces an error, andallisfalseunder the same condition. - Equality and membership of values with different types are errors, except
for numbers and
null. In CEL,"a" == 1and"1" in [1]arefalse. - Ordering of
boolvalues is an error. In CEL,false < true. - Optional chains require
.?or[?]at each step. In CEL, plain selection and indexing after an optional access also return optionals. - Comparing optionals is an error. CEL compares optionals by their values.
- Overloads and formats are limited to those on this page. For example,
string(1.5)andduration + timestampare errors, anddouble()andduration()reject strings that some CEL implementations accept, such as"Inf"and"1.5ns".
Nexigon supports only the syntax, types, functions, macros, and regular
expression features on this page. Among others, it omits unsigned integers,
bytes, hexadecimal literals, triple-quoted strings, protocol buffer messages,
type values, has(), the macros exists_one, map, and filter, and patterns
of matches() that are not literals.