✓
Passing This code compiles and runs correctly.
Code
// PINS: a `for ! each |> insert` on an INDEXED store takes the bulk append
// lowering AND keeps the index — the batch emits the bucket join inside its
// fill loop, so bulk-inserted rows are visible to `! first` and `! query`
// routing exactly as per-row inserts are. The `tags` half pins the
// multi-key shape: a boundary every row through three keys, then a second
// batch that must keep appending to the SAME buckets — the bucket memo and
// the just-left cache both have to stay honest.
import std/store
import std/indexes
import std/io
import std/control
std/store:new(players, capacity: 8) { key: i64, val: i64 }
std/indexes:store(players, key)
std/store:new(acc) { n: 0[i64] }
std/store:new(out) { v: 0[i64] }
std/store:watch(out)
! v x |> std/io:print.ln("{{ x:d }}")
for(0..4)
! each i |> std/store:insert(players) { key: 2, val: @as(i64, @intCast(i)) }
std/store:query(players)
! first p when p.key == 2 |> std/io:print.ln("first {{ p.val:d }}")
| none |> std/io:print.ln("lost")
std/store:query(players)
! query p when p.key == 2 |> std/store:stored { acc.n: acc.n + 1 }
std/store:stored { out.v: acc.n }
std/store:new(tags, capacity: 16) { grp: i32, val: i32 }
std/indexes:store(tags, grp)
// three keys cycling — every row is a boundary, and keys 1/2 arrive fresh
// mid-batch (the map's rehash path must not hand back a moved bucket)
for(0..10)
! each i |> std/store:insert(tags) { grp: @as(i32, @intCast(i % 3)), val: @as(i32, @intCast(i)) }
// two keys alternating into the SAME store — appends to live buckets
for(10..16)
! each i |> std/store:insert(tags) { grp: @as(i32, @intCast(i % 2)), val: @as(i32, @intCast(i)) }
std/store:query(tags)
! query t when t.grp == 0 |> std/io:print.ln("g0 {{ t.val:d }}")
std/store:query(tags)
! query t when t.grp == 1 |> std/io:print.ln("g1 {{ t.val:d }}")
std/store:query(tags)
! query t when t.grp == 2 |> std/io:print.ln("g2 {{ t.val:d }}")
Actual
first 0
4
g0 0
g0 3
g0 6
g0 9
g0 10
g0 12
g0 14
g1 1
g1 4
g1 7
g1 11
g1 13
g1 15
g2 2
g2 5
g2 8
Expected output
✓ Zig✓ JavaScriptfirst 0
4
g0 0
g0 3
g0 6
g0 9
g0 10
g0 12
g0 14
g1 1
g1 4
g1 7
g1 11
g1 13
g1 15
g2 2
g2 5
g2 8
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 ~new click a branch to expand · @labels scroll to their anchor
new (acc, source: n: 0[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (out, source: v: 0[i64])
flow ~watch click a branch to expand · @labels scroll to their anchor
watch (out)
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..4)
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 ~stored click a branch to expand · @labels scroll to their anchor
stored (source: out.v: acc.n)
flow ~new click a branch to expand · @labels scroll to their anchor
new (tags, capacity: 16, source: grp: i32, val: i32)
flow ~store click a branch to expand · @labels scroll to their anchor
store (expr: tags, grp, source: <implicit_source>)
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..10)
flow ~for click a branch to expand · @labels scroll to their anchor
for (10..16)
flow ~query click a branch to expand · @labels scroll to their anchor
query (tags)
flow ~query click a branch to expand · @labels scroll to their anchor
query (tags)
flow ~query click a branch to expand · @labels scroll to their anchor
query (tags)
Test Configuration
MUST_RUN LANGUAGES: zig js
Post-validation Script:
#!/bin/bash
# Emitted-code oracle: the `for ! each |> insert` on the indexed store
# must take the bulk lowering AND maintain the bucket map inside the fill
# loop — the failure mode being pinned is a batch that writes columns raw
# while leaving every row it added invisible to `__index_*`.
set -u
if [ ! -f output_emitted.zig ]; then
echo "FAIL: no output_emitted.zig"
exit 1
fi
if ! grep -q '__koru_bulk_frem' output_emitted.zig; then
echo "FAIL: bulk lowering did not fire on the indexed store"
exit 1
fi
if ! grep -q '__index_key: @import' output_emitted.zig; then
echo "FAIL: std/indexes:store(players, key) emitted no __index_key map"
exit 1
fi
if ! grep -q '__index_grp: @import' output_emitted.zig; then
echo "FAIL: std/indexes:store(tags, grp) emitted no __index_grp map"
exit 1
fi
if ! grep -q 'AutoHashMapUnmanaged(i32' output_emitted.zig; then
echo "FAIL: the tags bucket map did not take the column's i32 key type"
exit 1
fi
if ! grep -q '__index_key.getOrPut(koru_allocator(), __koru_ik)' output_emitted.zig; then
echo "FAIL: the bulk loop does not maintain the bucket"
exit 1
fi
if ! grep -q '__koru_bp\[__koru_bl\] = ' output_emitted.zig; then
echo "FAIL: the bulk loop lost the inline member store (register tail)"
exit 1
fi
if ! grep -q '__koru_op.items.len = __koru_bl' output_emitted.zig; then
echo "FAIL: the bucket-length commit on key switch is missing"
exit 1
fi
if ! grep -q '__koru_mp != null and __koru_mk == __koru_ik' output_emitted.zig; then
echo "FAIL: the just-left bucket cache is missing"
exit 1
fi
echo "PASS: indexed store bulk-lowers with per-row bucket maintenance — memo, just-left cache, register-tail store"
exit 0