This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.
Pump
import std/pumpKoru Standard Library: Pump — compile-time composition of participants.
pump.kz · 4 tors
Koru Standard Library: Pump — compile-time composition of participants. · 37 more lines
~[
- keyword
- comptime
- transform
- aspirational open-pump-marker-wire
Comment-wire markers restated per participant transform; the typed
program-item migration is resolved — concepts/frag-comment-markers-are-the-inter-transform-wire.
]pub tor create {
expr: Expression,
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
reporter: std/compiler:*ErrorReporter,
allocator: std.mem.Allocator
} -> SiteResult// PUMP.DEFAULT — the bare `std/pump(name)` reference form: a participant JOIN.
//
// std/pump(main)
// ! step |> <call> — required, `-> i32` progress count
// ! live |> <call> — optional, `-> i64` live-instance count
// ! wait i |> <call(i)> — optional, interest by return type:
// `i32` (fd) / `i128` (re-poll ns) / `{ fd, wait_ns }`
//
// Each arm compiles into `__pump_<name>_{step,live,wait}_<idx>`; run
// enumerates them. The verbs are ordinary calls — the pump never learns what
// implements them.
~[keyword|comptime|transform] pub tor default {
expr: Expression,
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
reporter: std/compiler:*ErrorReporter,
allocator: std.mem.Allocator
} -> SiteResult~part explain koru_std/pump.explain.kz
Koru Standard Library: the `explain` part of pump — joined via `~part explain` in pump.kz; members land in koru_pump. The pump is the most distributed surface in the stdlib: participants join from anywhere via `std/pump(name) ! step |> ...` and `run` enumerates them by generated-decl name. Nothing in any single file answers "who joined, which verbs each answers, does this pump ever drain" — the explainer folds the source sites in document order with the SAME checks the create/join/run transforms apply; a program that refuses still explains itself, each refusal verbatim via the shared `PM` messages. Callee spellings come from PH.lastInvocation — the same read the join transform uses — and `PS.synthesized` names callees the store transform will generate.
// @retain: explain_pump_event is referenced from generated code
// (koruc's koru_explain_gather invokes every discovered [explainer]).
~[comptime|explainer] pub tor explain-pump {
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> ExplainReport~part messages koru_std/pump.messages.kz
Koru Standard Library: the `messages` part of pump — joined via `~part messages` in pump.kz; members land in koru_pump. Every refusal text the three pump transforms can raise, named once. The transforms pass these to `ast.refusal` (they carry the KORU161 format args); the explainer formats the SAME consts for its `status` rows — so what `koruc explain` reports for a refusing program is the diagnostic verbatim, and the two can never drift on wording.
~part run-msgs koru_std/pump.run-msgs.kz
Koru Standard Library: the `run-msgs` part of pump — joined via `~part run-msgs` in pump.kz; members land in koru_pump. The `run` transform's refusal texts — split off `pump.messages.kz` when the retire contract outgrew that file's pin. Same rule applies: the explainer formats these verbatim, so wording lives here once.
~part synth koru_std/pump.synth.kz
Koru Standard Library: the `synth` part of pump — joined via `~part synth` in pump.kz; members land in koru_pump. A join arm's callee isn't always a declared tor: a store's `! step` / `! wait` arms SYNTHESIZE `<s>-step` / `<s>-live` / `<s>-wait` units at transform time, so nothing named `tasks-step` exists in the pre-transform tree the explainer folds. `synthesized` recognizes `<store>-<verb>` against a `std/store:new` site carrying the arm that generates it — reported as generated (with the generator site as `gen` witness), never refused.
~part wit koru_std/pump.wit.kz
Koru Standard Library: the `wit` part of pump — joined via `~part wit` in pump.kz; members land in koru_pump. Witness emission for join verb rows: each row's `at` carries the arm's call-site hash, plus the `std/store:new` generator site when the callee is synthesized — so a pump row resolves back through the door that minted it.
~part wait koru_std/pump.wait.kz
Koru Standard Library: the `wait` part of pump — joined via `~part wait` in pump.kz; members land in koru_pump. The `! wait` interest contract. A participant's wait callee declares its blocking interest BY RETURN TYPE: `-> i32` is a descriptor to poll, `-> i128` a relative re-poll duration in ns, `-> { fd: i32, wait_ns: i128 }` both at once. Field PRESENCE is the vocabulary — a participant never writes sentinels. The generated wait units normalize to `{ fd, wait_ns }` with internal sentinels (-1 / maxInt) for whichever interest the callee didn't declare, so the union poll loop reads one shape.
~part run koru_std/pump.run.kz
Koru Standard Library: the `run` part of pump — joined via `~part run` in pump.kz; members land in koru_pump. PUMP.RUN — drive a declared pump until every participant drains. std/pump:run(main) ! idle |> ... Enumerates the joined `__pump_<name>_step_<i>` units and emits `__pump_run_<name>`: while any participant's `live` counts rows, step each in join order. A pass with zero progress fires `! idle` — armed, the arm runs in the loop; unarmed, the union wait collects every `wait` unit's interests and polls once, or breathes 1ms when nothing was declared. Retirement: a participant may emit `__pump_<name>_retired_<i>` — fired by the driver exactly once, on the first pass whose `live` answers 0, ahead of `| drained`. This is where a captured participant's run-terminal arms (`| stopped`, `| done`) land. It requires `live` — an immortal participant never retires.
// Koru Standard Library: the `run` part of pump — joined via
// `~part run` in pump.kz; members land in koru_pump.
//
// PUMP.RUN — drive a declared pump until every participant drains.
//
// std/pump:run(main)
// ! idle |> ...
//
// Enumerates the joined `__pump_<name>_step_<i>` units and emits
// `__pump_run_<name>`: while any participant's `live` counts rows, step each
// in join order. A pass with zero progress fires `! idle` — armed, the arm
// runs in the loop; unarmed, the union wait collects every `wait` unit's
// interests and polls once, or breathes 1ms when nothing was declared.
//
// Retirement: a participant may emit `__pump_<name>_retired_<i>` — fired by
// the driver exactly once, on the first pass whose `live` answers 0, ahead
// of `| drained`. This is where a captured participant's run-terminal arms
// (`| stopped`, `| done`) land. It requires `live` — an immortal participant
// never retires.
~[keyword|comptime|transform] pub tor run {
expr: Expression,
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
reporter: std/compiler:*ErrorReporter,
allocator: std.mem.Allocator
} -> SiteResult