// Migration architecture diagram
// Compile: dot -Tpdf migrate-arch.dot -o migrate-arch-dot.pdf
//      or: dot -Tsvg migrate-arch.dot -o migrate-arch-dot.svg

digraph migrate_arch {

    // ── Global defaults ──────────────────────────────────────────────────
    graph [
        rankdir  = TB
        fontname = "Helvetica"
        fontsize = 11
        splines  = spline
        nodesep  = 0.8
        ranksep  = 0.9
        bgcolor  = "white"
    ]
    node [
        fontname = "Helvetica"
        fontsize = 10
        style    = "filled,rounded"
        shape    = box
        penwidth = 1.2
        margin   = "0.18,0.10"
    ]
    edge [
        fontname = "Helvetica"
        fontsize = 8
        color    = "#444444"
        penwidth = 1.0
    ]

    // ── Nodes ────────────────────────────────────────────────────────────

    Human [
        shape     = ellipse
        fillcolor = "#b3d9ff"
        label     = "Human"
    ]
    Script [
        fillcolor = "#fffacd"
        label     = "run-migrate.fish"
    ]
    Beads [
        shape     = cylinder
        fillcolor = "#c8e6c9"
        label     = "Beads DB\nwct-0jr · migration\nwct-4b1 · follow-up"
        height    = 1.1
    ]
    Claude [
        fillcolor = "#ffccbc"
        label     = "claude -p\n(fresh process per task)"
    ]
    LLM [
        shape     = ellipse
        fillcolor = "#ffccbc"
        label     = "Sonnet 4.6"
    ]
    Skill [
        fillcolor = "#fffacd"
        style     = "filled,rounded,dashed"
        penwidth  = 1.8
        label     = "migrate-test.md"
    ]
    Build [
        fillcolor = "#e0e0e0"
        label     = "wcb / wcdoctest-util"
    ]
    SRC [
        fillcolor = "#fff9c4"
        label     = "test_*.cxx"
    ]
    DST [
        fillcolor = "#c8e6c9"
        label     = "doctest_*.cxx"
    ]

    // ── Rank constraints (rows in TB layout) ─────────────────────────────
    { rank = same;   Human;  LLM            }   // row 1 – top
    { rank = same;   Script; Claude         }   // row 2
    { rank = same;   Skill;  Build          }   // row 3
    { rank = same;   Beads;  SRC;    DST    }   // row 4 – bottom

    // Invisible within-rank ordering: left → right
    Human  -> LLM   [ style = invis ]
    Script -> Claude [ style = invis ]
    Skill  -> Build  [ style = invis ]
    Beads  -> SRC    [ style = invis ]
    SRC    -> DST    [ style = invis ]

    // ── Visible edges ────────────────────────────────────────────────────

    Human -> Script [
        weight = 5
    ]

    Script -> Claude [
        label  = "per task\n(fresh process)"
        weight = 3
    ]

    // Script ↔ Beads: use constraint=false so these long edges
    // don't fight the rank=same placement of Beads
    Script -> Beads [
        label      = "bd list / bd close"
        style      = dashed
        constraint = false
        weight     = 1
    ]
    Beads -> Script [
        label      = "tasks"
        constraint = false
        weight     = 1
    ]

    Claude -> LLM [
        dir    = both
        label  = "inference"
        weight = 4
    ]

    Skill -> Claude [
        label  = "instructs"
        weight = 3
    ]

    Claude -> Build [
        label  = "build + test"
        weight = 2
    ]

    Claude -> SRC [
        label  = "reads + deletes"
        weight = 2
    ]
    Claude -> DST [
        label  = "writes"
        weight = 2
    ]
    SRC -> DST [
        label  = "migrate"
        weight = 3
    ]

    // Claude → Beads: also constraint=false (long backward edge)
    Claude -> Beads [
        label      = "bd update / bd create"
        style      = dashed
        constraint = false
        weight     = 1
    ]
}
