Skip to content

pipeloom architecture

Status: the code implements the versions listed in section 16: the scheduler, the polars, pandas and Spark engines, incremental models, merge, replace_partitions and scd2, expectations and quarantine, retries, timeouts and cancellation, the Databricks and Airflow integrations, per-model catalogs and, from 0.9, Python-first authoring. 1.0 freezes the contracts: what stays stable within a major version is listed in Stability and deprecations. Planned work lives in the roadmap. Decisions are recorded as ADRs in adr/. Diagrams are D2 sources in docs/diagrams with committed light and dark SVGs. From 0.9 models are decorated Python functions, and YAML keeps the project and properties files (ADR-0050). Through 0.8 every model was declared in a YAML model file (ADR-0003, superseded); that path is removed, and Migrating from 0.8 maps it to the decorator.

1. Vision, goals, non-goals, principles

Vision. A small, typed framework. Models are written in Python and the project and properties in YAML (from 0.9; through 0.8 pipelines are declared in YAML), then compiled into an immutable plan. That plan runs the same way on pandas, polars, PySpark or later engines, and runs locally, as one Databricks job, or as an Airflow DAG. Every run produces a single event stream and artifacts you can query.

Goals: Python models with a typed decorator, and YAML project and properties files with layered validation and editor completion; an engine-agnostic core with one plugin per tool; end-to-end events and styled logs; persisted metadata for each run and each model; a Databricks one-job renderer; a cosmos-style Airflow integration; open-source hygiene.

Non-goals (through 1.0, replaced after 1.0 by the list below): streaming; a scheduler service, or any UI that starts, schedules or changes runs (ADR-0043); a portable SQL dialect; Jinja templating; running user code at compile time (from 0.9: user code runs at compile time only for modules with dynamic decorator arguments, ADR-0050); Airflow 2 support.

Non-goals (after 1.0, ADR-0016 amendment 1.1 and the roadmap): streaming (reading Auto Loader or Lakeflow Connect landing tables through incremental is supported, checkpoint-based state is not); a scheduler service, or any UI or agent tool that starts, schedules or changes runs (MCP write tools fall under it); a portable SQL dialect; Jinja templating; user code at compile time beyond ADR-0050; Airflow 2 support; zero-copy environments (clone-only dev copies are allowed, promotion is not); a semantic layer; cross-engine data diff; ML anomaly models beyond fixed statistics. Engines beyond polars, pandas, Spark and DuckDB are community plugins tested by the conformance kit.

Principles. Each answers a lesson (L) from the concept spec. 1. One event stream. Logs, metrics, artifacts and lineage subscribe to it (L1). 2. Dependencies are declared, never traced. Tracing is an opt-in static check that warns (L2). 3. No module-level registries. A Project object owns plugins and config (L3). 4. Docs, the CLI reference, the JSON Schema and the error catalog are all generated from code. Every CLI flag has a test (L4). 5. No session-global mutation. Every engine setting lives in a context manager with guaranteed cleanup. Metrics never depend on global commit tags (L5, L10). 6. Ready-queue scheduling with no level barriers (L6). 7. Execution units never share in-memory state. Ephemeral models are inlined; intermediates are persisted (L7). 8. Maintenance operations (compaction, clustering) run only when declared (L8). 9. Each declared write option is either applied by every strategy or rejected at validation (L9). 10. Platform behavior is injected: clock, identity, catalog, secrets (L11). 11. Incremental logic is a declared key plus a lookback, with a watermark store (L12). 12. Retries, timeouts, data quality, persisted metadata, selectors, schema-change policy, SCD2 and deletes are all first-class (L13). 13. Python-first models, YAML with JSON Schema for the project and properties (L14; from 0.9, ADR-0050; through 0.8 YAML first).

2. Glossary

  • Project: a directory with pipeloom.yml, Python model modules and properties YAML files (through 0.8: YAML model files).
  • Model: a named dataset built from declared inputs. From 0.9 it is a Python function marked with @model, whose parameters are its inputs; through 0.8 it is a YAML entry with a Python callable or a SQL body.
  • Source: an external dataset declared in YAML. From 0.9 sources are tables in named groups under sources: in pipeloom.yml, with the unique id source.<project>.<group>.<table>.
  • Properties file: (from 0.9) any *.yml or *.yaml under model_paths other than pipeloom.yml; it describes and configures models by name and never declares one.
  • Folder config: (from 0.9) the models: tree of pipeloom.yml, whose +key settings apply to the models of a folder and its subfolders.
  • Target: a named runtime environment (engine, catalog, naming, state store).
  • Materialization: table, incremental, view, ephemeral or intermediate.
  • Write strategy: append, overwrite, replace_partitions, merge or scd2.
  • Plan: an immutable compiled graph of resolved models.
  • Execution unit: one schedulable node of the plan. It holds one persisted model plus any ephemeral models inlined into it.
  • Boundary: process (all units in one process) or task (each unit in its own process or orchestrator task).
  • Manifest: the serialized plan (manifest.json).
  • Run: one execution of a plan, identified by run_id.
  • Invocation: one process taking part in a run.
  • Attempt: one try of a unit.
  • Watermark: the high-water value of an incremental key.
  • Expectation: a data-quality rule with warn, drop or fail.
  • Sink: an event subscriber.
  • Renderer: turns a plan into an orchestrator artifact.
  • Executor: runs units.
  • Plugin API version: the version of the protocol contract between the core and plugins.

3. Architecture overview

pipeloom in context: an author writes YAML and @model functions, the core runs them on the polars, pandas, DuckDB or Spark engine, writes tables, state and run artifacts, sends events to sinks and OpenLineage, and renders Databricks jobs and Airflow DAGs. pipeloom in context: an author writes YAML and @model functions, the core runs them on the polars, pandas, DuckDB or Spark engine, writes tables, state and run artifacts, sends events to sinks and OpenLineage, and renders Databricks jobs and Airflow DAGs.
pipeloom in context. Source: context.d2.

Layers. Arrows point toward dependencies. The core never imports a plugin, and an import-linter contract enforces this in CI.

CLI / Python API (pipeloom.api.Project)
  ├─ diagnostics  Diagnostic, Report, Outcome and the error-code catalog (`pipeloom.diagnostics.codes`); a leaf package
  ├─ platform   Clock and Identity seams
  ├─ authoring  `@model`, `ModelSpec`, `ref`, `source`, `var` and the check helpers (from 0.9)
  ├─ discovery  AST resolver, discovery cache, ModuleLoader, load summary (from 0.9)
  ├─ config     YAML loader with line marks, pydantic models, defaults resolution, target binding, schema export
  ├─ validate   L2 references, L4 plan semantics, L5 capabilities, L6 static code (L0-L1 live in config, L3 in graph)
  ├─ graph      DAG, selectors, topological order, cycle paths
  ├─ plan       Plan, ExecutionUnit, Manifest, plan_hash
  ├─ runtime    Scheduler, Executor(thread|process), ModelRunner, ModelContext
  ├─ engine     protocols, logical types, capabilities, portable helpers (Narwhals)
  ├─ incremental / quality / state
  ├─ events     Event models, EventBus, console/jsonl/file sinks
  ├─ artifacts  manifest.json, run_results.json writers
  ├─ secrets    env provider, interpolation, redaction
  ├─ plugins    entry-point discovery, built-in table, API-version gate
  ├─ builtins   naming strategies, filesystem catalog spec, env secret provider
  └─ testing    contract suites, RecordingSink, FakeClock, MemoryEngine
Plugins: pipeloom-pandas | -polars | -spark (0.4) | -databricks (0.5) | -airflow (0.6) | -openlineage (0.9)

pipeloom-spark depends only on pipeloom. pyspark is not a dependency of it: the extra local brings pyspark[connect] and delta-spark, and pipeloom[spark] pulls pipeloom-spark[local] (ADR-0031). Databricks runtimes and Databricks Connect ship their own pyspark, so there the plugin is installed without extras.

The seven plugin distributions (polars, pandas, DuckDB, Spark, Databricks, Airflow, OpenLineage) depend on the core; Databricks also depends on Spark; the core imports no plugin. The seven plugin distributions (polars, pandas, DuckDB, Spark, Databricks, Airflow, OpenLineage) depend on the core; Databricks also depends on Spark; the core imports no plugin.
Distributions and their dependencies. The entry-point groups each plugin fills are listed in section 6. Source: packages.d2.
Core modules: the CLI and Project API import plugins, runtime and plan; runtime imports plan, engine protocols, incremental, quality and state, and events and artifacts; plan imports validate and graph, which import config and discovery. Core modules: the CLI and Project API import plugins, runtime and plan; runtime imports plan, engine protocols, incremental, quality and state, and events and artifacts; plan imports validate and graph, which import config and discovery.
Core modules; arrows point at the module imported. Source: core-modules.d2.

Lifecycle. Each stage is a pure function from the previous stage's output. Every stage emits events.

  1. Load: discover YAML files, then parse them while recording file, line and column for every node. From 0.9 the same scan also finds Python model files: an AST pass resolves static @model decorators without importing, the discovery cache skips unchanged files, and an import pass loads only the modules with dynamic decorator arguments (section 4).
  2. Validate schema: pydantic models (L0-L1), over YAML and, from 0.9, over decorator arguments.
  3. Resolve graph: bind refs and sources (from 0.9, function parameters), apply defaults and precedence, apply naming strategies to get physical names, apply selectors (L2-L3). A model's schema goes to the naming strategy; a model's catalog (same cascade as schema: through 0.8 the model file, folder _defaults.yml or defaults.models; from 0.9 the decorator, properties and the models: tree) replaces the catalog of the relation the strategy returns, so naming strategies keep transforming only the schema (ADR-0040). Path catalogs (filesystem, delta_path) lay a table out at <root>/<catalog>/<schema>/<name>/ when the relation has a catalog; catalogs with a catalog level (spark_catalog, unity) never create the catalog, only the schema.
  4. Validate plan: semantics, plugin capabilities and static code checks (L4-L6).
  5. Compile: fuse ephemeral models into units for the chosen boundary, then freeze. Output is Plan plus manifest.json with a plan_hash (sha256 of the canonical JSON of nodes, sources, units, edges and the project, target, boundary and config version; selection, versions, timestamps and ids are excluded).
  6. Execute: the scheduler runs units through an executor. Orchestrated tasks run pipeloom run --manifest ... --select unit:<id> --expect-plan-hash <h>.
  7. Finalize: merge per-invocation results, write run_results.json, commit run state, flush and close sinks.

Commands. init (scaffold a new project, ADR-0041), new model (add one decorated .py model file; ADR-0041 amendments), validate, compile, ls, graph (with --units, the unit graph for orchestrators, ADR-0049), run, retry (run again what a finished run did not finish, ADR-0013 amendment), test and build (unit tests, then a run with data tests, ADR-0045), runs ls|show (run history, ADR-0047), finalize, docs generate|serve (a read-only one-file site, ADR-0043), schema export, explain (print a diagnostic code's catalog entry and docs link) and plugins list; plugins add their own through pipeloom.commands (for example pipeloom databricks).

The seven lifecycle stages in order: load, validate schema, resolve graph, validate plan, compile, execute, finalize. Compile writes manifest.json, execute writes the unit attempt files, finalize writes run_results.json. The seven lifecycle stages in order: load, validate schema, resolve graph, validate plan, compile, execute, finalize. Compile writes manifest.json, execute writes the unit attempt files, finalize writes run_results.json.
Lifecycle stages and the artifacts they write. Source: lifecycle.d2.
Stage Error codes Writes
1. Load PLY (L0)
2. Validate schema PLS (L1)
3. Resolve graph PLR, PLG (L2, L3)
4. Validate plan PLP, PLC, PLK (L4 to L6); PLF with --preflight
5. Compile manifest.json
6. Execute PLX, PLM, PLQ, PLE, PLU units/<unit_id>/attempt-<n>.json
7. Finalize run_results.json, the run record in the state store

4. Configuration

From 0.9 (ADR-0050) a project is one pipeloom.yml, Python model modules and optional properties files. The YAML model files of 0.8 are gone; see "YAML model files" below.

Project file.

# yaml-language-server: $schema=https://emanuel-luis.github.io/pipeloom/latest/schema/v1/project.json
config_version: 1
name: shop
model_paths: [models]
python_paths: ["."]            # default; model modules are imported relative to these roots
vars:
  country: BR
models:                        # folder config, from 0.9
  +materialized: table         # root +keys are project defaults
  +retries: 1
  +timeout: 30m
  marts:
    +tags: [daily]
sources:                       # source groups, from 0.9
  raw:
    format: parquet
    location: data/raw
    tables:
      orders:
        location: orders/
      customers:
        location: customers/
targets:
  dev:
    engine:
      kind: polars
    catalog:
      kind: filesystem
      root: ./warehouse
    naming:
      kind: per_user
    state:
      kind: sqlite
      path: .pipeloom/state.db
    workers: 4
  prod:
    engine:
      kind: spark
    catalog:
      kind: unity
      catalog: main
    naming:
      kind: prefix
      schema_prefix: prod_
    state:
      kind: table
      table: ops._pipeloom_state
    artifacts:
      root: /Volumes/main/ops/pipeloom
    deploy:                                  # 0.5: a plugin block, validated against `renderers`
      kind: databricks
      pipelines:
        main: {}
        daily:
          select: ["tag:daily"]
      compute:
        default:
          kind: serverless
          environment_version: "5"
      task_grouping: none
events:
  sinks:
    - kind: console
    - kind: jsonl
      path: target/events.jsonl
      failure_budget: 5

Sources (from 0.9). sources maps a group name to format, location, schema, options, tags, meta and tables. A table may set the same keys plus location or table: a table location is joined to the group location, a table table is qualified by the group schema. A table entry whose merged result has no location and no table uses its key as table, qualified by the group schema; one with both is PLS108. targets.<t>.sources.<group> deep-merges over the group, and an explicit null removes a key, so a prod target can read the same tables from a catalog. Sources in properties files are rejected for now.

Models (from 0.9). A model is a function marked with @model in any *.py file under model_paths (a directory scanned recursively, or a glob) or inside a package named in model_packages. Every model file must lie under a python_paths root.

from pipeloom import ModelContext, Write, model


@model(
    materialized="incremental",
    incremental={"input": "orders", "column": "updated_at", "lookback": "2d"},
    write=Write(strategy="merge", unique_key=["order_id"]),
)
def fct_orders(ctx: ModelContext, orders, stg_customers):
    return ctx.sql("select o.*, c.name from orders o join stg_customers c using (customer_id)")
  • Parameters are the inputs. Each binds in this order: (1) an inputs= entry (ref(...), source(...) or a bare name, which resolves by steps 3 and 4); (2) a parameter with a default is never an input unless inputs= lists it; (3) a model of that name other than the model itself; (4) a source table of that name when exactly one group has it; (5) anything else is PLR201. A table name in two groups is PLR210. ctx is optional and reserved.
  • The default name is the function name, and a file may hold several models. Decorator arguments use the YAML keys, as plain dicts or as the re-exported config models (Write, Incremental, Column, Expectation, Quality, Deletes, DataTest), plus the helpers ref, source, var and the check helpers (not_null, unique, accepted_values, between, regex, row_count, freshness).
  • SQL runs through ctx.sql(query, *, dialect=None, inputs=None) against the inputs by alias (section 5). There are no SQL model files.

Properties files (from 0.9). Any *.yml or *.yaml under model_paths except pipeloom.yml. They describe and configure models; they never create one or set inputs.

# yaml-language-server: $schema=https://emanuel-luis.github.io/pipeloom/latest/schema/v1/properties.json
models:
  - name: fct_orders
    description: One row per order.
    config:
      partition_by: [order_date]
      tags: [finance]
    columns:
      - name: order_id
        dtype: int64
        nullable: false
    data_tests:
      - name: order_id_unique
        check:
          unique: [order_id]
        on_violation: fail

An entry that names no model, or a model another entry already describes, is PLR209 (suppressed while any PLY005 exists). unit_tests also live here (ADR-0045).

Discovery (from 0.9). One scan of model_paths and model_packages finds model modules and properties files. - An AST pass parses every .py file that imports pipeloom. A @model on a top-level def whose arguments are all static (literals, containers of static values, or calls to known helpers and re-exported config classes on static values) is resolved without importing the module. Any other use makes the module dynamic. Unknown keywords are PLS101 from the AST in both cases. - Dynamic modules, and only those, are imported through pipeloom.discovery.loader.ModuleLoader, which puts the python_paths roots on sys.path under a process-wide lock and purges the project's modules on exit. Each module that cannot be loaded is one PLY005; loading never stops at the first. - <project>/.pipeloom/cache/discovery.json caches static results per file, keyed by path, mtime_ns, size and the pipeloom and Python versions. Dynamic modules are always imported again. The cache is never part of the manifest or the plan hash, and a failed write is ignored. - Discovery.refresh() re-reads changed files and re-imports dynamic modules for long-lived processes such as docs serve. - An executor running a unit from a manifest never runs discovery: it imports the one module named by its node's callable. Any invocation that compiles runs discovery, including pipeloom run without --manifest and every unit task in Airflow PROJECT mode, so dynamic modules are imported there too.

Model-only keys (0.9, ADR-0045), which the models: tree cannot set: unit_tests (cases {name, given, expect}, given keyed by input alias, the parameter name of a decorated function), set in the model's properties entry; and data_tests ({name, check: {not_null | unique | relationships: {column, to: {ref | source}, field}}, on_violation: warn | fail}), set by the decorator's data_tests= or by properties, where the decorator list replaces the properties list. Unit tests stay out of the manifest; data_tests appears as nodes[].data_tests and enters the node checksum only when declared.

YAML model files (0.8 and earlier). Model entries with sql: or python:, flat sources: lists, _defaults.yml and defaults.models were removed in 0.9 with no deprecation release; their keys are PLS101 with a hint to the migration guide, and PLK601, PLK604, PLC502 and PLR205 are retired.

ADR-0050: Python-first model authoring (supersedes ADR-0003, which made YAML declare every model). - Context: a YAML-declared Python model was written twice, once in YAML and once as a function whose parameters had to match (PLK602). A benchmark of 1,000 models measured about 11 s to import every module and 1.4 s to parse them with ast. - Options: keep YAML-first; Python-first with static discovery only (no computed config); Python-first importing every module (slow, runs user code on every compile); Python-first with hybrid discovery. - Choice: hybrid. Every model is a decorated Python function; YAML holds the project, folder config, sources, targets and properties. The compiler resolves static decorators from the AST and imports only dynamic modules, with a per-file cache. SQL runs through ctx.sql. Dependencies stay declared through parameters and inputs=, never traced. - Consequences: a model is written once, with typed completion. Most compiles run no user code; a dynamic module runs its code at compile time. Every project is rewritten once, with no deprecation release, and plan hashes change once.

JSON Schema. pipeloom schema export --out schemas/ writes project.json and properties.json (draft 2020-12) from the pydantic models. models.json and defaults.json are no longer published under latest/ since 0.9 (older version folders keep them). - Plugin option models (engine, catalog, sink, state) are composed as oneOf branches on kind, using the plugins that are installed (--plugins builtin limits it to the built-ins). - The docs site publishes the schemas of the built-in plugins under latest/schema/v1/ (and under each version folder). - The modeline above enables completion in editors that use yaml-language-server.

Precedence. - Runtime settings (highest first): CLI flags; PIPELOOM_* environment variables (for example PIPELOOM_TARGET, PIPELOOM_WORKERS); an optional git-ignored user file ~/.pipeloom/profiles.yml with per-target overrides; the targets.<t> block; then top-level project keys. - Model config: the @model decorator; then the config of the model's properties entry; then the models: tree from the folder nearest the model up to the root; then the root +keys; then built-in defaults. Mappings deep-merge, lists replace, tags is an ordered union and an explicit null removes a key (YAML only). columns is a model key that the folder tree cannot set, and decorator columns replace properties columns whole. ResolvedModel.origins records the layer and location of each top-level key, so a diagnostic points at the layer that set the value; origins are not in the manifest. - Targets may change runtime keys (engine options, catalog, naming, state, workers, artifacts, deploy) and, from 0.9, override source groups (targets.<t>.sources: format, location, schema, options, tables). deploy is a runtime key like the others: the target block wins over the top-level one. The core validates its options with the config_model of the renderers plugin it names (the factory is never called), records them in the manifest as metadata.deploy (not part of the plan hash) and resolves nothing in them at runtime except ${secret:...} references in plugin options. They may not change model semantics, so plans differ across targets only in physical names, source relations and runtime settings. - Interpolation: ${env:NAME}, ${env:NAME:-default} and ${var:name} resolve at compile time and are recorded in the manifest. ${secret:provider/path} resolves only at runtime (section 14).

5. Core protocols

from typing import Any, Protocol, Mapping, Sequence, Iterator, ContextManager
from dataclasses import dataclass
from datetime import datetime


@dataclass(frozen=True)
class Column:
    name: str
    dtype: str
    nullable: bool = True  # logical type: int64, decimal(18,2), timestamp[UTC]...


Schema = tuple[Column, ...]


@dataclass(frozen=True)
class Relation:  # opaque handle; never inspected by core
    native: Any  # pandas/polars frame, Spark DataFrame...
    engine: str
    lazy: bool


@dataclass(frozen=True)
class EngineCapabilities:
    formats: frozenset[str]
    strategies: frozenset[str]
    sql_models: bool
    views: bool
    idempotent_writes: bool
    cancel: bool
    bytes_metrics: bool
    portable: bool  # Narwhals-compatible frames
    quality: bool  # evaluate and apply_drops (0.3)
    materializations: frozenset[str]  # table, view, ephemeral (0.2)
    sql_dialect: str | None = None  # sqlglot dialect for ctx.sql (0.9, ADR-0050)


@dataclass(frozen=True)
class StateStoreCapabilities:
    shared: bool  # visible to every process and task of a run


class Engine(Protocol):
    name: str
    version: str  # recorded as engine_version in run_results
    capabilities: EngineCapabilities

    def session(
        self, ctx: "RuntimeContext", *, catalog: "Catalog"
    ) -> ContextManager[
        "EngineSession"
    ]: ...  # one per invocation, thread-safe, cleanup guaranteed (L10)


class EngineSession(Protocol):
    native: Any  # escape hatch

    def reader(self, fmt: str) -> "Reader": ...
    def materializer(self, strategy: str) -> "Materializer": ...
    def sql(self, query: str, inputs: Mapping[str, Relation]) -> Relation: ...
    def schema(self, rel: Relation) -> Schema: ...
    def count(self, rel: Relation) -> int: ...
    def filter_since(
        self, rel: Relation, column: str, lower: Any, *, inclusive: bool = True
    ) -> Relation: ...  # strict (>) when not inclusive
    def relation(
        self, native: Any
    ) -> Relation: ...  # check a model's return value and wrap it; TypeError for a foreign type
    def persist(
        self, rel: Relation
    ) -> Relation: ...  # in-memory copy for results shared by several units
    def create_view(
        self, target: "TargetRef", query: str, inputs: Mapping[str, "ReadSpec"]
    ) -> "WriteResult": ...  # catalog view, never a session view
    def max_value(
        self, rel: Relation, column: str
    ) -> Any: ...  # a plain Python value, never numpy or pandas
    def evaluate(
        self, rel: Relation, checks: Sequence["ExpectationSpec"]
    ) -> "QualityCounts": ...  # raw counts; the core judges
    def apply_drops(
        self,
        rel: Relation,
        checks: Sequence["ExpectationSpec"],
        *,
        quarantine: "QuarantineMeta | None",
    ) -> "DropResult": ...
    def align(
        self, rel: Relation, schema: Schema
    ) -> Relation: ...  # schema order, missing columns as typed nulls, cast
    def write_intermediate(
        self, rel: Relation, ref: "IntermediateRef", token: str
    ) -> "WriteResult": ...  # overwrite at ref.location; a repeated token writes nothing (0.4)
    def applied_token(
        self, target: "TargetRef", token: str
    ) -> "WriteResult | None": ...  # stored result with skipped=True
    def unit_scope(
        self, unit_id: str
    ) -> ContextManager[None]: ...  # tags this thread's work so cancel can find it
    def is_transient(
        self, exc: BaseException
    ) -> bool | None: ...  # True retryable, False permanent, None no opinion
    def cancel(self, unit_id: str) -> None: ...  # cooperative; no-op if not capable


class Reader(Protocol):
    def read(self, spec: "ReadSpec") -> Relation: ...  # source or upstream target


class Writer(Protocol):  # format-level primitive
    def write(
        self, rel: Relation, target: "TargetRef", mode: str, opts: "WriteOptions"
    ) -> None: ...


class Materializer(Protocol):  # one per strategy
    strategy: str

    def materialize(
        self, rel: Relation, target: "TargetRef", cfg: "WriteConfig", token: str
    ) -> "WriteResult": ...  # token = idempotency key; cfg.run_started_at = the run's start (the session opens before it is resolved)


class Catalog(Protocol):
    def exists(self, target: "TargetRef") -> bool: ...
    def ensure_namespace(self, ns: "Namespace") -> None: ...  # idempotent, cached per invocation
    def table_schema(self, target: "TargetRef") -> Schema | None: ...
    def apply_grants(self, target: "TargetRef", grants: Sequence["Grant"]) -> None: ...
    def maintain(
        self, target: "TargetRef", ops: Sequence["MaintenanceOp"]
    ) -> None: ...  # explicit (L8)


class MetricsProvider(Protocol):  # plugin-internal since 0.4: not part of the core API
    def before_write(self, target: "TargetRef") -> "MetricsToken": ...
    def after_write(
        self, target: "TargetRef", token: "MetricsToken", result: "WriteResult"
    ) -> "WriteMetrics": ...


class StateStore(Protocol):
    def get_watermark(self, key: "StateKey") -> "Watermark | None": ...
    def cas_watermark(
        self, key: "StateKey", expected: "Watermark | None", new: "Watermark"
    ) -> bool: ...
    def record_run(self, record: "RunRecord") -> None: ...  # insert or replace
    def get_run(self, run_id: str) -> "RunRecord | None": ...
    def record_unit(self, record: "UnitRecord") -> None: ...  # keyed by (run_id, unit_id, attempt)
    def list_units(
        self, run_id: str
    ) -> tuple["UnitRecord", ...]: ...  # sorted by (unit_id, attempt)
    def list_runs(
        self, project: str, target: str, limit: int, before: str | None = None
    ) -> tuple["RunRecord", ...]: ...  # 0.9: newest first; before is a run id
    def lock(
        self, scope: str, run_id: str
    ) -> ContextManager[
        "LockInfo"
    ]: ...  # non-blocking; raises LockHeld; 60 s lease renewed every 20 s
    def close(self) -> None: ...


class EventSink(Protocol):
    name: str

    def handle(self, event: "Event") -> None: ...
    def flush(self) -> None: ...
    def close(self) -> None: ...


class Renderer(Protocol):
    name: str

    def render(
        self, plan: "Plan", options: Mapping[str, Any]
    ) -> Mapping[str, bytes]: ...  # path -> content

    # 0.5: the core only binds a renderer's options; it never builds one. The Databricks plugin
    # keeps rendering internal (`render_job`) and exposes `pipeloom_databricks.api`, so this
    # protocol stays a plugin-internal convention and is not called by the core.


class Executor(Protocol):
    name: str
    boundary: str  # "process" | "task"

    def submit(self, unit_id: str, *, queued_at: float) -> "UnitHandle": ...
    def wait_any(
        self, timeout: float | None
    ) -> "UnitCompletion | None": ...  # None on timeout or wake
    def cancel(
        self, handle: "UnitHandle", reason: str, *, final: bool = False
    ) -> bool: ...  # timeout and final also abandon the unit
    def has_terminal_event(
        self, handle: "UnitHandle"
    ) -> bool: ...  # a child process already emitted its own
    def wake(self) -> None: ...  # unblocks wait_any; safe from a signal handler
    def shutdown(self, *, wait: bool) -> None: ...


class Clock(Protocol):
    def now(self) -> datetime: ...  # timezone-aware UTC
    def monotonic(self) -> float: ...


class IdentityProvider(Protocol):
    def current(self) -> "Identity": ...  # user, host, orchestrator, orchestrator ids


class SecretProvider(Protocol):
    def resolve(self, path: str) -> str: ...

The engine protocols above omit Writer, Catalog.apply_grants and Catalog.maintain; they arrive with the versions that need them (section 16). MetricsProvider is shown for the shape of the before_write and after_write pair; with one implementation, the Spark engine's DeltaMetrics, it stays plugin-internal in 0.4 and the core has no such protocol. ReadSpec.format accepts "table" to read a catalog table through ReadSpec.table. The plugin API is (0, 2) in 0.2 (ADR-0021) and (0, 3) in 0.3 (ADR-0024) and (0, 4) in 0.4 (ADR-0030) and (0, 5) in 0.9 (ADR-0047); while the major version is 0 a plugin must match exactly.

0.3 contract additions. - WriteConfig carries strategy, unique_key, partition_by, update_condition (engine dialect; source. and target. qualifiers, a bare name means source), deletes (DeleteSpec), columns (the final schema, chosen by the core) and commit_meta. - WriteResult(rows_inserted, rows_updated, rows_deleted, rows_written, bytes_written, target_version, skipped, commit_meta). commit_meta is stored with the idempotency token and returned on a replay, so a replayed write hands back the watermark and the quality summary of the original attempt. - evaluate and apply_drops need the quality capability. Engines count and split rows; the core judges (section 10). - pipeloom.engine.errors: TransientError (raise it to force a retryable failure), CommitConflict (a transient error for a table commit race) and WriteKeyError (PLM206). - pipeloom.engine.types also holds ColumnChange, SchemaDiff, ExpectationSpec, QualityCounts, QuarantineMeta, DropResult, can_widen and diff_schemas.

0.4 contract additions (plugin API (0, 4), ADR-0030). - RuntimeContext gains run_started_at (timezone-aware UTC, the same in every invocation of a run) and artifacts_root (absolute POSIX path or URI). The engine session opens before any state-store call and before the run lock, so it has no run_started_at; the core passes it in WriteConfig.run_started_at and IntermediateRef.run_started_at. - EngineSession.write_intermediate(rel, ref, token) persists an intermediate model at IntermediateRef.location; ReadSpec(format="intermediate", location=...) reads it back. - CatalogCapabilities(views=) is static data on a catalog spec, so L5 can report PLC507 without importing the catalog. - unit_scope spans a unit's reads, body, checks and write, because a lazy engine does its work at the write. - WriteRefusedError is what an engine raises when its idempotency guard refuses a write; the core reports PLM207 (section 7).

0.9 contract additions (plugin API (0, 5), ADR-0047). - StateStore.list_runs(project, target, limit, before=None) returns the runs of one project and target, newest first by (started_at, run_id), at most limit; before is a run id to page from, and an unknown one raises UnknownRun. pipeloom.state.types.page_runs does the ordering and paging for any store. The core calls it through pipeloom.state.types.list_runs, which raises ListRunsUnsupported (PLX117) for a store that lacks the method. - EngineSession.from_rows(rows, schema) -> Relation, to_rows(rel) -> list[dict] (plain Python values) and orphans(rel, column, parent, field) -> int (child rows whose non-null key has no parent row; NaN is null, parent nulls never match) serve unit tests and relationships data tests (ADR-0045). pipeloom.engine.portable has to_rows and an anti-join orphans for narwhals engines; Spark counts orphans with a left_anti join. An engine without them fails only when a test uses them (PLX115). - EngineCapabilities.sql_dialect (0.9, ADR-0050) names the engine's sqlglot dialect, or None. It is part of (0, 5), which is unreleased, so the version does not change.

ModelContext.sql (0.9, ADR-0050). ModelContext keeps its fields and gains sql(query, *, dialect=None, inputs=None), backed by a private callable the runner sets. The query sees the model's inputs by alias as read (after the incremental filter); inputs= adds or replaces frames by name. It returns the native frame, or a Narwhals frame under frame_api: narwhals. The dialect is the dialect argument, then the inheritable model setting sql_dialect, then the engine's own. Only when the chosen dialect differs from the engine's does pipeloom.runtime.sql translate the query with sqlglot transpile, imported lazily; without the sqlglot extra that is PLC513. pandas runs SQL through DuckDB when the pipeloom-pandas[sql] extra is installed (ADR-0068); without it pandas declares no sql_dialect and raises SqlUnsupportedError (PLX101 with a hint), and L6 warns with PLK606 beforehand. In a view model the runner calls the function in view mode and ctx.sql returns a ViewQuery for create_view; any other return value is PLX120. The function is called by keyword: the input aliases, plus ctx when it is a parameter.

ADR-0002: Engine abstraction. - Context: the spec (section 4) lists coupling in the return type, reads, schema, temporary views, writes, merge, metrics and catalog SQL. - Options: - (a) A hand-written protocol per plugin: full control, more code per engine. - (b) Narwhals as the core abstraction: it has no write, SQL or catalog API, and only lazy PySpark. - (c) Ibis: heavy, its write support is unverified, and it pushes users into an expression API. - (d) A hybrid. - Choice: (d). - The core contract is the hand-written protocols above. Plugins own IO, writes, merge, catalogs, metrics and cancellation. - The core depends on Narwhals (it has no dependencies of its own) only for pipeloom.engine.portable. That module gives default count, filter_since, max_value, schema and evaluate that pandas, polars and PySpark plugins may reuse, through narwhals.stable.v2. - Model bodies receive native frames by default. frame_api: narwhals on a model passes Narwhals frames, so portable models work on any engine with capabilities.portable. - Consequences: no lowest-common-denominator API for Spark users. Engines can override portable defaults for speed. Narwhals stays a replaceable implementation detail.

6. Plugin system and plugin API version

ADR-0004: Discovery. - Options: entry points (stdlib importlib.metadata, the pytest model), pluggy (1:N hook fan-out), or a dbt-style namespace import. - Choice: entry points. pipeloom picks one implementation per role by kind, which is 1-of-N selection, not hook fan-out, so pluggy adds a dependency without a matching need.

Groups: - pipeloom.engines - pipeloom.catalogs - pipeloom.state_stores - pipeloom.sinks - pipeloom.secret_providers - pipeloom.executors - pipeloom.renderers - pipeloom.naming - pipeloom.commands (0.5, ADR-0034): a Click command or group that a plugin adds to the pipeloom CLI. pipeloom plugins list --group commands lists them from metadata; a command is imported only when invoked, built-in names win and a command that cannot be imported exits 1.

Each entry point resolves to a PluginSpec(name, kind, api_version: tuple[int, int], factory, config_model, compatible_engines).

Rules: - Discovery reads metadata only. A plugin is imported only when a config names its kind. - pipeloom plugins list imports nothing. - PIPELOOM_DISABLE_PLUGIN_AUTOLOAD=1 restricts loading to --plugin module:spec. - Duplicate kind names within a group are error PLU002.

Plugin API version. pipeloom.plugins.API_VERSION = (MAJOR, MINOR), independent of the package version. - MINOR covers additive changes: new optional protocol methods with defaults, new capabilities. - MAJOR covers breaking protocol changes. - In 1.x nothing is added to EngineSession or StateStore. An optional member gets its own small typing.Protocol and a core helper with a fallback, like pipeloom.state.types.list_runs (ADR-0016, amendment 1.1). - The core accepts plugins with the same MAJOR and MINOR ≤ its own. Otherwise it raises PLU001 naming the installed and required versions. - The plugin API is (1, 0). Before 1.0 it was 0.x with an exact match, so a plugin built for (0, 5) fails with PLU001. - config_version: 1 is the only accepted value through 1.x (CONFIG_VERSION in pipeloom.config.types). - Every distribution declares config-version and plugin-api in a [tool.pipeloom] table. tools/versions.py check compares them with CONFIG_VERSION and API_VERSION in the source and requires every PluginSpec to pass API_VERSION.

7. Validation layers and error catalog

Each finding is a Diagnostic(code, severity, message, hint, location{file,line,col,json_pointer}, context). Diagnostics serialize to JSON. The catalog lives in code (pipeloom.diagnostics.codes) and generates the docs page. Codes are never reused.

Layer Prefix Examples
L0 parse PLY PLY001 YAML syntax, several documents or an alias bomb; PLY002 duplicate key; PLY003 not valid UTF-8; PLY004 project or model file missing or unreadable; PLY005 model module cannot be loaded: syntax error, exception on import, file outside every python_paths root, or a module name that resolves to another file (0.9)
L1 schema PLS PLS101 unknown field (with "did you mean"); PLS102 type mismatch; PLS103 unsupported config_version; PLS104 literal value in a secret-like field; PLS105 required field missing; PLS106 ${env:X} unset or unknown ${var:x}; PLS107 malformed interpolation; PLS108 exactly one of a set of fields required
L2 references PLR PLR201 unknown ref (fuzzy suggestion); PLR202 duplicate model name; PLR203 unknown source; PLR204 unknown target or plugin kind; PLR205 duplicate source (retired in 0.9); PLR206 a model_paths entry does not exist (warning); PLR207 no target selected; PLR208 a unit test gives a wrong set of inputs or a duplicate case name (0.9); a relationships data test's to reuses PLR201 and PLR203 (0.9); PLR209 properties entry names no model, or describes one twice (0.9); PLR210 input name matches a table in several source groups (0.9). From 0.9 PLR201, PLR202 and PLR203 are also located on a decorator or parameter in Python
L3 graph PLG PLG301 cycle (prints the path); PLG302 self-reference; PLG303 selector matched nothing; PLG304 unknown selector method; PLG305 malformed selector; PLG306 unit: selector names an unknown unit (0.2); PLG307 state: or result: selector without --state (0.8); PLG308 result: selector and the --state folder has no run results (0.8)
L4 plan semantics PLP PLP401 merge or scd2 without unique_key; PLP402 incremental without column; PLP403 aggregate expectation with drop; PLP404 incremental.input not in inputs; PLP405 write option not applied by this strategy (L9); PLP406 ephemeral fan-out above threshold (warning); PLP407 replace_partitions without partition_by; PLP408 ephemeral model with no consumer (warning); PLP409 a view cannot inline an ephemeral (0.2; narrowed in 0.9, ADR-0050); PLP410 append with a lookback above zero reloads rows (warning, 0.3); PLP411 expectations on a view or ephemeral model (0.3); PLP412 <model>__quarantine is also a model in the same catalog and schema (0.3); PLP413 an intermediate model with incremental, a strategy other than overwrite, or partition_by (0.4); PLP414 columns (a contract) on a view or ephemeral model (0.9); PLP415 data_tests on an ephemeral model, or a relationships parent that is the model itself, a descendant, an ephemeral model, an intermediate model or closes a cycle among input and relationship edges (0.9)
L5 capability PLC PLC501 strategy unsupported by engine; PLC502 SQL model on an engine without SQL (retired in 0.9); PLC503 boundary: task with a non-shared state store (0.2); PLC504 catalog incompatible with engine; PLC505 non-idempotent append with retries > 0; PLC506 source format unsupported; PLC507 view without catalog views; PLC508 frame_api: narwhals without a portable engine; PLC509 materialization unsupported by the engine (0.3: the memory, polars and pandas engines accept incremental; 0.4: they and the Spark engine accept intermediate); PLC510 expectations, data tests (0.9) or non-nullable contract columns on an engine without the quality capability (0.3); PLC513 ctx.sql needs translation and the sqlglot extra is missing (0.9)
L6 static code PLK PLK601 callable file or function not found (retired in 0.9); PLK602 parameters do not match inputs (from 0.9: *args, positional-only parameters, or an inputs= key that is not a parameter, emitted while binding); PLK603 SQL references undeclared table (warning, active when the sqlglot extra is installed, 0.2; from 0.9 on literal ctx.sql queries); PLK604 callable name bound by something other than a def (warning; retired in 0.9); PLK605 SQL not parseable for that check (warning, 0.2; from 0.9 on literal ctx.sql queries); PLK606 ctx.sql on an engine without SQL (warning, 0.9)
L7 preflight (opt-in, connects) PLF PLF701 engine unreachable; PLF702 source missing; PLF703 target schema drift detected
Runtime PLX, PLM, PLQ, PLE, PLU PLX101 model raised; PLX102 timeout; PLX103 plan-hash mismatch; PLX104 cancelled; PLM201 write failed; PLM202 schema change rejected; PLM203 watermark CAS conflict (data already written; permanent); PLM205 watermark unusable (missing column, family mismatch or a lookback on a non-temporal column, 0.3); PLM206 write key invalid (missing key column or duplicate merge key, 0.3); PLM207 write refused by the idempotency guard: the engine skipped it because the model already has a later transaction version, nothing was written, permanent (0.4); PLM208 model contract violated: a missing or extra column, a type other than the declared dtype, or a null in a nullable: false column; nothing is written, permanent (0.9, ADR-0044); PLQ301 expectation failed or max_drop_ratio exceeded; PLQ302 expectation names an unknown column or an expr the engine rejects (0.3); PLQ303 data test failed after the write: the data stays written, permanent (0.9, ADR-0045); PLX114 unit test rows differ and PLX115 unit test cannot run (0.9); PLE401 sink disabled; PLU001 plugin API mismatch; PLU002 duplicate plugin kind; PLU003 plugin failed to load; PLX105 run lock held (0.2); PLX106 unit process exited without a result (0.2); PLX107 manifest invalid (0.2); PLM204 input read failed (0.2); PLX109 a ${secret:provider/path} reference could not be resolved (0.5); PLX110 the --state folder is unusable as a reference (0.8); PLX111 --defer refused: unit invocation, boundary: task or another catalog kind (0.8); PLX112 an unselected parent is read from this target instead of the reference (warning, 0.8); PLX120 a view model did not return ctx.sql(...) (0.9)
Renderers PLD, PLA PLD001 job above 1,000 tasks including finalize; PLD002 reserved, never emitted (runs/submit shares the 1,000-task limit); PLD003 task groups form a cycle; PLD004 invalid deploy options; PLD005 compute rule matches no model (warning); PLD006 two jobs carry one pipeloom_job tag; PLD007 job or run not found; PLD008 deployed job out of date; PLD009 Databricks API request failed; PLD010 no connection configured; PLD011 task ended without a unit result; PLD012 project file cannot be uploaded; PLD013 dynamic value reference not resolved; PLD014 run still active; PLD015 partly selected task group runs whole (warning); PLA001 unsupported execution mode, or its extra is missing (0.6); PLA002 invalid Airflow plugin configuration (0.6); PLA003 selection renders no unit (warning, 0.6); PLA004 unit task ended without a visible unit result (0.6); PLA005 unsupported Airflow version (0.6); PLA006 PROJECT compile cache unusable (warning, 0.6); PLA007 target boundary is not task (warning, 0.6); PLA008 WATCHER artifacts root not resolved, or the producer's run left no run_results.json under it (0.9); PLA009 WATCHER producer ended without run results (0.9)

Locations in Python (from 0.9, ADR-0050). A finding on a model carries the .py file, the decorator's line and column and, for a keyword argument, that argument's own line and column from the AST, whether the model was resolved statically or imported. The JSON pointer reads /@model/write/unique_key. Pydantic errors map through DecoratorSite.locate(pointer), which has the interface of LoadedDocument.locate. A retired code keeps its catalog entry with status: retired and the version, the docs page says "Retired in 0.9: no longer emitted", and it has no case file.

Commands: - pipeloom validate runs L0-L6. - --preflight adds L7. - Exit codes: 0 means OK, 1 means errors, 2 means usage error, 130 means interrupted.

8. Execution and scheduler

ADR-0006: Scheduler. A ready-queue scheduler with no level barrier (L6). - When a unit reaches a terminal state, each child's count of pending parents goes down by one. A child whose count reaches zero is enqueued. - Ready units are ordered by descending count of downstream units, then by name, which is deterministic. - workers caps concurrency. pool tags (a later milestone) cap per-resource concurrency.

Unit state machine.

pending → queued → running → succeeded | failed | timed_out | cancelled
                    running → retrying → running
pending → skipped   (an upstream is failed, timed_out or skipped)
queued  → skipped   (fail_fast stopped the run)
pending → cancelled (run cancelled)
queued  → cancelled (run cancelled)

The transition table is checked in code (pipeloom.runtime.states). retrying -> cancelled is part of it: a stop request, or fail-fast, cancels a unit that waits for its next attempt. A skipped unit carries a reason: upstream_failed (with the failed upstream) or fail_fast; pipeloom finalize adds not_run for a unit with neither an attempt file nor an orchestrator state (ADR-0034).

Run state machine: created → compiled → running → succeeded | failed | cancelled. A run with warnings is still succeeded.

Unit states: pending, queued, running; running ends succeeded, failed, timed_out or cancelled, or goes to retrying after a transient error and back to running after the delay; pending becomes skipped when an upstream failed. Unit states: pending, queued, running; running ends succeeded, failed, timed_out or cancelled, or goes to retrying after a transient error and back to running after the delay; pending becomes skipped when an upstream failed.
Unit states. The cancel and fail-fast transitions of pending, queued and retrying units are in the transition list above. Source: unit-states.d2.
Run states: created, compiled, running; running ends succeeded when no unit failed, failed when a unit failed, cancelled on SIGINT or SIGTERM. Run states: created, compiled, running; running ends succeeded when no unit failed, failed when a unit failed, cancelled on SIGINT or SIGTERM.
Run states. Source: run-states.d2.
One unit attempt: read the inputs filtered by the watermark from the state store, run the model body, apply expectations (dropped rows go to quarantine), write the target table with the idempotency token, commit the watermark, write the attempt file. One unit attempt: read the inputs filtered by the watermark from the state store, run the model body, apply expectations (dropped rows go to quarantine), write the target table with the idempotency token, commit the watermark, write the attempt file.
What one unit attempt does; every step emits events. Source: unit-lifecycle.d2.

Policies (ADR-0029): - Retries: retries (default 0), retry_delay (default 1s) and retry_on (transient, the default, or any). The scheduler keeps a retry heap and never sleeps: a failed attempt with retries left moves running -> retrying, emits unit.retrying and holds no worker slot while it waits. pipeloom.runtime.retry.classify decides the category, in this order: TransientError anywhere in the cause chain; the engine's is_transient opinion; ConnectionError or TimeoutError in the chain; in the read, write and state phases an OSError other than FileNotFoundError, PermissionError (a Windows sharing violation is transient), IsADirectoryError, NotADirectoryError and FileExistsError; PLX106 is transient. Everything else is permanent. PLQ301, PLQ302, PLQ303, PLM202, PLM203, PLM205, PLM206, PLM207 and PLM208 are always permanent, so retry_on: transient never repeats them; retry_on: any retries every failed attempt and therefore repeats deterministic failures. PLC505 rejects retries on an append model whose engine has no idempotent writes. - build (0.9): pipeloom build takes the flags of run. It runs the unit tests of the selection first and stops with exit 1 before a run id exists when one fails, then runs with data tests on: RunOptions.data_tests, passed to process-boundary children as the hidden run --data-tests true. Relationship parents become extra edges of the run's UnitGraph (UnitGraph.from_parents); the plan's unit_parent_map is unchanged. - Backoff: with n the retry number and base the retry_delay, d = min(max(base, 300 s), base * 2^(n-1)) and the wait is d * (0.5 + 0.5 * u), where u comes from random.Random(f"{run_id}:{unit_id}:{n}"). Delays fall in [d/2, d] and are reproducible. - Retry ownership: the owner of the schedule retries. pipeloom run --select unit:... runs with retries=0, so a child of the process executor and a unit run by an external orchestrator never retry inside; the orchestrator (or the parent scheduler) owns the retry and the attempt number. - Timeouts: per-attempt timeout, never retried. A timed-out unit is timed_out (PLX102), its descendants are skipped and the run fails. - The thread executor runs one daemon thread per attempt. It cannot kill a thread: it sets the attempt's cancel token, calls EngineSession.cancel(unit_id) once, writes the timed_out attempt file itself and drops whatever the thread reports later. The runner checks the token before reading, after the body, before the write and around the quarantine write, never between the start of the table write and the end of the watermark swap. A thread that is still working can therefore still commit after the verdict; the first terminal attempt file wins (write_json_once), finalize lets a scheduler timed_out or cancelled verdict beat a later result and records late_result: <status> in warnings[], and run.completed reports abandoned_threads. - The process executor starts each child in its own process group. The child enforces the timeout with its own thread executor; the parent's deadline is timeout + cancel_grace, after which it kills the child and everything it started (killpg on POSIX, the child's job object on Windows, with taskkill /T /F as the fallback; the pid-based kills run only while the child has not been reaped). - Cancellation: the first SIGINT or SIGTERM (SIGINT or Ctrl+Break on Windows) asks for a graceful stop: nothing new starts, pending, queued and retrying units are cancelled, and running units are asked to stop and get cancel_grace (default 30 s; target setting cancel_grace and flag --cancel-grace) to finish. Units that finish in time keep their real result; the rest are marked cancelled (PLX104). The run emits one run.cancel_requested, ends cancelled and exits 130. A second signal is a hard stop that skips the grace and abandons live thread attempts; a third raises KeyboardInterrupt. RunControl.request_stop does the same from the API. A unit invocation (child process) handles the same signals and exits 130. - Cancel on Spark: unit_scope adds one tag to the unit for the length of its reads, body, checks and write, and cancel(unit_id) interrupts the jobs that carry it: a session tag (addTag, interruptTag) on Spark Connect, a SparkContext job tag (addJobTag, cancelJobsWithTag) on classic Spark. Job groups are not used, since Connect has none. A job that has not started when the first interrupt arrives is not seen, so the engine repeats the interrupt for up to a minute or until the scope ends. Cancel stops Spark jobs, not Python code between jobs, and a Delta commit either completes or does not happen (ADR-0031). - Windows: a graceful stop of a child is CTRL_BREAK_EVENT to its process group (CTRL_C_EVENT cannot target one), followed by a kill after cancel_grace. Each child also runs in its own job object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, so the executor sweeps the child's job after it exits, as it sweeps the child's process group on POSIX: a grandchild of a child that exits on its own does not survive, and if the parent dies Windows ends the whole tree. When Windows refuses a job, the executor falls back to taskkill /T /F. - Failure isolation: skip-downstream is the default. Independent branches continue. --fail-fast stops dequeuing after the first failure. - Concurrency guard: StateStore.lock("<project>/<target>", run_id) blocks a second concurrent run on the same target (PLX105). The lock is a 60 s lease that a heartbeat thread renews every 20 s, so a crashed run frees it within a minute. --no-lock is the escape hatch. Unit mode (--select unit:<id>) takes no lock and does not finalize: the owning invocation does (ADR-0020).

ADR-0007: Data handoff. - Context: L7. With boundary: task, no in-memory or temporary-view handoff is possible. - Options: persisted intermediates everywhere (simple, costs IO); inlining (free IO, recomputes); a hybrid. - Choice: the hybrid, decided at compile time. - ephemeral models are inlined. Their bodies run inside each consuming unit. Under boundary: process the result is memoized per run, so it is computed once. - intermediate models are persisted to <artifacts.root>/runs/<run_id>/intermediate/<model> (a scratch schema the catalog provides is planned). Finalize deletes them after intermediate_ttl (section 11). - view creates a catalog view where the engine supports it, never a session view. - Consequences: the same plan runs in one process or many. PLP406 warns when an ephemeral model fans out to more than ephemeral_fanout_warn (default 3) units and suggests intermediate.

9. Incremental processing, write strategies, schema change

ADR-0008: Incremental and state. A declared key plus a lookback (L12), with watermarks in a StateStore.

Incremental config:

incremental:
  input: orders
  column: updated_at
  lookback: 2d
  watermark_source: state  # or: target

Algorithm per unit: 1. Look up the idempotency token with EngineSession.applied_token. A write that already used it is replayed: no read, no body, no write; the stored commit_meta gives the schema fields, the quality outcome and the watermark, and the unit goes straight to step 6 (ADR-0027). 2. is_incremental is true when the materialization is incremental, the target exists, the run is not a full refresh, and a watermark exists. With watermark_source: state the watermark is state.get_watermark(project, target, model); with no stored value and an existing target it is seeded from max(column) of the target (watermark_seeded: target in warnings[]). With watermark_source: target it is max(column) of the target and the state store is never written. The column's type family (timestamp with zone, timestamp without, date, integer, decimal, float, string) must match the stored one; a missing column or a mismatch is PLM205. 3. The input is filtered with filter_since. Without a lookback the bound is strict: column > w. With a lookback it is inclusive: column >= w - lookback, in seconds on timestamps and in whole days (rounded up) on dates; a lookback on any other family is PLM205. The body sees ctx.is_incremental, ctx.watermark and ctx.lower_bound, set only when the unit is incremental. 4. The batch maximum m is computed on the filtered input. The new watermark is max(w, m) when incremental (m may be empty or below w because of the lookback) and m otherwise; an empty first batch leaves the state alone. 5. Write, with the intended watermark in WriteConfig.commit_meta. 6. cas_watermark(expected, new), where expected is the value read from state in step 2 (none when seeded); emit state.watermark_committed. A store treats a stored value equal to new and written by the same run as success, which covers a crash between the swap and the attempt file. Any other mismatch is PLM203: the data is already written, the unit fails, and the error is permanent.

The watermark is committed after the write, and a retry with the same token replays the stored value instead of reading the input again (ADR-0027). A crash between the two commits exactly the original batch's watermark on retry, even when new input arrived. Append is safe only when the engine has idempotent writes (otherwise PLC505 forbids retries).

State stores: - sqlite: core, local, single host. - json: core, a directory; atomic rename for local and volume paths. - table: pipeloom-spark, shared. One Delta table, partitioned by kind (watermark, run, unit, lock), addressed by catalog name (table) or by path (path), exactly one of the two. A row is found by (kind, key). Every insert or replace is one MERGE INTO whose source is a one-row DataFrame: the watermark compare-and-set and the lease lock are single statements, a lost race gives a clean false or LockHeld, and a Delta concurrent-modification error is retried up to 10 times with jitter. Renewal and release are filtered UPDATE and DELETE. Times come from the client clock. The store reuses the engine's session and stops only a session it built (ADR-0033). boundary: task requires table or json on a shared path.

Write strategies. All return a WriteResult (section 5), with fields None when unknown. The strategy of a model that sets none is default_strategy(materialized): append for incremental, overwrite otherwise.

Strategy Semantics Full refresh
append insert all rows overwrite
overwrite replace data and schema same
replace_partitions replace partitions present in the batch (partition_by required) overwrite
merge unique_key equality; optional update_condition; an optional deletes block with column, value and mode (hard or soft); a missing key column or a duplicate key in the batch is PLM206; rows with a null key never match overwrite
scd2 unique_key, tracked_columns (default all but the key and the delete column), columns valid_from, valid_to, is_current; tracked columns compared null-safely; hard deletes close the current row (ADR-0008) rebuild

A full refresh writes append, merge and replace_partitions as overwrite. A first build (the target does not exist) keeps its strategy, because into an absent table every strategy writes the same rows and merge still checks its key. On filesystem tables (ADR-0025) every strategy writes one part file per partition when partition_by is set; replace_partitions swaps whole files without reading the others, and a merge rewrites the whole table in 0.3 as read-modify-write under a commit lock and an expected version. An scd2 write rewrites the whole table the same way.

Idempotency: each write receives token = "<run_id>:<model>". Engines with transactional idempotency use it. Engines without it declare idempotent_writes=False.

Interval incrementals (ADR-0054, since 1.3). incremental.interval (event_time, grain, begin, lookback) runs one unit as half-open UTC windows, first to last. Each window filters the incremental input with filter_between (an optional session member with a Narwhals default), writes with append and WriteConfig.replace_range (engines with interval_writes), and uses the token <run_id>:<model>:<interval_id>. The processed time is a merged list of ISO pairs in the state store under the reserved key <model>@intervals, dtype pipeloom.intervals/1, updated by compare-and-swap after each window. The run_results row lists its windows in the optional intervals array.

Delta mapping (pipeloom-spark, ADR-0032). All Delta statements are SQL text or DataFrameWriter options; no Spark conf is set, on any session. - Token: txnAppId is pipeloom/<project>/<model> (suffix #quarantine or #intermediate for those writes), txnVersion is the run start in epoch milliseconds, and userMetadata is {"pipeloom": {"v": 1, "token", "commit_meta", "result"?}}. - Check: before writing, DESCRIBE HISTORY ... LIMIT 100 is scanned for the token, and a hit returns the stored result with skipped=True. When a write produced no commit carrying the token, the scan repeats (a racing attempt may have won), then the full history; a token found nowhere means Delta refused the write because a later txnVersion exists for this app id, and the engine raises WriteRefusedError (PLM207). A newer run, an overlapping run (--no-lock) or a host clock that ran behind trips the guard; txn_guard: false turns it off, leaving only the history check. - MERGE and migration: Delta applies txnAppId to a MERGE only through session confs, which would leak into other units of the session, and a migration overwrite or mergeSchema commit runs before the guarded write. So with the guard on, a merge into an existing table, and any write that needs a migration, first makes an empty claim commit with the real txnAppId, txnVersion and userMetadata {"pipeloom": {"v": 1, "claim": token}}. It has no token key, so the token scan and the metrics ignore it. Delta refuses it when a later version exists, so PLM207 comes before any data or schema change for every strategy. Later commits of that write use the app id <app>@<token> with version 1, which still keeps two attempts of the same token from both committing. A SQL MERGE INTO is then followed by an empty append carrying the token and the stored result; re-running the MERGE with the same batch converges, so a crash between the commits is safe, and the retry finds its own claim. A claim is void once a later run of the same model has committed, so that retry gets PLM207 instead of merging over the later run's data (ADR-0032).

Strategy Delta write
append mode("append"); mergeSchema when the final columns add columns
overwrite mode("overwrite") with overwriteSchema, so any schema policy result is accepted
replace_partitions replaceWhere over the distinct partition tuples of the persisted batch (more than 10,000 tuples fails and recommends merge); works on physically partitioned and unpartitioned tables; an empty batch writes only the token commit
merge the claim commit, SQL MERGE INTO, then the token commit; null keys never match and insert; soft deletes are counted and moved from updated to deleted; a merge into a missing table is the first load, an append
scd2 a missing table is the first load: an append of the batch minus its delete rows, with valid_from set to the run start, valid_to null and is_current true; a full refresh writes the same rows as an overwrite. Otherwise the claim commit, then one SQL MERGE INTO whose source stages the batch twice: every row with its key copied to match keys (__pipeloom_mk_<k>) and a delete flag, and again with null match keys each row that changes a current row. A matched current row that is deleted or differs in a tracked column (<=>, NaN as null) closes at the run start; unmatched rows that are not deletes insert as current. The counts come from one query over the rows opened or closed at the run start, so a re-run MERGE reports the same, then the token commit

The schema policy (above) is applied by the core; the engine maps its result. Added columns go in the write itself (mergeSchema); a merge or scd2 write first makes an empty mergeSchema append instead. Removed or widened columns first run one migration commit: the table is read, aligned to the final columns and overwritten with overwriteSchema, keeping its partitioning. A migration commit carries no txn options and no token, so it never counts in the metrics; with the guard on, the claim commit before it takes the write version.

Schema-change policy (on_schema_change): - fail (default): any column added, removed or changed in type raises PLM202. - ignore: the final schema is the target's. The batch is aligned to it: extra columns dropped, missing ones filled with nulls, values cast to the target types (a failed cast is PLM201). - append_new_columns: the target's columns followed by the new ones, nullable, in batch order. Removed columns stay; a type change is PLM202. - sync_all_columns: the batch's columns. A type change is accepted only when can_widen(target, batch) (wider integer, int to float64, float32 to float64, decimals that keep every digit, finer timestamp units with the same zone, null to anything); otherwise PLM202.

The core decides the final schema (pipeloom.runtime.schema_policy.resolve_columns) and passes it as WriteConfig.columns; the engine only aligns the batch with EngineSession.align. A batch that differs from the target only by a lossless widening of the target's type is cast up to the target's types under every policy.

Every non-empty diff emits model.schema_changed (relation, policy, action: applied, ignored, rejected or replaced, and changes) and is copied to schema_changes[] of the run results. The policy applies only to strategies that keep existing rows (append, merge, replace_partitions) on an existing target outside a full refresh; overwrite, a full refresh and a first build use the batch schema and report the diff as replaced. Tables read every committed file through the table's current schema (schema-on-read), so append and widening never rewrite old files. See ADR-0026.

Table properties, partition_by, clustering and grants are applied by every strategy or rejected (PLP405). Maintenance (optimize, vacuum, clustering changes) runs only from maintenance: blocks with an explicit schedule (every_n_runs), never by default (L8).

10. Data quality

ADR-0009: Expectations. DLT-style actions plus quarantine, evaluated after the transformation and before the write.

expectations:
  - name: id_not_null
    check:
      not_null: [order_id]
    on_violation: fail
  - name: status_known
    check:
      accepted_values:
        column: status
        values: [new, paid, shipped]
    on_violation: drop
  - name: amount_ok
    expr: "amount >= 0 and amount < 1e6"   # engine-dialect, non-portable
    on_violation: warn
  - name: unique_id
    check:
      unique: [order_id]                   # aggregate
    on_violation: fail
quality:
  quarantine: true
  max_drop_ratio: 0.05
  • Row-level checks: not_null, accepted_values, range, regex, expr. Allowed actions: warn, drop, fail.
  • Aggregate checks: unique, row_count {min,max}, freshness {column, max_age}. Allowed actions: warn, fail; drop is PLP403. They see only the batch, after the drops; for an incremental model that is the new rows, not the table.
  • Engines count, the core judges (ADR-0028). EngineSession.evaluate returns raw counts: the total, violating rows per row check, rows that violate at least one drop check, and aggregate values. pipeloom.quality.judge decides pass or fail, the drop ratio, PLQ301 and the events. A pure-Python reference (pipeloom.testing.reference) defines the semantics and the contract suite compares every engine with it. Unlike DLT, counts are kept on fail too.
  • Null and NaN semantics: a null input passes every check except not_null; NaN counts as null; range bounds are inclusive; regex is an unanchored search and needs a string column; accepted_values compares exactly; expr true passes, null passes, false fails. unique counts rows minus distinct keys and ignores rows with a null key part. Freshness is now - max(column) computed by the core with the run's clock; a naive timestamp reads as UTC and an all-null column fails.
  • expr dialects: polars takes a SQL expression for pl.sql_expr; pandas takes a restricted Python expression (names, literals, operators, in with a tuple; no calls, attributes or @name; anything else is PLQ302); the memory engine takes a sqlite expression. An expr never runs code.
  • Order: row checks run on the full output; if a drop check failed the rows are split (apply_drops); aggregates then run on the kept rows (one evaluate call when nothing can drop). A lazy relation is persisted first (cached: true in the event).
  • Drop: filters rows that fail any drop check. A failed fail check, or a drop ratio above quality.max_drop_ratio, fails the unit with PLQ301 before it writes; the counts are still recorded.
  • Data tests (0.9, ADR-0045): a model's data_tests list (not_null, unique, relationships: {column, to: {ref | source}, field}, on_violation: warn | fail) runs only under pipeloom build (or run --data-tests true), inside the unit after the write and the watermark commit and before the attempt file, on the replay path too. It reads the whole written table, and the parent through the same read specs as an input, so --defer applies. Relationship parents become extra scheduling edges for that run only. Results join expectations[] with scope: table; warn adds a warning, fail is PLQ303 and the data stays written. Tables, incremental, intermediate and view models take them; an ephemeral model is PLP415.
  • Unit tests (0.9): unit_tests cases run a body on given rows with pipeloom test (or first under pipeloom build) and compare the output as a multiset; see the testing guide.
  • Quarantine: dropped rows are appended to <target>__quarantine under the token <run_id>:<model>#quarantine, so a replay writes them once. The table has the model's columns plus _pipeloom_run_id (string), _pipeloom_failed (list of the failing drop-check names; JSON text in a string column on csv catalogs) and _pipeloom_ts (timestamp[us, UTC]). Its schema policy is append_new_columns.

11. Events, logs and run metadata

ADR-0010: Events. One typed stream (L1) and a synchronous in-process bus.

Envelope (pipeloom.event/1): - id (uuid4 hex), run_id, invocation_id, seq (monotonic per invocation, assigned under the bus lock), ts (RFC 3339 UTC, microseconds), type, level, unit_id, model, attempt, data (typed payload), context (orchestrator ids). - Cross-invocation ordering is by (ts, invocation_id, seq).

Event types: - Run: run.started, run.compiled (plan summary), run.cancel_requested, run.completed. - Unit: unit.queued, unit.started, unit.retrying, unit.succeeded, unit.failed, unit.timed_out, unit.cancelled, unit.skipped. - Payloads added in 0.3 for control: unit.retrying{attempt, next_attempt, delay_ms, error} (warning; attempt is the one that failed); unit.timed_out{timeout_s, attempt}; unit.cancelled{reason: cancel|timeout}; run.cancel_requested{signal, grace_s} (signal is SIGINT, SIGTERM or SIGBREAK, or null for an API stop). - Model: model.input_read (0.8 adds relation and deferred: a read that --defer sent to the reference's relation), model.quality_evaluated, model.schema_changed, model.written, model.log (user ctx.log). - State: state.watermark_committed. - Payloads added in 0.3: model.written gains skipped (a replayed token); model.quality_evaluated carries total_rows, results[], rows_dropped, rows_quarantined, drop_ratio, cached and failures[] (it is a warning when anything warned, dropped or failed); model.schema_changed carries relation, policy, action and changes[] (a warning when rejected); state.watermark_committed carries column, dtype, before, after, source and seeded. - Other: sink.disabled, artifact.written, diagnostic (validation warnings). - run.completed also carries abandoned_threads, the number of timed-out or cancelled unit threads that were still alive when the run ended (a thread cannot be killed; it ends with the process). - run.completed also carries replay (0.9, ADR-0047): true when pipeloom finalize finds a finished record of this run id with the same status in the state store and no unit attempt started after it, as when an orchestrator retries the finalize task (a repair that ran units again is no replay). pipeloom run always sets false. The webhook sink skips replays. - run.completed carries the status, exit code, counts, totals, failures[] (one entry per failed unit with its diagnostic) and artifacts[] (POSIX paths of the files the run wrote), so the console prints the failure block and the artifacts line from it.

Bus and sinks: - The bus fans out to sinks in the order they are configured. - Each sink has a failure_budget (default 5 consecutive errors). When exhausted, the sink is disabled and sink.disabled goes to the remaining sinks. - buffered: true wraps a sink in a bounded queue and worker thread for slow transports, with drop-oldest and a count of drops. - A redaction filter masks registered secret values before any sink sees an event. - Built-in sinks: console, jsonl (stdout or file), file (per-invocation event files under artifacts), artifacts (always on; builds the result files). - pipeloom-openlineage (0.9, ADR-0046) maps the run to the OpenLineage job <project> and each unit to <project>.<model>, with uuid5 run ids, a parent run facet for the pipeline run, input and output datasets from the manifest, and the schema, outputStatistics, dataQualityAssertions, errorMessage, jobType and sourceCodeLocation facets. Inside an Airflow task it stays silent unless inside_airflow: emit; the unit operators give the Airflow OpenLineage provider the same datasets and facets through get_openlineage_facets_on_* (LOCAL and VIRTUALENV from the child's events, KUBERNETES from the manifest). Guide: Lineage with OpenLineage. - A sink may define plan_ready(PlanInfo) (0.9, additive in plugin API (0, 5)): the bus hands it the run's manifest dict and project dir right after run.started (or where a unit invocation would emit it) and in finalize. - model.written also carries columns (0.9): the table's columns after the write, null for intermediates, views and replayed writes. - RecordingSink in pipeloom.testing asserts ordered events.

Run stages, the scheduler and models emit to the EventBus; a redaction filter masks secrets before the console, jsonl, file, artifacts and openlineage sinks; the artifacts sink writes the run artifacts and the openlineage sink sends to a backend. Run stages, the scheduler and models emit to the EventBus; a redaction filter masks secrets before the console, jsonl, file, artifacts and openlineage sinks; the artifacts sink writes the run artifacts and the openlineage sink sends to a backend.
Event fan-out. Failure budgets and buffering are in the list above. Source: events.d2.

Console library: rich. It provides styled tables, colors and live progress in one dependency. structlog would still need a renderer for those. JSON lines need only the stdlib.

Sample console output (--log-format text):

14:02:11 pipeloom 0.5.0 | project shop | target dev | engine polars | run 20261029T140211Z-7f3a9c
14:02:11 plan: 6 units (3 table, 2 incremental, 1 view; 1 ephemeral inlined) | workers 4
14:02:12 1/6 OK    stg_customers ......... table          1,204 rows    88 KB   0.41s
14:02:12 2/6 OK    stg_orders ............ table          9,812 rows   412 KB   0.77s
14:02:13 3/6 WARN  fct_orders ............ merge  +311 ~42 -0  1 expectation warned  1.12s
14:02:13 4/6 FAIL  fct_payments .......... append  PLX101 KeyError: 'amount'        0.20s
14:02:13 5/6 SKIP  rpt_revenue ........... upstream fct_payments failed
14:02:14 6/6 OK    dim_customers ......... table          1,204 rows            0.35s
14:02:14 finished in 2.9s | OK 3 | WARN 1 | FAIL 1 | SKIP 1 | rows written 12,573
         fct_payments  PLX101 model raised KeyError: 'amount'
                       hint: column missing in input 'payments' (ref stg_payments)
                       at src/shop/marts/payments.py:14 in build
14:02:14 artifacts: target/run_results.json, target/manifest.json, target/events.jsonl

Long engine (JVM) traces are trimmed to the first user frame and the root cause. The full trace goes to JSON events only.

Per-model metadata (run_results.results[]): - Identity: unique_id (model.<project>.<name>), unit_id, materialization, strategy, relation_name. - Status: status, attempt, retries_used. - Timing: started_at, ended_at, duration_ms, queue_wait_ms. - Rows: rows_read{input: n|null}, rows_written, rows_inserted, rows_updated, rows_deleted, rows_dropped, rows_quarantined. - Bytes and version: bytes_written, bytes_read (null unless the engine reports it), target_version. - Incremental: watermark_before, watermark_after, is_incremental, full_refresh. - Schema: schema_hash, schema_changes[]{kind, column, old, new, action}. - Quality: expectations[]{name, kind, action, passed, failed, value, scope} (passed is null and value is set for aggregate checks; scope is batch for an expectation and table for a data test, 0.9, filled with batch when an older commit replays), warnings[] (expectation warnings and watermark_seeded: target). A replayed unit restores them from the stored commit metadata. - Error: {code, category, message, hint, exception_type, trace_excerpt}. - Runtime: engine, engine_version, executor, orchestrator_ids (Databricks job, run and task run ids; Airflow dag, run, task and try as airflow_dag_id, airflow_run_id, airflow_task_id and airflow_try_number; filled from --orchestrator-id, ADR-0034), idempotency_token.

Per-run metadata (run_results.run): - run_id, parent_run_id (null, or the run that pipeloom retry --from retried; 0.8), invocation_ids[], project, target, plan_hash, selector, args, full_refresh. args records the command line values that shaped the run, among them state (the --state folder, POSIX, relative to the project dir when possible, else absolute; null without the flag) and defer (0.8), and data_tests (true under pipeloom build; retry --from inherits it; 0.9). - status, started_at, ended_at, duration_ms, counts{status: n}, totals{rows_written, bytes_written}. - identity{user, host, orchestrator}, pipeloom_version, plugins{name: version}, python_version, git_sha (if available), exit_code, intermediate_ttl (seconds; the TTL this run was finalized with, which other runs use to judge its intermediates) and warnings[] (run-level messages, such as intermediate_cleanup_failed: <run_id>: <error>).

Metrics capture (L5): - MetricsProvider.before_write records the target version. - after_write reads commit history for versions in (before, after] and sums operation metrics. In the Spark engine only the commits whose userMetadata token equals the write's own count, plus the newest MERGE commit for a merge (a SQL MERGE carries no token, so a concurrent MERGE on the same table can be mistaken for it in the metrics, never in the data). Migration commits carry no token and are not counted. Metrics are rows_written, rows_inserted, rows_updated, rows_deleted, bytes_written and target_version, each null when the commits do not report it. - Engines without history count rows instead: count on eager frames, or the writer's return value.

Artifacts. Layout: <artifacts.root>/runs/<run_id>/{manifest.json, run_results.json, events/<invocation_id>.jsonl, units/<unit_id>/attempt-<n>.json, logs/<unit_id>-attempt-<n>.log}. artifacts.root defaults to target. An intermediate model's result lives under runs/<run_id>/intermediate/<model>. artifacts.intermediate_ttl (default 1d; 0 deletes the folder at the end of a succeeded run) governs it: finalize deletes the folders of other runs once expired, each judged by the TTL recorded in its own run_results.json (0 counts as one hour, since only a failed run is left with data) against its last activity, the newest modification time under its run folder. A run without results, or resumed after them (manifest newer than run_results.json), expires after max(ttl, 1h) idle. A deletion failure is a warning in run.warnings, never a run failure. Finalize copies the run's manifest.json and run_results.json to the root. - results[] has one row per persisted model, sorted by unit id; an ephemeral model appears in ephemeral_inlined of the units that inline it. Every row has every key, and fields 0.2 does not fill are null or empty. - manifest.json (pipeloom.manifest/1): metadata{pipeloom_version, plugins, config_version, plan_hash, project, target, boundary, python_paths, vars, env_vars, generated_at, invocation_id}, nodes{unique_id: resolved config, body, inputs, relation, unit_ids, checksum}, sources, units{unit_id: [unique_ids]}, unit_parent_map{unit_id: [unit_ids]}, parent_map, child_map, selectors{select, exclude, selected}. - plan_hash is the sha256 of the canonical JSON (sorted keys, no spaces) of nodes, sources, units, unit_parent_map, parent_map, child_map and metadata reduced to project, target, boundary and config_version. Selection, versions, timestamps and ids do not change it. A per_user naming strategy puts the user into the relations, so use none where the hash must match across machines. - A node checksum is the sha256 of its canonical config plus its body (the SQL text, or the callable and its file bytes), with CRLF read as LF. - From 1.2 (ADR-0052) a node also has optional checksums{code, config, contract, tests, upstream} and checksum_version, left out of plan_hash. They feed state:modified.<part> and ls --why; a reference without them falls back to checksum with PLG309. - With plan --diff (1.2, same ADR) a node also has an optional sql{shell, queries[{sql, dialect}], returned}, left out of plan_hash: the literal ctx.sql queries of its function and the module digest with every model function's queries blanked. plan --diff --state DIR sorts each changed model into new, removed, breaking, non-breaking, metadata, indirect-breaking or indirect-non-breaking, gates on --fail-on, and prints text or pipeloom.plan_diff/1. - From 0.9 (ADR-0050) the schema stays pipeloom.manifest/1 with a breaking change before 1.0. Every node body is {kind: "python", callable: "module:attr", file}; nodes[].file is the .py file and nodes[].line the decorator line. The SQL body goes away with the legacy path, after which a manifest with kind: sql is PLX107. The checksum keeps its formula (resolved config, callable, NUL, module file bytes, plus columns without description), so editing any function in a module marks every model of that module modified. Dynamic decorator config must be deterministic, or the plan hash differs between compiles (PLX103). - run_results.json (pipeloom.run_results/1): metadata, args, run, results[]. - Each tagged artifact has a published JSON Schema under schema/v1/ (ADR-0049): manifest.json, run_results.json (an attempt file is its #/$defs/result), event.json, unit_states.json and unit_graph.json. Objects are open, so consumers ignore unknown fields; a new field is optional, and a new value of a closed enum (status, level, materialized) needs /2. - Finalize merges unit files and picks the latest attempt per unit. Run records also go to the state store for history. - pipeloom finalize --run-id ID (0.5, ADR-0034) closes a run that an orchestrator drove unit by unit. A unit takes its attempt file, else the state given with --unit-states (pipeloom.unit_states/1: skipped, cancelled, failed or excluded), else it is skipped with the reason not_run, which does not fail the run; excluded drops the unit. orchestrator_ids come from --orchestrator-id KEY=VALUE. It exits 0, 1 or 130 and rewrites the same results when repeated.

12. The Databricks plugin

pipeloom-databricks depends on pipeloom-spark and databricks-sdk (>=0.50,<1). It provides the unity catalog, the databricks secret provider, the databricks renderer (the deploy block), the pipeloom databricks commands (bundle, deploy, run, repair), the task wrapper and task-value publishing. There is no databricks executor: ADR-0020 picks executors by boundary, and Databricks is an orchestrator. User guide: Databricks plugin. Amended by ADR-0035 and ADR-0036; the sections below are the delivered design.

A plan becomes bundle YAML or is deployed directly as one Databricks job; the job runs one task per unit, then a finalize task; tasks write unit files and finalize writes run_results.json to a UC Volume, and tasks set task values. A plan becomes bundle YAML or is deployed directly as one Databricks job; the job runs one task per unit, then a finalize task; tasks write unit files and finalize writes run_results.json to a UC Volume, and tasks set task values.
One plan, one Databricks job. Source: databricks.d2.

ADR-0011 (amended by ADR-0035): Rendering.

Task type. Each unit (or group) becomes one python_wheel_task that runs the plugin wrapper, not the core CLI:

{"task_key": "fct_orders", "depends_on": [{"task_key": "stg_orders"}],
 "python_wheel_task": {"package_name": "pipeloom_databricks", "entry_point": "pipeloom_databricks_task",
   "parameters": ["unit", "--project-dir=<root>", "--manifest=<root>/<stable manifest>",
     "--target=prod", "--pipeline=main", "--unit=fct_orders", "--plan-hash=<h>",
     "--run-id={{job.parameters.pipeloom_run_id}}", "--full-refresh={{job.parameters.full_refresh}}",
     "--job-id={{job.id}}", "--job-run-id={{job.run_id}}", "--task-key={{task.name}}",
     "--task-run-id={{task.run_id}}", "--start-ms={{job.start_time.timestamp_ms}}"]},
 "environment_key": "pipeloom_default", "max_retries": 1, "min_retry_interval_millis": 60000,
 "timeout_seconds": 1800}
  • The wrapper is a [project.scripts] entry plus a lazy function of the same name in the package, so both Databricks lookups find it. It resolves the run id (empty means dbx-<job run id>), turns start_ms into --run-started-at, rejects a parameter that still holds {{ (PLD013), calls the core CLI in the same process so an active Spark session stays the active one, passes the Databricks ids as orchestrator ids and exits with the core's code. Values use --opt=value so an empty value stays one argument.
  • Task keys use [A-Za-z0-9_-], at most 100 characters (a long or colliding key gets _ and 8 hex characters of the sha256 of the original). Groups are tag_<tag> or dir_<folder>.
  • The project is either synced by a bundle or uploaded by deploy. python_paths are prepended at execution.
  • Model tasks keep run_if: ALL_SUCCESS, which maps skip-downstream onto Databricks "upstream failed". Tasks are sorted by key, finalize last.

Compute. - Default: serverless, with one environments[] entry per compute (pipeloom_<compute>) whose spec.environment_version defaults to "5" (Python 3.12; version 1 is below the floor) and whose dependencies pin pipeloom, pipeloom-databricks and every plugin in the plan at the recorded version (Spark without extras). dependencies can be set to install from elsewhere. - Alternative: kind: job_cluster emits a shared job_clusters[] entry plus libraries, pinned from PyPI by default. - Compute comes from the target's compute_rules (selectors, first match wins, then default_compute), not from a model key: compute is a runtime key (section 4). A rule that matches no model is PLD005. - The Spark engine's active mode uses the existing session. When none is active and DATABRICKS_RUNTIME_VERSION is set (a wheel task starts without one), it attaches with builder.getOrCreate() and no conf, and never configures or stops that session.

Job lifecycle. - The default is a saved job: jobs/create, or reset when it exists, found by the tag pipeloom_job=<project>.<pipeline>.<target> (name lookup first, then a scan of all jobs; two matches are PLD006). Saved jobs give run history, repair, only-subset runs and up to 1,000 tasks. Equal settings hashes make a deploy a no-op; reset overwrites edits made in the UI. - Tags: pipeloom_job, pipeloom_plan_hash, pipeloom_settings_hash (sha256 of the canonical settings without that tag) and pipeloom_version; user tags merge and ours win. - Job settings: max_concurrent_runs: 1, queueing enabled, parameters pipeloom_run_id (default empty) and full_refresh (default false). The deploy block's settings pass through, except the keys pipeloom owns (PLD004). - runs/submit is used only with pipeloom databricks run --ephemeral (dev, serverless only). It shares the 1,000-task limit, so PLD002 is reserved and never emitted.

Bundles and direct deploy. - pipeloom databricks bundle --target prod --out resources/ writes, per pipeline, pipeloom_<project>_<pipeline>_<target>.job.yml and a stable manifest next to it. The output must lie inside the bundle; paths use ${workspace.file_path}; --check lists stale files. databricks bundle deploy remains the user's step. - pipeloom databricks deploy renders the same settings, uploads the project (content addressed, only pipeloom.yml, model files, *.py below python_paths and the stable manifest; from 0.9 pipeloom.yml, the nodes' .py files, every *.py below python_paths, the properties YAML files and the stable manifest, while model_packages modules must be installed in the job environment, ADR-0035 amendment) to <workspace_root>/<project>/<pipeline>/<target>/<hash>, then creates or resets the job. A folder with the marker _pipeloom/complete is never uploaded again; the current folder and the two newest others are kept. - A load_resources hook for Python bundle resources is on the roadmap.

Run identity and metadata. - An empty pipeloom_run_id resolves to dbx-<job run id>. Repairs keep the same job run id, so the pipeloom run_id is stable and the attempt number increments. - Each task writes its unit file to artifacts.root (a UC Volume path); this is the source of truth. - After a unit task the wrapper calls taskValues.set("pipeloom", {...}) with status, rows written, duration, target version, warnings and error code, dropping units from the end above 32 KiB (Databricks allows 48 KiB). Task values are documented for notebooks only, so this is best effort and never changes the exit code. - A final task pipeloom__finalize depends on every leaf with run_if: ALL_DONE, one retry and a 1,800 s timeout. It reads task states from the Jobs API (best effort), gives them to pipeloom finalize --unit-states (EXCLUDED to excluded; UPSTREAM_* to skipped; CANCELED or TIMEDOUT to cancelled; FAILED to failed with PLD011) and writes run_results.json. A job run's result comes from its leaf tasks, so a succeeding finalize would hide a failure: finalize exits 1 when the run failed.

Task limit. - jobs/create, reset and runs/submit allow up to 1,000 tasks including finalize. - Above the limit the plan fails with PLD001, with the hint to set task_grouping: by_tag | by_folder. That fuses models into multi-model tasks, run with --unit selectors through the in-process scheduler; membership is recomputed from the shipped manifest, which keeps the parameters short. Grouping applies whenever it is set, so the job shape does not flip at the 1,001st model. Alternatively, split into separate pipelines by selector. - No automatic job chaining before 1.0.

Subset and reruns. - pipeloom databricks run --select tag:x resolves on the plan, maps units to task keys (groups deduplicated), adds finalize and calls run-now with only. A partly selected group runs whole (PLD015). With --run-id, the start carries idempotency_token = sha256("<job_id>:<run_id>"). - pipeloom databricks repair --run-id reruns the tasks in FAILED, TIMEDOUT, CANCELED, UPSTREAM_FAILED, UPSTREAM_CANCELED or MAXIMUM_CONCURRENT_RUNS_REACHED plus finalize, with latest_repair_id from the run history. A run that is still active is PLD014.

Unity Catalog and secrets. The unity catalog subclasses the Spark session catalog (three-part backticked names, schema created only when absent). The databricks secret provider resolves ${secret:databricks/<scope>/<key>} through the client with no profile; failures are PLX109. Connection order: --profile, a user-set DATABRICKS_CONFIG_PROFILE, DATABRICKS_HOST with credentials, runtime authentication, else PLD010 (ADR-0036).

13. The Airflow plugin

pipeloom-airflow supports Airflow 3.2 up to 4.0 (apache-airflow>=3.2,<4, installed through the airflow extra; the package has no hard Airflow dependency, see ADR-0037). It imports from airflow.sdk import DAG, TaskGroup, BaseOperator, BaseSensorOperator, Asset. Triggers come from the Airflow 3 trigger base (verify the module path per minor version).

from pipeloom_airflow.config import (
    ProjectConfig,
    RenderConfig,
    ExecutionConfig,
    ExecutionMode,
    LoadMode,
)
from pipeloom_airflow.dag import PipeloomDag

shop_daily = PipeloomDag(
    dag_id="shop_daily",
    schedule="@daily",
    start_date=datetime(2026, 1, 1),
    project_config=ProjectConfig(
        project_dir="/opt/pipelines/shop", manifest_path="/opt/pipelines/shop/target/manifest.json"
    ),
    target="prod",
    render_config=RenderConfig(
        load_method=LoadMode.MANIFEST, select=("tag:daily",), emit_assets=True
    ),
    execution_config=ExecutionConfig(
        mode=ExecutionMode.DATABRICKS, databricks_conn_id="databricks_default"
    ),
)

PipeloomTaskGroup takes the same configs inside an existing DAG. ExecutionConfig fields: mode, project_dir and manifest_path (where units execute, defaulting to ProjectConfig's), virtualenv_dir, kubernetes (KubernetesConfig(image, namespace, python, pod_kwargs)), env, and the databricks_* fields: conn_id, pipeline, ensure_job, poll, poll_interval, timeout, and the watcher_* fields: workers, poll_interval, timeout, artifacts_root (the user guide, Airflow, lists them with defaults). The package has extras airflow, kubernetes (adds the cncf-kubernetes provider >=10.25,<11) and databricks (adds pipeloom-databricks, not the Databricks provider).

ADR-0012: Airflow rendering.

Load methods (parse time): - MANIFEST (recommended): reads a precompiled manifest.json. - PROJECT: compiles the project, cached by a hash of the inputs. Through 0.8 no user code runs (ADR-0003). From 0.9 static model modules are still read without importing, but the dynamic ones are imported inside the DAG processor and in every unit task, which compiles, and the cache key adds the model_packages directories (ADR-0037 amendment, ADR-0050). - Neither imports engines or connects to anything. MANIFEST imports no user code.

Execution modes: - LOCAL: PipeloomRunOperator per unit runs pipeloom run --select unit:<id> --run-id <rid> (with --manifest in MANIFEST mode, and always --expect-plan-hash) in a child process group. - VIRTUALENV: the same, using a prebuilt venv path. - KUBERNETES: PipeloomKubernetesOperator, a KubernetesPodOperator from the cncf provider extra with a user image. Never deferrable. - DATABRICKS: described below. - WATCHER (0.9, ADR-0048): one producer task runs the whole selection in one pipeloom run, and one deferrable watcher per unit reports what the run wrote for it. See "Watcher mode" below. - DOCKER: later (PLA001 in 0.6).

Artifact store (ADR-0038). The target's artifacts.root must be one shared POSIX directory for every unit task and the finalize task: any path under the LocalExecutor, NFS, EFS or SMB under Celery, a ReadWriteMany claim or a CSI mount (through pod_kwargs) on Kubernetes. fsspec is rejected for 0.6 because create-once files and atomic replace are not portable across its backends, and state stores and filesystem catalogs need shared storage anyway. A unit task that succeeded with no visible attempt file fails finalize with PLA004.

Retries.

Mode Retries owned by Notes
LOCAL, VIRTUALENV Airflow: model retries and retry_delay A unit invocation never retries itself. Exit 2: no retry. Exit 130: retry. Exit 1: no retry when the terminal error is permanent and retry_on is transient.
KUBERNETES Airflow, same counts retry_on is not enforced: Airflow sees only the pod result.
DATABRICKS Databricks task retries Sensors have no retries; the launch retries twice and attaches to its run.
WATCHER The core scheduler in the producer; Airflow for watchers The producer has retries=0 and runs once per DAG run. A watcher gets the model's retries and retry_delay; at try 2 or later it reruns its unit when the producer is done with it.

Shared behavior: - One Airflow task per unit. group_by only nests visual task groups (not in DATABRICKS mode). The cancel grace (SIGKILL delay, pod termination grace, execution timeout slack) is the core default of 30 s, because the manifest does not carry the target's cancel_grace. - Trigger rule all_success, so skip-downstream maps to upstream_failed. - A pipeloom_finalize task runs with all_done, reads the Airflow task states and exits 1 when the pipeloom run failed, so the DAG run fails. - rid is af- plus 16 hex characters of sha256 of the NUL-separated dag_id, Airflow run_id and, inside a task group, the group id (ADR-0037), stable across task retries. A clear-and-rerun of failed tasks therefore continues the same pipeloom run. - With emit_assets, each model task declares Asset(uri=<target URI>) outlets.

LOCAL, VIRTUALENV or KUBERNETES mode: the manifest is read at parse time, one task per unit follows the plan's dependencies with all_success, a finalize task runs with all_done, and every task writes to a shared artifacts root. LOCAL, VIRTUALENV or KUBERNETES mode: the manifest is read at parse time, one task per unit follows the plan's dependencies with all_success, a finalize task runs with all_done, and every task writes to a shared artifacts root.
LOCAL, VIRTUALENV and KUBERNETES modes: one Airflow task per unit. Source: airflow-task-per-unit.d2.
DATABRICKS mode: a launch task runs or repairs the saved Databricks job, one sensor per unit polls its task, and a finalize task runs with all_done. DATABRICKS mode: a launch task runs or repairs the saved Databricks job, one sensor per unit polls its task, and a finalize task runs with all_done.
DATABRICKS mode: launch, mirror sensors, finalize; repair stays in Databricks. Source: airflow-databricks.d2.
WATCHER mode: one producer task runs the selection and writes unit files to the shared artifacts root, one watcher per unit reads its file, and finalize waits for the producer and every leaf. WATCHER mode: one producer task runs the selection and writes unit files to the shared artifacts root, one watcher per unit reads its file, and finalize waits for the producer and every leaf.
WATCHER mode: one producer, one watcher per unit. Source: airflow-watcher.d2.

Databricks mode. - Options: (a) DatabricksWorkflowTaskGroup with DatabricksTaskOperator children; (b) one run-now of the bundle-deployed job, with per-model status mirroring. - Option (a) builds the job spec from Airflow operators at parse time. That duplicates the pipeloom renderer, forces job name <dag_id>.<group_id>, fixes max_concurrent_runs=1, and disables "Repair All Failed Tasks" on Airflow 3. - Choice: (b). The plugin calls pipeloom_databricks.api (stable since 0.5): find_job, deploy (as ensure_job), run_job, find_run, repair, task_states and task_key_map, with the DatabricksClient protocol and FakeDatabricks for tests. - A launch task (PipeloomDatabricksRunOperator) finds the job by tag, or deploys it at run time with databricks_ensure_job (PLD007 or PLD008 otherwise). It calls run-now with job_parameters {pipeloom_run_id: rid} and pushes the Databricks run id to XCom. It compiles the project on the worker and checks the plan hash (PLX103). - If a Databricks run already exists for rid, it attaches to it, or repairs it when tasks failed (for example after a cleared launch), recording each rerun task's attempt count as a baseline. - Each model gets a PipeloomDatabricksTaskSensor that mirrors the task state of its task_key: success, failed (AirflowFailException with the Databricks task message and the run page URL), or skipped (AirflowSkipException for upstream-failed or excluded tasks). A last sensor on the job's finalize task, trigger rule all_done, is pipeloom_finalize. - The sensors keep the plan's dependencies, so the Airflow graph is the pipeline graph. - Poll modes (ADR-0039). per_task (default): the launch returns after run-now or repair, each sensor makes one get_run call and defers on its own DatabricksRunTrigger without a verdict. shared: the launch defers on one whole-run trigger and the sensors read its final snapshot from XCom, with no call. Every deferral is bounded by databricks_timeout (default 24 hours). - Consequences: one job definition whether the run is triggered by Airflow, the Databricks UI or the CLI, and repair stays in Databricks. Reruns go through launch. Polling load in per_task is one call per waiting sensor per interval; shared is one call per interval but results show only when the run is over.

Watcher mode (ADR-0048). - Graph: a root task pipeloom_run (the producer) has no edge to the watchers. Watchers follow the plan edges, so a failed unit leaves its descendants upstream_failed. Each watcher has one Asset outlet per model with emit_assets. pipeloom_finalize (all_done) runs after the producer and every leaf. The producer has priority_weight = len(tasks) + 2 with weight_rule="absolute". - Producer (PipeloomWatcherProducerOperator): python -m pipeloom run --log-format json with the project and plan arguments (--manifest in MANIFEST mode, always --expect-plan-hash), the rendered --select and --exclude, --run-id, --run-started-at, --full-refresh, the orchestrator ids, --vars and --workers (watcher_workers). An empty rendered selection is passed as --select name:*, because a run without selectors keeps the selection a non-stable manifest recorded at compile time. Exit 0 or 1 is a success once runs/<rid>/run_results.json is visible under the resolved root within the grace, else PLA008; the unit results belong to the watchers, and finalize fails the DAG run if the pipeloom run failed. Exit 2 or 130 raises AirflowFailException. A try above 1 raises AirflowSkipException. The timeout is watcher_timeout. - Artifacts root: resolved at parse time from <project_dir>/pipeloom.yml read as plain YAML (targets.<t>.artifacts replaces the top-level block whole, root falls back to target, a relative root joins the execution project dir), or taken from watcher_artifacts_root. An unreadable file or a ${...} reference in the root is PLA008. The project is never bound in the worker for this. The triggerer must mount the root at the same path. - Watcher (PipeloomWatcherSensor, a PipeloomRunOperator subclass, no execution_timeout): reads the unit's attempt files and the producer's task state. At try 2 or later, with the producer no longer running the unit, it reruns the unit (same run id, unit mode, one attempt). Otherwise decide() maps the files: latest attempt succeeded is a success; timed out or cancelled is a failure; failed with no retry left under the unit's policy is a failure raised as AirflowFailException; a skipped row in run_results.json runs the unit in the watcher; a terminal row without its attempt file is PLA004 after the grace; no results with the producer ended is PLA009 after the grace. PLA004, PLA009 and the watch timeout raise a retryable AirflowException. Anything else defers. - Trigger (PipeloomWatcherTrigger): reads files only, every watcher_poll_interval, in a thread. It yields done, run, invisible or, after 300 s, pending; on pending the watcher's execute_complete(context, event, deadline, grace=False) checks the producer's state on a worker and defers again with the remaining deadline. The trigger never reads task states (Airflow 3.2.2 triggerer deadlock fix). On shared storage the reader also opens attempt-1 to attempt-<retries + 1> by name, and partial JSON counts as not visible. - Rerun: a unit invocation takes no lock and writes no results. Clearing a failed watcher with Downstream reruns its unit; pipeloom_finalize merges the new attempt and overwrites the producer's run_results.json. - Consequences: one process start per DAG run, and watchers hold triggerer slots instead of worker slots. A producer worker that dies can leave its child running, so PLA009 and a watcher retry may run a unit twice, and a retry after a watch timeout can rerun a unit the producer finished meanwhile.

14. Security and secrets

  • Secrets never appear as literals in YAML. Fields whose names match secret patterns accept only ${secret:...} or ${env:...} (PLS104).
  • ${secret:<provider>/<path>} resolves at runtime inside the executing process through the pipeloom.secret_providers group. Providers: env (core), file (core, mode-checked), databricks (secret scopes, ${secret:databricks/<scope>/<key>}, 0.5), airflow (connections and variables; later, no plugin registers it yet). A reference that cannot be resolved is PLX109, naming the path and never the value.
  • Connections. Airflow DATABRICKS mode maps the Airflow connection itself (host; token in the password or extra.token; extra.service_principal_oauth with the client id as login) and builds the client with pipeloom_databricks.api.connect_explicit, so no profile, ~/.databrickscfg or worker DATABRICKS_* variable changes the authentication. Errors name the connection id, never a value (PLD010); secrets pass through Airflow's mask_secret and a trigger serializes only the connection id (ADR-0039). The PROJECT compile cache stores a sha256 fingerprint of each environment variable the plan read, never its value (ADR-0037).
  • The manifest, events and artifacts store only the references. Resolved values are registered with the redaction filter.
  • Discovery never imports plugins until a config names them. PIPELOOM_DISABLE_PLUGIN_AUTOLOAD exists for locked-down hosts.
  • Supply chain:
  • Trusted publishing (OIDC) with PEP 740 attestations.
  • Actions pinned by commit SHA, with Dependabot updates.
  • No pull_request_target workflows.
  • Integration secrets only in protected environments, never for fork PRs.
  • Private vulnerability reporting through SECURITY.md.
  • Grants are declared in YAML and applied by the catalog. pipeloom never escalates privileges.

15. Testing, CI, release, docs

Tests: - Unit tests per package. - Property tests (hypothesis) for the scheduler: random DAGs, injected failures and timeouts. Invariants: a unit starts only after all parents succeed; every unit reaches exactly one terminal state; no level barrier, checked with timed fakes. - Golden tests for the manifest and diagnostics. - The case harness: one tests/cases/<CODE>.yml per diagnostic code, each an inline project compiled in the same process. From 0.9 its projects use Python models; ModuleLoader purges each project's modules on exit, so about a hundred projects load in one process without seeing each other, and every code located in Python has a case for a static and for an imported model. A retired code has no case. - CLI tests for every flag via click.testing.CliRunner (L4). - A synthetic, deterministic "shop" dataset (customers, orders, payments) generated in pipeloom.testing.data.

Engine contract suite (pipeloom.testing.contract.EngineContract). Every engine plugin subclasses it with a factory fixture, and each test is skipped unless the matching capability is declared. It covers: - read for each declared format; - logical-type round trip; - sql alias binding; - each strategy, including merge deletes, SCD2 history and replace_partitions; - the idempotent retry of each strategy with the same token; - the schema-change policy matrix, and align (cells that write a changed schema are skipped unless the harness sets schema_on_read, meaning old files are read through the table's current schema); - incremental filter_since (strict and inclusive bounds) and max_value types; - evaluate counts and apply_drops against the reference; - metrics fields that are non-null where declared; - cancel stops long work; - session cleanup restores settings (L10).

Catalog, state-store and sink contract suites follow the same pattern.

Renderer tests: - Databricks: snapshot JSON and YAML, the limits, and task-key sanitizing. - Airflow: DAG-bag parse with no network access, with a parse-time budget, and per-mode task graphs. Pure modules (configs, loading, rendering, argv, states) run on every matrix cell with no Airflow installed; a test proves airflow stays out of sys.modules. - The airflow CI job (Ubuntu) runs the Airflow-importing tests against the locked latest Airflow (3.4), the 3.3 line and the 3.2.2 floor. Tests opt in with PIPELOOM_TEST_AIRFLOW=1 and refuse to start unless AIRFLOW_HOME is a throwaway directory under the temporary directory, the database is a sqlite file under it, and no AIRFLOW_CONN_* or AIRFLOW__SECRETS__* variable is set. - DAG-bag parses run in a subprocess with an explicit environment, a socket audit hook that forbids connections, and a sqlite file that must never be created. Budgets: 2 seconds for the shop DAGs, 4 for Kubernetes, 8 for 500 units (Airflow parses the file before every task, so this is also task start-up cost). - Live Databricks and Airflow tests run only in a manually dispatched workflow. - Databricks (0.5, ADR-0036): the databricks-live workflow (on: workflow_dispatch only, protected environment databricks-live, permissions: contents: read, 60-minute timeout, no profile file) builds the wheels, uploads them to a volume, deploys tests/fixtures/databricks_live and prints CHECK <fact> ok|failed for the facts offline tests cannot confirm: dynamic references in wheel parameters, the empty run id default, only with an ALL_DONE finalize, job.start_time across repairs, files on /Volumes, a Spark session in a wheel task. It deletes what it created unless keep_job is set. No other workflow and no test reaches a workspace; the check logic is unit-tested against FakeDatabricks.

CI: - ruff check and format; mypy --strict; pytest with coverage. - Matrix: Python 3.11-3.14 on Ubuntu, Windows and macOS. Spark tests run in their own spark job on Ubuntu with Java 17: the plugin suite as a parallel matrix of three legs (classic contract, classic rest and Connect), because classic and Connect cannot share a Python process. They opt in through the test-only variable PIPELOOM_TEST_SPARK=classic|connect (and need pyspark importable, java on PATH and a non-Windows host; otherwise they skip). Tests that start a second JVM also need PIPELOOM_TEST_SPARK_HEAVY=1, which CI does not set (ADR-0033 explains why). The job runs on every PR with no path filter and is meant to become a required check after two green runs on main. - uv build plus installing the wheel into a clean venv plus pipeloom --version. - Docs build with --strict and D2 compile.

Release (ADR-0016): - SemVer per distribution, with lockstep versions for first-party distributions during 0.x and one tag vX.Y.Z. - Prereleases (vX.Y.ZrcN, also a and b) use the same tag flow. Members pin pipeloom~=X.Y.ZrcN, which accepts the rc and the final version, and the GitHub release is marked as a prerelease. - tools/versions.py check runs in the CI lint job and in the tag workflow. Besides the lockstep it checks the [tool.pipeloom] declarations against CONFIG_VERSION and API_VERSION and that every PluginSpec passes API_VERSION. - The tag workflow checks that the tag equals the version, builds, then publishes to PyPI by trusted publishing through the protected pypi environment, then creates the GitHub release with notes from CHANGELOG.md (Keep a Changelog). - config_version, the manifest and event schema versions, and the plugin API version are versioned separately.

Docs: - mkdocs-material with mkdocstrings (API), mkdocs-click (CLI), generated error-code and JSON Schema pages, and D2-rendered SVGs. - Versioned with mike on GitHub Pages. - ADRs in docs/adr/.

16. Roadmap

  • 0.0.2: reserve the name; skeleton (section 18); CI, release, governance; this document and the ADRs.
  • 0.1: config models, loader with line marks, L0-L6, graph, selectors (name, +name, name+, tag:, path:, materialized:; 0.2 adds unit:, 0.8 adds state:modified, state:new and result: with --state, ADR-0042), plan, manifest, schema export, event bus with console and jsonl sinks. CLI: validate, compile, ls, graph, schema, plugins. A MemoryEngine for tests. Deferred to 0.2: PLC503 and PLK603, the ~/.pipeloom/profiles.yml file, PIPELOOM_* variables beyond PIPELOOM_TARGET, PIPELOOM_PROJECT_DIR and PIPELOOM_LOG_FORMAT, and Narwhals support.
  • 0.2: scheduler, thread and process executors, pipeloom-polars and pipeloom-pandas, table/view/ephemeral, append and overwrite, sqlite and json state, run_results, the contract suite. pandas has no SQL models or views yet (PLC502, PLC507), so SQL on pandas is deferred. incremental and intermediate are rejected with PLC509 until their versions. PLK603 and PLK605 need the sqlglot extra.
  • 0.3 (delivered): incremental models with watermarks, merge and replace_partitions on filesystem tables (format /2), schema-change policies, expectations and quarantine, retries with backoff, per-attempt timeouts, graceful and hard cancellation, plugin API (0, 3). SCD2 and intermediate moved out of 0.3.
  • 0.4 (delivered): pipeloom-spark (local Spark, Spark Connect and an active session; the delta_path and spark_catalog catalogs), Delta writes with append, overwrite, merge and replace_partitions, idempotent writes through transaction ids and a token in the commit, metrics from commit history, expectations and quarantine on Spark, the table state store, intermediate materialization on every engine, --run-started-at, plugin API (0, 4). pyspark is an opt-in extra. SCD2 stays planned.
  • 0.5 (delivered): pipeloom-databricks: renderer, bundle YAML, direct deploy, run, repair, finalize with task states, task values, task grouping, compute rules, the unity catalog, the databricks secret provider and the manual live workflow. The core gained the deploy block, pipeloom.commands, --orchestrator-id, pipeloom finalize and runtime secret resolution (ADR-0034 to ADR-0036). Plugin API stays (0, 4).
  • 0.6 (delivered): pipeloom-airflow: LOCAL, VIRTUALENV, KUBERNETES and DATABRICKS modes (live per_task and shared polling), PipeloomDag and PipeloomTaskGroup, the PROJECT compile cache, pipeloom finalize --unit-states-json, pipeloom_databricks.api.connect_explicit, PLA001 to PLA007, the airflow CI job. Later: the DOCKER mode and an airflow secret provider (connections and variables); a dag.test() end-to-end test of DATABRICKS mode needs a file-backed Databricks fake or the live workflow.
  • 0.7 (delivered): a catalog setting per model and per folder that wins over the naming strategy's catalog, path catalogs that map a catalog to a leading directory (ADR-0040), and pipeloom compile --stable for reproducible manifests. Plugin API stays (0, 4).
  • 0.8 (delivered): pipeloom init with editor setup and pipeloom new model (ADR-0041 and its amendment), block-style YAML, pipeloom explain, the state:modified, state:new and result: selectors with --state and --defer (ADR-0042), pipeloom retry --from (ADR-0013 amendment), and pipeloom docs generate|serve, a read-only one-file docs and lineage site (ADR-0043). Plugin API stays (0, 4).
  • 0.9 (delivered): Python-first authoring with @model, hybrid AST and import discovery, the models: tree and properties files, ctx.sql and Python views (ADR-0050), with YAML model declarations removed; model contracts (ADR-0044); pipeloom test, pipeloom build and post-write data tests (ADR-0045); the scd2 write strategy (ADR-0008 amendment); run history and the webhook sink (ADR-0047); the pipeloom-openlineage distribution and Airflow facets (ADR-0046); CSV sample data on Spark and Databricks; Airflow WATCHER mode (ADR-0048). Plugin API (0, 5).
  • 1.0 (delivered, after the 1.0.0rc1 release candidate): stable contracts. The manifest JSON Schema joins the artifact schemas and the orchestrator protocol of 0.9 (ADR-0049), the plugin API moves to (1, 0), and the stability and deprecation policy of the ADR-0016 amendment applies (Stability and deprecations). Every command has help text and a page that explains it.
  • 1.1 (delivered): the pipeloom-duckdb distribution with the duckdb engine and catalog (ADR-0051), the engine conformance kit as an opt-in pytest plugin (ADR-0067) with an engine author guide and a generated capability matrix, pipeloom demo and pipeloom init --engine duckdb, the portable models guide with PLX122 and a cross-engine matrix, the experimental tier of the stability policy (ADR-0016 amendment 1.1), Airflow 3.4, the Databricks CLI documentation and Polars 2 guards. Plugin API stays (1, 0).
  • 1.2 (delivered): split checksums and the state:modified.<part> selectors, plan --diff with change categories and pipeloom diff for keyed table comparison (ADR-0052, ADR-0053), canonical dataset identity (ADR-0055), machine-readable output (compile --output json, --log-format on every command) and generated AGENTS.md and skills, ctx.sql on pandas through DuckDB (ADR-0068), a 1,000-model performance budget, artifact schema compatibility guards, and the docs overhaul. Plugin API stays (1, 0). The stretch items Slim CI recipe on DuckDB, validate --dry-run, llms.txt and the Coming from dbt guide did not ship.
  • 1.3 (delivered): interval incrementals with half-open UTC windows, replace_range writes and per-window idempotency on polars, pandas, DuckDB and Spark/Delta, and the interval ledger (ADR-0054, ADR-0032 amendment); pipeloom backfill with rerun, restate, mark-done and on-failure continue, plus the Migrating within 1.x guide; run outcome fields failed_upstream, non-blocking data tests and skip reason classes (ADR-0056); on_cursor_value_missing (ADR-0027 amendment). Plugin API moves to (1, 1); a (1, 0) plugin still loads. The stretch items sequence_by and ignore-null updates, an EL-then-T recipe with dlt and SIGTERM process-group signaling did not ship.
  • 1.x and later: planned in the roadmap.

17. ADR list and diagrams

Each ADR is Context, Options, Choice, Consequences, as written in the sections above.

ADR Topic Where
0001 Record architecture decisions docs/adr/
0002 Engine abstraction: protocols plus Narwhals helpers §5
0003 Model authoring: YAML plus Python or SQL, declared inputs (superseded by 0050) §4
0004 Plugin discovery via entry points; eight groups, a ninth (pipeloom.commands) in 0.5 §6
0005 Packaging (see below) §17
0006 Ready-queue scheduler §8
0007 Data handoff: execution units, inlining, intermediates §8
0008 Incremental key, watermark state, strategies §9
0009 Expectations and quarantine §10
0010 Events, sinks, artifacts; rich for the console §11
0011 Databricks job rendering (amended by 0035) §12
0012 Airflow rendering and modes §13
0013 Run identity, idempotency, reruns (see below) §17
0014 Secrets by reference §14
0015 Python ≥ 3.11; click CLI; pydantic v2; hatchling; mypy strict §17
0016 Versioning, release, plugin API version §15
0034 Core orchestration hooks (amends 0004, 0010, 0013, 0014) §4, §6, §11
0035 Databricks rendering and job lifecycle (amends 0011, 0012) §12
0036 Databricks client and connection §12, §15
0050 Python-first model authoring (supersedes 0003; amends 0035, 0037, 0040, 0041, 0042, 0044, 0047) §1-§5, §7, §11-§13, §15

ADR-0005: Packaging. - Options: - One distribution with extras. Its entry points are registered even when the extra's dependencies are missing, which leads to import errors at load. It also couples dependency bounds. - Separate distributions in separate repos: high overhead. - Separate pipeloom-<plugin> distributions in one uv workspace. - Choice: the uv workspace. The core is distribution pipeloom at the repo root; plugins live in plugins/pipeloom-<name>/ with import package pipeloom_<name> (no namespace packages). - Convenience extras on pipeloom (for example pipeloom[polars]) just depend on the plugin distribution. - PyPI now: publish pipeloom 0.0.2 only. Plugin names get published with their first functional release, which avoids PEP 541 placeholder squatting. - Pending trusted publishers may be registered for the plugin names. Assumption: a pending publisher does not reserve a name; verify. - [tool.uv.workspace] is added in 0.2 with the first plugin (whether uv accepts an empty members glob is unverified).

ADR-0013: Run identity. - run_id is either caller-supplied or generated as YYYYMMDDTHHMMSSZ-<6 hex>, matching [A-Za-z0-9._-]{1,64}. - Orchestrators derive it deterministically: dbx-<job_run_id> or af-<hash>. - Orchestrator retries and repairs keep the run_id and increment the attempt. - Local pipeloom retry --from <run_id> creates a new run with parent_run_id, that runs the failed, skipped and cancelled units of the parent (0.8 amendment: it selects those result: values from the parent folder, not result:fail+, so it never runs a unit the parent did not select). - Writes are idempotent through the token <run_id>:<model>.

ADR-0015: Python version. Python 3.10 reaches end of life in October 2026, so the floor is 3.11.

D2 diagrams (docs/diagrams/). Each <name>.d2 renders to <name>.light.svg and <name>.dark.svg (make diagrams); pages embed both with Material's #only-light and #only-dark, so a diagram follows the site's palette toggle. Shared classes are in _style.d2, the two themes in _theme.d2 and _theme-dark.d2. - Section 3: context, packages, core-modules, lifecycle. - Section 8: unit-states, run-states, unit-lifecycle. - Section 11: events. Section 12: databricks. Section 13: airflow-task-per-unit, airflow-databricks, airflow-watcher. - Guides: quickstart, incremental, retry-cancel, portable-models, orchestrator, openlineage, conformance-kit (Writing an engine), use-cases (home page).

18. Package skeleton for now

pipeloom/
├── .github/
│   ├── workflows/ci.yml            # ruff, mypy --strict, pytest matrix (3.11-3.14 on Ubuntu, Windows and macOS), uv build + wheel smoke, docs --strict, d2 compile
│   ├── workflows/release.yml       # on tag v*: verify tag==version, uv build, one PyPI publish job per distribution (env pypi or pypi-<plugin>), GitHub release
│   ├── workflows/docs.yml          # mkdocs + mike deploy on main and tags
│   ├── dependabot.yml              # ecosystems: uv, github-actions; weekly; grouped
│   ├── CODEOWNERS
│   ├── pull_request_template.md
│   └── ISSUE_TEMPLATE/{bug_report.yml, feature_request.yml, config.yml}
├── docs/
│   ├── index.md
│   ├── architecture.md
│   ├── adr/README.md               # index + status table
│   ├── adr/0000-template.md
│   ├── adr/0001-record-architecture-decisions.md … 0016-versioning-and-plugin-api.md
│   └── diagrams/<name>.d2, <name>.light.svg, <name>.dark.svg
├── src/pipeloom/
│   ├── __init__.py                 # __version__ = importlib.metadata.version("pipeloom")
│   ├── __main__.py                 # from pipeloom.cli import main; main()
│   ├── cli.py                      # @click.group() + @click.version_option(package_name="pipeloom", prog_name="pipeloom")
│   └── py.typed
├── tests/
│   ├── test_version.py             # __version__ equals installed metadata
│   └── test_cli.py                 # CliRunner: `--version` exit 0, output "pipeloom, version X"; `python -m pipeloom --version`
├── pyproject.toml                  # see below
├── uv.lock
├── mkdocs.yml
├── .pre-commit-config.yaml         # ruff, ruff-format, mypy, end-of-file, check-yaml
├── .editorconfig  .gitignore  .python-version (3.12)
├── README.md  LICENSE (Apache-2.0)  NOTICE
├── CONTRIBUTING.md                 # uv setup, DCO sign-off, ADR process, tests per flag
├── CODE_OF_CONDUCT.md              # Contributor Covenant 2.1
├── SECURITY.md                     # GitHub private vulnerability reporting, supported versions
├── GOVERNANCE.md                   # single-maintainer model, path to maintainers
└── CHANGELOG.md                    # Keep a Changelog; [0.0.2] entry

The core sits at the repo root so README and LICENSE ship in the distribution without copies.

pyproject.toml essentials: - [build-system] requires = ["hatchling"] - [project]: - name = "pipeloom", version = "0.0.2", requires-python = ">=3.11" - license = "Apache-2.0", license-files = ["LICENSE", "NOTICE"], readme = "README.pypi.md" - dependencies = ["click>=8.1"] - [project.scripts] pipeloom = "pipeloom.cli:main" - classifiers including Typing :: Typed - authors: to be filled by the maintainer - [dependency-groups]: dev = ["pytest", "pytest-cov", "mypy", "ruff", "pre-commit"], docs = ["mkdocs-material", "mkdocstrings[python]", "mkdocs-click", "mike"] - Tool configs: [tool.ruff], [tool.mypy] strict = true, [tool.pytest.ini_options].


Verification plan (for the skeleton commit)

  • uv sync && uv run pytest -q && uv run mypy --strict src && uv run ruff check
  • uv build, then install the wheel into a clean venv and run pipeloom --version and python -m pipeloom --version.
  • mkdocs build --strict, and d2 compile of all diagrams.
  • The first tag, v0.0.2, is the real release: there is no TestPyPI dry run.

Risks

  • The orchestrator thread executor's timeouts are cooperative. Code that ignores cancellation keeps running until the process ends.
  • In Airflow DATABRICKS mode the per_task sensors poll per model. Large DAGs need a longer poll interval or databricks_poll="shared".
  • Unverified facts are marked inline: serverless environment_version, the task-key length limit, whether pending publishers reserve names, pydantic's draft-2020-12 output, whether uv accepts an empty workspace, and the OpenLineage output-statistics facet. Verify each before implementing it.
  • Narwhals stable-API drift: pinning to stable.v2 limits it.
  • Lockstep versioning means plugin-only fixes still bump every distribution during 0.x.

Resolved defaults (2026-10-29)

  1. Airflow 3 only (ADR-0012).
  2. Only pipeloom is published now. Plugin names are published with their first functional release (ADR-0005).
  3. Docs and JSON Schema URLs live at https://emanuel-luis.github.io/pipeloom/. The repo has been public since 2026-11-02.
  4. DCO sign-off. The author and CODEOWNERS are Emanuel Luis. Security reports go through GitHub private vulnerability reporting or email.
  5. The shared artifact store for the Airflow LOCAL and KUBERNETES modes: decided in 0.6 as one shared POSIX artifacts.root with a PLA004 sentinel; fsspec is deferred (ADR-0038).
  6. CI runs Python 3.11 to 3.14 on Ubuntu, Windows and macOS. While the repo was private it ran one Windows and one macOS job on 3.12 only, because macOS minutes cost 10x; the full matrix came back when the repo went public on 2026-11-02.