# `WorkflowDagCheck`
[🔗](https://github.com/jaizendra-netizen/workflow_dag_check/blob/main/lib/workflow_dag_check.ex#L1)

Check a list of workflow steps and their dependencies.

Input is a CSV with the columns `step` (an id, trimmed) and `depends_on` (zero or more
step ids separated by a semicolon, empty for none). Extra columns are ignored.

An arrow in a report reads "depends on": `A -> B` means step A depends on step B.

Checks: duplicate step ids, a dependency naming a step that does not exist, a step
depending on itself, and a cycle (one cycle path is reported). After removing unknown
and self dependencies the tool lists start steps (no dependencies), end steps (nothing
depends on them), a run order (Kahn's algorithm, ties broken by step id) and the levels.
When a step id appears on more than one row, the rows are merged and their dependencies
are combined. Steps are always visited in sorted id order, so the output is deterministic.

# `row`

```elixir
@type row() :: %{step: String.t(), deps: [String.t()]}
```

# `analyze`

```elixir
@spec analyze([row()]) :: map()
```

Analyse the rows. Returns a map with `:steps`, `:problems` (a list of strings),
`:start`, `:end`, `:order` and `:levels` (`order` and `levels` are `nil` when a cycle exists).

# `parse`

```elixir
@spec parse(String.t()) :: {:ok, [row()]} | {:error, String.t()}
```

Parse the CSV text into a list of rows.

# `problems?`

```elixir
@spec problems?(map()) :: boolean()
```

True when the analysis found any problem.

# `render`

```elixir
@spec render(map()) :: String.t()
```

Printable report: problems first, then start and end steps, run order and levels.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
