This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.

Node

import std/node

Koru Standard Library: node — a named, custody-owning index of cells.

node.kz · 12 tors

Koru Standard Library: node — a named, custody-owning index of cells. · 37 more lines
Koru Standard Library: node — a named, custody-owning index of cells. std/node:new(main, scope: "cell", world: "cells", capacity: 256) std/node(main) // borrow the node | node f |> std/node:spawn(f, id: "room-42", cell: room_state) | spawned b |> ... | resident |> ... | refused |> ... std/node(main.room-42) // borrow a member, static name | cell c |> std/cell:run(c, src) | not-found |> ... std/node(main[id]) // borrow a member, runtime key | cell c |> ... | not-found |> ... A node is residency + custody: it owns every `*Cell<cell!>` it mints (`spawn` wraps `std/cell`'s cell-create, `evict` its destroy), so the cell obligation never leaves the index — a member cannot be dropped, only evicted through the discharge path. `| node f |` and `| cell c |` are BORROWS: enough to run, define, and inspect; never enough to mint or hang up. That is the whole shape of the surface — one transform reading the target's form, ordinary borrow-gated tors for everything else. `new` mints the NAME, not the contents — membership is runtime data, the way a store's name is comptime while its rows are not. The registry maps the declared name to a `*Node`; `default`'s rewrite bakes the name into a `node-self`/`member-named` call, so a lookup with no `std/node:new` is a comptime refusal, not a runtime miss. Naming, celld-aligned: a NODE is one process's residency index — residency, custody, and a durable floor under `world`. `fleet` is RESERVED for the cross-machine layer: the nodes that share one `world`, with ownership CAS, epoch fencing, and peer routing. That layer does not exist yet; nothing in this file claims it.

Phantom lifecycles

Derived from the phantom labels in the declarations below — state! issues an obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.

Node carries the label <node> with no obligation attached — a dimension, not a lifecycle.

Cell carries the label <cell> with no obligation attached — a dimension, not a lifecycle.

node-self

<node> koru_std/node.kz:90

member

<node><cell> koru_std/node.kz:105

member-named

<cell> koru_std/node.kz:118

cell-spawn

<node><cell> koru_std/node.kz:138

spawn

keywordcomptimetransformpre koru_std/node.kz:356

default

keywordcomptimetransformpre koru_std/node.kz:442

~part fleetretain koru_std/node.fleetretain.kz

Koru Standard Library: the `fleetretain` part of node — the fleet-event retention splice `node:new` needs. Joined via `~part fleetretain` in node.kz; merged into the node module at load. The fleet tors are called from HOST code — nothing in the program spells `std/fleet:claim`, so dead-strip retires the tors and `koru_fleet` would never emit. This splice is duplicated in `cell.retain.kz` ON PURPOSE: the transform's emitted handler runs inside the backend compiler, so its body must not reference `koru_fleet` — the module exists in that emit only because the retain already ran. Sharing this helper creates a bootstrap cycle.

~part new koru_std/node.new.kz

Koru Standard Library: the `new` part of node — the declaration machinery. `std/node:new` is comptime-only: it validates the name and options, retains the host-called surfaces, and rewrites to a `node-init` turn so the registry is populated at the point the declaration sat in source. Joined via `~part new` in node.kz. NODE-INIT — what `std/node:new` rewrites to. Void: the declaration is a statement, not a turn.

new

keywordcomptimetransform koru_std/node.new.kz:39

~part world koru_std/node.world.kz

Koru Standard Library: the `world` part of node — the shared-floor ownership boundary. Activation claims on the durable floor, retire is fenced by the record, and the `new` transform retains fleet's surface against dead-strip. Joined via `~part world` in node.kz; merged into the node module at load.