✓
Passing This code compiles and runs correctly.
Code
// NEGATIVE TEST (designed rejection — transplant purity, DESIGN.md T1 +
// ruling (a)). A watch body executes at the store's WRITE SITES, not at
// its lexical position — so it may reference only its own branch bindings
// and comptime-known names (module decls, qualified calls, store names).
// Here the body reaches for `ctx`, a RUNTIME binding of the enclosing
// flow: rejected, with a koru-level diagnostic (never a raw Zig
// undeclared-identifier leak — the check lives IN the store transform,
// rewrite-time, per the 2026-07-04 ruling).
//
// The watch's lexical placement mid-flow is otherwise LEGAL (links live
// anywhere — organizational principle, ruling 4); placement is not the
// crime, the ambient reference is.
//
// Branch-payload grammar: single-payload branches use identity syntax
// (`| ready []const u8` — the parser rejects single-field braces,
// PARSE003); whole-payload binding on a `|` branch (`| ready ctx |>`)
// grounded via 910_LANGUAGE_SHOOTOUT/2104_17 (`| connected c |>
// app/db:tx.begin(conn: c)`). Note: expected_error.txt here is
// DOCUMENTARY (the designed diagnostic text) — the harness checks the
// EXPECT CONTAINS lines, not this file, when both are present.
~import std/io
~import std/store
~std/store:create(game) { entities: 0[i64] }
~pub event setup {}
| ready []const u8
~proc setup|zig {
return .{ .ready = "local" };
}
~setup()
| ready ctx |> std/store:watch(game)
! entities e |> std/io:print.ln("{{ ctx:s }}: {{ e:d }}")
Backend must reject with:
CONTAINS watch body
CONTAINS ctx
CONTAINS write sitesError Verification
Actual Compiler Output
🎯 Compiler coordination: Passes: 15 (flow-based: frontend, analysis, emission)
Error: output_emitted.zig:70:20: error: std/store: watch body references 'ctx', runtime state of the enclosing flow - a watch body executes at 'game's write sites, not here; bind it through a store or react at a write site
comptime { @compileError("std/store: watch body references 'ctx', runtime state of the enclosing flow - a watch body executes at 'game's write sites, not here; bind it through a store or react at a write site"); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
main: output_emitted.zig:716:22
callMain [inlined]: /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:618:22
callMainWithArgs [inlined]: /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:587:20
main: /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:602:28
1 reference(s) hidden; use '-freference-trace=5' to see all referencesFlows
flow ~create click a branch to expand · @labels scroll to their anchor
create (expr: game, source: entities: 0[i64])
flow ~setup click a branch to expand · @labels scroll to their anchor
setup
Test Configuration
MUST_FAIL
Expected Error:
watch body references 'ctx', runtime state of the enclosing flow — a watch body executes at 'game's write sites, not here; bind it through a store or react at a write site