✓
Passing This code compiles and runs correctly.
Code
// Test: `koruc explain` on a refined proto — std/refine's explainer folds
// contributor blocks through the same meet machinery the transform runs
// (declared base, resolved terminal scalar, per-field effect); std/list's
// explainer reports what push enforces on the element's facet. post.sh
// drives both formats.
import std/proto
import std/refine
import std/list
import std/io
import std/explain
std/proto:i64(Port)
std/proto(Server) {
port: Port,
gain: i64,
host: string
}
std/refine(Server) {
port: Port & >1024 & <=65535
gain: i64 & clamp(0, 100)
host: string
}
std/list:new(Server)
| list xs |> std/list:push(xs, port: 8080, gain: 42, host: "web-01")
| ok |> std/list:len(xs): n |> std/io:print.ln("len={{ n:d }}") |> std/list:free(xs)
| violated f |> std/io:print.ln("refused")
| err e |> std/io:print.ln("ERR")
Actual
len=1
Expected output
len=1
Flows
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Port)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Server, source: port: Port,
gain: i64,
host: string)
flow ~std/refine click a branch to expand · @labels scroll to their anchor
std/refine (Server, source: port: Port & >1024 & <=65535
gain: i64 & clamp(0, 100)
host: string)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Server)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# `koruc explain` gathers [explainer] reports: std/refine reports the met
# facet (declared base, resolved terminal scalar, effect), std/list
# reports what push enforces on it. Asserted in text rows and the typed
# json catalog — integers stay integers, strings stay quoted.
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:Server" || { echo "FAIL: section heading missing"; exit 1; }
echo "$TEXT" | grep -q "contributors = 1" || { echo "FAIL: contributor count missing"; exit 1; }
echo "$TEXT" | grep -q "port.scalar = i64" || { echo "FAIL: terminal resolution missing"; exit 1; }
echo "$TEXT" | grep -q "port.effect = refuse" || { echo "FAIL: bound effect missing"; exit 1; }
echo "$TEXT" | grep -q "gain.effect = saturate" || { echo "FAIL: clamp effect missing"; exit 1; }
echo "$TEXT" | grep -q "host.effect = declared only" || { echo "FAIL: plain field effect missing"; exit 1; }
echo "$TEXT" | grep -q "📖 std/list" || { echo "FAIL: list report missing"; exit 1; }
echo "$TEXT" | grep -q "facets_enforced = 2" || { echo "FAIL: enforcement count missing"; exit 1; }
echo "=== koruc explain json (typed) ==="
JSON=$(koruc "$KORU_INPUT" explain json 2>&1)
echo "$JSON"
echo "$JSON" | grep -q '"contributors":1' || { echo "FAIL: contributor count not typed"; exit 1; }
echo "$JSON" | grep -q '"port.scalar":"i64"' || { echo "FAIL: resolved scalar missing"; exit 1; }
echo "$JSON" | grep -q '"port.effect":"refuse"' || { echo "FAIL: refuse effect missing"; exit 1; }
echo "$JSON" | grep -q '"gain.effect":"saturate"' || { echo "FAIL: saturate effect missing"; exit 1; }
echo "$JSON" | grep -q '"facets_enforced":2' || { echo "FAIL: enforcement not typed"; exit 1; }
echo "=== PASS: explain reports declared + enforced facets ==="