✓
Passing This code compiles and runs correctly.
Code
// `koruc at` reports the line the user wrote, for every site class:
// - a `|>`-chained site lands on the line its own `|>` stands on — the
// flattened chain below stamps the `|> query` link at its line, not the
// `| row` head's;
// - nested arm sites (`! first`, `| none`) land on their `|`/`!` line;
// - a flow's hash reports the flow head's own line.
// The bootstrap `import std/compiler` the frontend prepends is invisible:
// no reported line sits one past what the author wrote.
import std/io
import std/store
import std/indexes
import std/explain
std/store:new(players, capacity: 8) { key: i64, val: i64 }
std/indexes:store(players, key)
std/store:insert(players) { key: 10, val: 100 }
| row a |> std/store:insert(players) { key: 20, val: 200 }
| row b |> std/store:insert(players) { key: 30, val: 300 }
|> std/io:print.ln("seeded")
|> std/store:query(players)
! first p when p.key == 30 |> std/io:print.ln("nested {{ p.val:d }}")
| none |> std/io:print.ln("nested none")
// routed: the guard's equality is on the indexed column
std/store:query(players)
! first p when p.key == 30 |> std/io:print.ln("first {{ p.val:d }}")
| none |> std/io:print.ln("first none")
// sweep: visits every row
std/store:query(players)
! query q |> std/io:print.ln("row {{ q.key:d }}")
// scan: the predicate names a non-indexed column — same `! first`
// spelling, no index to route through
std/store:query(players)
! first p when p.val == 100 |> std/io:print.ln("scan {{ p.val:d }}")
| none |> std/io:print.ln("scan none")
// a [tree] store: its `parent` self-FK is synthesized by the annotation
// and invisible to the query surface — plans for it read the same column
// list the transform does
[tree]std/store:new(tree, capacity: 4) { val: i64 }
std/store:insert(tree) { val: 10 }
| row r |> std/store:insert(tree) { val: 20 }
|> std/store:query(tree)
! first n when n.val == 20 |> std/io:print.ln("tree nested {{ n.val:d }}")
| none |> std/io:print.ln("tree none")
std/store:query(tree)
! first n when n.val == 10 |> std/io:print.ln("root {{ n.val:d }}")
| none |> std/io:print.ln("no root")
Actual
seeded
nested 300
first 300
row 10
row 20
row 30
scan 100
tree nested 20
root 10
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (players, capacity: 8, source: key: i64, val: i64)
flow ~store click a branch to expand · @labels scroll to their anchor
store (expr: players, key, source: <implicit_source>)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (players, source: key: 10, val: 100)
flow ~query click a branch to expand · @labels scroll to their anchor
query (players)
flow ~query click a branch to expand · @labels scroll to their anchor
query (players)
flow ~query click a branch to expand · @labels scroll to their anchor
query (players)
flow ~new click a branch to expand · @labels scroll to their anchor
new (tree, capacity: 4, source: val: i64)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (tree, source: val: 10)
flow ~query click a branch to expand · @labels scroll to their anchor
query (tree)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# `koruc at` reports the line the user wrote, for every site class: a
# `|>`-chained site lands on the line its own `|>` stands on (not the chain
# head's), nested arm sites on their `|`/`!` line, and a flow's hash reports
# the flow head's own line. The bootstrap `import std/compiler` the frontend
# prepends is invisible in all of it. `--ast-json` emits the same
# user-coordinate lines for continuation locations.
set -e
echo "=== witness hash from explain ==="
TEXT=$(koruc "$KORU_INPUT" explain 2>&1)
QHASH=$(echo "$TEXT" | grep -oE "query\[0\] = ! first p — index lookup on key \[[0-9a-z]+\]" | grep -oE "\[[0-9a-z]+\]" | tail -1 | tr -d '[]')
[ -n "$QHASH" ] || { echo "FAIL: no query witness hash"; exit 1; }
echo "=== chained |> site reports its own link line ==="
QAT=$(koruc "$KORU_INPUT" at "$QHASH" 2>&1)
echo "$QAT"
echo "$QAT" | grep -q "std.store:query.*input.k:21" || { echo "FAIL: |> query link not reported on line 21"; exit 1; }
echo "$QAT" | grep -q "std.io:print.ln.*input.k:22" || { echo "FAIL: ! first arm not reported on line 22"; exit 1; }
echo "$QAT" | grep -q "std.io:print.ln.*input.k:23" || { echo "FAIL: | none arm not reported on line 23"; exit 1; }
echo "=== flow hash reports the flow head's own line ==="
FAT=$(koruc "$KORU_INPUT" at "${QHASH:0:6}" 2>&1)
echo "$FAT"
echo "$FAT" | grep -q "^ flow std.store:insert.*input.k:17" || { echo "FAIL: flow head not reported on line 17"; exit 1; }
echo "=== --ast-json continuation locations are user lines ==="
koruc "$KORU_INPUT" --ast-json 2>/dev/null | python3 -c '
import json, sys
d = json.load(sys.stdin)
found = []
def walk(o):
if isinstance(o, dict):
if o.get("type") == "flow":
for c in o.get("continuations", []):
found.append((c.get("branch"), c.get("location", {}).get("line")))
for v in o.values(): walk(v)
elif isinstance(o, list):
for v in o: walk(v)
walk(d["items"])
assert ("row", 18) in found, "arm continuation not on its own line: %r" % found
' || { echo "FAIL: ast-json continuation line not user coords"; exit 1; }
echo "=== PASS: at reports site lines ==="