✓
Passing This code compiles and runs correctly.
Code
// Test: `koruc explain` on a participant store — `std/store:new` with
// `! step`/`! wait` exposes `<s>-step`/`<s>-live`/`<s>-wait`, which the
// pump joins by name. The two explainers corroborate across the
// generated-name channel: store reports "pump participant — exposes
// tasks-step …" and pump reports each callee as "synthesized by
// std/store:new(tasks)" — pre-transform, those units don't exist yet,
// so the report names their generator rather than demanding a decl.
// post.sh drives the text rows and the typed json catalog.
import std/io
import std/store
import std/pump
import std/explain
import lib/tasklib
std/store:new(tasks, capacity: 4) { *lib/tasklib:Task<live!> }
! step s |> lib/tasklib:work(s)
! discharge s |> lib/tasklib:done(s)
! wait t |> lib/tasklib:poll(t)
std/pump:create(main)
| drained |> std/io:print.ln("drained")
std/pump(main)
! step |> tasks-step()
! live |> tasks-live()
! wait i |> tasks-wait(i)
std/pump:run(main)
Supporting Files
const std = @import("std");
pub const Task = struct { work: i32, state: u8 };
~pub tor work { s: *Task<live> }
| running
| complete
~proc work|zig {
if (s.work <= 0) return .{ .complete = .{} };
s.work -= 1;
if (s.work == 0) return .{ .complete = .{} };
return .{ .running = .{} };
}
~pub tor done { s: *Task<!live> } -> i64
~proc done|zig {
const w = s.work;
std.heap.page_allocator.destroy(s);
return w;
}
~pub tor poll { t: *Task<live> } -> i128
~proc poll|zig {
_ = t;
return 1_000_000;
}
Actual
drained
Expected output
drained
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (tasks, capacity: 4, source: *lib/tasklib:Task<live!>)
flow ~create click a branch to expand · @labels scroll to their anchor
create (expr: main)
flow ~std/pump click a branch to expand · @labels scroll to their anchor
std/pump (main)
flow ~run click a branch to expand · @labels scroll to their anchor
run (main)
Test Configuration
MUST_RUN
koru.json:
{
"paths": {
"lib": "./lib"
}
}Post-validation Script:
#!/bin/bash
# `koruc explain` on a store-as-participant program: std/store reports the
# owned column, the interceptor arms, and the exposed pump verbs; std/pump
# resolves the generated callees to their synthesizer. Both halves of the
# generated-name channel are reported by the modules that own them.
set -e
echo "=== koruc explain (text) ==="
TEXT=$(koruc "$KORU_INPUT" explain 2>&1)
echo "$TEXT"
echo "$TEXT" | grep -q "📖 std/store" || { echo "FAIL: store report missing"; exit 1; }
echo "$TEXT" | grep -q "capacity = 4" || { echo "FAIL: capacity missing"; exit 1; }
echo "$TEXT" | grep -q "columns = 1" || { echo "FAIL: owned column missing"; exit 1; }
echo "$TEXT" | grep -q "Task<live!> — owned" || { echo "FAIL: owned mark missing"; exit 1; }
echo "$TEXT" | grep -q "interceptors = step, discharge, wait" || { echo "FAIL: interceptor list missing"; exit 1; }
echo "$TEXT" | grep -q "pump participant — exposes tasks-step" || { echo "FAIL: participant row missing"; exit 1; }
echo "$TEXT" | grep -q "tasks-wait" || { echo "FAIL: wait verb missing"; exit 1; }
echo "$TEXT" | grep -q "📖 std/pump" || { echo "FAIL: pump report missing"; exit 1; }
echo "$TEXT" | grep -q "tasks-step ← synthesized by std/store:new(tasks)" || { echo "FAIL: synthesized callee missing"; exit 1; }
echo "$TEXT" | grep -q "drains = true" || { echo "FAIL: drain policy missing"; exit 1; }
echo "=== witness hashes: the generated-name channel is a link ==="
# The j0.step row carries two witnesses: the arm's call site and the
# `std/store:new(tasks)` site that synthesized the callee — resolve the
# generator and land on the store decl, from a pump row.
GEN=$(echo "$TEXT" | grep -oE "j0.step = [^ ]+ ← synthesized by std/store:new\(tasks\)( \[[0-9a-z]+\])+" | grep -oE "\[[0-9a-z]+\]" | tail -1 | tr -d '[]')
[ -n "$GEN" ] || { echo "FAIL: no witness on j0.step"; exit 1; }
AT=$(koruc "$KORU_INPUT" at "$GEN" 2>&1)
echo "$AT"
echo "$AT" | grep -q "std.store:new" || { echo "FAIL: generator did not resolve"; exit 1; }
echo "=== koruc explain json (typed) ==="
JSON=$(koruc "$KORU_INPUT" explain json 2>&1)
echo "$JSON"
echo "$JSON" | grep -q '"capacity":4' || { echo "FAIL: capacity not typed"; exit 1; }
echo "$JSON" | grep -q '"drains":true' || { echo "FAIL: drains not typed"; exit 1; }
echo "=== PASS: explain reports the store participant ==="