# OpenFlange conformance fixtures

Portable, data-only fixtures for the OpenFlange v0.1 specifications. There
is no code here: a runner in any language consumes these files and compares
what it does with what the fixtures expect.

Status: **experimental**, like the specifications. Window fixtures exercise
a **proposed** feature. The fixtures were written before any runner
existed; see "What has and has not been verified" below.

Licence: Apache-2.0 (see the repository `LICENSE`).

## Layout

```
conformance/
  manifests/
    valid/<case>/OPENFLANGE.md             (+ any files the manifest references)
    invalid/<case>/OPENFLANGE.md
    invalid/<case>/expect.yaml
  pipelines/
    valid/<case>/pipeline.yaml             standalone, or
    valid/<case>/OPENFLANGE.md + pipeline.yaml   composite
    valid/<case>/pipes/<id>/OPENFLANGE.md  local pipes used by the case
    valid/<case>/expect.yaml
    invalid/<case>/...                     same shape
  runs/
    **/*.test.yaml                         portable tests (Test specification)
    **/OPENFLANGE.md, pipeline.yaml, *.star, data/   targets and data
```

Every case is a directory with a descriptive kebab-case name. Pipeline
cases are self-contained (they carry their own copies of the small local
pipes they use). `runs/` is one tree: some tests reference pipes elsewhere
under `runs/` with `../`, so consume it whole.

## `expect.yaml`

```yaml
description: Why the case is invalid (or what the valid case demonstrates).
errors: [E_REF]          # the exact SET of error codes a validator must report; [] for valid pipeline cases
stage: semantic          # invalid cases only: parse | schema | semantic
warnings: [W_SCHEMA]     # valid pipeline cases only, optional: the exact set of warning codes
```

- `errors` is compared as a **set of codes**. A validator may report a code
  several times (for several locations); messages and locations are not
  compared.
- `stage` is informative for runners and normative for the repository's own
  checker. It says where the defect is first detectable:
  - `parse` — the safe YAML / frontmatter rules reject the document
    (`E_DUPLICATE` for duplicate keys, `E_MANIFEST` otherwise);
  - `schema` — the document parses but violates its JSON Schema; the code
    is always `E_MANIFEST`;
  - `semantic` — the document is schema-valid; a specific rule is violated.
- Each invalid case isolates **one** defect.
- Valid manifest cases have no `expect.yaml`: they must validate without
  errors.

## How a runner consumes the fixtures

**Manifests.** For every directory under `manifests/valid` and
`manifests/invalid`, validate `OPENFLANGE.md` as a pipe manifest (reference
CLI: `openflange validate <dir> --json`). Valid cases must produce no
errors. Invalid cases must be rejected with exactly the codes in
`expect.yaml`. Features a runner does not implement may additionally yield
`E_UNSUPPORTED` on *valid* cases that require them (for example
`requires: [windows]` or an `arrow` schema); report those as skipped, not
passed.

**Pipelines.** For every case, compile the entry point — the
`OPENFLANGE.md` in the case directory if there is one, otherwise
`pipeline.yaml` — **with no run-level grants and not in trusted mode**
(node-level `grants:` in the files apply). Compare error and warning code
sets with `expect.yaml`. Nothing is executed: cases that reference
`executable` pipes contain placeholder scripts and are validated only.
Cases use only local `./pipes/...` and `std:` references; no network is
needed.

**Runs.** Execute every `*.test.yaml` under `runs/` with the portable test
runner (reference CLI: `openflange test conformance/runs`). Tests use only
local Starlark pipes and `std:` references, need no grants and no network.

| Directory | Covers |
|---|---|
| `runs/email` | The reference fixture: `lowercase`, `mask-email` (invalid addresses, short local parts, Unicode, parameter bounds, rejected routing), the `normalize-and-mask-email` composite and the branching variant |
| `runs/precision` | Big-integer and decimal pass-through, byte-exact number literals |
| `runs/ordering` | Order preservation through multi-node chains and broadcast |
| `runs/empty` | Empty required streams |
| `runs/optional-ports` | Disabled optional outputs; a disconnected optional input |
| `runs/failure-after-output` | `failed` status after output was produced |
| `runs/windows` | `std:window`: tumbling, sliding, partitioned, final partial windows, a window-scope consumer (**proposed**) |
| `runs/batch` | Batch mode (**experimental**, feature `batch`): Starlark `process_batch` pipes run under several pinned slice sizes (1, 2, 3, larger than the input) with identical expected output; `cardinality: one-to-one` checked per slice; the list return rule; empty input; tighten-only settings; `batch` on targets without batch mode |
| `runs/std` | Standard pipes: map, filter, limit, skip, distinct, select, rename, cast, batch, unbatch, merge, split, csv-decode, csv-encode, json-parse, json-format, validate-schema |

A runner that does not implement a capability (`windows`, `arrow`,
`batch`) reports the affected tests as skipped and names the capability.

**Usage reporting.** `manifests/{valid,invalid}/usage-*` cover the
`implementation.usage` key (CLI specification, section 5.3); the endpoint
itself needs a subprocess and is exercised by the reference
implementation's own tests. **Text assertions** (`minLength`,
`maxLength`, `pattern`; experimental) are used by two tests of
`runs/std/json-roundtrip`.

**Batch mode.** `manifests/{valid,invalid}/batch-*` and
`pipelines/{valid,invalid}/batch-*` cover the declaration, its
preconditions and the tighten-only rule for node settings. The run
fixtures use only Starlark scripts, the one runtime every runner has
without installing anything. `manifests/valid/batch-executable`,
`batch-script-r`, `batch-file-long-running`, `batch-file-per-batch` and
`batch-file-literal-brace` are validated only. The framing of subprocess
pipes — array lines and batch files (CLI specification, sections 5.1 and
5.2) — and the timing of the two-slot delivery rule have **no portable run
fixtures**: there is no interpreter that every platform provides, and the
run fixtures need no grants. It is verified by implementation-level tests
(in the reference Go runner: `stream` and `runner` tests with an injected
clock and a deliberately slow pipe; `adapter/exec` against `sh`, `awk`,
`python3` and a Go helper process; and the examples `batch-python`,
`batch-r` and `batch-file-duckdb`). Run fixtures pin `batch` per test (Test specification, section
3.4) to vary the slicing; they never assert where slice boundaries fall,
because the delivery rule leaves that to the runner. The wait timer
(`maxWaitMs` with a slow producer), bounded pending size and cancellation
during a wait cannot be expressed portably and are implementation-level
tests.

## Not covered by portable fixtures

Cancellation, backpressure and bounded memory, large-stream behaviour,
race and leak checks, the CLI multi-port endpoints, the HTTP Pipe Protocol,
permissions at run time, lockfiles and `--locked`, lossless media
conversion in plans, and run-report contents cannot be expressed in the
v0.1 test format. They are verified by implementation-level tests and are
listed as deferred in the Test specification.

## Checking the fixtures themselves

```
uv run tools/validate.py        # from the repository root; add -v to list every check
```

The checker validates every fixture against the JSON Schemas, checks that
each invalid case fails at its stated stage, and re-derives the expected
codes of manifest and pipeline cases with a small structural checker of its
own (references, direction, cycles, connectivity, parameters, demonstrable
schema incompatibility, media types, grants). For run fixtures it checks
only static properties: schema validity, that targets resolve and compile,
that ports and parameters exist, and that data files are well-formed
NDJSON.

## What has and has not been verified

- Manifest and pipeline expectations: machine-checked by
  `tools/validate.py`, which is an independent (Python) reading of the
  specifications, not a runner.
- Run fixtures: **not executed by any OpenFlange runner** at the time of
  writing, with one exception: the batch-mode fixtures (`*/batch-*`,
  `runs/batch`) were added together with the reference Go runner's
  implementation of the feature and are executed by its conformance
  harness (every manifest, pipeline and run case passes there). For the
  older fixtures: the Starlark sources (`mask.star`, the lowercase expression, the
  failure and window-summary scripts, and the `expr` parameters of the map,
  filter and split tests) were executed with go.starlark.net through a
  Python binding under a shim of the Starlark binding; window, CSV decode
  and CSV encode expectations were checked against a Python model written
  from the specification text; the remaining standard-pipe expectations
  were derived by hand.
- A disagreement between a runner and a fixture is therefore a finding to
  report against the specification repository, not automatically a runner
  bug.
