Skip to content

ADR-0071: Partition spec and the completeness gate

Architecture: Section 9, Write strategies and idempotency

Builds on ADR-0054 (windows, ledger) and ADR-0056 (skip reasons). The 1.5 roadmap named ADR-0056 for this item; the work is large enough for its own record, so it takes the next free number outside the range the roadmap reserves.

Context

The 1.5 items that follow (Airflow partitioned assets, Databricks window parameters, Dagster time partitions) all need the same three things from the core: a name for each window that an orchestrator can use as a partition key, a way to learn that name from the artifacts, and a rule for a unit whose upstream has not produced the window yet. Without them each orchestrator plugin would invent its own key format and its own skip behavior.

Options

  • Derive keys from the interval id. The id is <start>_<end> as compact UTC text. It is stable, but unreadable as an asset key and not what Airflow or Dagster show (2026-11-01). Rejected as the key; it stays the idempotency name.
  • A free-form key template with a general parser. Flexible, but a template that does not name one window (no day in a day grain) silently maps two windows to one key. Rejected for a small token set that is checked against the grain.
  • A new run or unit status for an incomplete upstream. Breaks /1 readers (stability policy). Rejected: a skip reason is an open string.
  • Make the gate a scheduler feature. The scheduler knows units, not windows. The runner already loads ledgers, so the gate lives there and only reports its outcome.

Decision

Partition spec. An interval model has a spec: its grain and a key format. The format is incremental.interval.partition_format, optional, with tokens %Y, %m, %d, %H and %% and literal text. Defaults: hour %Y-%m-%dT%H, day %Y-%m-%d, week %Y-%m-%d (the Monday that starts the week), month %Y-%m, year %Y. Every token the grain needs appears exactly once and none finer does, so a key names exactly one window. A key is read back through an anchored regex (\A...\Z) built from the format, then checked to be a real window start (a week key must be a Monday). Keys are UTC, like the windows. PartitionSpec in pipeloom.config.partitions has key(start) and window_start(key); it is pure, so orchestrator plugins can use it without importing the runtime.

Validation. L4 reports the new code PLP418 for an invalid format, listing each problem. Nothing else changes in validation. partition_format is dropped from dumps while unset, so checksums and plan hashes of 1.4 projects hold.

Artifacts. The run_results row of an interval unit gains the optional partition_keys: the keys of the windows the unit ran, first to last (empty when it ran none). Each entry of intervals gains partition_key. The events unit.succeeded, unit.failed and unit.skipped gain the same optional partition_keys, left out of data while unset and optional in the schema, so frozen 1.0 documents still validate and no event of a non-interval unit changes. On unit.skipped the field lists the partitions the unit was due to run and did not. The OpenLineage sink adds a custom run facet pipeloom_partitions with the keys to the COMPLETE and FAIL events of a unit that has them. A unit.skipped that follows unit.started (a gate skip) closes the unit run as COMPLETE, since its reason is non-failing; a scheduler skip never started, so it still has no OpenLineage run.

Completeness gate. Before a unit runs, completeness(window, now, upstreams) answers (satisfied, unreachable, reason, upstream, through) for each window it would run, so a window is judged on its own. The upstreams are the interval models the unit reads directly (ephemeral inputs resolved, as in the unit graph). A complete window is satisfied when one upstream ledger interval covers all of it. The current, partial window is satisfied when each upstream has recorded some of it, whatever the time of that record: an upstream that ran an hour ago does not block a downstream that runs now. through is the time the window's data is complete up to (the window end, or the earliest end the upstreams recorded for the partial window), and the unit records that, not the run start, in its own ledger, so the next run redoes the rest of the partial window. A window is unreachable when it starts before the first window of an upstream, which no run of that upstream can fill; the reason says so and suggests moving a begin. Otherwise a gap is reachable: the upstream may still run. The unit runs every ready window in order. Windows that are not ready are held back: listed in the optional row field held_back (partition keys), named in a warning on the row, and recorded nowhere, so a later run or a backfill takes them. On a full refresh a held-back window is also removed from the ledger, since the table was rebuilt without it. Only when no window is ready does the unit settle skipped with skip_reason: upstream_incomplete, no window run and partition_keys empty. When some windows ran, the status is succeeded. Non-interval upstreams are not gated.

Scheduler. A unit may settle skipped itself, after unit.started (state transition RUNNING to SKIPPED; amendment note in ADR-0020). upstream_incomplete skips its descendants with the same reason, since their input is not there either. Neither the unit nor its descendants fail the run (ADR-0056 class rule), and pipeloom retry selects skipped units. The skipped row of a descendant carries no failed_upstream, which stays for upstream_failed rows.

Nothing to run. An interval unit whose ledger already covers every window keeps status succeeded, as in 1.4, with zero rows written (the stability policy allows only additions in a minor). The row gets the optional outcome: "up_to_date" and partition_keys: [], and unit.succeeded gets the same optional outcome. Both are absent while unset. Console counts, totals and pipeloom retry see the same status as before. The skip reason up_to_date of ADR-0056 stays reserved for --skip-unchanged; nothing emits it here. The orchestrator signal for such a unit is a documented no-op in the core: pipeloom has no orchestrator-facing signal of its own, and the row and event carry the outcome and the keys. Orchestrator plugins decide what to emit; the Airflow work of this milestone emits the asset event for the key even for an up-to-date unit, so a downstream partition is not stuck. The Airflow watcher treats an attempt skipped with a non-failing reason as a final success and never runs the unit itself.

Consequences

  • One key per window, spelled the same in artifacts, events, lineage and (later) in Airflow, Databricks and Dagster.
  • A downstream that runs alone, later than its upstream, still runs: it is judged against what the upstream recorded, not against the clock of this run.
  • A downstream whose begin is earlier than its upstream's holds back those early windows every run, and runs the rest. Moving a begin fixes it.
  • Gating is by ledger, so it needs the same state store as the interval run, and a deferred upstream (--defer) is judged by this run's state.
  • Left for the next 1.5 items: renderers that pass a key, Airflow partitioned assets, Dagster partitions.

Provenance: designed from this project's own windows and ledger and public descriptions of partitioned assets in orchestrators; no code was copied.

Status

Accepted

Date

2026-12-05