003 subflow locally pure

✓ Passing This code compiles and runs correctly.

Code

// Layer 1 demonstration: subflows are ALWAYS locally pure
// because they are pure composition of dispatches. The body of
// a subflow has no execution that produces side effects.
//
// Whether the subflow is *transitively* pure depends on what
// it dispatches into — that is Layer 2 (covered by 410_007/010).
// Here we only assert: is_pure=true on the subflow itself.

const std = @import("std");

~[pure] event a {}
~[pure] event b {}

~proc a|zig {}
~proc b|zig {}

// Subflow composing two dispatches. Locally pure by structure.
~a() |> b()
input.kz

Test Configuration

MUST_RUN

Post-validation Script:

#!/bin/bash
# Verify: subflow is_pure = true ALWAYS (Layer 1 structural fact).
# Composition has no body execution, so locally pure regardless
# of what it dispatches.

if [ ! -f "backend.zig" ]; then
    echo "✗ backend.zig not found"
    exit 1
fi

# AST literal moved from backend.zig to program_ast.zig (split landed 2026-05-20).
# Concatenate both so grep -n / sed -n by line number still work.
cat backend.zig program_ast.zig 2>/dev/null > _combined_emit.zig

# Find any top-level Flow declaration
FLOW_LINE=$(grep -n '\.flow = Flow{' _combined_emit.zig | head -1 | cut -d: -f1)

if [ -z "$FLOW_LINE" ]; then
    echo "✗ Could not find Flow declaration"
    exit 1
fi

FLOW=$(sed -n "${FLOW_LINE},$((FLOW_LINE + 50))p" _combined_emit.zig)

if echo "$FLOW" | grep -q '.is_pure = true'; then
    echo "✓ subflow: is_pure = true (Layer 1 structural fact — composition is always locally pure)"
else
    echo "✗ FAIL: subflow should be is_pure = true ALWAYS"
    exit 1
fi

echo ""
echo "✓ Subflow correctly marked locally pure regardless of dispatch contents"
exit 0