Skip to main content

Module script

Module script 

Source
Expand description

Workflow documents written as Rhai scripts.

A script builds the same document JSON states, and Document::parse then reads it: the graph a script produces is type-checked, cost-bounded and stored exactly as a hand-written one is. What a script adds is variables, functions, loops and comments – a library of twelve near-identical review workflows is a loop rather than twelve copies.

The script runs once, when a document is read. It never runs during a pass, never sees a unit, and decides no guard: were it to, the worst case could not be computed before activation, and a proposed revision would be code rather than data. A revision therefore stores the generated document, and --emit-json prints it, so what was activated is readable without the script.

The engine is built without a clock and without modules (no_time and no_module in Cargo.toml), with eval disabled and every limit set, so the same script yields the same document on every machine.

Structs§

Graph
A graph under construction, and the value a script passes from one combinator to the next. It carries its own output port, so a stage is wired by application rather than by repeating a node’s name in an edge list, and a reusable piece of a graph is an ordinary function from Graph to Graph.

Functions§

script_json
The document a script returns, as JSON. Kept separate from from_script so --emit-json can print it without validating twice.