This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.
Supervisor
import std/supervisorKoru Standard Library: Supervision
supervisor.kz · 2 tors
Koru Standard Library: Supervision · 64 more lines
~part h koru_std/supervisor.h.kz
Koru Standard Library: the `h` part of supervisor.kz — the shared emission helpers. Joined via `~part h` in supervisor.kz; merged into the supervisor module at load. `std`/`ast` arrive at module scope from the other parts — a local import here would shadow them.
~part decl koru_std/supervisor.decl.kz
Koru Standard Library: the `decl` part of supervisor.kz — policy declaration parsing. Joined via `~part decl` in supervisor.kz; merged into the supervisor module at load. Declarations are DATA — they live in the supervised block, not in arm position (`| [key: value]` refuses pointing here). `within: N unit` is the wall-clock min-spacing throttle; `policy: Name` delegates the decision rules to a named same-module tor. `ticks` is pinned vocabulary awaiting its supplier — an enclosing signal model's steppable clock.
~part policy koru_std/supervisor.policy.kz
Koru Standard Library: the `policy` part of supervisor.kz — delegated policy resolution and emission. Joined via `~part policy` in supervisor.kz; merged into the supervisor module at load. `std`, `ast`, `errors`, and `H` arrive at module scope from the sibling parts. ---- `policy: Name` — delegated policy ------------------------------------ The block delegates the decision to a named same-module tor consuming the failure stream under the arm vocabulary — `{ f: <payload>, t: i64 }`, `f` optional, `t` required (the bound channel) — and producing the SAME vocabulary the arms spell: `| retry { <child input fields> }` re-enters with adapted args, `| exhausted` is terminal (payload → same-branch produce, bare → forward the last failure in kind). `within` composes — a declined retry fails the keep-alive contract and the pending failure proceeds upward.
~part fold koru_std/supervisor.fold.kz
Koru Standard Library: the `fold` part of supervisor.kz — the elaboration itself: the `supervised` transform decl+proc and the generated-AST constructors it builds the step tor and `#`/`@` fold from. Joined via `~part fold` in supervisor.kz; merged into the supervisor module at load. `std`/`ast`/`H`/`functional` arrive at module scope from the other parts — local imports here would shadow them.
~[keyword|comptime|transform] pub tor supervised {
source: Source,
invocation: *const Invocation,
item: std/compiler:*const Item,
program: std/compiler:*const Program,
reporter: std/compiler:*ErrorReporter,
allocator: std.mem.Allocator
} -> SiteResult~part home koru_std/supervisor.home.kz
Koru Standard Library: the `home` part of supervisor.kz — the home-branch lookup the fold runs when a site sits inside a module_decl. Joined via `~part home` in supervisor.kz; merged into the supervisor module at load. `H`, `std`, and `ast` arrive at module scope from the other parts. The enclosing tor's declared `| <site.branch>` for a site inside a module_decl — the same lookup the main body runs at program top level.
~part explain koru_std/supervisor.explain.kz
Koru Standard Library: the `explain` part of supervisor.kz — joined via `~part explain`; members land in koru_supervisor. `supervised` is the most elaborating surface in std: the arm you write retargets the call that produced its branch (retarget_producer), the outcome dispatch moves to a generated step tor, and every name inside a re-entry expression resolves in the STEP's scope — the attempt's inputs and the retry counter, not the caller's. The explainer lifts exactly that: per site it reports the producer, the child's declared vocabulary (a void branch stays void), the step tor and `#`/`@` fold the site becomes, the policy it read, and which names the re-entry expressions actually rebind. Then it shows the work: the program is cloned, the real transform pass runs over the clone, and the generated step decl + the retargeted home flow print through the canonical AST printer (src/ast_printer.zig). The elaborated view cannot drift from the transform — it IS the transform's output.
// @retain: explain_supervised_event is referenced from generated code
// (koruc's koru_explain_gather invokes every discovered [explainer]).
~[comptime|explainer] pub tor explain-supervised {
program: std/compiler:*const Program,
allocator: std.mem.Allocator
} -> ExplainReport