✓
Passing This code compiles and runs correctly.
Code
// Test: `koruc explain` on a packed store — std/store's explainer folds
// the sites (new's capacity and member block, insert/query/watch counts)
// and reports the composition alongside the facet-honesty row: `Limb`
// carries a refine facet on `health`, both members declare it, and
// `std/store:insert` enforces it — the catalog says so plainly.
// post.sh drives the text rows and the typed json catalog.
import std/io
import std/proto
import std/refine
import std/store
import std/explain
std/proto:i64(Health)
std/proto(Limb) {
health: Health
}
std/refine(Limb) {
health: Health & >0 & <=100
}
std/store:new(body, capacity: 8) { left: Limb, right: Limb }
std/store:insert(body) { left.health: 10, right.health: 20 }
std/store:query(body)
! query e |> std/io:print.ln("left {{ e.left.health:d }}")
Actual
left 10
Expected output
left 10
Flows
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Health)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Limb, source: health: Health)
flow ~std/refine click a branch to expand · @labels scroll to their anchor
std/refine (Limb, source: health: Health & >0 & <=100)
flow ~new click a branch to expand · @labels scroll to their anchor
new (body, capacity: 8, source: left: Limb, right: Limb)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (body, source: left.health: 10, right.health: 20)
flow ~query click a branch to expand · @labels scroll to their anchor
query (body)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# `koruc explain` gathers [explainer] reports: std/store reports the folded
# composition (capacity, members, interceptor arms, site counts) and the
# facet-honesty row — declared on the member proto, enforced at insert.
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 = 8" || { echo "FAIL: capacity missing"; exit 1; }
echo "$TEXT" | grep -q "columns = 2" || { echo "FAIL: member count missing"; exit 1; }
echo "$TEXT" | grep -q "left: Limb" || { echo "FAIL: member spelling missing"; exit 1; }
echo "$TEXT" | grep -q "inserts = 1" || { echo "FAIL: insert count missing"; exit 1; }
echo "$TEXT" | grep -q "queries = 1" || { echo "FAIL: query count missing"; exit 1; }
echo "$TEXT" | grep -q "facets_declared = 2" || { echo "FAIL: facet count missing"; exit 1; }
echo "$TEXT" | grep -q "insert enforces them" || { echo "FAIL: facet honesty missing"; exit 1; }
echo "=== witness hashes + at resolution ==="
echo "$TEXT" | grep -qE "inserts = 1 \[[0-9a-z]+\]" || { echo "FAIL: insert witness missing"; exit 1; }
HASH=$(echo "$TEXT" | grep -oE "inserts = 1 \[[0-9a-z]+\]" | grep -oE "\[[0-9a-z]+\]" | tr -d '[]')
AT=$(koruc "$KORU_INPUT" at "$HASH" 2>&1)
echo "$AT"
echo "$AT" | grep -q "std.store:insert" || { echo "FAIL: at missed the insert site"; exit 1; }
echo "$AT" | grep -q "input.k" || { echo "FAIL: at lost the file"; exit 1; }
koruc "$KORU_INPUT" at "${HASH}zz" 2>&1 | grep -q "tail drifted" || { echo "FAIL: drifted tail not absorbed"; exit 1; }
echo "=== koruc explain json (typed) ==="
JSON=$(koruc "$KORU_INPUT" explain json 2>&1)
echo "$JSON"
echo "$JSON" | grep -q '"capacity":8' || { echo "FAIL: capacity not typed"; exit 1; }
echo "$JSON" | grep -q '"columns":2' || { echo "FAIL: columns not typed"; exit 1; }
echo "$JSON" | grep -q '"inserts":1' || { echo "FAIL: inserts not typed"; exit 1; }
echo "$JSON" | grep -q '"facets_declared":2' || { echo "FAIL: facets not typed"; exit 1; }
echo "=== PASS: explain reports the store composition ==="