digraph ReflowSubmitFlow {
  rankdir=TB;
  graph [fontname="Helvetica", labelloc=t, label="Reflow submit and execution flow", fontsize=20, pad=0.2];
  node [shape=box, style="rounded,filled", fillcolor="#f8fafc", color="#475569", fontname="Helvetica"];
  edge [color="#64748b", fontname="Helvetica"];

  a [label="wf.submit(...) / CLI submit", fillcolor="#dbeafe"];
  b [label="Validate DAG and parameters"];
  c [label="Create run_id + run_dir"];
  d [label="Persist run + task specs + instances", fillcolor="#dcfce7"];
  e [label="Topological dispatch loop"];
  f [label="Resolve upstream inputs"];
  g [label="Compute cache identity", fillcolor="#fef3c7"];
  h [label="Cache hit?", shape=diamond, fillcolor="#fef3c7"];
  i [label="Reuse output\nmark SUCCESS", fillcolor="#dcfce7"];
  j [label="Submit via executor", fillcolor="#fde68a"];
  k [label="Backend launches worker", fillcolor="#fde68a"];
  l [label="Worker executes Python task", fillcolor="#fce7f3"];
  m [label="Persist output / hashes / state", fillcolor="#dcfce7"];
  n [label="More runnable tasks?", shape=diamond, fillcolor="#e0f2fe"];
  o [label="Update run state\nstatus / retry / cancel available", fillcolor="#dbeafe"];

  a -> b -> c -> d -> e -> f -> g -> h;
  h -> i [label="yes"];
  h -> j [label="no"];
  j -> k -> l -> m;
  i -> n;
  m -> n;
  n -> e [label="yes"];
  n -> o [label="no"];
}
