Skip to main content

Module transform

Module transform 

Source
Expand description

The Transform node’s evaluator: shape lists and objects with a restricted expression language and no code execution (docs/specs/SPEC_DRONE_GENERAL_AUTOMATION_2026_11_11.md §3.9).

Module A of the engine. The types, the bounds and taint_out are fixed here; evaluate is the module’s job. Its acceptance tests are transform_acceptance_tests.rs. The language itself (the tokenizer, the parser and the evaluator) is in expr.rs, the operations are in ops.rs, and the module’s own unit tests are in tests.rs; all three are private to this module.

§Expression grammar

Lowest precedence first; all binary operators are left associative.

expr    := or
or      := and ( "||" and )*
and     := not ( "&&" not )*
not     := "!" not | cmp
cmp     := sum ( ( "==" | "!=" | "<" | "<=" | ">" | ">=" | "contains" | "matches" | "in_set" ) sum )?
sum     := prod ( ( "+" | "-" ) prod )*
prod    := unary ( ( "*" | "/" | "%" ) unary )*
unary   := "-" unary | atom
atom    := number | string | "true" | "false" | "null" | list | call | path | "(" expr ")"
list    := "[" ( expr ( "," expr )* )? "]"
call    := name "(" ( expr ( "," expr )* )? ")"      // lower, trunc, default, exists
path    := name ( "." name )*                         // item, item.user.login, index
string  := 'text' or "text"                           // no escapes beyond \' \" \\
  • item is the current element and index its position (0-based) inside map, filter and the key expressions (by). A missing path is null, never an error.
  • a contains b: a string contains a substring, or a list holds an element. a matches 're': the Rust regex crate (linear time) on a string. The pattern must be a string literal, compiled once when the chain is read, so no element pays for a compile. a in_set [..]: the list holds a (JSON equality).
  • lower(s), trunc(s, n) (at most n characters), default(x, d) (d when x is null), exists(path) (the path is not null). No other function exists, no variable, no assignment, no loop, no recursion, no call to the host and no network: an unknown name is TransformError::Expr.
  • Arithmetic is on numbers only; / by zero and % by zero are errors; an integer result stays an integer (1 + 2 is 3, not 3.0).
  • Comparing values of different types is false for ==, true for !=, and an error for <, <=, >, >=.

Re-exports§

pub use condition::evaluate_condition;

Modules§

condition 🔒
The Condition block’s richer expressions run on the Transform expression language (docs/specs/SPEC_DRONE_REAL_WORLD_JOBS_2026_11_11.md §4.1): &&, ||, !, grouping, contains, matches, in_set, exists and the filters, with every bound the language has (source size, nesting, operations, a linear-time regex). The block turns each {{reference}} into a name bound to the value it holds, so the expression is read as written and what a reference holds is never read as syntax.
expr 🔒
The Transform expression language: the tokenizer, the parser and the evaluator (docs/specs/SPEC_DRONE_GENERAL_AUTOMATION_2026_11_11.md §3.9).
ops 🔒
The Transform operations: one function per TransformOp, and the chain runner (docs/specs/SPEC_DRONE_GENERAL_AUTOMATION_2026_11_11.md §3.9).

Structs§

Transform

Enums§

BoundKind
Which bound a node went over.
TransformError
TransformOp
One step of a chain. A chain reads top to bottom, each result feeding the next.

Constants§

MAX_ITEMS
An input of at most this many items (§3.9).
MAX_OPERATIONS
An evaluation budget per node: one unit per element an operation visits and per expression node evaluated (§3.9).
MAX_OUTPUT_BYTES
An output of at most the state cap, in bytes of JSON (§3.2).
MAX_REGEX_BYTES 🔒
A compiled matches pattern may be at most this big: a pattern that would compile to more is an expression error, so a hostile one cannot make the compiler work without bound.

Functions§

chain_taint
The bits of a chain’s output: taint_out applied step by step, starting from the input’s.
check_items 🔒
The item bound: an input list, or a list a step makes, of more than MAX_ITEMS.
check_output 🔒
The output bound, checked after every step so a runaway intermediate stops early rather than filling memory first.
evaluate
Run t over input. The output’s bits are chain_taint of the chain. Every bound of §3.9 is checked and named in TransformError::Bound.
expr_step 🔒
expressions_of
The expressions an op carries, for the validator and the canvas.
op_names
Every op as it is written in a graph, with a few words for the canvas.
op_step 🔒
taint_out
What an operation does to the taint bits of the value it reads (the table of §3.9 and the derived-value rule of §4.5). Returns (tainted, derived).