007 event purity from impure impl

✓ Passing This code compiles and runs correctly.

Code

// Layer 2 demonstration (event derivation, negative case):
// an event with an unannotated proc impl derives is_pure=false on
// the event itself. The proc is structurally impure (Layer 1) and
// the event inherits that.

const std = @import("std");

~event log { message: []const u8 }

~proc log|zig {
    std.debug.print("LOG: {s}\n", .{message});
}

~event main {}

~log(message: "hello")
input.kz

Actual

LOG: hello

Test Configuration

MUST_RUN

Post-validation Script:

#!/bin/bash
# Verify: event with unannotated proc impl derives is_pure=false on
# the event declaration itself. Layer 2: event purity is computed
# from impl purity. Unannotated proc is structurally impure (Layer 1)
# and the event inherits that.

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

EVENT_LINE=$(grep -n 'event_decl = EventDecl' _combined_emit.zig | while read line; do
    linenum=$(echo "$line" | cut -d: -f1)
    if sed -n "$((linenum)),$((linenum + 5))p" _combined_emit.zig | grep -q '"log"'; then
        echo "$linenum"
        break
    fi
done)

if [ -z "$EVENT_LINE" ]; then
    echo "✗ Could not find log event_decl"
    exit 1
fi

EVENT=$(sed -n "$((EVENT_LINE)),$((EVENT_LINE + 40))p" _combined_emit.zig)

if echo "$EVENT" | grep -q 'is_pure = false'; then
    echo "✓ log event: is_pure = false (derived from unannotated proc impl)"
else
    echo "✗ FAIL: log event should be is_pure = false (derived from unannotated proc impl)"
    exit 1
fi

if echo "$EVENT" | grep -q 'is_transitively_pure = false'; then
    echo "✓ log event: is_transitively_pure = false (derived)"
else
    echo "✗ FAIL: log event should be is_transitively_pure = false"
    exit 1
fi

echo ""
echo "✓ Event correctly derives is_pure=false from its impure proc impl"
exit 0