01 · Pipeline spec
Status: Implemented (T6) · Owner: Platform ·
Code: engine/crates/flux-core/src/{spec.rs,formula/,validate.rs}, control-plane/src/flux_cp/pipelines/
A pipeline version is one JSON document: nodes, edges, per-node configuration, optional
partitioning, compute settings and notifications. It’s stored as config kind pipeline
(10) and executed by the engine (02).
One source of truth, two languages
Section titled “One source of truth, two languages”flowchart LR rs[Rust types<br/>flux-core/spec.rs] -->|schemars, golden test| schema[pipeline.schema.json] schema -->|copied, parity test| py[control plane<br/>jsonschema] rs --> val[Rust validator<br/>validate.rs] val --> cli[flux-cli validate --json] cli --> py val --> runner[flux-runner at run start] val --> preview[flux-preview in canvas]
- The Rust types define the spec.
json_schema()generatesflux-core/schema/pipeline.schema.json, and a test fails when the file is stale (FLUX_UPDATE_SCHEMA=1 cargo test -p flux-core). - The control plane keeps a byte-identical copy (
flux_cp/schemas/). A test compares the two files. - Save checks structure only (JSON Schema), so the canvas can save drafts.
- Activate runs the full Rust validator through
flux-cli validate --json. A version with any error can’t become active, and version 1 is only auto-activated when it’s valid. - The runner validates again when a run starts and fails loudly if it can’t.
Document shape
Section titled “Document shape”{ "spec_version": 1, "name": "Monthly revenue", "compute": { "profile": "small", "shards": 1 }, "nodes": [ { "id": "orders", "type": "extract", "config": { "connection": "erp-pg", "object": "public.orders" } }, { "id": "completed", "type": "filter", "config": { "condition": "status = 'COMPLETED'" } }, { "id": "out", "type": "target", "config": { "kind": "dataset", "dataset": "orders_completed", "key": ["order_id"] } } ], "edges": [ { "from": "orders", "to": "completed" }, { "from": "completed", "to": "out" } ], "notifications": [ { "on": ["failed"], "channel": "email", "to": ["ops@nasterra.com"] } ]}A complete example is engine/crates/flux-core/examples/monthly_revenue.json. It’s used
as a golden fixture by both the Rust and Python tests.
- Node =
id(a-z, 0-9,_,-; max 63) +type+config, optionallabel,partition(03) andposition(canvas only). - Edge =
from[.from_port] →to[.to_port]. Ports default to the node’s primary port. Any output can feed any number of inputs; an input takes one edge, except Union’sin, which takes any number. uiandpositionare ignored by the engine.
Node types and ports
Section titled “Node types and ports”| Type | Inputs | Outputs | Config |
|---|---|---|---|
extract |
— | out |
connection, object | query, columns, mode full/incremental + watermark, split, options, broadcast |
map |
in |
out |
fields[{name, expr?, type?}], keep_unmapped (choose, rename, cast, compute) |
calculate |
in |
out |
fields[{name, expr, type?}]: add or overwrite columns; later fields see earlier ones |
filter |
in |
out |
condition |
aggregate |
in |
out |
group_by[], measures[{name, expr}]: expr is an aggregate formula |
join |
left, right |
out |
how inner/left/right/full/semi/anti, on[{left,right}], right_prefix |
lookup |
in, lookup |
out |
on, fields[{from, name?}], missing null/drop/fail, duplicates fail/first |
union |
in (many) |
out |
by name/position, distinct |
route |
in |
one per route + default_port |
routes[{port, condition}], mode first_match/all_matches |
dedupe |
in |
out |
keys[], keep first/last, order_by[] |
sort |
in |
out |
by[{column, desc, nulls_first}] |
window |
in |
out |
partition_by[], order_by[], fields[{name, expr}], frame |
limit |
in |
out |
rows |
repartition |
in |
out |
partition |
validate |
in |
valid, invalid |
rules[{name, check…}], on_invalid route/fail/warn, max_invalid_ratio |
target |
in |
— | kind: dataset (dataset, key, mode replace/append/upsert, description) or kind: connection (connection, object, mode, key, options) |
Validate rules: not_null, range {min,max}, in_set {values}, regex {pattern},
expr {expr}. Invalid rows carry a _flux_errors list naming the failed rules.
Formula language
Section titled “Formula language”Row expressions with spreadsheet-style syntax and SQL semantics. The full reference is
generated from the Rust catalogue (/docs/reference/formulas/).
- Columns:
amount,[Customer Tier],`unit price`. Text:'…'or"…"(double the quote to escape it). Numbers: integers, exact decimals,1_000,1e3. - Operators:
+ - * / %,&(concatenate), comparisons,AND OR NOT(and&& || !),IN,BETWEEN,LIKE/ILIKE,IS [NOT] NULL,CASE,CAST(x AS T). - 85 functions in three classes: scalar (anywhere), aggregate (Aggregate measures and Window fields), window (Window fields only). Nesting aggregates is an error.
- Aggregate context: columns outside an aggregate call must be in
group_by. - Errors carry a position, and unknown functions suggest the closest name
(
unknown function ROUDN; did you mean ROUND?). Parser depth is capped at 128, so hostile input can’t overflow the stack.
The AST (formula::Expr) is engine-neutral. The executor lowers it to DataFusion
expressions (02).
Validation rules
Section titled “Validation rules”Diagnostics have severity, a stable code, node, field (a dotted path inside the
config, e.g. measures.0.expr) and a readable message. The canvas uses node and field
to highlight the exact input.
| Area | Codes |
|---|---|
| Spec | spec.version, spec.empty, spec.no_target, spec.parse, spec.schema |
| Nodes and edges | node.id, node.duplicate_id, node.unconnected_input, node.unused_output (warning), edge.unknown_node, edge.bad_output_port, edge.bad_input_port, edge.duplicate_input, edge.no_input, edge.no_output, edge.port_required, graph.cycle |
| Config | formula.invalid, extract.*, map.*, aggregate.*, join.keys, lookup.*, route.*, validate.*, target.* (including target.duplicate: two targets writing one dataset) |
| Compute | compute.profile, compute.cpu (0.5 steps, custom only), compute.memory, compute.shards (1–64), compute.shard_key, compute.timeout |
| Concurrency | partition.*, shard.* (03) |
The report also returns order, a topological execution order that keeps the spec
order among independent nodes.
POST /api/pipelines/validate: full report for a draft (viewer).GET /api/pipelines/functions: function catalogue for autocomplete.GET /api/pipelines/schema: the JSON Schema.- Versions:
/api/config/pipeline/{key}/…(10). - CLI:
flux-cli validate [file|-] [--json](exit 0 valid, 1 invalid, 2 I/O),flux-cli schema,flux-cli functions.
Open questions
Section titled “Open questions”- Port naming for future multi-output nodes (e.g.
split_by_valuewith dynamic ports). - Spec migration when
spec_versionbecomes 2: plan anupgrade(v1) -> v2function in flux-core, run on read, with the stored body unchanged until the next save.