---
title: OpenFlange Pipeline Specification
spec: openflange.org/pipeline/v0.1
version: 0.1.0-draft
status: experimental
updated: 2026-12-03
summary: Composition and execution — the pipeline.yaml graph format, references, parameter binding, compile-time validation, stream formats, execution semantics, window framing, run reports and error codes.
---

# OpenFlange Pipeline Specification v0.1

This specification defines how OpenFlange pipes are composed and executed: the `pipeline.yaml` file, in which each node names the producer of each of its inputs, and the validation a runner performs before anything runs. It also defines the stream formats, the execution semantics (ordering, backpressure, broadcast, failure, cancellation), window framing, the run report and the error codes shared by all OpenFlange specifications.

This document is published at <https://openflange.org/pipeline/v0.1>. Its identifier, `openflange.org/pipeline/v0.1`, is that URL without the scheme, and is the value documents of this kind carry in `spec:`.

## At a glance

- **Identifier:** `openflange.org/pipeline/v0.1` — the value of `spec:` in documents of this kind
- **Published at:** <https://openflange.org/pipeline/v0.1> (raw Markdown: <https://openflange.org/pipeline/v0.1.md>)
- **Version:** 0.1.0-draft
- **Status:** experimental (feature maturity labels are listed in the document)
- **Updated:** 2026-12-03
- **JSON Schemas (2020-12):**
  - <https://openflange.org/schemas/pipeline-v0.1.schema.json>
  - <https://openflange.org/schemas/plan-v0.1.schema.json>
  - <https://openflange.org/schemas/run-report-v0.1.schema.json>
  - <https://openflange.org/schemas/error-v0.1.schema.json>
  - <https://openflange.org/schemas/window-frame-v0.1.schema.json>
  - <https://openflange.org/schemas/layout-v0.1.schema.json>
- **Related specifications:**
  - Pipe: <https://openflange.org/pipe/v0.1>
  - Standard library: <https://openflange.org/std/v0.1>
  - Lockfile: <https://openflange.org/lock/v0.1>
  - CLI protocol: <https://openflange.org/cli/v0.1>
  - HTTP Pipe Protocol: <https://openflange.org/http/v0.1>
  - Portable tests: <https://openflange.org/test/v0.1>
  - Pipeline layout: <https://openflange.org/layout/v0.1>

## Minimal example

A complete, valid standalone pipeline with two nodes, one input and one
output:

```yaml openflange:pipeline
spec: openflange.org/pipeline/v0.1
nodes:
  lowercase:
    pipe: ./pipes/lowercase
    inputs:
      text: {from: inputs.email}
  mask:
    pipe: ./pipes/mask-email
    inputs:
      email: {from: lowercase.outputs.text}
outputs:
  email: {from: mask.outputs.email}
```

Connections are written once, on the consumer: `mask` says where its
`email` input comes from.

## 1. Introduction

A pipeline connects pipes. This document specifies:

- the **pipeline file** `pipeline.yaml`: nodes, consumer-side input mappings
  and pipeline outputs (sections 3–5);
- **compilation**: what a runner validates before anything runs and the
  explicit execution plan it produces (section 6);
- **streams**: the data formats that flow between ports (section 7);
- **execution semantics**: ordering, backpressure, broadcast, port and run
  states, failure, cancellation and partial output (section 8);
- **window framing** (proposed, section 9), the **run report** (section 10)
  and the **error code registry** (section 11) shared by all OpenFlange
  specifications.

The pipe contract itself is defined by the
[Pipe specification](https://openflange.org/pipe/v0.1).

### 1.1 Conventions

The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT,
RECOMMENDED, MAY and OPTIONAL are to be interpreted as described in RFC 2119
and RFC 8174 when, and only when, they appear in capitals.

Fenced examples whose info string contains `openflange:<kind>` are normative
and machine-checked against the JSON Schemas in [`schemas/`](https://openflange.org/schemas/)
(`pipeline-v0.1`, `layout-v0.1`, `plan-v0.1`, `run-report-v0.1`,
`error-v0.1`, `window-frame-v0.1`).

### 1.2 Citing this document

Normative statements are cited by **section number**, for example
`pipeline/v0.1 §4.2`, and numbered or bulleted rules within a section by their
position, for example `pipeline/v0.1 §4.2(3)`. Section numbers are stable
within v0.1: sections are appended, never renumbered. Every heading has a
stable fragment identifier derived from its text (lower-cased; characters
other than letters, digits, spaces, hyphens and underscores removed; spaces
replaced by hyphens), so a section is addressable as
`https://openflange.org/pipeline/v0.1#<fragment>`. Cross-references to other
OpenFlange specifications are absolute URLs of that form. This document
does not rely on images; its diagrams are text.

## 2. Terminology and maturity

### 2.1 Terminology

The terms **pipe**, **source**, **sink**, **pipeline**, **subpipeline**,
**node**, **port**, **stream**, **run** and **dataset** are defined in the
[Pipe specification, section 2](https://openflange.org/pipe/v0.1#2-terminology); **workflow**
is reserved for future control-flow orchestration and is not used here.
Additional terms:

- **producer** — something a stream comes from: an output port of a node, or
  an external input of the pipeline.
- **consumer** — something a stream goes to: an input port of a node, or an
  external output of the pipeline.
- **edge** — one producer-to-consumer connection in the compiled plan.
- **broadcast** — one producer feeding several consumers.
- **item** — one element of a `records` or `values` stream.
- **runner** — software that compiles and executes pipelines.
- **adapter** — the part of a runner that executes one implementation type.

### 2.2 Feature maturity

| Feature | Maturity |
|---|---|
| Pipeline file: nodes, consumer-side mappings, outputs, shorthand string form (3) | experimental |
| Output controls `discard`, `enabled` (3.4) | experimental |
| Standalone pipelines with inferred ports (3.6) | experimental |
| Layout file `pipeline.layout.yaml` (3.7) | experimental |
| Reference forms: path, `std:`, `builtin:`, `npm:`, `git:`, `https:`, registry (4) | experimental |
| Reference forms `pypi:`, `cran:`, `oci:` (4) | experimental (recognised; installing them is unsupported in v0.1) |
| Parameter bindings `$param`, `$env`, `$expr`; `$secret` (5) | experimental |
| Compile-time validation and execution plan (6) | experimental |
| NDJSON, text and binary streams; number fidelity (7) | experimental |
| Arrow IPC streams (7) | experimental (optional capability `arrow`) |
| Automatic lossless conversion (7.4) | experimental |
| Execution semantics: order, backpressure, broadcast, states, fail-fast (8) | experimental |
| Batch mode: node `batch` settings (3.8), delivery rule (8.11), effective settings in the plan (6.5) | experimental (feature `batch`) |
| Window framing (9) | **proposed** |
| Processing-time windows | **proposed** (draft, see the standard library) |
| Run report (10) | experimental |
| OpenTelemetry export | experimental, optional |
| Error codes (11) | experimental; the registry is append-only |

Nothing is `stable` or `deprecated` in v0.1.

## 3. The pipeline file

### 3.1 Structure

A pipeline file is a YAML document, conventionally named `pipeline.yaml`,
parsed with the safe YAML rules of the
[Pipe specification, section 4.2](https://openflange.org/pipe/v0.1#42-safe-yaml), and valid
against `https://openflange.org/schemas/pipeline-v0.1.schema.json`.

| Key | Required | Meaning |
|---|---|---|
| `spec` | see below | The constant `openflange.org/pipeline/v0.1`. |
| `parameters` | no | Parameter declarations of a *standalone* pipeline (3.6). |
| `nodes` | yes | Map of node id to node (3.2). At least one node. |
| `outputs` | no | Map of pipeline output name to `{from: <source>}`, or to the source string as a shorthand (3.5). |
| `x-<vendor>-<name>` | no | Extensions. |

`spec` is REQUIRED when the file is run or validated standalone. It MAY be
omitted when the file is referenced by a manifest
(`implementation: {type: pipeline}`), whose own `spec` then governs.

Any other top-level key is an error (`E_MANIFEST`). Two absences are
deliberate and normative:

- There is **no `connections` section and no producer-side mapping**. A
  connection is written exactly once, on the consumer.
- **`layout` is forbidden** in the pipeline file; visual coordinates and
  tool state live in a separate file (3.7).

### 3.2 Nodes

```yaml
nodes:
  mask:
    pipe: ./pipes/mask-email
    inputs:
      email: {from: lowercase.outputs.text}
    outputs:
      rejected: {enabled: false}
    parameters:
      character: "*"
    grants: {}
```

A node id matches `^[a-z][a-z0-9_-]{0,63}$` and is unique within the file (a
repeated id is a duplicate YAML key, `E_DUPLICATE`). The identifiers
`inputs`, `outputs`, `params`, `env`, `std` and `builtin` are **reserved**
and MUST NOT be used as node ids (`E_RESERVED`); they keep the source
grammar and reference schemes unambiguous.

| Key | Required | Meaning |
|---|---|---|
| `pipe` | yes | Reference to the pipe this node instantiates (4). |
| `inputs` | no | Map of the pipe's input port names to their producer (3.3). |
| `outputs` | no | Consumer-side controls for the pipe's outputs (3.4). |
| `parameters` | no | Parameter bindings (5). |
| `secrets` | no | Secret bindings (5.3). |
| `grants` | no | Permissions granted to this node (Pipe specification, section 10). |
| `batch` | no | Batch settings for a pipe that declares batch mode; they may only tighten (3.8). |

Each node is one instance: it is started once per run and executes once,
however many consumers read its outputs.

### 3.3 Consumer-side input mappings

Each input of a node names its producer with a **source**:

```
source = "inputs." name                 ; an external input of this pipeline
       / nodeId ".outputs." port        ; an output port of a node
```

An input mapping is either the object form `{from: <source>}` or, as a
shorthand, the source string itself:

```yaml
inputs:
  text: {from: inputs.email}
  other: inputs.email
```

Rules:

1. **Consumer-side only.** Mappings are written on the consumer. Pipeline
   outputs are consumers too (3.5).
2. **Broadcast.** A producer MAY be referenced by any number of consumers.
   This is a broadcast of one stream — the producing node runs **once**; it
   is never re-executed per consumer.
3. **One producer per input.** A non-variadic input has exactly one
   producer. Feeding one logical input from several producers requires an
   explicit merge node (`std:merge`), whose **variadic** input takes a list:
   `{from: [a.outputs.out, b.outputs.out]}`. The list form on a non-variadic
   input, or the same producer listed twice, is `E_DUPLICATE`.
4. **Joins** are simply pipes with several inputs; each input is mapped
   independently.
5. **Direction.** A source names a producer. Using a consumer as a source —
   `x.inputs.y`, or `outputs.y` — is `E_DIRECTION`. A source that does not
   match the grammar, or names a node, port or pipeline input that does not
   exist, is `E_REF`.
6. **Acyclic.** The graph of nodes MUST be acyclic, including self-loops
   (`E_CYCLE`).
7. **Required connectivity.** Every required input of every node MUST be
   mapped (`E_UNCONNECTED`). An optional input MAY be left unmapped and is
   then *disconnected*.

### 3.4 Output controls

Outputs need no declaration to be used: an output is connected when at
least one consumer references it. The optional `outputs` map of a node
carries consumer-side *controls* for outputs that are deliberately not
consumed:

```yaml
outputs:
  unmatched: {discard: true}    # a required output nobody reads
  stats: {enabled: false}       # an optional output switched off
```

- A **required output** MUST have at least one consumer or
  `discard: true`; otherwise the pipeline is invalid (`E_UNCONNECTED`).
  With `discard: true` and no consumer, the runner itself drains the stream
  and discards the data; the pipe sees an enabled, connected output. If the
  output also has consumers, `discard` has no effect (a runner SHOULD warn).
- An **optional output** with no consumer is *disconnected* and therefore
  disabled; `enabled: false` states this explicitly. An optional output MAY
  be discarded with `discard: true`, in which case it is enabled and drained.
- `enabled: false` on a required output is invalid (`E_UNCONNECTED`), as is
  a consumer that references an output disabled with `enabled: false`
  (`E_REF`).
- A control for a port the pipe does not declare is `E_REF`.

### 3.5 Pipeline outputs

```yaml
outputs:
  masked: {from: mask.outputs.email}
  normalized: {from: lowercase.outputs.text}
```

Each entry of the top-level `outputs` map is an external output of the
pipeline and a consumer of the named source. As for node inputs (3.3), an
entry is either the object form `{from: <source>}` or, as a shorthand, the
source string itself; the two are equivalent and MAY be mixed:

```yaml
outputs:
  masked: mask.outputs.email
  normalized: lowercase.outputs.text
  rejected: {from: mask.outputs.rejected}
```

A pipeline output has exactly one producer; there is no list form. A pipeline output MAY be fed directly from a
pipeline input (`{from: inputs.x}`), which is a pass-through.

### 3.6 External ports

**Composite.** When a pipeline file is the implementation of a manifest,
its external ports are exactly the manifest's ports:

- every `inputs.<name>` source MUST name an input declared by the manifest
  (`E_REF`);
- every entry of `outputs` MUST name an output declared by the manifest
  (`E_REF`), and every output declared by the manifest MUST have an entry
  (`E_UNCONNECTED`);
- the top-level `parameters` key MUST be absent; `$param` refers to the
  manifest's parameters;
- whether an external port is enabled is decided by the *enclosing*
  pipeline and propagates inwards: if the consumer leaves the composite's
  optional output `rejected` disconnected, then the inner output that feeds
  it has one consumer fewer and may itself become disconnected. If the
  consumer leaves an optional *input* disconnected, an inner node input
  mapped to it is disconnected if that input is optional, and otherwise
  receives an empty, completed stream; in a variadic list it contributes
  nothing.

**Standalone.** A pipeline file without a manifest gets its external ports
by inference: every distinct `inputs.<name>` that is referenced is a
required, untyped input of kind `records`; every entry of `outputs` is a
required output with the kind and schema of its source. Its parameters are
those declared under the top-level `parameters` key.

### 3.7 Layout

Visual coordinates and other tool state are kept in a separate file next to
the pipeline, `pipeline.layout.yaml`, specified by the
[Pipeline layout specification](https://openflange.org/layout/v0.1):

```yaml openflange:layout
spec: openflange.org/layout/v0.1
nodes:
  lowercase: {x: 120, y: 80}
  mask: {x: 360, y: 80}
```

Runners MUST ignore layout files entirely; a missing, stale or invalid
layout file never affects validation or execution. Tools MUST NOT store
secrets or cached records in layout files. Tool-specific state uses `x-`
keys.

### 3.8 Node batch settings

A pipe may declare **batch mode**
([Pipe specification, section 5.7](https://openflange.org/pipe/v0.1#57-batch-mode)):
its implementation receives its input in slices of up to `maxItems` items,
which the runner holds back for at most `maxWaitMs`. The consumer MAY
adjust both per node:

```yaml
nodes:
  embed:
    pipe: ./pipes/embed            # declares batch: {maxItems: 100, maxWaitMs: 1000}
    inputs:
      text: {from: inputs.text}
    batch:
      maxItems: 16                 # smaller slices
      maxWaitMs: 0                 # never hold a record back
```

| Key | Type | Meaning |
|---|---|---|
| `maxItems` | integer ≥ 1 | Replaces the declared `maxItems`. MUST be less than or equal to it. |
| `maxWaitMs` | integer ≥ 0 | Replaces the declared `maxWaitMs`. MUST be less than or equal to it. |

Rules:

1. **Tighten only.** A node setting MUST be smaller than or equal to the
   value the pipe declares (for `maxWaitMs`, to the declared value or its
   default `0`). A larger value is `E_PARAM`: the pipe's author stated the
   largest slice and the longest wait the implementation is prepared for,
   and a consumer cannot exceed that.
2. At least one of the two keys MUST be present (`E_MANIFEST`, by the
   schema); a key that is absent leaves the declared value in force. A
   node cannot change `delivery`: it is part of how the pipe is written
   (`E_MANIFEST`, by the schema).
3. `batch` on a node whose pipe **does not declare batch mode** is
   `E_PARAM`. A consumer cannot switch batch mode on; a pipe that was
   written per item stays per item.
4. The values are literals. Parameter bindings (`$param`, `$env`, `$expr`)
   are not accepted here in v0.1.
5. The **effective settings** of the node — the declared values with the
   node's replacements applied — are part of the execution plan (6.5).
6. Settings never change *what* a conformant pipe outputs, only how its
   input is sliced: batch boundaries are not semantic. Tightening is a
   latency, memory and cost decision.

A composite pipe cannot declare batch mode, so a node that instantiates a
composite cannot carry `batch` (rule 3); the consumer of a composite has no
handle on the batch settings of its inner nodes.

```yaml openflange:pipeline
spec: openflange.org/pipeline/v0.1
nodes:
  embed:
    pipe: ./pipes/embed
    inputs:
      text: {from: inputs.text}
    batch: {maxItems: 16, maxWaitMs: 0}
outputs:
  vectors: {from: embed.outputs.vectors}
```

## 4. References

The `pipe` key of a node holds a **reference**. The forms defined by v0.1:

| Form | Meaning |
|---|---|
| `./path`, `../path`, `/abs/path` | A directory containing `OPENFLANGE.md`, or a manifest file. Relative paths resolve against the directory of the pipeline file. |
| `std:<name>[@<range>]` | A portable [standard library](https://openflange.org/std/v0.1) pipe. |
| `builtin:<runtime>/<name>` | A runtime-specific pipe (not portable). |
| `npm:<pkg>[@<range>][#<manifest subpath>]` | An npm package containing a manifest. |
| `git:<https url>[#<ref>][:<subpath>]` | A Git repository; `ref` is a branch, tag or commit. |
| `https://host/base/pipes/<id>` | A remote pipe served with the [HTTP Pipe Protocol](https://openflange.org/http/v0.1); its contract is discovered live. |
| `<publisher>/<name>[@<range>]` | A [registry](https://openflange.org/registry/v0.1) reference, resolved through the configured registry index to one of the forms above. |
| `pypi:…`, `cran:…`, `oci:…` | Recognised distributions. A v0.1 runner MUST NOT claim to install them and reports `E_UNSUPPORTED`. |

A reference that matches none of these forms is `E_REF`. `<range>` is a
SemVer range (`0.1`, `^0.1.2`, `>=0.1 <0.3`, an exact version). References
are resolved to exact versions and integrity hashes recorded in the
lockfile; resolution, integrity, transitive dependencies and safe fetching
are specified in the [Lockfile specification](https://openflange.org/lock/v0.1). Registry,
npm and relative references to the same pipe MUST resolve to the same
contract.

Reference resolution MUST detect cycles between composite pipes (a pipe
that, directly or through other composites, contains itself) and report
`E_CYCLE`.

## 5. Parameters and secrets

### 5.1 Bindings

A node supplies values for its pipe's parameters under `parameters`. Each
value is one of:

| Form | Meaning |
|---|---|
| a literal | Any YAML value that is not one of the objects below. |
| `{$param: name}` | The value of parameter `name` of the *enclosing* pipeline (standalone) or manifest (composite). |
| `{$env: NAME}` | The value of `NAME` in the runner's environment configuration. The node needs an `environment` grant for `NAME` (`E_PERMISSION` otherwise). The value is a string and is converted to the declared type. |
| `{$expr: "<starlark>"}` | A Starlark expression over `params`, the dict of the enclosing parameters, evaluated **once, before the node starts**. |

An object whose only key is `$param`, `$env` or `$expr` is a binding. Any
other object with a top-level key beginning with `$` — including
`{$secret: …}`, which is only valid under `secrets` (5.3) — is invalid and
fails the pipeline schema (`E_MANIFEST`); literal
objects for `object`-typed parameters therefore cannot have top-level keys
starting with `$`.

```yaml openflange:pipeline
spec: openflange.org/pipeline/v0.1
parameters:
  keep: {type: integer, default: 1, minimum: 0, maximum: 4}
nodes:
  mask:
    pipe: ./pipes/mask-email
    inputs:
      email: {from: inputs.email}
    outputs:
      rejected: {enabled: false}
    parameters:
      character: "#"
      preserveFirst: {$param: keep}
      preserveLast: {$expr: 'params["keep"] * 2'}
outputs:
  email: {from: mask.outputs.email}
```

### 5.2 Resolution and immutability

All bindings of a node are resolved before the node starts, defaults are
applied, and the result is validated against the pipe's declarations
(`E_PARAM` for an unknown parameter, a missing required parameter, a wrong
type, a value outside `enum` or bounds, a `$param` naming an undeclared
parameter, or an `$expr` that fails). Whatever can be checked at compile
time MUST be checked at compile time; a binding that depends on run-time
input (`$env`, a `$param` supplied by the invoker) is checked when the run
is prepared, still before any node starts.

Resolved parameters are **immutable for the duration of the node
execution**. A runner MUST NOT re-evaluate a binding during a run.

### 5.3 Secrets

Secrets are never parameters. A node maps each secret its pipe declares
(`permissions.secrets`) to a reference in the runner's secret provider:

```yaml
secrets:
  OPENAI_API_KEY: {$secret: TEAM_OPENAI_KEY}
```

- The default secret provider reads the runner's own environment, so the
  reference above means "the value of the runner's `TEAM_OPENAI_KEY`".
- The node needs a `secrets` grant for the declared name. A binding for a
  name the pipe does not declare is `E_PARAM`.
- The value is delivered **out of band** by the adapter (for a subprocess:
  an environment variable with the declared name; for HTTP: as defined by
  the deployment), never through parameters, files in the package, argument
  vectors or streams.
- A resolved secret MUST NOT appear in the plan, the run report, logs or
  error messages. The plan shows secret bindings as `"<redacted>"`.

## 6. Compilation and validation

Before a run starts, a runner **compiles** the pipeline: it resolves every
reference, validates the graph, negotiates formats and produces an explicit
execution plan. Compilation has no side effects on data. A pipeline that
does not compile MUST NOT be started.

### 6.1 Checks

A compiler MUST report **all** errors it can find, not only the first, each
as a structured error (11) with a code and a location (file, and where
available line, column and a path such as `nodes.mask.inputs.email`).

| Check | Code |
|---|---|
| Document cannot be parsed, or violates its schema; unknown top-level key; `layout`/`connections` present; standalone file without `spec` | `E_MANIFEST` |
| Duplicate YAML key (including a duplicate node id); several producers for a non-variadic input; a producer listed twice | `E_DUPLICATE` |
| Reserved node id | `E_RESERVED` |
| Malformed source; unknown node, port, pipeline input or reference; control for an unknown output; consumer of a disabled output; pipeline output not declared by the manifest | `E_REF` |
| Consumer used as a source | `E_DIRECTION` |
| Cycle among nodes or among composite pipes | `E_CYCLE` |
| Required input without producer; required output with neither consumer nor discard; required output disabled; manifest output without mapping | `E_UNCONNECTED` |
| Parameter unknown, missing, wrongly typed or out of bounds; node `batch` settings that loosen the pipe's declaration, or on a pipe that does not declare batch mode (3.8) | `E_PARAM` |
| Demonstrably incompatible kinds or schemas (6.2) | `E_SCHEMA` |
| No common media type and no lossless conversion (6.3) | `E_MEDIA` |
| Required permission not granted; child exceeding parent grants (6.4) | `E_PERMISSION` |
| Unsupported implementation type, language, feature, standard pipe or distribution; a pipe declaring batch mode for an implementation type the runner cannot batch | `E_UNSUPPORTED` |
| Invalid pipe manifest | `E_MANIFEST`, `E_ATTRIBUTION`, `E_PATH` (Pipe specification) |
| Lockfile problems in locked mode | `E_LOCK` |

Composite pipes are compiled recursively; errors inside a composite are
reported with the path of nodes leading to them.

### 6.2 Schema compatibility

For every edge the compiler compares the producer port with the consumer
port and classifies the edge as compatible, uncertain or incompatible.

1. **Kinds.** The kinds MUST be equal, except that `records` and `values`
   are mutually compatible (both are item streams of JSON values; the item
   schemas decide). Any other difference is incompatible.
2. **Untyped.** If either port has no schema, the edge is compatible.
3. **Different schema formats** (for example `json-schema` and `arrow`), or
   a format the runner does not understand: uncertain.
4. **JSON Schema.** If both definitions have a `type` keyword and the type
   sets cannot overlap, the edge is incompatible. `integer` satisfies
   `number`. If the definitions are deeply equal the edge is compatible.
   Otherwise it is uncertain. A compiler MAY prove more incompatibilities
   (for example a consumer requiring a member the producer's closed object
   schema cannot have) but MUST NOT report an incompatibility it has not
   demonstrated.
5. **Arrow.** Equal field lists are compatible; a field with the same name
   and a different type is incompatible; anything else is uncertain.

**Incompatible** edges are errors (`E_SCHEMA`). **Uncertain** edges produce
the warning `W_SCHEMA`; the pipeline still compiles. A runner MAY offer
run-time validation of items against port schemas (a violation then fails
the run with `E_SCHEMA`), but only when the invoker **explicitly enables
it**: by default a runner MUST NOT reject, drop or alter an item because it
does not match a declared schema. Schemas describe; pipes decide — the
reference `mask-email` pipe, for example, receives non-string items and
routes them to `rejected` itself. A runner MUST NOT silently coerce data to
make an edge fit.

### 6.3 Media types and conversions

For every edge the compiler picks a media type both ports support:

1. the first media type in the consumer's preference order that the
   producer also lists (after applying defaults per kind and treating
   `application/jsonl` as an alias of `application/x-ndjson`);
2. otherwise, a pair for which a **demonstrably lossless** conversion is
   defined (7.4), which the compiler inserts and **lists in the plan**;
3. otherwise the edge fails with `E_MEDIA`.

Potentially lossy conversions are never inserted. They are explicit nodes
(`std:csv-decode`, `std:csv-encode`, `std:ndjson-to-arrow`,
`std:arrow-to-ndjson`), visible in the pipeline file.

### 6.4 Permissions

The compiler computes each node's required permissions (declared, implied
and parameter-derived; Pipe specification section 10) and checks them
against the *effective grants*: the node's `grants`, intersected with the
enclosing composite's grants when nested, plus run-level grants supplied by
the invoker. A missing grant is `E_PERMISSION`, and the node is never
started. Validation without run-level grants (the default for
`openflange validate`) therefore reports `E_PERMISSION` for nodes that rely
on them; conformance fixtures are validated this way.

### 6.5 Execution plan

The output of compilation is an explicit **execution plan**. It contains:

- the **nodes** with, for each: the reference as written, the resolved
  location and version, the **adapter** and **execution location**
  (`local-go` — in-process in the reference runner; `subprocess`;
  `remote-http`), the resolved parameters (secrets redacted), the sets
  of enabled inputs, enabled outputs and runner-discarded outputs, and —
  for a node whose pipe declares batch mode — the **effective batch
  settings** `batch: {maxItems, maxWaitMs}` (3.8), with `delivery` when
  the pipe declares one. A node without `batch`
  in the plan is not batched;
- the internal **edges**: `from` (a source), `to` (`<nodeId>.inputs.<port>`
  or `outputs.<name>`), the negotiated media type, and the inserted
  conversion, if any;
- the external inputs and outputs;
- warnings.

A runner MUST be able to show the plan without executing anything (the
reference CLI: `openflange validate --plan`, JSON with `--json`). The JSON
shape below is `experimental`; additional members are allowed. How nested
composites are presented (inlined with path-like node ids, or as a nested
plan) is not prescribed by v0.1.

```json openflange:plan
{
  "spec": "openflange.org/pipeline/v0.1",
  "nodes": {
    "lowercase": {
      "pipe": "./pipes/lowercase",
      "resolved": "pipes/lowercase",
      "version": "0.1.0",
      "adapter": "starlark-expression",
      "location": "local-go",
      "parameters": {},
      "enabledInputs": ["text"],
      "enabledOutputs": ["text"]
    },
    "mask": {
      "pipe": "./pipes/mask-email",
      "resolved": "pipes/mask-email",
      "version": "0.1.0",
      "adapter": "starlark-script",
      "location": "local-go",
      "parameters": {"character": "*", "preserveFirst": 1, "preserveLast": 1},
      "enabledInputs": ["email"],
      "enabledOutputs": ["email", "rejected"]
    }
  },
  "edges": [
    {"from": "inputs.email", "to": "lowercase.inputs.text", "mediaType": "application/x-ndjson", "conversion": null},
    {"from": "lowercase.outputs.text", "to": "mask.inputs.email", "mediaType": "application/x-ndjson", "conversion": null},
    {"from": "lowercase.outputs.text", "to": "outputs.normalized", "mediaType": "application/x-ndjson", "conversion": null},
    {"from": "mask.outputs.email", "to": "outputs.masked", "mediaType": "application/x-ndjson", "conversion": null},
    {"from": "mask.outputs.rejected", "to": "outputs.rejected", "mediaType": "application/x-ndjson", "conversion": null}
  ],
  "warnings": []
}
```

A node in batch mode shows its effective settings; here the pipe declares
`maxItems: 100, maxWaitMs: 1000` and the node tightened `maxItems` to 16:

```json openflange:plan
{
  "spec": "openflange.org/pipeline/v0.1",
  "nodes": {
    "embed": {
      "pipe": "./pipes/embed",
      "version": "0.1.0",
      "adapter": "starlark-script",
      "location": "local-go",
      "parameters": {},
      "enabledInputs": ["text"],
      "enabledOutputs": ["vectors"],
      "batch": {"maxItems": 16, "maxWaitMs": 1000}
    }
  },
  "edges": [
    {"from": "inputs.text", "to": "embed.inputs.text", "mediaType": "application/x-ndjson", "conversion": null},
    {"from": "embed.outputs.vectors", "to": "outputs.vectors", "mediaType": "application/x-ndjson", "conversion": null}
  ],
  "warnings": []
}
```

## 7. Streams

A stream carries the data of one connected port during one run. The
*logical* content is described by the port's kind and schema; the
*encoding* by a media type. The two are separate.

### 7.1 Kinds and default media types

| kind | default media type | content |
|---|---|---|
| `records` | `application/x-ndjson` (alias `application/jsonl`) | one JSON value, normally an object, per line |
| `values` | `application/x-ndjson` | one JSON scalar per line; a string is a JSON string line: `"a@b.c"` |
| `batches` | `application/vnd.apache.arrow.stream` | Arrow IPC stream of record batches |
| `windows` | `application/x-ndjson; profile="openflange-windows"` | one window frame per line (9) |
| `text` | `text/plain; charset=utf-8` | opaque UTF-8 chunks |
| `binary` | `application/octet-stream` | opaque bytes |

`records` is the default kind and NDJSON the default record format,
including on the command line. `text` and `binary` streams are passed
through untouched: a runner MUST NOT re-chunk them in a way that changes
their bytes, and chunk boundaries carry no meaning. Parquet is a
**snapshot** format for sources and sinks; it is never the format of a live
stream and never a default.

### 7.2 NDJSON

- UTF-8, without a byte order mark.
- One JSON value per line. Lines end with `\n` (LF). A writer MUST NOT emit
  `\r\n`; a reader MUST accept it (the CR is JSON whitespace).
- A writer MUST terminate the last line with `\n`. A reader MUST tolerate a
  missing final newline.
- **Blank lines are an error.** A reader MUST fail with `E_FORMAT` on an
  empty or whitespace-only line, on invalid JSON, and on invalid UTF-8; it
  MUST NOT skip the line.
- A JSON value MUST NOT contain a raw line feed (JSON forbids it inside
  strings, and writers MUST NOT pretty-print).
- The empty stream is zero bytes.

A runner MAY bound the length of a single line and MUST fail with
`E_RESOURCE`, not truncate, when the bound is exceeded.

### 7.3 Number fidelity

JSON numbers MUST round-trip losslessly through a runner and through every
component that passes them on without computing with them. An
implementation MUST keep the original number literal (or an exact decimal
representation) rather than parsing into a binary floating-point value, so
that **large integers and decimals are preserved exactly** — in practice
byte for byte: `12345678901234567890123` and
`0.1000000000000000055511151231257827` leave as they arrived.

This applies to the runner's own plumbing (edges, broadcast, discard,
buffering, conversion between the NDJSON alias media types), to standard
pipes on values they do not modify, and to members of an item that a pipe
does not touch. A pipe that computes with a number is subject to its
language's arithmetic; that is the pipe's documented behaviour, not the
transport's.

### 7.4 Conversions

The planner inserts a conversion automatically only when it is demonstrably
lossless, and lists it in the plan and in the run report:

| from | to | automatic? |
|---|---|---|
| `application/jsonl` | `application/x-ndjson` (and back) | yes — an alias; the bytes are unchanged |
| NDJSON | CSV | **no** — lossy; explicit `std:csv-encode` |
| CSV | NDJSON | **no** — explicit `std:csv-decode` |
| NDJSON | Arrow IPC (and back) | **no** — explicit `std:ndjson-to-arrow` / `std:arrow-to-ndjson`, which refuse values they cannot preserve |
| anything | Parquet | never in a live stream |

Explicit conversions MUST preserve decimal precision, large integers,
timestamps, nullability and binary data, or refuse (`E_FORMAT`). A future
version may add further automatic conversions only where losslessness can
be demonstrated from the schemas.

## 8. Execution semantics

This section defines what every runner MUST provide. v0.1 assumes **one
orchestrating runner** per run, which may execute nodes in-process, as
subprocesses or on remote HTTP servers. The semantics are written so that
other locations (a browser, distributed agents) can be added later;
distributed scheduling itself is deferred.

### 8.1 Ordering

- Order is preserved **per stream**: a consumer receives the items of a
  stream in the order the producer emitted them. This holds across
  broadcast, buffering and conversions.
- There is no ordering relation *between* different streams.
- `std:merge` preserves the relative order of each input; the interleaving
  is unspecified unless `mode: concat` is requested, which yields the
  inputs completely, in declaration order.
- A pipe promises nothing about the order of its output relative to its
  input unless its contract says so (`cardinality: one-to-one` does).

### 8.2 Buffers and backpressure

- Streams between nodes are transported in **batches**: groups of
  consecutive items (or chunks of bytes). Batches are transport units; they
  are invisible to pipes and **never imply window boundaries**. The slices
  handed to a pipe that declares batch mode (8.11) are transport units too:
  such a pipe sees *that* its input arrives in slices, and MUST NOT attach
  meaning to where they begin and end.
- Every edge has a **bounded buffer**. The default bound is 64 batches of
  at most 256 items each. A runner MAY make this configurable; it MUST NOT
  be unbounded.
- When a buffer is full, the producer **blocks** (backpressure). A runner
  MUST NOT drop data to relieve pressure and MUST NOT grow buffers without
  bound: memory use is bounded regardless of stream length, for every pipe
  whose own scope is bounded.
- Backpressure propagates to subprocesses (the runner stops reading their
  stdout) and to HTTP servers (the client stops reading the response).

### 8.3 Broadcast

When a producer has several enabled consumers, each batch is delivered to
every one of them, in order. Batches are **immutable**: a runner MUST NOT
let one consumer observe another's modifications, and SHOULD share rather
than copy. The **slowest consumer bounds the producer**: when any
consumer's buffer is full the producer blocks. Because every enabled
output has a reader (a consumer or the runner's discard), an unread output
cannot deadlock a run.

### 8.4 Enabled ports

The set of enabled ports of every node is **computed before execution** and
is part of the plan.

- An input is enabled when it is mapped (and, inside a composite, not fed
  solely by a disconnected external input).
- An output is enabled when it has at least one consumer or is discarded
  by the runner, and is not disabled.
- The implementation is **given the enabled-port set before it processes
  anything** (the CLI configuration file, the HTTP session request, the
  Starlark `enabled()` function).
- A disabled or disconnected optional output needs no reader. Writing to a
  port that is not enabled is an error of the implementation (`E_RUNTIME`;
  in the protocols, a refused attachment).
- A required output always has a reader: a consumer or the runner's drain.

### 8.5 Port states

| State | Meaning |
|---|---|
| `disconnected` | Not part of this run (optional and unmapped, or disabled). Carries no stream. |
| `connected` | Enabled; the stream exists but no data has moved yet (pending). |
| `active` | Data is flowing, or the stream is open. |
| `completed` | The stream ended normally (EOF). |
| `failed` | The stream ended abnormally: an error or cancellation. |

**Empty streams are valid.** A required port whose stream completes with
zero items has satisfied its requirement; `completed` with a record count of
zero ("connected and empty") is distinct from `disconnected`. A pipe that
needs at least one item MUST state and check that itself.

End of stream is signalled by the transport (end of file, end of an HTTP
body, closing of a channel), never by an in-band marker.

### 8.6 Run and node states

```
pending ──► running ──► completed
                   ├──► failed
                   └──► cancelled
```

- A node is `pending` until the runner starts it, `running` until all its
  enabled outputs have completed and its implementation has returned, and
  then `completed`.
- A run is `completed` when every node has completed and every external
  output has reached EOF.
- The **terminal state is authoritative**. Output that a consumer has
  already received says nothing about success; a consumer MUST consult the
  terminal state (exit status, run report, HTTP session status).

### 8.7 Failure

- **Record-level errors are data.** A pipe that can reject items routes
  them on a declared output (for example `rejected`). The runner attaches
  no meaning to such outputs, and nothing is routed implicitly.
- **Unhandled errors fail fast.** The first unhandled error — an
  implementation failure, a format error, a protocol error, a resource
  bound, a non-zero exit — fails its node and the run:
  1. the run's context is cancelled;
  2. every blocked send and receive unblocks;
  3. subprocesses are terminated: `SIGTERM`, then `SIGKILL` after a grace
     period (5 s by default);
  4. HTTP sessions are cancelled with `DELETE`;
  5. loopback endpoints, temporary files and other resources are released.
- Nodes that were running when the run failed, and did not fail
  themselves, end as `cancelled`; nodes not yet started stay `pending`. The
  run is `failed`, and its report carries the *first* error.
- **No rollback.** Output already emitted — to stdout, to a file, to an
  HTTP client, to a sink — is not rolled back; OpenFlange gives no
  transactional guarantee. When a failed or cancelled run has delivered any
  data on an external output or to a sink, its report says
  `partialOutput: true`.

### 8.8 Cancellation

A run can be cancelled by its invoker (a signal to the CLI, `DELETE` of an
HTTP session, a programmatic context). Cancellation performs steps 1–5 of
8.7; the run ends as `cancelled` with error code `E_CANCELLED`. A run that
exceeds a configured time limit ends as `failed` with `E_TIMEOUT`.
Cancellation MUST unblock every wait in bounded time: no goroutine, thread,
process or connection may outlive the run.

### 8.9 Diagnostics

Diagnostics — logs, warnings, progress — go to the **diagnostics channel**
(standard error for the CLI; the session status and server logs for HTTP)
and **never into data streams**. A subprocess's standard error is
diagnostics. By default diagnostics MUST NOT contain record contents,
prompts sent to models, credentials or secrets; a runner MAY offer an
explicit, opt-in debug mode that includes samples of data.

### 8.10 Adapters and locations

An adapter executes one implementation type and reports where it runs. The
distinctions kept separate by the model are: **origin** (who published the
pipe), **distribution** (how it is fetched), **implementation** (type),
**language**, **runtime**, **processing scope**, **transport** (in-memory,
stdio, HTTP) and **execution location**. A runner MUST check, at compile
time, that it has an adapter for every node and that the adapter's
prerequisites are present (an interpreter on `PATH`, a reachable capability)
and report `E_UNSUPPORTED` otherwise.

### 8.11 Batch mode

> **Maturity: experimental** (feature `batch`). See RFC 0003
> (`rfcs/0003-batch-mode.md` in the specification repository).

A node whose pipe declares batch mode
([Pipe specification, section 5.7](https://openflange.org/pipe/v0.1#57-batch-mode)) has
**effective settings** `maxItems` (≥ 1) and `maxWaitMs` (≥ 0): the declared
values with the node's replacements applied (3.8). The runner delivers the
node's single input to the implementation in **slices** — non-empty runs of
consecutive items — instead of item by item.

**Two slots.** At any moment a batch-mode node has at most one slice **in
flight** — delivered to the implementation and not yet finished — and one
slice **accumulating**. The runner MUST keep reading the node's input into
the accumulating slice *while the implementation is busy* with the slice
in flight: accumulation never waits for the pipe.

**Ready.** The accumulating slice is *ready* when the **first** of these
holds:

1. **Full.** It holds `maxItems` items.
2. **Waited long enough.** `maxWaitMs` milliseconds have elapsed since
   **its first item arrived** at the node. The clock of a slice starts with
   its first item — also when that item arrives while the previous slice is
   still in flight.
3. **End of input.** The input stream has ended and the slice is not
   empty.

**Delivery rule.** A slice is delivered when it is ready **and** no slice
is in flight:

- If the implementation is idle, the accumulating slice is delivered the
  moment it becomes ready: immediately when full, when the wait has
  elapsed, or at end of input.
- If the slice became ready while the implementation was busy, it is
  delivered **immediately when the implementation finishes** the slice in
  flight — and until then it **keeps growing**, up to `maxItems`. Under
  load, slices therefore fill toward the maximum by themselves, without
  any waiting being configured.
- When the accumulating slice is full and the implementation is still
  busy, the runner stops reading the node's input. The edge's bounded
  buffer (8.2) then fills and the producer blocks: ordinary backpressure.
- **An empty slice is never delivered.** An empty input stream leads to no
  delivery at all.

With `maxWaitMs: 0` a non-empty slice is always ready, so the runner
**never waits**: an idle implementation receives whatever has arrived, up
to `maxItems`, and a lone item MUST NOT be delayed in the hope of a fuller
slice. How many items "have arrived" at that instant depends on the
runner's internal buffering and is not specified, except that it is at
least one and at most `maxItems`.

There is **no minimum slice size** in v0.1. Every slice has between 1 and
`maxItems` items. There is **one slice in flight** per node in v0.1; a
runner MUST NOT hand an implementation a second slice before the first is
finished.

When an implementation has *finished* a slice is defined by how slices
reach it: a Starlark `process_batch` call has returned; an executable has
written its answer line for the slice, or — started once per slice — has
exited
([CLI specification, sections 5.1 and 5.2](https://openflange.org/cli/v0.1#51-batch-framing)).

```text
maxItems: 4, maxWaitMs: 100. Items a…l arrive; the pipe needs a while per slice.

time ─────────────────────────────────────────────────────────────────────►
arrivals      a b c d   e f      g h i        j             k l  <EOF>
in flight            [a b c d]·········  [e f g h]·····  [i j]·····  [k l]··
                     ▲                   ▲               ▲           ▲
                     full, pipe idle:    pipe finished;  pipe        end of
                     delivered at once   e–h was full:   finished;   input:
                                         delivered       i arrived   remainder
                                         at once         >100 ms
                                                         ago: at once
accumulating           e f g h                i j            k l
                       (full while the pipe is busy: the runner stops
                        reading; i waits upstream until e–h is delivered)
```

**Invariants.** All of section 8 continues to hold. In particular:

- **Batch boundaries are not semantic.** A runner is free to choose any
  slicing the rule permits, and two runs of the same pipeline may slice
  differently. A conformant pipe gives the same output items in the same
  order regardless (Pipe specification, section 5.7); where grouping
  carries meaning, the pipeline uses windows (9), which a runner MUST NOT
  split or join.
- **Order is preserved.** Items appear in slices, and slices are
  delivered, in stream order. No item is dropped, duplicated or reordered.
- **Bounded memory and backpressure.** A batch-mode node holds **at most
  2 × `maxItems` items**: one slice in flight and one accumulating, each of
  at most `maxItems`. (A runner that has already taken a transport batch
  from the edge may hold the part of it that does not fit; that part
  belongs to the edge's bound, 8.2.) With file delivery the bound on disk
  is the input and output file of the slice in flight plus the input file
  of the accumulating slice. A slow batch-mode pipe blocks its producer
  like any other.
- **Cancellation and failure release both slots.** A runner waiting for a
  slice to become ready MUST abandon the wait when the run fails or is
  cancelled (8.7, 8.8). Both slices are dropped, batch files are removed,
  and no timer, thread or goroutine may outlive the run.
- **Counters count items.** The `records` counters of the run report (10)
  count items, never slices. An item is counted on the input when it is
  delivered to the implementation.
- **One-to-one per slice.** If the pipe also declares
  `cardinality: one-to-one`, each slice MUST yield exactly as many output
  items as it has input items, in order, before the next slice is
  delivered; a violation fails the node with `E_RUNTIME`.
- **Failure.** If the implementation fails on a slice, the node fails as in
  8.7; output already emitted for earlier slices is not rolled back, and
  the items of the failed slice are not retried.

The slices of a batch-mode node are independent of the transport batches of
8.2 and of the framing of any protocol: a runner re-slices as needed. How a
slice reaches the implementation depends on its type (Pipe specification,
section 5.7): a Starlark `script` is called once per slice with a list; an
`executable` (and a `script` in another language) receives one JSON array
per line, by the framing of the
[CLI specification, section 5.1](https://openflange.org/cli/v0.1#51-batch-framing),
or — with `delivery: file` — one NDJSON file per slice
([section 5.2](https://openflange.org/cli/v0.1#52-batch-files)).
`builtin`, `expression`, `pipeline` and `http` implementations cannot
declare batch mode in v0.1.
A runner that cannot deliver slices to an implementation type MUST reject
the pipe at compile time with `E_UNSUPPORTED`; it MUST NOT run it
unbatched.

Batch mode is unrelated to [`std:batch`](https://openflange.org/std/v0.1#54-batching),
which is a *data* transformation (items become JSON arrays that downstream
pipes can see), and to `windows` ports. A pipe without `batch` is executed
exactly as before.

## 9. Window framing (proposed)

> **Maturity: proposed.** This section may change incompatibly or be
> replaced. See RFC 0001 (`rfcs/0001-window-framing.md` in the specification repository). A pipe using
> it lists `windows` in `requires`.

Windows are **logical groups with semantic boundaries**; they are produced
and consumed by ordinary pipes (for example `std:window`), not by hidden
per-node behaviour. A window boundary is data; a transport batch boundary
is not. The two MUST NOT be conflated: a runner is free to split or join
batches, never windows.

On a port of kind `windows` the stream is NDJSON in which **each line is
one complete window**, a *window frame*:

```json openflange:window-frame
{"window": {"index": 0, "partition": null, "start": 0, "end": 2, "final": false, "partial": false}, "items": ["a", "b", "c"]}
```

| Member | Meaning |
|---|---|
| `window.index` | Index of the window within its partition, from 0. |
| `window.partition` | The partition value (any JSON value), or `null` when the stream is not partitioned. |
| `window.start`, `window.end` | Ordinals, within the partition and from 0, of the first and last item contained in the frame. |
| `window.partial` | `true` if the window holds fewer items than its definition calls for. |
| `window.final` | `true` if the frame was emitted by the end-of-stream flush of its producer. |
| `items` | The items of the window, in order. Never empty. |

Rules:

- The media type is `application/x-ndjson; profile="openflange-windows"`.
  The profile distinguishes framed windows from plain NDJSON; a consumer
  expecting plain records MUST NOT be connected to a `windows` port (kinds
  differ: `E_SCHEMA`).
- **Empty windows are not emitted** by count windows.
- **End of stream is the stream EOF.** There is no terminator frame. With
  count windows, `final` and `partial` coincide; they are separate members
  because they will not coincide for time-based windows, and consumers MUST
  NOT assume they are equal.
- A window frame is one item for the purposes of ordering, buffering and
  record counters. A producer MUST bound window size (its contract states
  the bound) so that a frame is a bounded line.
- The schema of a `windows` port describes one element of `items`.

The exact windows produced — tumbling, sliding, partitioned; what happens
to unfilled windows at end of stream; state bounds — are defined by the
producing pipe; see [`std:window`](https://openflange.org/std/v0.1#55-windows).

## 10. Run report

A runner produces a **run report** for every run that started. It is a
JSON document valid against `run-report-v0.1.schema.json`:

```json openflange:run-report
{
  "runId": "run-01JE5R0V7M",
  "state": "failed",
  "startedAt": "2026-12-03T10:15:00Z",
  "durationMs": 42,
  "error": {"code": "E_RUNTIME", "message": "mask-email: expected exactly one @", "node": "mask"},
  "partialOutput": true,
  "nodes": {
    "lowercase": {
      "state": "cancelled",
      "durationMs": 40,
      "ports": {
        "inputs": {"text": {"state": "failed", "records": 3, "bytes": 53}},
        "outputs": {"text": {"state": "failed", "records": 3, "bytes": 53}}
      }
    },
    "mask": {
      "state": "failed",
      "durationMs": 38,
      "ports": {
        "inputs": {"email": {"state": "failed", "records": 3, "bytes": 53}},
        "outputs": {
          "email": {"state": "failed", "records": 2, "bytes": 38},
          "rejected": {"state": "disconnected"}
        }
      },
      "usage": {},
      "batch": {"batches": 2, "maxBatchItems": 2, "avgBatchItems": 1.5,
                "waitFlushes": 0, "maxFlushes": 1, "eofFlushes": 1, "highWaterItems": 3}
    }
  },
  "conversions": []
}
```

- `state` is the authoritative terminal state. `error` is present when the
  state is `failed` (and SHOULD be present, with `E_CANCELLED`, when
  `cancelled`).
- `partialOutput` is `true` when a run that did not complete delivered
  data externally (8.7).
- Per node: state, duration and, per port, state plus `records` and
  `bytes` counters **where applicable** (`records` is omitted for `text`
  and `binary` streams). A runner that knows a total in advance MAY report
  progress as additional members.
- `usage` is free-form, adapter-reported resource usage — for example
  language-model token counts. It MUST NOT contain prompts, record contents
  or secrets.
- `batch` (experimental, feature `batch`) is present for a node that ran in
  batch mode (8.11) and says how its input was actually cut:
  `batches` (slices delivered), `maxBatchItems` and `avgBatchItems`
  (largest and mean slice), why slices were closed — `maxFlushes` (the
  slice was full), `waitFlushes` (the oldest item had waited `maxWaitMs`)
  and `eofFlushes` (the input ended) — which sum to `batches`, and
  `highWaterItems`, the largest number of items the node held at once, in
  flight and accumulating together (at most 2 × `maxItems`). A slice that
  is full when the input ends counts as full. These numbers describe one
  run; they are diagnostics for choosing `maxItems` and `maxWaitMs`, not
  part of the pipe's contract.
- `conversions` lists the automatic conversions that were in effect
  (`from`, `to`, media types).

Reports are delivered to the invoker (the reference CLI: `--report`).
OpenTelemetry export of the same information is OPTIONAL. A runner is
**not required to keep any persistent run history**.

## 11. Errors

### 11.1 Structured errors

Every error and warning reported by an OpenFlange tool or protocol is a
structured object, valid against `error-v0.1.schema.json`:

```json openflange:error
{
  "code": "E_UNCONNECTED",
  "message": "required input 'email' of node 'mask' has no producer",
  "node": "mask",
  "port": "email",
  "details": {"file": "pipeline.yaml", "line": 9, "column": 3, "path": "nodes.mask.inputs"}
}
```

`code` and `message` are REQUIRED. `node` and `port` locate the error in the
graph when applicable. `details` is free-form; for validation errors it
SHOULD carry `file`, `line`, `column` and `path`. Messages are for humans
and are not stable; programs MUST dispatch on `code`. Messages and details
MUST NOT contain secrets and SHOULD NOT contain record contents.

### 11.2 Code registry

Codes are append-only: a code is never removed or given a different meaning.
A consumer MUST treat an unknown `E_*` code as an error and an unknown
`W_*` code as a warning.

Validation (compile-time) codes:

| Code | Meaning |
|---|---|
| `E_MANIFEST` | A document cannot be parsed safely, or violates its schema or structural rules. |
| `E_ATTRIBUTION` | A manifest body lacks the visible link to `https://openflange.org/`. |
| `E_PATH` | An unsafe path: absolute, traversing out of the package root, or escaping through a symbolic link. |
| `E_DUPLICATE` | A duplicate: YAML key, node id, pipe id in a package, producer of a non-variadic input. |
| `E_RESERVED` | A reserved identifier used as a node id. |
| `E_REF` | An unknown or malformed reference to a node, port, pipeline input or pipe. |
| `E_DIRECTION` | A consumer used where a producer is required. |
| `E_CYCLE` | A cycle among nodes or composite pipes. |
| `E_UNCONNECTED` | A required port without the connection it needs. |
| `E_PARAM` | A parameter or secret binding that is unknown, missing, wrongly typed or out of bounds; node batch settings that loosen the pipe's declaration or target a pipe without batch mode. |
| `E_SCHEMA` | Demonstrably incompatible kinds or schemas; at run time, an item violating a validated schema. |
| `E_MEDIA` | No common media type and no lossless conversion. |
| `E_PERMISSION` | A required permission is not granted. |
| `E_UNSUPPORTED` | A feature, implementation type, language, standard pipe, spec version or distribution the runner does not support. |
| `E_LOCK` | In locked mode: a reference missing from the lockfile, or an integrity mismatch; a malformed lockfile. |

Run-time codes:

| Code | Meaning |
|---|---|
| `E_RUNTIME` | A pipe failed: an implementation error, a non-zero exit, a write to a port that is not enabled, a violated `one-to-one` declaration (per item, or per slice in batch mode). |
| `E_FORMAT` | Malformed stream data: invalid NDJSON, a blank line, invalid UTF-8, a value a conversion cannot represent. |
| `E_CANCELLED` | The run or session was cancelled. |
| `E_TIMEOUT` | A time limit was exceeded. |
| `E_RESOURCE` | A declared or configured bound on state, size or steps was exceeded. |
| `E_PROTOCOL` | A CLI or HTTP protocol violation by a peer. |

Warnings:

| Code | Meaning |
|---|---|
| `W_SCHEMA` | Schema compatibility of an edge is uncertain. |

## 12. Security considerations

- **Untrusted documents.** Pipeline files, manifests, lockfiles, test files
  and registry entries are parsed with the safe YAML rules (size limit, no
  aliases, no custom tags, duplicate keys rejected) and validated against
  their schemas before use.
- **Permissions: enforce or refuse.** Compilation computes required
  permissions and refuses (`E_PERMISSION`) what is not granted (6.4). A
  runner MUST NOT start a node on the assumption that a grant will not be
  needed. Composite children cannot exceed their parent's grants.
- **A subprocess is not a sandbox**, and **trusted mode must be honest**:
  see the [Pipe specification, section 15](https://openflange.org/pipe/v0.1#15-security-considerations).
  A runner that offers no isolation MUST say so when it grants `subprocess`.
- **Bounded, safe fetches.** Every network fetch a runner performs on its
  own behalf — resolving references, fetching manifests, registry indexes,
  remote definitions, `std:http-source` — MUST:
  - use HTTPS; plain HTTP is allowed only for loopback addresses;
  - be bounded in response size and total time;
  - refuse to connect to private, loopback, link-local, multicast and
    otherwise non-public address ranges (**SSRF**), checked against the
    address actually connected to (after DNS resolution, defeating DNS
    rebinding), unless the user explicitly addressed such a host;
  - **not follow redirects** to a different scheme, to a non-public address
    range, or — when credentials are attached — to a different host; the
    number of redirects is bounded;
  - never send credentials or secrets to a host they were not granted for.
- **Path traversal.** References and file parameters are resolved to real
  paths and checked (`E_PATH`); archive extraction (npm tarballs, Git
  checkouts) MUST reject entries that escape the destination, including
  through symbolic links.
- **Package lifecycle scripts.** Resolving or installing a dependency MUST
  NOT execute code from it. npm installs use `--ignore-scripts`; Git
  checkouts do not run hooks or filters from the repository.
- **Secret leakage.** Secrets are bound separately (5.3), redacted from
  plans, reports, logs and errors, never placed in argument vectors or
  query strings, and never inherited by subprocesses. `$env` requires a
  grant because environment variables commonly hold credentials.
- **Remote data transmission.** Sending records to a remote pipe requires a
  `remoteData` grant for that host; the plan shows which nodes execute
  remotely (`remote-http`).
- **Resource exhaustion.** Buffers are bounded; line lengths, step counts,
  window sizes, partition counts, fetch sizes and session lifetimes are
  bounded; exceeding a bound is an explicit failure (`E_RESOURCE`,
  `E_TIMEOUT`), never silent truncation. Compilation itself is bounded:
  nesting depth of composites and the number of nodes SHOULD be limited.
- **Expression injection.** `$expr` and expression parameters are code.
  Tools MUST NOT build them by concatenating untrusted strings; pass data
  through `params` instead.
- **Diagnostics.** Default logs contain no record data, prompts or secrets
  (8.9).
- **Limitations.** v0.1 defines no isolation mechanism, no signing of
  manifests or lockfiles, and no authentication of registry content beyond
  integrity hashes and Git history. These are known limitations, not
  solved problems.

## 13. Examples

### 13.1 The email pipeline (linear)

The pipeline file referenced by the `normalize-and-mask-email` manifest. It
has no `spec` because the manifest governs:

```yaml openflange:pipeline
nodes:
  lowercase:
    pipe: ./pipes/lowercase
    inputs:
      text:
        from: inputs.email
  mask:
    pipe: ./pipes/mask-email
    inputs:
      email:
        from: lowercase.outputs.text
    parameters:
      character: '*'
      preserveFirst: 1
      preserveLast: 1
outputs:
  email:
    from: mask.outputs.email
```

`"Alice@Example.COM"` → `lowercase` → `"alice@example.com"` → `mask` →
`"a***e@example.com"`. The optional output `mask.outputs.rejected` is not
connected, so an invalid address fails the run with `E_RUNTIME`.

### 13.2 Branching (broadcast)

`normalize-and-mask-email-branching` exposes both the masked and the
normalised address. Both `mask` and the pipeline output `normalized` consume
`lowercase.outputs.text`: one execution of `lowercase`, two consumers.
Rejected addresses are an optional pipeline output.

```yaml openflange:pipeline
spec: openflange.org/pipeline/v0.1
nodes:
  lowercase:
    pipe: ./pipes/lowercase
    inputs:
      text: {from: inputs.email}
  mask:
    pipe: ./pipes/mask-email
    inputs:
      email: {from: lowercase.outputs.text}
outputs:
  masked: {from: mask.outputs.email}
  normalized: {from: lowercase.outputs.text}
  rejected: {from: mask.outputs.rejected}
```

The same pipeline with the shorthand string form for inputs and outputs:

```yaml openflange:pipeline
spec: openflange.org/pipeline/v0.1
nodes:
  lowercase:
    pipe: ./pipes/lowercase
    inputs:
      text: inputs.email
  mask:
    pipe: ./pipes/mask-email
    inputs:
      email: lowercase.outputs.text
outputs:
  masked: mask.outputs.email
  normalized: lowercase.outputs.text
  rejected: mask.outputs.rejected
```

### 13.3 Join, merge and discard

A two-input pipe (a join), an explicit merge of two producers, and an
explicit discard of a required output:

```yaml openflange:pipeline
spec: openflange.org/pipeline/v0.1
nodes:
  all-orders:
    pipe: std:merge
    inputs:
      in: {from: [inputs.web_orders, inputs.shop_orders]}
    parameters:
      mode: concat
  paid:
    pipe: std:split
    inputs:
      in: {from: all-orders.outputs.out}
    outputs:
      unmatched: {discard: true}
    parameters:
      expr: 'item["status"] == "paid"'
  enrich:
    pipe: ./pipes/join-customers
    inputs:
      orders: {from: paid.outputs.matched}
      customers: {from: inputs.customers}
    grants:
      subprocess: true
outputs:
  orders: {from: enrich.outputs.joined}
```

### 13.4 Invalid pipelines

A producer-side `connections` section does not exist:

```yaml openflange:pipeline invalid
spec: openflange.org/pipeline/v0.1
nodes:
  lowercase:
    pipe: ./pipes/lowercase
connections:
  - {from: inputs.email, to: lowercase.inputs.text}
```

Layout does not belong in the pipeline file:

```yaml openflange:pipeline invalid
spec: openflange.org/pipeline/v0.1
nodes:
  lowercase:
    pipe: ./pipes/lowercase
    inputs: {text: inputs.email}
layout:
  lowercase: {x: 10, y: 10}
```

### 13.5 An R summary with ordinary Unix pipes

Because the default record format is NDJSON on standard streams, a
single-input, single-output pipe composes with any Unix tool, with or
without a runner:

```sh
printf '%s\n' '{"value":10}' '{"value":20}' '{"value":30}' \
  | Rscript --vanilla summary.R
# {"count":3,"mean":20,"median":20,"sd":10}
```

## 14. Compatibility and versioning

- This specification is identified by `openflange.org/pipeline/v0.1`
  (document version 0.1.0-draft). A pipeline file states it in `spec`.
- While `experimental`, a later 0.x version MAY change incompatibly, with a
  `CHANGELOG.md` entry. Window framing is `proposed` and may change without
  notice.
- Unknown top-level keys are rejected; `x-` keys are preserved and ignored.
- The error-code registry is append-only. The run-report and plan JSON
  shapes are open: consumers MUST ignore members they do not know.
- Default buffer sizes and grace periods are defaults, not guarantees;
  pipelines MUST NOT depend on them for correctness.

See `COMPATIBILITY.md` in the specification repository.

## 15. Deferred

Explicitly not part of v0.1:

- **event-time watermarks**, allowed lateness and **session windows**;
- a **minimum batch size** for batch mode, batch mode for pipes with
  several inputs, for `builtin` implementations or over the HTTP Pipe
  Protocol, parameter bindings in node `batch` settings, batch settings
  addressed to nodes inside a composite, and **several slices in flight**
  for one node (parallel workers, which need ordered reassembly)
  (RFC 0003);
- **checkpointing**, recovery, exactly-once delivery and persistent
  streaming state;
- **distributed scheduling**, multi-runner execution and parallelism of a
  single node;
- **WASM** implementations and browser-hosted runners;
- stream **reconnect** and resume;
- **dynamic ports** and graphs that change during a run;
- control flow (conditionals, loops, retries, schedules) — the reserved
  **workflow** concept;
- transactional output and rollback;
- automatic conversions beyond the alias in 7.4;
- persistent run history, scheduling and cache management in runners.
