✓
Passing This code compiles and runs correctly.
Code
// Ruling 5: stores emit inserted/removed/updated, and everything reactive
// compiles down into these same interceptor branches. Here the store's own
// contract maintains COUNT(*) in a second (singleton) store: `inserted`
// bumps it, `removed` decrements it. The lifecycle branches fire from the
// insert and take write paths — the qbody transplant pattern.
//
// The bodies don't read the row, so the payload is DISCARDED (`_`) — the same
// KORU100 discipline as any binding; naming a field you never use is rejected
// (690_032). Consuming the field is 690_033.
//
// Bare take (no `[entity]`) is frictionless: swap-remove, no obligation.
import std/io
import std/store
std/store:new(stats) { count: 0[i64] }
std/store:new(pool, capacity: 64) { hp: i64 }
! inserted _ |> std/store:stored { stats.count: stats.count + 1 }
! removed _ |> std/store:stored { stats.count: stats.count - 1 }
std/store:watch(stats)
! count c |> std/io:print.ln("count {{ c:d }}")
std/store:insert(pool) { hp: 1 }
| row a |> std/store:insert(pool) { hp: 2 }
| row b |> std/store:take(pool[b])
| item _ |> _
Actual
count 1
count 2
count 1
Expected output
count 1
count 2
count 1
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: stats, source: count: 0[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: pool, capacity: 64, source: hp: i64)
flow ~watch click a branch to expand · @labels scroll to their anchor
watch (expr: stats)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (expr: pool, source: hp: 1)
Test Configuration
MUST_RUN