# OpenFlange for AI agents and the people who use them

This page is written to be read by a language model that has been asked to build a data-processing job, and by the person who asked. It is self-contained: the files, commands, outputs and error messages below are enough to build, test and run an ad-hoc ETL with OpenFlange without reading anything else.

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 `kind` says what flows through it: `records` (JSON values, one per line: NDJSON), `values`, `text` (for example a CSV file), `windows`, `batches` or `binary`.
- **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 `openflange` command.
- **Standard pipe**: a pipe built into every runner, referenced as `std:<name>` (for example `std: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 `rejected` output or fail the run; nothing is dropped silently.
- The job should be testable (`openflange test`) and reproducible (`openflange resolve`, then `run --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`, `awk` or 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`.

```bash
go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1
```

The binary is written to `$(go env GOPATH)/bin` (usually `~/go/bin`); put that directory on `PATH`. Check the installation and the version:

```bash
openflange version
```

It printed (exit status 0):

```text
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.1` installs the first tagged release, which is experimental. `@main` installs 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 passes `claude 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.

```text
signups-etl/
├── openflange.yaml
├── OPENFLANGE.md
├── pipeline.yaml
├── signups.csv
└── tests/
    └── signups-etl.test.yaml
```

Four 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`:

```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`:

```markdown
---
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 constant `openflange.org/pipe/v0.1`), `id` (lower-case letters, digits and `-`), `version` (SemVer) and `implementation`. Unknown top-level keys are an error.
- The Markdown body MUST contain a link whose target is exactly `https://openflange.org/`. Keep the sentence `Implements the [OpenFlange](https://openflange.org/) specification.` Without it validation fails with `E_ATTRIBUTION`.
- `implementation: {type: pipeline, path: pipeline.yaml}` says that this pipe is the pipeline in the next file. Its `inputs` and `outputs` are the ports of the job as a whole.
- The manifest is what lets the job read CSV: the input `csv` is declared with `kind: text`. A `pipeline.yaml` run on its own, without a manifest, has only `records` (NDJSON) inputs.
- A port is required unless it says `required: false`. `rejected` is 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; `yes` and `no` are strings.
- Parameters of the job are declared in the manifest (`parameters: {size: {type: integer, default: 3, minimum: 1}}`), and `pipeline.yaml` refers to them with `{$param: size}`. A `pipeline.yaml` that belongs to a manifest has no `parameters` section of its own.
- An input or output that carries NDJSON records is declared with `kind: records`; no `mediaTypes` are needed.

### pipeline.yaml: the steps and their connections

File `pipeline.yaml`:

```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 `nodes` is a node id (`^[a-z][a-z0-9_-]{0,63}$`). The ids `inputs`, `outputs`, `params`, `env`, `std` and `builtin` are reserved.
- `pipe` is a reference: `std:<name>` for a standard pipe, `./relative/path` for a directory that contains an `OPENFLANGE.md`.
- Connections are written once, on the consumer: `inputs: {<port>: {from: <source>}}`. A source is `inputs.<name>` (an input of the whole job) or `<node>.outputs.<port>`. There is no `connections` section and no `depends_on`.
- The top-level `outputs` map 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:merge` with `in: {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: true` also works on an optional output: its records are produced and thrown away on purpose, for example `outputs: {rejected: {discard: true}}` on a `std:validate-schema` node drops invalid rows instead of failing.
- `parameters` are 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) and `params`. Quote them with single quotes in YAML so that `item["email"]` needs no escaping.
- `std:csv-decode` emits every value as a string. Convert with `std:cast` after validating, as here.

### tests/signups-etl.test.yaml: a portable test

File `tests/signups-etl.test.yaml`:

```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.yaml` beside a manifest tests that manifest. Add `pipe: <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, for `text` ports such as CSV) or `{file: path}`.
- `expect.outputs.<port>` takes `values` (exact records, in order; member order inside an object does not matter), `count`, `schema` (a JSON Schema every record must satisfy), `ordered: false`, or `disabled: true` (run with this optional output not connected).
- `expect.status: failed` with `expect.error.code` asserts a failure. Validation errors count: a wrong parameter is observed as `failed` with `E_PARAM`.
- Parameters of the job under test go in `parameters:`; permissions in `grants:` (for example `grants: {subprocess: true}`).
- For a `text` output (CSV) `expect.outputs.<port>` takes `{text: "..."}`, compared byte for byte. Assertions can be combined, for example `count` with `schema`. A `file:` path is relative to the test file.
- The `message` text inside a rejected record is worded differently for each schema keyword (`pattern`, `enum`, `minimum`, ...) and no document promises its wording. Assert rejected outputs with `count` or `schema` rather than exact `values`.

### signups.csv: sample input

File `signups.csv`:

```text
email,country,age
Ada@Example.com,GB,36
bob@example.org,US,abc
 carol@example.net ,DE,29
not-an-email,FR,41
```

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

1. `openflange validate .`: check every file without running anything. Repeat after every edit until it prints `valid`.
2. `openflange test .`: run the portable tests.
3. `openflange run . --input <port>=<file> --output <port>=<file>`: run the job on real data.
4. `openflange resolve`, then `openflange 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.

```bash
openflange validate .
```

It printed (exit status 0):

```text
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.

```bash
openflange validate . --plan
```

It printed (exit status 0):

```text
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.

```bash
openflange test .
```

It printed (exit status 0):

```text
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.

```bash
openflange run . --input csv=signups.csv --output clean=clean.ndjson --output rejected=rejected.ndjson
```

It printed (exit status 0):

```text
completed in 551µs — clean: 2 records, rejected: 2 records
```

The command wrote `clean.ndjson`:

```json
{"email":"ada@example.com","country":"GB","age":36}
{"email":"carol@example.net","country":"DE","age":29}
```

The command wrote `rejected.ndjson`:

```json
{"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 `--input` binds it, and one with exactly one output (or exactly one required output) writes it to standard output. So `openflange run . < signups.csv` works, with `clean` on standard output and `rejected` not connected.
- An optional output that is not bound is not connected. Here that makes the first invalid row fail the run (see `E_RUNTIME` below), which is the intended behaviour.
- `--param k=v` sets a parameter of the job: strings verbatim, other types as JSON (`--param size=3`, `--param fields='["a","b"]'`).
- `--grant` gives 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 has `nodes.<node>.ports.outputs.<port>.records` for every node and port. The report counts per node port, not per job output: in the job above the number of rejected rows is `nodes.check.ports.outputs.rejected.records`. For a `text` output the summary line says `1 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.

```bash
openflange resolve
```

It printed (exit status 0):

```text
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.

```bash
openflange run . --locked --input csv=signups.csv --output clean=- --output rejected=rejected.ndjson
```

It printed (exit status 0):

```text
{"email":"ada@example.com","country":"GB","age":36}
{"email":"carol@example.net","country":"DE","age":29}
completed in 4ms — clean: 2 records, rejected: 2 records
```

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

```bash
openflange inspect std:validate-schema
```

It printed (exit status 0):

```text
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.ndjson
```

### init: 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`.

```bash
openflange init ./pipes/shout
```

It printed (exit status 0):

```text
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/shout
```

The command wrote `pipes/shout/OPENFLANGE.md`:

````markdown
---
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`:

```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}
```

```bash
printf '"hello"\n' | openflange run ./pipes/shout
```

It printed (exit status 0):

```text
"HELLO"
completed in 209µs — text: 1 record
```

In 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 `--json` for a machine-readable result on standard output (for example `openflange validate . --json` prints `{"valid": ..., "errors": [...], "warnings": [...]}`).
- Each error is one line that starts with its code (`E_PARAM: ...`), followed by the source lines and often a `hint:`. 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 to `list`, string to `string`, a number without fraction or exponent to an exact `int` of any size, any other number to `float`, `null` to `None`.
- Available: `len`, `str`, `int`, `float`, `bool`, `dict`, `list`, `sorted`, `reversed`, `min`, `max`, `abs`, `any`, `all`, `enumerate`, `range`, `zip`, `type`, the operator `in` (`"@" 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 modules `math` (`math.round`, `math.floor`, `math.sqrt`, ...) and `json` (`json.encode`, `json.decode`).
- Not available: `sum` (write a loop), `round` (use `math.round`), regular expressions (no `re`; validate patterns with `std:validate-schema` and its `pattern` keyword), `"%.2f"` formatting, f-strings, `while` loops (use `for`), `import` and `load`, recursion, files, network, clock and random numbers.
- To change one member of a record: `dict(item, email=item["email"].lower())` or `item | {"email": ...}`. `item["x"]` fails the run when `x` is missing; `item.get("x")` returns `None`. `dict(item, ...)` keeps the order of the existing members and appends new ones.
- `/` is float division, `//` integer division. `len(s)` counts bytes; use `len(list(s.codepoints()))` for characters. `math.round(x * 10) / 10` rounds to one decimal (halves away from zero). A float with an integral value is written without a fraction: `13`, not `13.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 with `E_RUNTIME`. With exactly one output, a returned value that is not `None` is emitted on it and returning `None` emits nothing. With several outputs, use `emit`.
- An unknown name or a syntax error is found by `openflange validate`, not at run time: `E_MANIFEST` in a script file, `E_PARAM` in 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):

```bash
printf '{"value":%s}\n' 10 20 30 | openflange run std:window --param size=2
```

It printed (exit status 0):

```text
{"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 windows
```

File `pipes/window-mean/OPENFLANGE.md`:

```markdown
---
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`:

```python
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`:

```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`:

```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}
```

```bash
openflange test . ./pipes/window-mean
```

It printed (exit status 0):

```text
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)
```

```bash
printf '{"value":%s}\n' 10 20 30 40 55 | openflange run ./moving-average.yaml
```

It printed (exit status 0):

```text
{"end":2,"mean":20}
{"end":3,"mean":30}
{"end":4,"mean":41.666666666666664}
completed in 2ms — means: 3 records
```

`size` is a parameter of the standalone pipeline (declared under its top-level `parameters`), so it can be set on the command line:

```bash
printf '{"value":%s}\n' 10 20 30 40 55 | openflange run ./moving-average.yaml --param size=2
```

It printed (exit status 0):

```text
{"end":1,"mean":15}
{"end":2,"mean":25}
{"end":3,"mean":35}
{"end":4,"mean":47.5}
completed in 404µs — means: 4 records
```

- `size` items per window; `step` is the distance between window starts (default: `size`, so windows do not overlap; `step: 1` slides by one record). `emitPartial: false` drops the incomplete windows at the end, which is what a moving average wants.
- `partitionBy: 'item["customer"]'` forms windows per key; the key is in `frame["window"]["partition"]`. With a `size` larger than any group (the maximum is 1000000) and the default `emitPartial: true`, each group arrives as one frame at the end of the input: that is how to total per key in Starlark.
- `partitionBy` together with `step: 1` and `emitPartial: false` gives a sliding window per key; each frame is emitted as soon as it is full.
- A `windows` output can only be connected to a `windows` input. `std:map` and the other record pipes do not accept it (`E_SCHEMA`).
- The manifest of the consumer lists `requires: [windows]` and `scope: 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`:

```markdown
---
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`:

```python
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`:

```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`:

```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:

```bash
printf '{"country":"%s"}\n' GB DE GB | openflange run ./pipes/count-by-country
```

It printed (exit status 2):

```text
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 file
```

Grant 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:`:

```bash
printf '{"country":"%s"}\n' GB DE GB | openflange run ./pipes/count-by-country --grant subprocess
```

It printed (exit status 0):

```text
{"country": "DE", "count": 1}
{"country": "GB", "count": 2}
completed in 22ms — counts: 2 records
```

```bash
printf '{"country":"%s"}\n' GB DE GB | openflange run ./count.yaml
```

It printed (exit status 0):

```text
{"country": "DE", "count": 1}
{"country": "GB", "count": 2}
completed in 22ms — counts: 2 records
```

```bash
openflange test ./pipes/count-by-country
```

It printed (exit status 0):

```text
pipes/count-by-country/tests/count-by-country.test.yaml
  ok    counts and sorts
ok 1 test passed in 1 file (25ms)
```

- Declare `scope: dataset` when the script reads the whole input before writing, as this one does.
- Parameters reach the program as environment variables: parameter `largeAbove` is `OPENFLANGE_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 with `E_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`:

```diff
-       in: {from: decode.outputs.out}
+       in: {from: decode.outputs.records}
```

```bash
openflange validate .
```

It printed (exit status 2):

```text
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 file
```

Fix: 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`:

```diff
-     pipe: std:cast
+     pipe: std:sort
```

```bash
openflange validate .
```

It printed (exit status 2):

```text
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 file
```

Fix: 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`:

```diff
      pipe: std:cast
-     inputs:
-       in: {from: check.outputs.valid}
```

```bash
openflange validate .
```

It printed (exit status 2):

```text
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 file
```

Fix: 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`:

```diff
-       fields: {age: integer}
+       field: {age: integer}
```

```bash
openflange validate .
```

It printed (exit status 2):

```text
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 file
```

Fix: 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`:

```diff
-       expr: 'dict(item, email=item["email"].strip().lower())'
+       expr: 'dict(item, total=sum([1, 2]))'
```

```bash
openflange validate .
```

It printed (exit status 2):

```text
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 file
```

Fix: 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`.

```bash
openflange run ./pipeline.yaml --input csv=signups.csv --output clean=- --output rejected=rejected.ndjson
```

It printed (exit status 2):

```text
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`:

```diff
- nodes:
+ steps:
```

```bash
openflange validate .
```

It printed (exit status 2):

```text
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 file
```

Fix: 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`:

```diff
- Implements the [OpenFlange](https://openflange.org/) specification.
- 
```

```bash
openflange validate .
```

It printed (exit status 2):

```text
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 file
```

Fix: 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.

```bash
printf '{"a":1}\n' | openflange run std:file-sink --param path=out.ndjson
```

It printed (exit status 2):

```text
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.

```bash
printf '{"a":1}\n' | openflange run std:file-sink --param path=out.ndjson --grant filesystem.write=out.ndjson
```

It printed (exit status 0):

```text
completed in 3ms
```

### E_LOCK

A locked run found no lockfile, or a pipe that differs from it.

`--locked` before the lockfile exists.

```bash
openflange run . --locked --input csv=signups.csv --output clean=- --output rejected=rejected.ndjson
```

It printed (exit status 2):

```text
E_LOCK: --locked needs openflange.lock.yaml, and there is none in . or above
  hint: run `openflange resolve` in the project directory to create it
```

Fix: 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`:

```diff
-       fields: {age: integer}
+       fields: {age: number}
```

```bash
openflange run . --locked --input csv=signups.csv --output clean=- --output rejected=rejected.ndjson
```

It printed (exit status 2):

```text
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 intended
```

Fix: if the change is intended, update the lock entry and commit the lockfile. If not, restore the file.

```bash
openflange update ./
```

It printed (exit status 0):

```text
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.

```bash
openflange run . --input csv=signups.csv
```

It printed (exit status 1):

```text
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 records
```

Fix: 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`:

```diff
-       expr: 'dict(item, email=item["email"].strip().lower())'
+       expr: 'dict(item, email=item["e-mail"].strip().lower())'
```

```bash
openflange run . --input csv=signups.csv --output clean=- --output rejected=rejected.ndjson
```

It printed (exit status 1):

```text
E_RUNTIME: item 1: key "e-mail" not in dict (node clean)
failed in 248µs — clean: 0 records, rejected: 0 records
```

Fix: 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.

```bash
printf 'email,country,age\nada@example.com,GB\n' | openflange run . --output clean=- --output rejected=rejected.ndjson
```

It printed (exit status 1):

```text
E_FORMAT: CSV row 2 has 2 fields, expected 3 (node decode)
failed in 257µs — clean: 0 records, rejected: 0 records
```

Fix: 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.

```bash
printf '{"a":1}\n\n{"a":2}\n' | openflange run std:filter --param expr='item["a"] > 1'
```

It printed (exit status 1):

```text
E_FORMAT: NDJSON line 2: blank lines are not allowed (node filter)
failed in 155µs — out: 0 records
```

Fix: 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.

```bash
printf '{"a":1}\n' | openflange run std:split --param expr='item["a"] > 1'
```

It printed (exit status 2):

```text
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 usage
```

Fix: 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`](https://openflange.dev/std/map/) | Emits the value of a Starlark expression for every item. | `in` → `out` | `expr` (string, required) |
| [`std:select`](https://openflange.dev/std/select/) | Keeps only the listed members of each record. | `in` → `out` | `fields` (array, required) |
| [`std:rename`](https://openflange.dev/std/rename/) | Renames members of each record. | `in` → `out` | `mapping` (object, required) |
| [`std:cast`](https://openflange.dev/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`](https://openflange.dev/std/filter/) | Keeps the items for which a Starlark expression is truthy. | `in` → `out`, `rejected`? | `expr` (string, required) |
| [`std:limit`](https://openflange.dev/std/limit/) | Emits at most the first `count` items. | `in` → `out` | `count` (integer, required) |
| [`std:skip`](https://openflange.dev/std/skip/) | Discards the first `count` items. | `in` → `out` | `count` (integer, required) |
| [`std:distinct`](https://openflange.dev/std/distinct/) | Keeps the first item for every distinct key; bounded by maxKeys. | `in` → `out` | `fields` (array), `maxKeys` (integer, default 1000000) |
| [`std:split`](https://openflange.dev/std/split/) | Routes each item to `matched` or `unmatched` by a boolean expression. | `in` → `matched`, `unmatched` | `expr` (string, required) |
| [`std:partition`](https://openflange.dev/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`](https://openflange.dev/std/merge/) | Merges several streams into one, interleaved or concatenated. | `in` (variadic) → `out` | `mode` (string, default "interleave", "interleave" \| "concat") |
| [`std:batch`](https://openflange.dev/std/batch/) | Groups consecutive items into JSON arrays of `size` items. | `in` → `out` | `size` (integer, required) |
| [`std:unbatch`](https://openflange.dev/std/unbatch/) | Flattens array items into their elements. | `in` → `out` | — |
| [`std:window`](https://openflange.dev/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`](https://openflange.dev/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`](https://openflange.dev/std/json-parse/) | Parses NDJSON text into items. | `in` (text) → `out` | — |
| [`std:json-format`](https://openflange.dev/std/json-format/) | Serialises items as NDJSON text. | `in` → `out` (text) | — |
| [`std:csv-decode`](https://openflange.dev/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`](https://openflange.dev/std/csv-encode/) | Serialises records as CSV text. | `in` → `out` (text) | `header` (boolean, default true), `delimiter` (string, default ","), `fields` (array) |
| [`std:ndjson-to-arrow`](https://openflange.dev/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`](https://openflange.dev/std/arrow-to-ndjson/) | Converts Arrow record batches to records, refusing lossy values. | `in` (batches) → `out` | — |
| [`std:validate-schema`](https://openflange.dev/std/validate-schema/) | Routes items by validity against a JSON Schema. | `in` → `valid`, `rejected`? | `schema` (object, required) |
| [`std:stdin`](https://openflange.dev/std/stdin/) | Source: the runner's standard input as NDJSON. | — → `out` | — |
| [`std:stdout`](https://openflange.dev/std/stdout/) | Sink: the runner's standard output as NDJSON. | `in` → — | — |
| [`std:file-source`](https://openflange.dev/std/file-source/) | Source: an NDJSON file. Needs a filesystem.read grant covering `path`. | — → `out` | `path` (string, required) |
| [`std:file-sink`](https://openflange.dev/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`](https://openflange.dev/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`](https://openflange.dev/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 `in` and one output `out`. Exceptions to remember: `std:validate-schema` writes to `valid` and `rejected`; `std:split` to `matched` and `unmatched` (both required); `std:partition` to `p0` ... `p7`.
- Records keep the order of their members from input to output (CSV columns stay in header order).
- `std:filter` drops records for which the expression is false unless its `rejected` output is connected. `std:validate-schema` fails the run on an invalid record unless `rejected` is connected; rejected records look like `{"item": <record>, "errors": [{"path": "/age", "message": "..."}]}`.
- The `schema` of `std:validate-schema` is JSON Schema 2020-12: `type`, `required`, `properties`, `enum`, `const`, `minimum`, `exclusiveMinimum`, `minLength`, `pattern`, `if` and `then` all work. `pattern` uses RE2 syntax: no look-ahead, no back-references. `format` is not enforced (`format: email` accepts any string). To write the original record instead of the `{"item", "errors"}` wrapper, put `std:map` with `expr: 'item["item"]'` after `rejected`.
- `std:cast` takes `fields: {name: string|integer|number|boolean}`: `"19.99"` cast to `number` becomes `19.99`, `"42"` cast to `integer` becomes `42`. A value that cannot be converted exactly fails the run, or with `onError: reject` goes to `rejected` as `{"item": <record>, "errors": [{"field": "age", "message": "..."}]}`. For numeric rules on CSV data, validate the text, cast, then use `std:filter` with an expression such as `item["amount"] > 0`.
- `std:distinct` keeps the first record per key; `fields: [email]` makes `email` the key, and without `fields` the whole record is the key. A missing member and a `null` member are two different keys. It remembers every key (up to `maxKeys`).
- `std:file-source`, `std:file-sink` and `std:http-source` read and write NDJSON only and need grants (`filesystem.read`, `filesystem.write`, `network`). For most jobs binding files with `--input` and `--output` is simpler and needs no grant.
- CSV is read by declaring a `text` input in the manifest and decoding it with `std:csv-decode`; it is written with `std:csv-encode` into a `text` output. Every decoded value is a string, and an empty cell is the empty string `""`, never `null` or a missing member. `std:csv-encode` writes the columns named in `fields`, in that order (without `fields`: 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, `expression` pipes 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:window` or a `scope: dataset` pipe.

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`:

```markdown
---
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`:

```python
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 it
```

```bash
printf '{"email":"%s"}\n' ada@example.com carol@example.net | openflange run ./pipes/email-domain --grant subprocess
```

It printed (exit status 0):

```text
{"email": "ada@example.com", "domain": "example.com"}
{"email": "carol@example.net", "domain": "example.net"}
completed in 23ms — records: 2 records
```

- `maxWaitMs` is how long the runner may hold a partial slice while waiting for more records; `0` (the default) never waits. Every slice has between 1 and `maxItems` records.
- With `cardinality: one-to-one` the 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>=100` on the command line.

Measured gains, from [RFC 0003](https://github.com/openflange/spec/blob/main/rfcs/0003-batch-mode.md) (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](https://openflange.dev/agents/#files), [`std:csv-decode`](https://openflange.dev/std/csv-decode/) |
| Write a CSV file | `std:csv-encode` into a manifest output with `kind: text` | [`std:csv-encode`](https://openflange.dev/std/csv-encode/) |
| Read or write NDJSON (JSON Lines) | `--input port=file`, `--output port=file`; nothing to decode | [Running the job](https://openflange.dev/agents/#loop-run) |
| Drop rows by a condition | `std:filter` with `expr` | [`std:filter`](https://openflange.dev/std/filter/) |
| Keep the dropped rows too | `std:filter` with its `rejected` output connected, or `std:split` (`matched`, `unmatched`) | [`std:filter`](https://openflange.dev/std/filter/), [`std:split`](https://openflange.dev/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`](https://openflange.dev/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](https://openflange.dev/agents/#loop-run) |
| Convert strings to numbers or booleans | `std:cast` with `fields` | [`std:cast`](https://openflange.dev/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`](https://openflange.dev/std/map/), [Starlark rules](https://openflange.dev/agents/#custom-starlark) |
| Keep only some columns; rename columns | `std:select` with `fields`; `std:rename` with `mapping` | [`std:select`](https://openflange.dev/std/select/), [`std:rename`](https://openflange.dev/std/rename/) |
| Remove duplicates by a key | `std:distinct` with `fields: [key]` | [`std:distinct`](https://openflange.dev/std/distinct/) |
| First N rows; skip a header-like prefix | `std:limit` for the first N; `std:skip` to skip a prefix | [`std:limit`](https://openflange.dev/std/limit/), [`std:skip`](https://openflange.dev/std/skip/) |
| Route rows to several outputs by a key | `std:partition` (up to 8 outputs) or chained `std:split` | [`std:partition`](https://openflange.dev/std/partition/), [`std:split`](https://openflange.dev/std/split/) |
| Combine several inputs into one stream | `std:merge` (`mode: concat` keeps the order of the inputs) | [`std:merge`](https://openflange.dev/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`](https://openflange.dev/std/window/), [Moving average](https://openflange.dev/agents/#custom-window) |
| 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](https://openflange.dev/agents/#custom-window), [A Python script](https://openflange.dev/agents/#custom-python) |
| Sort; join two inputs; exact aggregates over everything | A `scope: dataset` custom pipe (Python, DuckDB); no standard pipe does this | [A Python script](https://openflange.dev/agents/#custom-python) |
| Call an API or a language model for every row | A script or executable pipe in batch mode, with `network` grants | [Batch mode](https://openflange.dev/agents/#batch), [Examples](https://openflange.dev/examples/) |
| Fetch NDJSON from a URL | `std:http-source` with a `network` grant | [`std:http-source`](https://openflange.dev/std/http-source/) |
| Read Parquet, Excel, XML, a database or cloud storage | A custom pipe; not in the standard library | [Custom steps](https://openflange.dev/agents/#custom) |
| Run it every night | Cron or CI calls `openflange run . --locked ...`; OpenFlange does not schedule | [ETL guide](https://openflange.dev/etl/) |
| Make the run reproducible | `openflange resolve`, commit `openflange.lock.yaml`, run with `--locked` | [Locking](https://openflange.dev/agents/#loop-lock) |
| Expose a step over HTTP | `openflange serve <pipe>` | [CLI reference](https://openflange.dev/cli/) |
| A quick one-off on one file | Probably no OpenFlange: `jq`, `awk` or a short script | [When it does not fit](https://openflange.dev/agents/#fit) |

## Where to read more

- [Quickstart](https://openflange.dev/quickstart/): the same loop with a pipe of your own, step by step.
- [ETL guide](https://openflange.dev/etl/): a larger CSV-to-CSV job with an aggregate, a lockfile and a scheduler.
- [CLI reference](https://openflange.dev/cli/): every command, the output contract, exit codes.
- [Standard pipes](https://openflange.dev/std/): one page per pipe with a worked example.
- [Concepts](https://openflange.dev/concepts/): manifest, ports, streams, pipelines, permissions, lockfiles, batch mode.
- [Everything on this site as one text file](https://openflange.dev/llms-full.txt) and the [index](https://openflange.dev/llms.txt).
- Normative specifications, as Markdown: [pipe](https://openflange.org/pipe/v0.1.md), [pipeline](https://openflange.org/pipeline/v0.1.md), [standard library](https://openflange.org/std/v0.1.md), [portable tests](https://openflange.org/test/v0.1.md), [lockfile](https://openflange.org/lock/v0.1.md), [CLI protocol](https://openflange.org/cli/v0.1.md).

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.
