The same text is served as raw Markdown at https://openflange.dev/agents.md. Every command below was run with the openflange runner built from commit 11cf8cc5378d of https://github.com/openflange/openflange-go on 2026-12-03, and its output is quoted exactly as printed. Durations (completed in 4ms) differ from run to run, and /work/signups-etl stands for the directory the commands ran in.
What OpenFlange is #
OpenFlange is an open standard for describing, connecting and running data-processing steps, called pipes: each pipe declares its inputs, outputs and parameters, so the same step runs from a terminal, over HTTP, inside a query or on a visual canvas.
Status: draft v0.1, experimental; the format may still change. The reference runner (the openflange command, written in Go), the standard library of 28 pipes, lockfiles, portable tests and batch mode are in release v0.0.1 (experimental): go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1. There are no prebuilt binaries yet. A visual designer and a hosted registry are not available yet.
The words used below:
- Pipe: one data-processing step with named input ports, named output ports and parameters. It is described by a manifest file,
OPENFLANGE.md. - Port: a named input or output. Its
kindsays what flows through it:records(JSON values, one per line: NDJSON),values,text(for example a CSV file),windows,batchesorbinary. - Pipeline: a file,
pipeline.yaml, that lists nodes (each node is one use of a pipe) and connects their ports. A pipeline with a manifest is itself a pipe. - Runner: the program that validates and runs pipes and pipelines. Here it is the
openflangecommand. - Standard pipe: a pipe built into every runner, referenced as
std:<name>(for examplestd:filter). - Grant: a permission given to a node or a run (start a subprocess, open a network connection, read or write a path). Without grants a pipe can only transform the data it is given.
When it fits an ETL request, and when it does not #
Choose OpenFlange when the request looks like this:
- An extract-transform-load or clean-up job over files or streams of records (CSV, NDJSON) made of several steps: decode, clean, validate, convert types, filter, deduplicate, route, re-encode.
- The user wants the job as files they can read, review and keep in Git, not as one opaque script.
- Bad rows must go somewhere visible. Standard pipes send them to a
rejectedoutput or fail the run; nothing is dropped silently. - The job should be testable (
openflange test) and reproducible (openflange resolve, thenrun --locked). - Steps are written in different languages (Starlark in-process, Python, Node, R, any executable, SQL through DuckDB) and must still connect.
- The same step should later run from a terminal, from a scheduler and over HTTP (
openflange serve).
Do not choose it, or say what else is needed, when:
- The user needs a scheduler. OpenFlange does not schedule, retry or monitor anything. Cron, a CI job or a workflow engine calls
openflange run; see https://openflange.dev/etl/. - The user needs a warehouse or a database. OpenFlange stores nothing and has no query engine. A pipe may call a database, but that pipe is yours to write.
- The user needs ready-made connectors. There is no catalogue of hundreds of connectors. The standard library reads and writes NDJSON files, standard input and output, and fetches NDJSON with one HTTP GET. Anything else (Parquet, a database, an API with paging, cloud storage) is a custom pipe.
- A tiny one-off will do. One
jq,awkor ten lines of Python that nobody will run twice does not need a manifest, a pipeline file and a test. Say so and write the script. - The data does not fit one machine. The runner is one process on one machine. Record-by-record steps use bounded memory; grouping and sorting hold their group or the whole input in memory.
- The user needs a stable, released product. This is a draft, v0.1, with one experimental release (v0.0.1).
If you choose it, tell the user that it is an experimental draft and that the runner is release v0.0.1, installed with Go.
Install #
Prerequisites: the Go toolchain, version 1.27 or newer (the runner's go.mod says go 1.27), and network access to fetch the module. Nothing else is needed for the standard pipes and for Starlark pipes: they run inside the runner. A pipe written in Python, Node or R needs that interpreter on PATH.
go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1The binary is written to $(go env GOPATH)/bin (usually ~/go/bin); put that directory on PATH. Check the installation and the version:
openflange versionIt printed (exit status 0):
openflange 0.0.1 (go1.27.1 linux/amd64)openflange version --capabilities also lists the specification versions, the languages found on this machine and the standard pipes of this runner. openflange help and openflange help <command> print the commands and flags.
@v0.0.1installs the first tagged release, which is experimental.@maininstalls the latest development version instead.- Release notes: https://github.com/openflange/openflange-go/releases/tag/v0.0.1. Changelog: https://github.com/openflange/openflange-go/blob/main/CHANGELOG.md.
- Without Go there is no way to install the runner today: no binaries, no Homebrew formula, no container image, no npm or pip package.
- Claude Code users can install the OpenFlange skills instead of pasting this guide:
/plugin marketplace add openflange/ai-plugin, then/plugin install openflange@openflange(https://github.com/openflange/ai-plugin; its README has an AGENTS.md snippet and a Cursor rule for other agents). The install commands come from Claude Code's documentation and the plugin passesclaude plugin validate; the install has not yet been run end to end.
The complete minimal file set #
The example used on this whole page: read a CSV of signups, normalise the e-mail address, validate every row, convert age to an integer, write the valid rows as NDJSON and the invalid rows to a second output. It uses standard pipes only. Create a directory named signups-etl with these five files; every one is shown in full.
signups-etl/
├── openflange.yaml
├── OPENFLANGE.md
├── pipeline.yaml
├── signups.csv
└── tests/
└── signups-etl.test.yamlFour of them are the job (openflange.yaml, OPENFLANGE.md, pipeline.yaml and the test); signups.csv is sample data. Paths in the commands below are relative to this directory.
openflange.yaml: the project root #
File openflange.yaml:
spec: openflange.org/package/v0.1
default: .
pipes:
- .This file marks the project root. openflange resolve writes the lockfile, openflange.lock.yaml, next to it. Without it the runner takes the nearest parent directory that contains .git as the root, so inside somebody's repository openflange resolve would lock every pipe of that repository and write the lockfile at its top. default names the pipe that a reference to this directory selects; pipes lists the manifests of the package. A pipe in a sub-directory that pipeline.yaml references by path (./pipes/window-mean) works whether or not it is listed under pipes.
OPENFLANGE.md: the manifest of the job #
File OPENFLANGE.md:
---
spec: openflange.org/pipe/v0.1
id: signups-etl
version: 0.1.0
title: Signups ETL
description: Reads a signups CSV, normalises the e-mail address, validates every row and writes the valid rows as NDJSON; invalid rows go to `rejected`.
license: Apache-2.0
maturity: experimental
inputs:
csv:
kind: text
mediaTypes: [text/csv]
description: 'CSV with a header row: email,country,age.'
outputs:
clean:
kind: records
description: 'Valid rows: {"email", "country", "age"} with a lower-case e-mail address and an integer age.'
rejected:
kind: records
required: false
description: 'Invalid rows as {"item", "errors"}. If not connected, the first invalid row fails the run.'
implementation:
type: pipeline
path: pipeline.yaml
---
# Signups ETL
Implements the [OpenFlange](https://openflange.org/) specification.
CSV in, NDJSON out: decode, clean, validate, cast.- The file name is exactly
OPENFLANGE.md. The first line is---; the YAML between the two---lines is the contract; the Markdown below is documentation. - Required keys:
spec(the constantopenflange.org/pipe/v0.1),id(lower-case letters, digits and-),version(SemVer) andimplementation. Unknown top-level keys are an error. - The Markdown body MUST contain a link whose target is exactly
https://openflange.org/. Keep the sentenceImplements the [OpenFlange](https://openflange.org/) specification.Without it validation fails withE_ATTRIBUTION. implementation: {type: pipeline, path: pipeline.yaml}says that this pipe is the pipeline in the next file. Itsinputsandoutputsare the ports of the job as a whole.- The manifest is what lets the job read CSV: the input
csvis declared withkind: text. Apipeline.yamlrun on its own, without a manifest, has onlyrecords(NDJSON) inputs. - A port is required unless it says
required: false.rejectedis optional here: a caller who does not connect it gets a failed run on the first invalid row instead of a silent drop. - YAML rules for every OpenFlange file: no anchors, aliases or merge keys, no duplicate keys, no custom tags;
yesandnoare strings. - Parameters of the job are declared in the manifest (
parameters: {size: {type: integer, default: 3, minimum: 1}}), andpipeline.yamlrefers to them with{$param: size}. Apipeline.yamlthat belongs to a manifest has noparameterssection of its own. - An input or output that carries NDJSON records is declared with
kind: records; nomediaTypesare needed.
pipeline.yaml: the steps and their connections #
File pipeline.yaml:
spec: openflange.org/pipeline/v0.1
nodes:
decode:
pipe: std:csv-decode
inputs:
in: {from: inputs.csv}
clean:
pipe: std:map
inputs:
in: {from: decode.outputs.out}
parameters:
expr: 'dict(item, email=item["email"].strip().lower())'
check:
pipe: std:validate-schema
inputs:
in: {from: clean.outputs.out}
parameters:
schema:
type: object
required: [email, country, age]
properties:
email: {type: string, pattern: "^[^@ ]+@[^@ ]+$"}
country: {type: string, minLength: 2, maxLength: 2}
age: {type: string, pattern: "^[0-9]+$"}
typed:
pipe: std:cast
inputs:
in: {from: check.outputs.valid}
parameters:
fields: {age: integer}
outputs:
clean: {from: typed.outputs.out}
rejected: {from: check.outputs.rejected}- Each key under
nodesis a node id (^[a-z][a-z0-9_-]{0,63}$). The idsinputs,outputs,params,env,stdandbuiltinare reserved. pipeis a reference:std:<name>for a standard pipe,./relative/pathfor a directory that contains anOPENFLANGE.md.- Connections are written once, on the consumer:
inputs: {<port>: {from: <source>}}. A source isinputs.<name>(an input of the whole job) or<node>.outputs.<port>. There is noconnectionssection and nodepends_on. - The top-level
outputsmap names the outputs of the whole job; each takes{from: <node>.outputs.<port>}. - One output may feed any number of consumers (the node still runs once). One input has exactly one producer; to combine streams use
std:mergewithin: {from: [a.outputs.out, b.outputs.out]}. - Every required output of every node must be consumed, or discarded on purpose with
outputs: {<port>: {discard: true}}on that node. An optional output with no consumer is simply off.discard: truealso works on an optional output: its records are produced and thrown away on purpose, for exampleoutputs: {rejected: {discard: true}}on astd:validate-schemanode drops invalid rows instead of failing. parametersare literal YAML values.{$param: name}takes the value of a parameter of the enclosing job, and{$expr: "<starlark over params>"}computes one before the node starts.- Expressions (
expr,key,partitionBy) are Starlark, a small Python dialect. Two names exist in them:item(the current record) andparams. Quote them with single quotes in YAML so thatitem["email"]needs no escaping. std:csv-decodeemits every value as a string. Convert withstd:castafter validating, as here.
tests/signups-etl.test.yaml: a portable test #
File tests/signups-etl.test.yaml:
spec: openflange.org/test/v0.1
tests:
- name: cleans, validates and casts
inputs:
csv:
text: |
email,country,age
Ada@Example.com,GB,36
not-an-email,FR,41
expect:
outputs:
clean:
values:
- {email: ada@example.com, country: GB, age: 36}
rejected: {count: 1}
- name: without a rejected consumer an invalid row fails the run
inputs:
csv: {text: "email,country,age\nnot-an-email,FR,41\n"}
expect:
status: failed
error: {code: E_RUNTIME}
outputs:
rejected: {disabled: true}- A file
tests/<anything>.test.yamlbeside a manifest tests that manifest. Addpipe: <reference>at the top to test something else (pipe: ../pipeline.yaml,pipe: std:filter). - Each test is one independent run.
inputs.<port>takes{values: [...]}(one list element per record),{text: "..."}(raw text, fortextports such as CSV) or{file: path}. expect.outputs.<port>takesvalues(exact records, in order; member order inside an object does not matter),count,schema(a JSON Schema every record must satisfy),ordered: false, ordisabled: true(run with this optional output not connected).expect.status: failedwithexpect.error.codeasserts a failure. Validation errors count: a wrong parameter is observed asfailedwithE_PARAM.- Parameters of the job under test go in
parameters:; permissions ingrants:(for examplegrants: {subprocess: true}). - For a
textoutput (CSV)expect.outputs.<port>takes{text: "..."}, compared byte for byte. Assertions can be combined, for examplecountwithschema. Afile:path is relative to the test file. - The
messagetext inside a rejected record is worded differently for each schema keyword (pattern,enum,minimum, ...) and no document promises its wording. Assert rejected outputs withcountorschemarather than exactvalues.
signups.csv: sample input #
File signups.csv:
email,country,age
Ada@Example.com,GB,36
bob@example.org,US,abc
carol@example.net ,DE,29
not-an-email,FR,41Row 2 has a non-numeric age, row 3 has spaces around the address, row 4 has no @. Two rows are valid after cleaning.
The command loop: validate, test, run, lock #
Run the commands in the project directory. The target . is the pipe whose OPENFLANGE.md is in the current directory.
openflange validate .: check every file without running anything. Repeat after every edit until it printsvalid.openflange test .: run the portable tests.openflange run . --input <port>=<file> --output <port>=<file>: run the job on real data.openflange resolve, thenopenflange run . --locked ...: record exactly what ran and refuse to run anything else.
There is no openflange lock command: the lockfile is written by openflange resolve and moved forward by openflange update. openflange init scaffolds a single pipe, not a pipeline project; it is described after the main loop because the job above needs no pipe of its own.
validate: check without running #
Compiles the manifest and the pipeline: YAML, references, port names, connections, parameter names and types, Starlark syntax, permissions. Exit status 0 means valid, 2 means invalid; every problem is reported in one pass.
openflange validate .It printed (exit status 0):
valid: . (4 nodes, 6 edges)--plan prints what would run: nodes in execution order, resolved parameters with defaults, every edge and its media type. Read it when a connection is not what you meant.
openflange validate . --planIt printed (exit status 0):
PLAN . (pipe signups-etl@0.1.0)
INPUTS
csv text
NODES (execution order)
1. decode std:csv-decode [builtin, local-go]
pipe csv-decode@0.1.0
params delimiter="," header=true
in in <- inputs.csv
out out -> clean.inputs.in
2. clean std:map [builtin, local-go]
pipe map@0.1.0
params expr="dict(item, email=item[\"email\"].strip().lower())"
in in <- decode.outputs.out
out out -> check.inputs.in
3. check std:validate-schema [builtin, local-go]
pipe validate-schema@0.1.0
params schema={"properties":{"age":{"pattern":"^[0-9]+$","type":"string"},"country":{"maxLength":2,"minLength":2,"type":"string"},"email":{"pattern":"^[^@ ]+@[^@ ]+$","type":"string"}},"required":["email","country","age"],"type":"object"}
in in <- clean.outputs.out
out rejected -> outputs.rejected
out valid -> typed.inputs.in
4. typed std:cast [builtin, local-go]
pipe cast@0.1.0
params fields={"age":"integer"} onError="fail"
in in <- check.outputs.valid
out out -> outputs.clean
out rejected -> (not connected)
OUTPUTS
clean records <- typed.outputs.out
rejected records optional <- check.outputs.rejected
EDGES
inputs.csv -> decode.inputs.in text/csv
decode.outputs.out -> clean.inputs.in application/x-ndjson
clean.outputs.out -> check.inputs.in application/x-ndjson
check.outputs.valid -> typed.inputs.in application/x-ndjson
typed.outputs.out -> outputs.clean application/x-ndjson
check.outputs.rejected -> outputs.rejected application/x-ndjson
CONVERSIONS
(none)
valid: . (4 nodes, 6 edges)test: run the portable tests #
With a directory that holds an OPENFLANGE.md it runs the tests of that pipe only (the files in its tests/ directory). A pipe in a sub-directory needs its own target, and several targets can be given: openflange test . ./pipes/window-mean. With a directory that has no manifest it runs every *.test.yaml below it. Exit status 0: all passed; 1: a test failed; 2: a test file is invalid.
openflange test .It printed (exit status 0):
tests/signups-etl.test.yaml
ok cleans, validates and casts
ok without a rejected consumer an invalid row fails the run
ok 2 tests passed in 1 file (8ms)run: execute the job #
--input name=path binds an input port to a file, --output name=path an output port; - means standard input or output. The summary line goes to standard error and reports the number of records per output.
openflange run . --input csv=signups.csv --output clean=clean.ndjson --output rejected=rejected.ndjsonIt printed (exit status 0):
completed in 551µs — clean: 2 records, rejected: 2 recordsThe command wrote clean.ndjson:
{"email":"ada@example.com","country":"GB","age":36}
{"email":"carol@example.net","country":"DE","age":29}The command wrote rejected.ndjson:
{"item":{"email":"bob@example.org","country":"US","age":"abc"},"errors":[{"path":"/age","message":"'abc' does not match pattern '^[0-9]+$'"}]}
{"item":{"email":"not-an-email","country":"FR","age":"41"},"errors":[{"path":"/email","message":"'not-an-email' does not match pattern '^[^@ ]+@[^@ ]+$'"}]}- A job with exactly one input reads it from standard input unless
--inputbinds it, and one with exactly one output (or exactly one required output) writes it to standard output. Soopenflange run . < signups.csvworks, withcleanon standard output andrejectednot connected. - An optional output that is not bound is not connected. Here that makes the first invalid row fail the run (see
E_RUNTIMEbelow), which is the intended behaviour. --param k=vsets a parameter of the job: strings verbatim, other types as JSON (--param size=3,--param fields='["a","b"]').--grantgives a permission to every node:--grant subprocess,--grant network=api.example.com:443,--grant filesystem.read=data,--grant filesystem.write=out.- To count records, read the summary line, or add
--report report.json: the report hasnodes.<node>.ports.outputs.<port>.recordsfor every node and port. The report counts per node port, not per job output: in the job above the number of rejected rows isnodes.check.ports.outputs.rejected.records. For atextoutput the summary line says1 chunk, not a number of rows. - To run a single standard pipe without any file:
openflange run std:filter --param expr='item["age"] >= 18' < people.ndjson.
resolve and run --locked: pin what ran #
resolve computes a content hash of every pipe the project uses, including the standard ones, and writes openflange.lock.yaml in the project root. Commit it.
openflange resolveIt printed (exit status 0):
ok: 6 references locked in openflange.lock.yaml (6 added, 0 changed)With --locked the runner refuses to start unless every pipe matches the lockfile (E_LOCK). Use it in schedulers and CI.
openflange run . --locked --input csv=signups.csv --output clean=- --output rejected=rejected.ndjsonIt printed (exit status 0):
{"email":"ada@example.com","country":"GB","age":36}
{"email":"carol@example.net","country":"DE","age":29}
completed in 4ms — clean: 2 records, rejected: 2 recordsAfter an intended change run openflange update ./ (or openflange update for everything) and commit the new lockfile. The count above is 6 because the project also contained pipes/shout from the init step below.
inspect: look up the contract of any pipe #
Before using a pipe you have not used, print its contract: ports, their kinds, parameters with types and defaults, permissions. It works for std:<name> and for a directory.
openflange inspect std:validate-schemaIt printed (exit status 0):
Validate schema validate-schema@0.1.0 [pipe, experimental, Apache-2.0]
Routes items by validity against a JSON Schema.
INPUTS
in records required untyped
OUTPUTS
valid records required untyped
rejected records optional untyped
Invalid items wrapped as {item, errors}.
PARAMETERS
schema object required
JSON Schema 2020-12 for one item.
BEHAVIOUR
scope record, cardinality any, not declared deterministic
IMPLEMENTATION
builtin std:validate-schema (runs in-process)
PERMISSIONS NEEDED
none
LOCATION
std:validate-schema@0.1.0
RUN IT
openflange run std:validate-schema --param schema=<object> < input.ndjsoninit: scaffold a pipe of your own #
openflange init <dir> creates one small working pipe: a manifest with a Starlark expression and a test file. Use it as the starting point for a step of your own. It never overwrites files, and it does not create pipeline.yaml or openflange.yaml.
openflange init ./pipes/shoutIt printed (exit status 0):
ok: created pipe "shout"
pipes/shout/OPENFLANGE.md
pipes/shout/tests/shout.test.yaml
Next:
openflange test ./pipes/shout
printf '"hello"\n' | openflange run ./pipes/shoutThe command wrote pipes/shout/OPENFLANGE.md:
---
spec: openflange.org/pipe/v0.1
id: shout
version: 0.1.0
title: Shout
description: Upper-cases each string. Replace the expression with your own logic.
license: Apache-2.0
maturity: experimental
scope: record
cardinality: one-to-one
deterministic: true
inputs:
text:
schema: {format: json-schema, definition: {type: string}}
outputs:
text:
schema: {format: json-schema, definition: {type: string}}
implementation:
type: expression
language: starlark
expression: text.upper()
---
# Shout
Upper-cases each string of the input stream.
```sh
printf '"hello"\n' | openflange run .
# "HELLO"
```
The expression is Starlark; the input item is bound to the name of the input
port (`text`). For logic that needs several statements, parameters or more
than one output, switch to `type: script` with a `.star` file.
Implements the [OpenFlange](https://openflange.org/) specification.The command wrote pipes/shout/tests/shout.test.yaml:
spec: openflange.org/test/v0.1
tests:
- name: upper-cases strings
inputs:
text: {values: ["hello", "Wörld"]}
expect:
outputs:
text: {values: ["HELLO", "WÖRLD"]}
- name: an empty stream stays empty
inputs:
text: {values: []}
expect:
outputs:
text: {count: 0}printf '"hello"\n' | openflange run ./pipes/shoutIt printed (exit status 0):
"HELLO"
completed in 209µs — text: 1 recordIn an expression pipe the current item is bound to the name of the input port (text here), and the value of the expression is the output item. Use the pipe in a pipeline as pipe: ./pipes/shout.
Output contract and exit status #
- Standard output carries data only. Diagnostics, the summary line and errors go to standard error.
- Exit status: 0 success; 1 a run failed or was cancelled, or a test failed; 2 a usage or validation error, nothing was executed.
- Every reporting command accepts
--jsonfor a machine-readable result on standard output (for exampleopenflange validate . --jsonprints{"valid": ..., "errors": [...], "warnings": [...]}). - Each error is one line that starts with its code (
E_PARAM: ...), followed by the source lines and often ahint:. Dispatch on the code, not on the message.
When no standard pipe does the job #
The standard pipes cover decoding, cleaning, validating, routing and windows. They do not sort, join or aggregate. For anything else, write a pipe: a directory with an OPENFLANGE.md and, usually, one script. Choose the implementation type by what the step needs:
| Need | implementation |
Permissions | Notes |
|---|---|---|---|
| One output value per input record, computed by one expression | {type: expression, language: starlark, expression: "..."} |
none | Exactly one input and one output. Often std:map in the pipeline is enough and no pipe is needed. |
| Several statements, several outputs, parameters, routing bad records | {type: script, language: starlark, path: x.star} |
none | Runs inside the runner. def process(item, params) is called per record. |
| Work on a window of records (moving average, totals per group) | Starlark script with an input of kind: windows |
none | Put std:window in front of it. |
| The whole input at once (sort, join, exact aggregates), or a library | {type: script, language: python} (also node, r), scope: dataset |
subprocess |
NDJSON on standard input, NDJSON on standard output. |
| Any other program | {type: executable, command: [prog, arg, ...]} |
subprocess |
Same protocol: standard input to standard output. |
Starlark rules and limits #
Starlark looks like Python but is deliberately small. These facts were checked with this runner:
- JSON maps to Starlark as: object to
dict, array tolist, string tostring, a number without fraction or exponent to an exactintof any size, any other number tofloat,nulltoNone. - Available:
len,str,int,float,bool,dict,list,sorted,reversed,min,max,abs,any,all,enumerate,range,zip,type, the operatorin("@" in s,x in [1, 2]), negative indexes and slices (items[-1],s[::-1]), string methods (strip,lower,upper,split,join,replace,startswith,endswith,index,find,count,isdigit,isalpha,isupper,islower), list and dict comprehensions,x if c else y,"%s and %d" % (a, b), and the modulesmath(math.round,math.floor,math.sqrt, ...) andjson(json.encode,json.decode). - Not available:
sum(write a loop),round(usemath.round), regular expressions (nore; validate patterns withstd:validate-schemaand itspatternkeyword),"%.2f"formatting, f-strings,whileloops (usefor),importandload, recursion, files, network, clock and random numbers. - To change one member of a record:
dict(item, email=item["email"].lower())oritem | {"email": ...}.item["x"]fails the run whenxis missing;item.get("x")returnsNone.dict(item, ...)keeps the order of the existing members and appends new ones. /is float division,//integer division.len(s)counts bytes; uselen(list(s.codepoints()))for characters.math.round(x * 10) / 10rounds to one decimal (halves away from zero). A float with an integral value is written without a fraction:13, not13.0.- In a script,
emit(port, value)writes to a named output any number of times;enabled(port)tells whether an optional output is connected;fail(msg)stops the run withE_RUNTIME. With exactly one output, a returned value that is notNoneis emitted on it and returningNoneemits nothing. With several outputs, useemit. - An unknown name or a syntax error is found by
openflange validate, not at run time:E_MANIFESTin a script file,E_PARAMin an expression parameter.
A Starlark script over windows: moving average #
std:window turns records into window frames; a pipe with an input of kind: windows receives one frame at a time. A frame looks like this (size: 2, three records in):
printf '{"value":%s}\n' 10 20 30 | openflange run std:window --param size=2It printed (exit status 0):
{"window":{"index":0,"partition":null,"start":0,"end":1,"final":false,"partial":false},"items":[{"value":10},{"value":20}]}
{"window":{"index":1,"partition":null,"start":2,"end":2,"final":true,"partial":true},"items":[{"value":30}]}
completed in 355µs — out: 2 windowsFile pipes/window-mean/OPENFLANGE.md:
---
spec: openflange.org/pipe/v0.1
id: window-mean
version: 0.1.0
title: Window mean
description: Emits the mean of `value` over the items of each window frame.
license: Apache-2.0
maturity: experimental
scope: window
requires: [windows]
inputs:
windows:
kind: windows
outputs:
means:
kind: records
implementation:
type: script
language: starlark
path: mean.star
---
# Window mean
Implements the [OpenFlange](https://openflange.org/) specification.File pipes/window-mean/mean.star:
def process(frame, params):
total = 0
for item in frame["items"]:
total += item["value"]
return {"end": frame["window"]["end"], "mean": total / len(frame["items"])}File pipes/window-mean/tests/window-mean.test.yaml:
spec: openflange.org/test/v0.1
tests:
- name: mean of one frame
inputs:
windows:
values:
- {window: {index: 0, partition: null, start: 0, end: 1, final: false, partial: false}, items: [{value: 10}, {value: 20}]}
expect:
outputs:
means: {values: [{end: 1, mean: 15}]}File moving-average.yaml:
spec: openflange.org/pipeline/v0.1
parameters:
size: {type: integer, default: 3, minimum: 1}
nodes:
window:
pipe: std:window
inputs:
in: {from: inputs.records}
parameters:
size: {$param: size}
step: 1
emitPartial: false
mean:
pipe: ./pipes/window-mean
inputs:
windows: {from: window.outputs.out}
outputs:
means: {from: mean.outputs.means}openflange test . ./pipes/window-meanIt printed (exit status 0):
tests/signups-etl.test.yaml
ok cleans, validates and casts
ok without a rejected consumer an invalid row fails the run
pipes/window-mean/tests/window-mean.test.yaml
ok mean of one frame
ok 3 tests passed in 2 files (9ms)printf '{"value":%s}\n' 10 20 30 40 55 | openflange run ./moving-average.yamlIt printed (exit status 0):
{"end":2,"mean":20}
{"end":3,"mean":30}
{"end":4,"mean":41.666666666666664}
completed in 2ms — means: 3 recordssize is a parameter of the standalone pipeline (declared under its top-level parameters), so it can be set on the command line:
printf '{"value":%s}\n' 10 20 30 40 55 | openflange run ./moving-average.yaml --param size=2It printed (exit status 0):
{"end":1,"mean":15}
{"end":2,"mean":25}
{"end":3,"mean":35}
{"end":4,"mean":47.5}
completed in 404µs — means: 4 recordssizeitems per window;stepis the distance between window starts (default:size, so windows do not overlap;step: 1slides by one record).emitPartial: falsedrops the incomplete windows at the end, which is what a moving average wants.partitionBy: 'item["customer"]'forms windows per key; the key is inframe["window"]["partition"]. With asizelarger than any group (the maximum is 1000000) and the defaultemitPartial: true, each group arrives as one frame at the end of the input: that is how to total per key in Starlark.partitionBytogether withstep: 1andemitPartial: falsegives a sliding window per key; each frame is emitted as soon as it is full.- A
windowsoutput can only be connected to awindowsinput.std:mapand the other record pipes do not accept it (E_SCHEMA). - The manifest of the consumer lists
requires: [windows]andscope: window.
A Python script over the whole input: group and count #
A script in Python, Node or R is an ordinary program: it reads the first input as NDJSON on standard input and writes the first output as NDJSON on standard output, one JSON value per line, no blank lines, nothing else on standard output. It starts a process, so its manifest declares permissions: {subprocess: true} and whoever runs it must grant that.
File pipes/count-by-country/OPENFLANGE.md:
---
spec: openflange.org/pipe/v0.1
id: count-by-country
version: 0.1.0
title: Count by country
description: Counts the records per `country` and emits one record per country, sorted by country.
license: Apache-2.0
maturity: experimental
scope: dataset
inputs:
records:
kind: records
outputs:
counts:
kind: records
implementation:
type: script
language: python
path: count_by_country.py
permissions:
subprocess: true
---
# Count by country
Implements the [OpenFlange](https://openflange.org/) specification.File pipes/count-by-country/count_by_country.py:
import json
import sys
from collections import Counter
counts = Counter(json.loads(line)["country"] for line in sys.stdin)
for country in sorted(counts):
print(json.dumps({"country": country, "count": counts[country]}))File pipes/count-by-country/tests/count-by-country.test.yaml:
spec: openflange.org/test/v0.1
tests:
- name: counts and sorts
grants: {subprocess: true}
inputs:
records: {values: [{country: GB}, {country: DE}, {country: GB}]}
expect:
outputs:
counts: {values: [{country: DE, count: 1}, {country: GB, count: 2}]}File count.yaml:
spec: openflange.org/pipeline/v0.1
nodes:
count:
pipe: ./pipes/count-by-country
inputs:
records: {from: inputs.records}
grants:
subprocess: true
outputs:
counts: {from: count.outputs.counts}Without the grant nothing runs:
printf '{"country":"%s"}\n' GB DE GB | openflange run ./pipes/count-by-countryIt printed (exit status 2):
E_PERMISSION: node "count-by-country": pipe "count-by-country" needs permissions that were not granted: subprocess (pipes/count-by-country/OPENFLANGE.md, at nodes.count-by-country)
hint: grant it with `--grant subprocess` (or `grants:` on the node), or run with `--trusted`
E_PERMISSION: node "count-by-country": pipe "count-by-country" runs a subprocess, which was not granted (pipes/count-by-country/OPENFLANGE.md, at nodes.count-by-country)
hint: grant it with `--grant subprocess` (or `grants: {subprocess: true}` on the node), or run with `--trusted`
2 errors in 1 fileGrant it for one run with --grant subprocess, or in the pipeline on the node that needs it (grants: in count.yaml above), and in a test with grants::
printf '{"country":"%s"}\n' GB DE GB | openflange run ./pipes/count-by-country --grant subprocessIt printed (exit status 0):
{"country": "DE", "count": 1}
{"country": "GB", "count": 2}
completed in 22ms — counts: 2 recordsprintf '{"country":"%s"}\n' GB DE GB | openflange run ./count.yamlIt printed (exit status 0):
{"country": "DE", "count": 1}
{"country": "GB", "count": 2}
completed in 22ms — counts: 2 recordsopenflange test ./pipes/count-by-countryIt printed (exit status 0):
pipes/count-by-country/tests/count-by-country.test.yaml
ok counts and sorts
ok 1 test passed in 1 file (25ms)- Declare
scope: datasetwhen the script reads the whole input before writing, as this one does. - Parameters reach the program as environment variables: parameter
largeAboveisOPENFLANGE_PARAM_LARGE_ABOVE; strings verbatim, other types JSON-encoded. - A non-zero exit status fails the run with
E_RUNTIME; anything on standard output that is not one JSON value per line fails it withE_FORMAT. Write logs to standard error.
Common errors and their fixes #
Each error below was produced on purpose: the change shown was applied to the files above, the command was run, and the message is quoted as printed. Fix the first error first; one mistake often causes two messages.
- The parenthesis after the message is the location:
(pipeline.yaml:10:12, at nodes.clean.inputs.in.from)is file, line, column and the path inside the document. - A
hint:line, when present, usually contains the exact fix. - Exit status 2: nothing ran. Exit status 1: the run started and failed; outputs may be partly written.
E_REF #
A reference to a node, a port, a job input or a pipe that does not exist.
Wrong port name. The outputs of the standard pipes are not all called out, and none is called records.
Change in pipeline.yaml:
- in: {from: decode.outputs.out}
+ in: {from: decode.outputs.records}openflange validate .It printed (exit status 2):
E_UNCONNECTED: required output `out` of node `decode` has no consumer (pipeline.yaml:3:3, at nodes.decode, port out)
|
3 | decode:
| ^
hint: connect it (`from: decode.outputs.out`) or discard it explicitly: `outputs: {out: {discard: true}}`
E_REF: node "decode" (pipe csv-decode) has no output "records" (pipeline.yaml:10:12, at nodes.clean.inputs.in.from)
|
10 | in: {from: decode.outputs.records}
| ^
hint: outputs of csv-decode: out
invalid: 2 errors in 1 fileFix: use a port name from the hint (or from openflange inspect std:csv-decode). The E_UNCONNECTED message disappears with it: it only says that the real output out lost its consumer.
A standard pipe that does not exist. There is no std:sort, std:join, std:group-by, std:aggregate, std:count or std:dedupe.
Change in pipeline.yaml:
- pipe: std:cast
+ pipe: std:sortopenflange validate .It printed (exit status 2):
E_REF: unknown pipe "std:sort" (pipeline.yaml:26:5, at nodes.typed.pipe)
|
26 | pipe: std:sort
| ^
hint: did you mean `std:cast`?
invalid: 1 error in 1 fileFix: pick a name from the cheat-sheet below (deduplication is std:distinct), or write a pipe of your own for sorting, joining and aggregating. The suggestion in the hint is only the closest spelling, not a replacement.
E_UNCONNECTED #
A required input without a producer, or a required output without a consumer.
A node without its inputs mapping.
Change in pipeline.yaml:
pipe: std:cast
- inputs:
- in: {from: check.outputs.valid}openflange validate .It printed (exit status 2):
E_UNCONNECTED: required output `valid` of node `check` has no consumer (pipeline.yaml:13:3, at nodes.check, port valid)
|
13 | check:
| ^
hint: connect it (`from: check.outputs.valid`) or discard it explicitly: `outputs: {valid: {discard: true}}`
E_UNCONNECTED: required input `in` of node `typed` has no producer (pipeline.yaml:25:3, at nodes.typed, port in)
|
25 | typed:
| ^
hint: add `inputs: {in: {from: …}}` to the node (a source is `inputs.<name>` or `<node>.outputs.<port>`)
invalid: 2 errors in 1 fileFix: map every required input (inputs: {in: {from: check.outputs.valid}}). For a required output that nobody needs, say so on the node that produces it: outputs: {unmatched: {discard: true}}.
E_PARAM #
A parameter that is unknown, missing, of the wrong type or out of bounds; also an expression parameter that does not compile.
A misspelt parameter name.
Change in pipeline.yaml:
- fields: {age: integer}
+ field: {age: integer}openflange validate .It printed (exit status 2):
E_PARAM: node "typed": missing required parameter "fields" (object) of cast (pipeline.yaml:25:3, at nodes.typed)
|
25 | typed:
| ^
hint: add `parameters: {fields: <value>}` to the node
E_PARAM: node "typed": parameter "fields" must be a non-empty object {name: string|integer|number|boolean} (pipeline.yaml:25:3, at nodes.typed)
|
25 | typed:
| ^
E_PARAM: pipe cast has no parameter "field" (pipeline.yaml:30:7, at nodes.typed.parameters.field)
|
30 | field: {age: integer}
| ^
hint: did you mean `fields`?
invalid: 3 errors in 1 fileFix: use the name from the hint. All three messages come from the one typo.
An expression that uses a name Starlark does not have.
Change in pipeline.yaml:
- expr: 'dict(item, email=item["email"].strip().lower())'
+ expr: 'dict(item, total=sum([1, 2]))'openflange validate .It printed (exit status 2):
E_PARAM: node "clean": parameter "expr": invalid Starlark expression "dict(item, total=sum([1, 2]))": expr:3:18: undefined: sum (pipeline.yaml:7:3, at nodes.clean)
|
7 | clean:
| ^
invalid: 1 error in 1 fileFix: see the Starlark rules above. There is no sum; inside an expression use a comprehension with a known function, or move the logic to a script pipe and write a loop.
E_SCHEMA #
Two connected ports that cannot work together: different kinds, or schemas that contradict each other.
The pipeline file was run directly, without its manifest. On its own, every input of a pipeline is of kind records, but std:csv-decode needs text.
openflange run ./pipeline.yaml --input csv=signups.csv --output clean=- --output rejected=rejected.ndjsonIt printed (exit status 2):
E_SCHEMA: inputs.csv → decode.inputs.in: incompatible port kinds: the producer emits `records` but the consumer expects `text` (./pipeline.yaml:6:12, at nodes.decode.inputs.in.from)
|
6 | in: {from: inputs.csv}
| ^
hint: the inputs of a standalone pipeline file are always `records` (pipeline specification 3.6). To feed it `text` — a CSV file, for example — make the pipeline a composite pipe: an OPENFLANGE.md next to it with `implementation: {type: pipeline, path: <this file>}` that declares the input as `kind: text`Fix: run the directory (openflange run . ...), whose OPENFLANGE.md declares csv with kind: text. The hint does not apply here. The same error with windows and records means a record pipe was connected to the output of std:window.
E_MANIFEST #
A file that does not follow its format: unknown or missing keys, invalid YAML, a Starlark script that does not compile.
A top-level key that the format does not define.
Change in pipeline.yaml:
- nodes:
+ steps:openflange validate .It printed (exit status 2):
E_MANIFEST: missing required key "nodes" (pipeline.yaml:1:1)
|
1 | spec: openflange.org/pipeline/v0.1
| ^
E_MANIFEST: unknown key "steps" (pipeline.yaml:2:1, at steps)
|
2 | steps:
| ^
hint: did you mean `spec`?
invalid: 2 errors in 1 fileFix: the keys of a pipeline file are spec, nodes, outputs and parameters. There is no steps, connections, inputs or name.
E_ATTRIBUTION #
The Markdown body of an OPENFLANGE.md has no link to https://openflange.org/.
The attribution sentence was removed from the manifest body.
Change in OPENFLANGE.md:
- Implements the [OpenFlange](https://openflange.org/) specification.
- openflange validate .It printed (exit status 2):
E_ATTRIBUTION: the Markdown body must contain a visible hyperlink to https://openflange.org/, for example: Implements the [OpenFlange](https://openflange.org/) specification. (OPENFLANGE.md:26:1)
|
26 | # Signups ETL
| ^
invalid: 1 error in 1 fileFix: put Implements the [OpenFlange](https://openflange.org/) specification. in the Markdown body, outside code blocks. The target must be exactly https://openflange.org/, with https and the trailing slash.
E_PERMISSION #
A pipe needs a permission that the node or the run did not grant.
A file sink without a grant for its path.
printf '{"a":1}\n' | openflange run std:file-sink --param path=out.ndjsonIt printed (exit status 2):
E_PERMISSION: node "file-sink": std:file-sink may not write /work/signups-etl/out.ndjson: the path is not covered by a filesystem.write grant (at nodes.file-sink)
hint: grant it with `--grant filesystem.write=/work/signups-etl` (or `grants: {filesystem: {write: [...]}}` on the node)Fix: grant exactly what is needed, for the run (--grant) or on the node (grants: {filesystem: {write: [out.ndjson]}}). A subprocess pipe needs --grant subprocess or grants: {subprocess: true}. --trusted grants everything every pipe declares; use it only for code you have read.
printf '{"a":1}\n' | openflange run std:file-sink --param path=out.ndjson --grant filesystem.write=out.ndjsonIt printed (exit status 0):
completed in 3msE_LOCK #
A locked run found no lockfile, or a pipe that differs from it.
--locked before the lockfile exists.
openflange run . --locked --input csv=signups.csv --output clean=- --output rejected=rejected.ndjsonIt printed (exit status 2):
E_LOCK: --locked needs openflange.lock.yaml, and there is none in . or above
hint: run `openflange resolve` in the project directory to create itFix: run openflange resolve once in the project directory and commit openflange.lock.yaml.
A file of a locked pipe changed after openflange resolve.
Change in pipeline.yaml:
- fields: {age: integer}
+ fields: {age: number}openflange run . --locked --input csv=signups.csv --output clean=- --output rejected=rejected.ndjsonIt printed (exit status 2):
E_LOCK: reference "./" does not match openflange.lock.yaml: ./OPENFLANGE.md now hashes to sha256-4df4baa1acb5…, the lockfile has sha256-c744e64b7498…
hint: run `openflange update ./` if the change is intendedFix: if the change is intended, update the lock entry and commit the lockfile. If not, restore the file.
openflange update ./It printed (exit status 0):
ok: 5 references locked in openflange.lock.yaml (0 added, 1 changed)E_RUNTIME #
A pipe failed while running: an expression raised an error, a script called fail, a program exited with a non-zero status, or a record had nowhere to go.
An invalid row while the optional output rejected is not connected.
openflange run . --input csv=signups.csvIt printed (exit status 1):
E_RUNTIME: item 2 does not match the schema: /age: 'abc' does not match pattern '^[0-9]+$' (node check)
hint: connect the output `rejected` to receive invalid items as data instead of failing
failed in 528µs — clean: 0 recordsFix: bind the output (--output rejected=rejected.ndjson), or connect it inside the pipeline. This failure is deliberate: invalid data is never dropped silently.
An expression that reads a member the record does not have.
Change in pipeline.yaml:
- expr: 'dict(item, email=item["email"].strip().lower())'
+ expr: 'dict(item, email=item["e-mail"].strip().lower())'openflange run . --input csv=signups.csv --output clean=- --output rejected=rejected.ndjsonIt printed (exit status 1):
E_RUNTIME: item 1: key "e-mail" not in dict (node clean)
failed in 248µs — clean: 0 records, rejected: 0 recordsFix: use the real member name; for members that may be absent use item.get("name") or validate first with std:validate-schema. The message gives the item number and the node.
E_FORMAT #
The data is malformed: a CSV row with the wrong number of fields, invalid JSON, a blank line in NDJSON.
A CSV row with fewer fields than the header.
printf 'email,country,age\nada@example.com,GB\n' | openflange run . --output clean=- --output rejected=rejected.ndjsonIt printed (exit status 1):
E_FORMAT: CSV row 2 has 2 fields, expected 3 (node decode)
failed in 257µs — clean: 0 records, rejected: 0 recordsFix: repair the input. Structural CSV errors fail the run; they cannot be sent to rejected, because the row cannot be read at all.
A blank line in an NDJSON input.
printf '{"a":1}\n\n{"a":2}\n' | openflange run std:filter --param expr='item["a"] > 1'It printed (exit status 1):
E_FORMAT: NDJSON line 2: blank lines are not allowed (node filter)
failed in 155µs — out: 0 recordsFix: NDJSON is one JSON value per line, with no blank lines and no enclosing array. A file that holds one big JSON array is not NDJSON; convert it first (for example jq -c ".[]").
Usage errors (no code) #
Mistakes on the command line are reported with error: instead of a code, also with exit status 2.
A target with two required outputs and no --output flags.
printf '{"a":1}\n' | openflange run std:split --param expr='item["a"] > 1'It printed (exit status 2):
error: the target has several ports, so each required one must be bound: add --output matched=<path|-> --output unmatched=<path|->
hint: run `openflange help run` for usageFix: bind every required port, as the message says. - binds one of them to standard output.
The remaining codes #
| Code | Meaning | Usual fix |
|---|---|---|
E_DUPLICATE |
A duplicate YAML key or node id, or two producers for one input. | Rename the node; merge streams with std:merge. |
E_RESERVED |
A node is called inputs, outputs, params, env, std or builtin. |
Rename the node. |
E_DIRECTION |
A consumer was used as a source (x.inputs.y or outputs.y in from). |
Use <node>.outputs.<port> or inputs.<name>. |
E_CYCLE |
The nodes form a loop. | Remove the back edge; pipelines are acyclic. |
E_MEDIA |
Two ports share no media type. | Insert a conversion pipe (std:csv-encode, std:json-format, ...). |
E_PATH |
A path leaves the package directory or is absolute where that is not allowed. | Keep scripts and schemas inside the pipe directory. |
E_UNSUPPORTED |
A feature, language or version this runner does not have (for example R is not installed). | Check openflange version --capabilities. |
E_RESOURCE |
A declared bound was exceeded (maxKeys of std:distinct, maxPartitions of std:window). |
Raise the parameter, or use a dataset-scope pipe. |
E_TIMEOUT, E_CANCELLED |
A time limit was exceeded, or the run was interrupted. | Run again. |
E_PROTOCOL |
A program did not follow the batch or multi-port protocol. | In batch mode answer every input line with exactly one line. |
W_SCHEMA |
A warning: the compatibility of two schemas could not be proven. | None needed; add schemas to be sure. |
Standard pipes cheat-sheet #
The 28 pipes of standard library v0.1, generated from their manifests. Each name links to a page with a worked example. openflange inspect std:<name> prints the same contract.
| Pipe | What it does | Inputs → outputs | Parameters |
|---|---|---|---|
std:map |
Emits the value of a Starlark expression for every item. | in → out |
expr (string, required) |
std:select |
Keeps only the listed members of each record. | in → out |
fields (array, required) |
std:rename |
Renames members of each record. | in → out |
mapping (object, required) |
std:cast |
Converts members of each record to a JSON type, exactly or not at all. | in → out, rejected? |
fields (object, required), onError (string, default "fail", "fail" | "reject") |
std:filter |
Keeps the items for which a Starlark expression is truthy. | in → out, rejected? |
expr (string, required) |
std:limit |
Emits at most the first count items. |
in → out |
count (integer, required) |
std:skip |
Discards the first count items. |
in → out |
count (integer, required) |
std:distinct |
Keeps the first item for every distinct key; bounded by maxKeys. | in → out |
fields (array), maxKeys (integer, default 1000000) |
std:split |
Routes each item to matched or unmatched by a boolean expression. |
in → matched, unmatched |
expr (string, required) |
std:partition |
Routes items to one of up to eight outputs by key. | in → p0?, p1?, p2?, p3?, p4?, p5?, p6?, p7? |
key (string, required), partitions (integer, required) |
std:merge |
Merges several streams into one, interleaved or concatenated. | in (variadic) → out |
mode (string, default "interleave", "interleave" | "concat") |
std:batch |
Groups consecutive items into JSON arrays of size items. |
in → out |
size (integer, required) |
std:unbatch |
Flattens array items into their elements. | in → out |
— |
std:window |
Record-count tumbling, sliding and partitioned windows. | in → out (windows) |
size (integer, required), step (integer), partitionBy (string), emitPartial (boolean, default true), maxPartitions (integer, default 10000) |
std:window-processing-time |
Draft. Groups items by arrival time. Non-deterministic. | in → out (windows) |
durationMs (integer, required), maxItems (integer, default 100000) |
std:json-parse |
Parses NDJSON text into items. | in (text) → out |
— |
std:json-format |
Serialises items as NDJSON text. | in → out (text) |
— |
std:csv-decode |
Parses CSV text into records of strings. | in (text) → out |
header (boolean, default true), delimiter (string, default ","), fields (array) |
std:csv-encode |
Serialises records as CSV text. | in → out (text) |
header (boolean, default true), delimiter (string, default ","), fields (array) |
std:ndjson-to-arrow |
Converts records to Arrow record batches, refusing lossy values. | in → out (batches) |
schema (object, required), batchSize (integer, default 1024) |
std:arrow-to-ndjson |
Converts Arrow record batches to records, refusing lossy values. | in (batches) → out |
— |
std:validate-schema |
Routes items by validity against a JSON Schema. | in → valid, rejected? |
schema (object, required) |
std:stdin |
Source: the runner's standard input as NDJSON. | — → out |
— |
std:stdout |
Sink: the runner's standard output as NDJSON. | in → — |
— |
std:file-source |
Source: an NDJSON file. Needs a filesystem.read grant covering path. |
— → out |
path (string, required) |
std:file-sink |
Sink: an NDJSON file. Needs a filesystem.write grant covering path. |
in → — |
path (string, required), append (boolean, default false) |
std:http-source |
Source: NDJSON fetched with one HTTP GET. Needs a network grant for the URL's host:port. | — → out |
url (string, required), timeoutMs (integer, default 30000) |
std:discard |
Sink: consumes and discards its input. | in → — |
— |
Ports are of kind records unless a kind is given in parentheses; ? marks an optional port. A parameter marked required has no default.
- Unless the table says otherwise a standard pipe has one input
inand one outputout. Exceptions to remember:std:validate-schemawrites tovalidandrejected;std:splittomatchedandunmatched(both required);std:partitiontop0...p7. - Records keep the order of their members from input to output (CSV columns stay in header order).
std:filterdrops records for which the expression is false unless itsrejectedoutput is connected.std:validate-schemafails the run on an invalid record unlessrejectedis connected; rejected records look like{"item": <record>, "errors": [{"path": "/age", "message": "..."}]}.- The
schemaofstd:validate-schemais JSON Schema 2020-12:type,required,properties,enum,const,minimum,exclusiveMinimum,minLength,pattern,ifandthenall work.patternuses RE2 syntax: no look-ahead, no back-references.formatis not enforced (format: emailaccepts any string). To write the original record instead of the{"item", "errors"}wrapper, putstd:mapwithexpr: 'item["item"]'afterrejected. std:casttakesfields: {name: string|integer|number|boolean}:"19.99"cast tonumberbecomes19.99,"42"cast tointegerbecomes42. A value that cannot be converted exactly fails the run, or withonError: rejectgoes torejectedas{"item": <record>, "errors": [{"field": "age", "message": "..."}]}. For numeric rules on CSV data, validate the text, cast, then usestd:filterwith an expression such asitem["amount"] > 0.std:distinctkeeps the first record per key;fields: [email]makesemailthe key, and withoutfieldsthe whole record is the key. A missing member and anullmember are two different keys. It remembers every key (up tomaxKeys).std:file-source,std:file-sinkandstd:http-sourceread and write NDJSON only and need grants (filesystem.read,filesystem.write,network). For most jobs binding files with--inputand--outputis simpler and needs no grant.- CSV is read by declaring a
textinput in the manifest and decoding it withstd:csv-decode; it is written withstd:csv-encodeinto atextoutput. Every decoded value is a string, and an empty cell is the empty string"", nevernullor a missing member.std:csv-encodewrites the columns named infields, in that order (withoutfields: the members of the first record, in their order), and quotes values that need it. - There is no standard pipe for sorting, joining, grouping, aggregating or counting, and none for Parquet, Excel, XML or databases.
Batch mode: a rule of thumb #
Batch mode lets a script or executable pipe receive its input in slices of up to maxItems records instead of one record at a time. Rule of thumb: declare batch when the cost is per call or per process round trip, not per record.
- A pipe in R or NumPy-style Python, where one vectorised call on a thousand values costs about as much as on one.
- A pipe that calls something priced per request: a language model, an embedding service, an enrichment API, a bulk insert.
- A file-in, file-out tool such as DuckDB (
delivery: file).
Do not declare it:
- On standard pipes,
expressionpipes and pipelines: it is not allowed there (E_MANIFEST). - For Starlark, expecting a large gain: it already runs inside the runner.
- With
maxItems: 1: for a subprocess that is slower than no batch mode at all. - To aggregate: slice boundaries carry no meaning and the output must not depend on them. A sum per slice is a wrong sum. Aggregates need
std:windowor ascope: datasetpipe.
A Python pipe in batch mode. The manifest adds batch:; the program reads one JSON array per line and answers each line with exactly one JSON array, flushed:
File pipes/email-domain/OPENFLANGE.md:
---
spec: openflange.org/pipe/v0.1
id: email-domain
version: 0.1.0
title: E-mail domain
description: Adds the domain of `email` to every record.
license: Apache-2.0
maturity: experimental
scope: record
cardinality: one-to-one
batch:
maxItems: 500
maxWaitMs: 100
inputs:
records:
kind: records
outputs:
records:
kind: records
implementation:
type: script
language: python
path: domain.py
permissions:
subprocess: true
---
# E-mail domain
Implements the [OpenFlange](https://openflange.org/) specification.File pipes/email-domain/domain.py:
import json
import sys
for line in sys.stdin: # one line = one batch = a JSON array of records
batch = json.loads(line)
out = [{**r, "domain": r["email"].rsplit("@", 1)[-1]} for r in batch]
sys.stdout.write(json.dumps(out) + "\n") # exactly one answer line per input line
sys.stdout.flush() # the runner waits for itprintf '{"email":"%s"}\n' ada@example.com carol@example.net | openflange run ./pipes/email-domain --grant subprocessIt printed (exit status 0):
{"email": "ada@example.com", "domain": "example.com"}
{"email": "carol@example.net", "domain": "example.net"}
completed in 23ms — records: 2 recordsmaxWaitMsis how long the runner may hold a partial slice while waiting for more records;0(the default) never waits. Every slice has between 1 andmaxItemsrecords.- With
cardinality: one-to-onethe answer must have as many elements as the slice. - A consumer may only lower the limits:
batch: {maxItems: 100}on a pipeline node, or--batch <node>=100on the command line.
Measured gains, from RFC 0003 (reference runner, one 8-vCPU virtual machine, 2026-12-03, single runs, ±30 %): an R pipe went from 720 to 21,900 records per second with 1000 records per batch; a Python pipe doing per-record work from 64,000–118,000 to 96,000–155,000; a pipe whose call costs 5 ms from 160 to 141,000 with 1000 records per call; Starlark from 55,000 to 68,000–73,000. More: https://openflange.dev/concepts/batch/.
Decision table: the user asks X, use Y #
Each row was checked against the manifests and the runner used for this page. "Custom pipe" means a directory with its own OPENFLANGE.md, as in the section on custom steps.
| The user asks for | Use | Details |
|---|---|---|
| Read a CSV file | A manifest input with kind: text, then std:csv-decode |
The minimal file set, std:csv-decode |
| Write a CSV file | std:csv-encode into a manifest output with kind: text |
std:csv-encode |
| Read or write NDJSON (JSON Lines) | --input port=file, --output port=file; nothing to decode |
Running the job |
| Drop rows by a condition | std:filter with expr |
std:filter |
| Keep the dropped rows too | std:filter with its rejected output connected, or std:split (matched, unmatched) |
std:filter, std:split |
| Validate rows against a JSON Schema; separate valid from invalid | std:validate-schema, with the outputs valid and rejected; to drop the invalid rows on purpose add outputs: {rejected: {discard: true}} to the node |
std:validate-schema |
| Count the valid and invalid rows | The summary line of openflange run, or --report report.json (records per node port; extract them with jq) |
Running the job |
| Convert strings to numbers or booleans | std:cast with fields |
std:cast |
| Add, change or compute a field; trim, lower-case, mask a value | std:map with expr (dict(item, name=...)); a Starlark script pipe when one expression is not enough |
std:map, Starlark rules |
| Keep only some columns; rename columns | std:select with fields; std:rename with mapping |
std:select, std:rename |
| Remove duplicates by a key | std:distinct with fields: [key] |
std:distinct |
| First N rows; skip a header-like prefix | std:limit for the first N; std:skip to skip a prefix |
std:limit, std:skip |
| Route rows to several outputs by a key | std:partition (up to 8 outputs) or chained std:split |
std:partition, std:split |
| Combine several inputs into one stream | std:merge (mode: concat keeps the order of the inputs) |
std:merge |
| Moving average, rolling sum, anything over the last N rows | std:window with size and step: 1, then a Starlark script with a windows input |
std:window, Moving average |
| Totals or counts per key (group by) | std:window with partitionBy and a large size, then a Starlark script; or a scope: dataset script in Python |
Windows, A Python script |
| Sort; join two inputs; exact aggregates over everything | A scope: dataset custom pipe (Python, DuckDB); no standard pipe does this |
A Python script |
| Call an API or a language model for every row | A script or executable pipe in batch mode, with network grants |
Batch mode, Examples |
| Fetch NDJSON from a URL | std:http-source with a network grant |
std:http-source |
| Read Parquet, Excel, XML, a database or cloud storage | A custom pipe; not in the standard library | Custom steps |
| Run it every night | Cron or CI calls openflange run . --locked ...; OpenFlange does not schedule |
ETL guide |
| Make the run reproducible | openflange resolve, commit openflange.lock.yaml, run with --locked |
Locking |
| Expose a step over HTTP | openflange serve <pipe> |
CLI reference |
| A quick one-off on one file | Probably no OpenFlange: jq, awk or a short script |
When it does not fit |
Where to read more #
- Quickstart: the same loop with a pipe of your own, step by step.
- ETL guide: a larger CSV-to-CSV job with an aggregate, a lockfile and a scheduler.
- CLI reference: every command, the output contract, exit codes.
- Standard pipes: one page per pipe with a worked example.
- Concepts: manifest, ports, streams, pipelines, permissions, lockfiles, batch mode.
- Everything on this site as one text file and the index.
- Normative specifications, as Markdown: pipe, pipeline, standard library, portable tests, lockfile, CLI protocol.
Verified with openflange 0.0.1 (go1.27.1 linux/amd64), commit 11cf8cc5378d of https://github.com/openflange/openflange-go, on 2026-12-03. If your runner prints something different, trust the runner: openflange help <command> and openflange inspect <pipe> describe what is installed.