Skip to main content

Design — konsol-exec as a Pipeline Orchestrator

Written: June 2026 (konsolidat b3fb1af, 2026-06-29) · Scope then: konsol app (konsol-exec SPA + control_api.py + pipeline doctypes) · Related: konsol#56 (epic), konsol#55 (year selector), konsolidat#91 (FX surfacing), konsolidat#109/#110/#111 (data-quality follow-ups)

Status as of 2026-11-05

This design is built in its core and partly superseded in its user interface.

  • Built (konsol 83de313c, 2026-06-29, "full epic P1/P2/P3", then hardened): the doctypes Pipeline (template), Pipeline Step (template step), Pipeline Run (PIPE-#####), Run Step, Pipeline Schedule; the package konsol/orchestrator/ (dag.py, plan.py, state.py, handlers.py, executor.py, run.py, api.py, resume.py, reaper.py, cron.py, lineage.py, resources.py, fx.py); scheduled execution (konsol.orchestrator.cron.run_due_schedules, every minute from hooks.py); the single-flight guard and the reaper (every 15 minutes).
  • Renamed on 2 July 2026 (konsol 547ff9f8, e61594dc): "Pipeline Definition" → Pipeline, "Step Definition" → Pipeline Step, the per-run rows → Run Step; the close doctype is Assertion Run (child Assertion Step). This page uses the current names.
  • Removed: konsol-exec was removed. The konsol-exec SPA, control_api.py, home_api and home_model were deleted with konsol#305 Delivery 1 (26 Sep 2026; control_api.py deleted in 0387e48f). /konsol-exec returns 404. The close (checks, sign-off, trial balances, rates, journals, audit trail) runs in the /close app; pipeline runs are started from the Pipeline Run form's Run Pipeline button in the Desk, or by a Pipeline Schedule. The control-plane mock-up below therefore describes a screen that no longer exists; konsol's HANDOFF.md records that the live step rail with per-step Retry/Resume and the stage-range launch are the two things konsol-exec did that the Desk does not.
  • Not built as proposed: a Resource / Connection doctype (the resolver resources.py reads EPM Settings and Connector instead); a lineage or metrics view (lineage.py is a pure-python core); step type cube_refresh and sql exist as Pipeline Step options, but only airbyte_sync, close_assertions and signoff are registered by name in handlers.py, and the dbt verbs are built by build_dbt_command.

Evidence: file listing of konsol/orchestrator/, konsol/pipeline/doctype/, konsol/hooks.py:120-132, konsol/public/ (contains close/, no konsol-exec/), konsol HANDOFF.md "Update (26 Sep)". See also the decision pages for konsol #56, #58, #59 and #74.

Context (June 2026)​

The data platform runs a real pipeline: D365 → Airbyte → ClickHouse epm_raw → dbt (staging→bronze→silver→gold) → consolidation/close → Cube/Excel. But konsol-exec at the time was a launcher, not an orchestrator: four hardcoded process cards (PROCESSES = budgeting / forecasting / consolidation / assertions) — budgeting/forecasting/consolidation routed through run_governed_build (via build_scope), close/assertions through trigger_close_run — each firing one backend function and streaming a single log. There was:

  • no decomposition into steps (you couldn't see or control extract vs transform vs test);
  • no parameters (couldn't pick fiscal year/period — #55 — or dbt run vs build, --full-refresh, scope, skip-sync);
  • no retry / resume / cancel, no per-step logs, no lineage;
  • no scheduling;
  • a binary preflight instead of a real readiness model.

Bringing up real D365 data that cycle required a dozen server-side workarounds (set connector last_sync_at, dbt run instead of governed build, --full-refresh to clear stale incremental rows, trigger_close_run(2024,12) by hand). Every one of those should be a UI-driven step or parameter.

This doc proposed turning konsol-exec into a first-class orchestrator modeled on Airbyte (connections + jobs/attempts + logs), Frappe Press (stepped builds with live-streamed output, retryable), and Dagster/Airflow (a DAG of typed tasks with params, schedules, retries, run history, lineage). The common shape they all share — and the thing that was missing — is:

A Run is a DAG of typed Steps, each independently observable, retryable, and parameterized.

Architecture​

Data model (Frappe doctypes)​

Pipeline (the DAG template)
└─< Pipeline Step type · depends_on · default params

Pipeline Run (one execution = pipeline + run params) PIPE-#####
├─ params: fiscal_year · fiscal_period · scope · full_refresh · skip_sync
└─< Run Step type · status · depends_on · params
· log · started_at · ended_at · rows · retry_count

Resource ── Airbyte Connection | dbt Project | ClickHouse Target
(proposed; built as a resolver over EPM Settings + Connector, not a doctype)
DoctypeRoleStatus (2026-11-05)
PipelineDAG template: ordered steps + dependencies + default paramsexists (konsol/pipeline/doctype/pipeline)
Pipeline Steptemplate step: step_id, step_type, depends_on, paramsexists
Pipeline Runrun aggregate + params; statuses Queued / Extracting / Transforming / Running / Completed / Failed / Cancelledexists
Run Stepper-step status / rows / timing / retries / deps / params / output / errorexists
Pipeline Schedulecron trigger (cron, params, enabled, last_run, next_run)exists; executed by cron.run_due_schedules
Resource / ConnectionAirbyte conn, dbt project, CH targetnot a doctype; orchestrator/resources.py resolves from run params, then EPM Settings and Connector

Step-type library​

Each step type is a handler the executor knows how to run and stream. dbt steps take select/exclude, full_refresh, and vars — so run-vs-build, full-refresh, scope and fiscal year stop being special cases and become step parameters.

airbyte_sync dbt_seed dbt_run dbt_build dbt_test
close_assertions signoff(gate) cube_refresh sql

(These are the step_type options on Pipeline Step today. dbt_seed is kept as an option although the project has no seeds since konsolidat 85dff3b.)

The pipeline as a DAG​

extract transform validate surface
┌──────────┐ ┌──────────────────────────────┐ ┌───────────────┐ ┌──────────┐
│ airbyte │──▶│ staging → bronze │──▶│ close │──▶│ cube │
│ sync │ │ → silver → gold │ │ assertions │ │ refresh │
└──────────┘ └──────────────────────────────┘ └──────┬────────┘ └──────────┘
writes back │
last_sync_at ┌─────▼──────┐
│ sign-off │ (manual gate)
└────────────┘

Executor​

A worker process (konsol.orchestrator.run) that:

  1. resolves the Run's DAG from its Pipeline + params (plan.py: skip_sync drops the Airbyte step and rewires dependencies, full_refresh applies to incremental dbt steps, scope becomes select, fiscal year/period become dbt vars),
  2. walks steps in dependency order, running each handler in a subprocess (dbt) or client (Airbyte),
  3. checkpoints each Run Step's status and streams logs via frappe.publish_realtime,
  4. supports resume-from-step, retry-failed-step, cancel, and a single-flight lock (the binary guard in trigger_close_run generalised; api.py:51),
  5. is idempotent per (definition, params) so a re-run is safe.

Control plane (the SPA) — removed​

This is the June 2026 mock-up of the konsol-exec screen. The screen was removed with konsol#305; it is kept here because it states what the orchestrator was meant to show.

┌─ Konsol Exec ────────────────────────────────────────────────────┐
│ Pipeline: Group Close FY 2024 ▾ Period 12 ▾ [ Run ▸ ] │
│ Options: ☑ full-refresh ☐ skip sync scope: consolidation ▾ │
├───────────────────────────────────────────────────────────────────┤
│ Run PIPE-00042 ● Running started 12:04 ⟳ 00:42 │
│ │
│ ① Extract · airbyte_sync ✓ 6.2s 511,789 rows │
│ ② Transform · dbt_run (silver) ● running ▓▓▓▓▓░░ 04:12 │
│ ③ Gold · dbt_run (gold) ◷ pending │
│ ④ Assertions · close_assertions ◷ pending │
│ ⑤ Sign-off · signoff (gate) ◷ pending │
│ │
│ ┌ Step ② log ────────────────────────────── [retry] [skip] ──┐ │
│ │ 12:06 11 of 34 OK silver_gl_entries ......... [OK 4.1s] │ │
│ │ 12:06 12 of 34 START silver_exchange_rates ... │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
│ History: PIPE-00041 ✓ Green · PIPE-00040 ✗ Red(step④) · … │
└───────────────────────────────────────────────────────────────────┘
  • Param form to launch (year/period/scope/flags) → the orchestrator API start_run(definition, params) and launch_options(fiscal_year) still exist (orchestrator/api.py:160, 287); the Desk's Run Pipeline button is the launcher now.
  • DAG / timeline with per-step status + live per-step logs: the Run Step child table holds the data; no live rail renders it today.
  • Retry / resume / cancel per step: resume.py and state.py implement it; no UI.
  • Schedules: Pipeline Schedule, executed every minute.

How this subsumes the manual workarounds​

Manual workaround (June 2026)Became
trigger_close_run(2024,12) server-sidethe close takes fiscal_year / fiscal_period from the caller (close/checks_api.run_checks; /close app and the Period Close Desk report)
dbt run instead of governed dbt builda step type choice (dbt_run vs dbt_build)
--full-refresh to clear stale bronzea run param (full_refresh on Pipeline Run)
set Connector.last_sync_at by handthe airbyte_sync step and the airbyte_sync_complete webhook write it back
scope selection (+tag:domain:consolidation)a run param (scope → select)
read TB/close failures from the DBAssertion Run results and the /close Checks screen
FX rate visibility/entry (#91 B/C)governed Group Exchange Rates; orchestrator/fx.py get_fx_rates; /close Rates & ownership screen

Out of scope (intentionally): editing dbt SQL and opening PRs — that is code/Git work, not an ops console. Data fixes flow through the repo.

Reuse vs build · build-vs-buy​

  • Reuse: Airbyte itself (extract); the existing _run_airbyte_sync / _run_dbt_build / run_close_assertions logic (refactored into step handlers); Frappe permissions/audit/scheduler.
  • Build: the Run Step doctype, the DAG executor, and the param/timeline UI (the first two were built; the UI was built and later removed).
  • Build-vs-buy: stay native (Frappe doctypes + worker). Bolting on Dagster/Airflow would fight the single-container deployment and forfeit Frappe's permissions / realtime / sign-off / audit. Dagster is the conceptual reference, not a dependency.

Phasing (as proposed) and outcome​

  • P1 — Step engine over the existing pipeline. Run Step + executor; decompose sync→dbt→close into visible, retryable, parameterized steps with live logs. Built (konsol#57, #60, #66, #69, #73, #76).
  • P2 — Editable Pipelines, schedules, resume-from-step. Built for schedules (cron.py) and the resume core (resume.py); pipelines are edited in the Pipeline form. See konsol #58.
  • P3 — Lineage/metrics, Connection-management UI, FX surfacing (#91 B/C), multi-ERP. Cores only (lineage.py, resources.py, fx.py); FX is shown in /close. See konsol #59.

Acceptance (P1, as written)​

From konsol-exec, a user can launch a Group Close for any fiscal year/period, watch it run as discrete steps with live logs, retry or resume from a failed step, choose dbt run/build + full_refresh + scope, and have the Airbyte step record its own sync status — with zero server-side intervention.

As of 2026-11-05 the first clause is met by the /close app and the Period Close report rather than by konsol-exec; the step rail with retry/resume has no screen. See the Period Close guide.