✓
Passing This code compiles and runs correctly.
Code
// PINS: `[id]` across a MODULE BOUNDARY, with a lexical capture — the exact
// combination the single-file `[id]` tests cannot reach.
//
// `[id]`'s synthesized value names the store's SoA cell, and the cell is
// declared in the store's OWN module. Every other reference the sweep loop
// emits carries a qualifier for that module; `[id]`'s did not, because the twin
// it was modelled on (`[ordinal]`) names no store and was safe by accident.
//
// THE COMBINATION IS THE BUG, and neither half reaches it alone:
// - `[id]` in the entry file -> the loop is LIFTED into a
// `__store_sweeprun_*` event placed in the store's own module, so a bare
// `__koru_store_<s>` resolves by coincidence of placement (690_246);
// - a capturing cross-module sweep with no `[id]` -> no store name is emitted
// into the caller's namespace at all (115_043).
//
// A LEXICAL capture is what forces the loop to stay INLINE at the sweep site,
// which is the caller's namespace. `[id]` does not do that on its own: its
// value is computed from the cursor inside the loop, so it is deliberately not
// counted as lexical. `tick(): k` supplies the lexical half, and only then does
// the unqualified cell reference land somewhere it is not declared.
//
// Caught by review, not by the board: every request-annotation test in the tree
// is a single-file entry-module program, where the qualifier is `main_module.`
// and a bare name resolves anyway.
//
// The oracle carries both halves. `k` = 2 scales 10/20/30 to 20/40/60, proving
// the lexical capture arrived; the chain head is the LAST row visited, so
// reading it back through its handle yields 60, proving `[id]` named a row that
// can actually be addressed.
import std/io
import std/store
import app/lib/world
import app/lib/systems
app/lib/world:seed()
app/lib/systems:scale-and-link()
app/lib/world:peek()
Supporting Files
// A system in a DIFFERENT module than the store: it captures a value per row
// (`k`, lexical) AND asks for the visited row's handle (`[id]`, synthesized).
import std/store
pub tor tick {} -> i64
tick -> 2
pub tor scale-and-link {}
scale-and-link = tick(): k |> std/store:query(cells)
! query { [row]e, [id]h } |> std/store:stored { e.v: e.v * k }
|> std/store:stored { e.next: head.h }
|> std/store:stored { head.h: h }
// Components: the store is declared HERE, in its own module.
import std/io
import std/store
std/store:new(cells, capacity: 8) { v: i64, next: -1[i64] }
std/store:new(head) { h: -1[i64] }
std/store:new(probe) { v1: 0[i64] }
pub tor seed {}
seed = std/store:insert(cells) { v: 10, next: -1 }
| row _ |> std/store:insert(cells) { v: 20, next: -1 }
| row _ |> std/store:insert(cells) { v: 30, next: -1 }
| row _ |> _
| full |> _
| full |> _
| full |> _
// Read the chain head back through its handle and report. Same module as the
// store, so this half is not what the test is probing.
pub tor peek {}
// The read goes through a cell rather than straight into the interpolation:
// print.ln does not run the indexed-read lowering, which is its own gap.
peek = std/store:stored { probe.v1: cells[head.h].v }
|> std/io:print.ln("head v {{ probe.v1:d }}")
Actual
head v 60
Expected output
head v 60
Flows
flow ~seed click a branch to expand · @labels scroll to their anchor
seed
flow ~scale-and-link click a branch to expand · @labels scroll to their anchor
scale-and-link
flow ~peek click a branch to expand · @labels scroll to their anchor
peek
Test Configuration
MUST_RUN