Skip to content

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).

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() generates flux-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.
{
"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, optional label, partition (03) and position (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’s in, which takes any number.
  • ui and position are ignored by the engine.
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.

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).

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.
  • Port naming for future multi-output nodes (e.g. split_by_value with dynamic ports).
  • Spec migration when spec_version becomes 2: plan an upgrade(v1) -> v2 function in flux-core, run on read, with the stored body unchanged until the next save.