✓
Passing This code compiles and runs correctly.
Code
// Test: a `|variant` tag on std/refine selects a declared impl variant —
// `proc default|fpga` — and scopes the facet it lands. The universal
// facet carries unscoped blocks only; the scoped facet carries the
// materialized meet of universal + same-scope blocks (value folds
// `>=0` with `<=255`). A tag with no declared impl refuses KORU122 —
// never a silently universal facet.
//
// Expected: Stage C prints both canonical meets (expected_comptime);
// post.sh asserts `explain` reports the scopes as separate
// sections with their own contributor counts.
import std/proto
import std/refine
import std/io
import std/explain
std/proto(Sample) {
value: i64
mode: i64
}
std/refine(Sample) {
value: i64 & >=0
mode: i64
}
std/refine(Sample)|fpga {
value: i64 & <=255
}
std/io:print.ln("scoped")
Actual
scoped
Expected output
scoped
Expected comptime output
refine input:Sample: value: i64 & >=0, mode: i64
refine input:Sample|fpga: value: i64 & >=0 & <=255, mode: i64Flows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Sample, source: value: i64
mode: i64)
flow ~std/refine click a branch to expand · @labels scroll to their anchor
std/refine (Sample, source: value: i64 & >=0
mode: i64)
flow ~std/refine click a branch to expand · @labels scroll to their anchor
std/refine|fpga (Sample, source: value: i64 & <=255)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "scoped")
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# `koruc explain` reports each refine scope as its own section: the
# universal facet from unscoped blocks (contributors = 1), and the
# `|fpga` facet from the universal + scoped fold (contributors = 2).
set -e
echo "=== koruc explain (text) ==="
TEXT=$(koruc "$KORU_INPUT" explain 2>&1)
echo "$TEXT"
echo "$TEXT" | grep -q "📖 std/refine" || { echo "FAIL: refine report missing"; exit 1; }
echo "$TEXT" | grep -q "input:Sample|fpga" || { echo "FAIL: scoped section missing"; exit 1; }
echo "$TEXT" | grep -q "value.meet = i64 & >=0 & <=255" || { echo "FAIL: scoped meet missing"; exit 1; }
echo "$TEXT" | grep -q "contributors = 2" || { echo "FAIL: scoped fold count missing"; exit 1; }
echo "=== koruc explain json (typed) ==="
JSON=$(koruc "$KORU_INPUT" explain json 2>&1)
echo "$JSON"
echo "$JSON" | grep -q '"contributors":2' || { echo "FAIL: scoped fold not typed"; exit 1; }
echo "$JSON" | grep -q '"value.effect":"refuse"' || { echo "FAIL: scoped effect missing"; exit 1; }
echo "=== PASS: scoped refine reports as its own facet ==="