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

Cell

import std/cell

Koru Standard Library: cell — a shape-bound session.

cell.kz · 9 tors

Koru Standard Library: cell — a shape-bound session. · 20 more lines
Koru Standard Library: cell — a shape-bound session. std/proto(room_state) { visits: u32 } std/cell:open(room_state, id: "assistant", scope: "cell", world: "cells") | cell c |> std/cell:run(c, source: "...") | result r |> ... ... |> std/cell:hibernate(c) `open` is the standalone custodian path — the caller takes the `cell!` obligation into the arm and is answerable for `hibernate`. `std/node` is the shared custodian: `spawn` mints the same session and keeps it in the residency index instead. Cell-ness is shape + scope + world; custody is whoever holds the obligation, and the cell code cannot tell the difference. The shape is a comptime name: `open`'s transform resolves `room_state` against the program's `std/proto(...)` declarations — an unknown shape is a refusal, not a runtime miss. Materializers (a `[SQLite]`-style field backend) consume the declared shape later; nothing here bakes a storage model in.

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.

Cell 1 state cell!

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

cell-open

<cell!> koru_std/cell.kz:184

fields

<cell> koru_std/cell.kz:310

hibernate

<!cell> koru_std/cell.kz:322

capture

keywordcomptimetransformpre koru_std/cell.kz:347

open

keywordcomptimetransformpre koru_std/cell.kz:769

~part run koru_std/cell.run.kz

Koru Standard Library: the `run` part of cell — turn dispatch and the two-tier error surface. Joined via `~part run` in cell.kz; merged into the cell module at load. The canonical failure union — owned by `std/bridge`, which produces it; cell re-exports so `run`'s `| error` arm and `error-decode` share the type with the seam underneath.

~part fleet koru_std/cell.fleet.kz

Koru Standard Library: the `fleet` part of cell — the ownership stamp, the fenced write seam, and the dead-strip retain splice. Joined via `~part fleet` in cell.kz; merged into the cell module at load. The node's ownership stamp: when a node claims an id on the shared floor it marks the cell with (world, id, node, granted-epoch, lease TTL + cached deadline) — what `cellFlush` presents to the fence and the due-check the resident-hit renewal reads without touching the floor. Zero/empty is "unstamped": standalone `cell:open` cells and worldless nodes carry no claim and write unfenced.

~part retain koru_std/cell.retain.kz

Koru Standard Library: the `retain` part of cell — the dead-strip splice for fleet's tors. Joined via `~part retain` in cell.kz; merged into the cell module at load. `cellFlush` calls `Fl.fleetGuard`/`Fl.fleetRenewDue` from HOST code — nothing in a cell-only program spells `std/fleet:*`, so dead-strip would retire the tors and `koru_fleet` would never emit. The `open` transform in cell.kz calls this for every open. Duplicated in `node.new.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.