EKOSdocs
Docs / Guides Build

Transformation Chains

Draw a recovered view, routine or query as a left-to-right chain of steps, each with a sentence, its source text, columns and evidence, and leave a note on a step.

EKOS recovers views, routines and queries into its Transformation IR (source → filter → join → aggregate → sink). New in v1.5.0 (RFC 0257), you can read one as a chain of steps: what each step does in one sentence, the exact source text it was recovered from, the columns it reads and writes, and its evidence. It is read-only and calls no model.

Find and draw one

ekos transformation list                         # views, routines and queries with a recovered graph
ekos transformation list --filter order --limit 20
ekos transformation list --all                   # also statements recovery understood nothing of
ekos transformation graph --object <id>          # a TransformNode, View or Procedure id
ekos transformation graph --object <id> --expand all --json

Each step has:

  • its type: Source, Filter, Join, Aggregate, Calculate, Sink, or Unmapped;
  • a sentence from a fixed template, for example "keeps rows where sl.source_class is 2";
  • the columns in, out and used;
  • the source text it came from and its span in the definition;
  • its evidence, and people's notes on it.

Unmapped is reported, never filled in. A step recovery did not understand is shown as such.

Large routines are drawn collapsed by statement: above 40 nodes each body statement is one node, and a run of statements none of which was understood is one block. --expand 1,3 draws those statements in full, --expand all every step.

Row counts per step are not available for a recovered transformation, and the output says so.

In the console

The Transformations page lists them; "Open as a chain of steps" on an object's panel opens one. Selecting a step shows its sentence, source text, columns, evidence and notes, and marks its span in the definition; selecting text in the definition selects the step.

Notes on a step

A step is an entity like any other, so a person can annotate it, from its panel in the console or on the CLI:

ekos annotate add <step-id> comment "source_class 2 is orders; should quotations (3/4) be here too?" --as ann

The next transformation graph shows the note on that step. A note goes stale when the step's content changes, for example after a re-recover. See Annotating Entities.

For agents (MCP)

ekos_transformation_graph returns the same document (ekos.transformation-graph/1) for an id and an optional expand. It follows the caller's read scope. Pair it with ekos_transformation_explain and ekos_transformation_diff (Indexing a Database).

Measured

On LedgerSMB's sql/ (PostgreSQL, no model), every view and routine was drawn, 576 graphs and 0 failures:

graphs steps understood with a span not understood
views 17 59 58 (98%) 11
routines 559 961 911 (95%) 2,201 (70% of routine steps)

A missing span is an expression the SQL parser reprinted differently from the file: spans are found, never guessed.

Not yet: most PL/pgSQL bodies are "not understood" here, because the statement-level procedural reader is not lowered into this IR; columns are shown, not linked to their lineage down to the source column; row counts, structured edits and an assistant for recovered transformations.