workflow_dag_check
Elixir library and Mix task. Give it a CSV of workflow steps and the steps each one depends on. It checks for duplicate step ids, a dependency that names a step that does not exist, a step that depends on itself and cycles, prints every problem first, and then lists the start steps (no dependencies), the end steps (nothing depends on them), a valid run order and the levels.
The depends_on cell holds zero or more step ids separated by a semicolon; empty means no dependency. In a report, A -> B reads "A depends on B". The run order uses Kahn's algorithm with ties broken by step id, so the output is the same on every run. A level is the longest chain of dependencies leading to a step, counted in steps: a step with no dependencies is on level 1, any other step is one level above its highest dependency, and the number of levels is the longest chain. Only one cycle path is reported, found by visiting steps in sorted id order. Unknown and self dependencies are dropped before the start steps, end steps, run order and levels are worked out. When a step id appears on more than one row, the rows count as one step and their dependencies are combined. When a cycle exists the run order and levels are not available. Extra columns are ignored.
Exit code 0 means no problem was found, 1 means at least one problem was found (all problems are printed first), 2 means the input could not be read: a missing file, a missing column, no rows, an empty step id or a wrong number of fields on a line. The tool describes the file you give it; it does not run anything.
Part of the OneGTMLab free GTM tools. Background on the idea: agentic workflow.
Install
{:workflow_dag_check, "~> 1.0"} # in mix.exs deps
Use
CSV columns: step, depends_on. A second file, sample_problems.csv, holds a duplicate, an unknown step, a self reference and a cycle.
$ mix workflow_dag_check sample.csv
steps: 9
problems: none
start steps (no dependencies): load_input, load_rules
end steps (nothing depends on them): archive, notify
run order (dependencies first, ties by step id):
1. load_input
2. clean
3. load_rules
4. score
5. draft
6. notify
7. review
8. publish
9. archive
levels: 7 (longest chain, counted in steps)
level 1: load_input, load_rules
level 2: clean
level 3: score
level 4: draft, notify
level 5: review
level 6: publish
level 7: archive
Test
mix test
Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.