# Diamond dependency pattern: A -> (B, C) -> D
# Tests job coordination with shared dependencies

rule all:
    input:
        "output/final.txt"

rule step_a:
    output:
        "output/step_a.txt"
    shell:
        """
        echo "Step A - Starting point" > {output}
        """

rule step_b:
    input:
        "output/step_a.txt"
    output:
        "output/step_b.txt"
    shell:
        """
        echo "Step B - Branch 1" > {output}
        cat {input} >> {output}
        """

rule step_c:
    input:
        "output/step_a.txt"
    output:
        "output/step_c.txt"
    shell:
        """
        echo "Step C - Branch 2" > {output}
        cat {input} >> {output}
        """

rule step_d:
    input:
        b="output/step_b.txt",
        c="output/step_c.txt"
    output:
        "output/final.txt"
    shell:
        """
        echo "Step D - Merge point" > {output}
        echo "From B:" >> {output}
        cat {input.b} >> {output}
        echo "From C:" >> {output}
        cat {input.c} >> {output}
        """
