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

Trellis

~import std/trellis

Koru Standard Library: Trellis — AST-shape sessions as regex-over-paths.

trellis.kz · 3 tors · ~[comptime]

Koru Standard Library: Trellis — AST-shape sessions as regex-over-paths. · 47 more lines
Koru Standard Library: Trellis — AST-shape sessions as regex-over-paths. A trellis DESCRIBES VALID SHAPES OF THE AST. Its arms are regex patterns (the branch name IS the pattern, byte-for-byte — the std/regex:match surface) over SERIALIZED ANCESTRY PATHS of the program's flow trees, with branch-constructor verdicts: std/trellis:define("kernel-shape") | `std/kernel:init/kernel/.*` => ok | `.*std/kernel:pairwise` => error "std/kernel:pairwise found outside std/kernel:init" | `.*std/kernel:self` => error "std/kernel:self found outside std/kernel:init" PATH ALPHABET: every invocation in every flow yields one path — event names (module qualifier slash-rendered, segments dot-joined) and branch labels as `/`-separated segments, root-to-node. Bindings and args are excluded: patterns describe SHAPE, not data. Example: std/kernel:init/kernel/std/kernel:self Each path is matched against the arms IN ORDER, first match wins (regex dispatch semantics, FULL match — the whole path must match). An `ok` arm accepts the path; an `error` arm rejects it, and its payload is the user message. Paths matching no arm are unconstrained (placement-constraint semantics; closedness is spelled with a catch-all error arm). std/trellis:enforce("kernel-shape") — program-wide LAW: a violation halts compilation at Stage C with a located koru-level diagnostic: Check "kernel-shape" failed: <message> at file:line:col (Immediate halt, not @compileError injection: a later transform must never get the chance to trip over the malformed tree and bury the real message under a panic.) std/trellis:check("kernel-shape") — CATEGORIZATION: the verdict | ok |> ... arrives as ordinary branch | error msg |> ... dispatch, resolved at comptime; the losing branch is dead code. The check dissolves at Stage C — zero runtime cost. Matching runs the regex engine (src/regex_engine.zig) directly on path strings inside the transform: linear-time, no backtracking, ReDoS-immune. This generalizes kernel.kz's hand-rolled validateKernelSubtree denylist into declarative allowlists, and is the categorization substrate for variant capability-float (gpu-legal, simd-fusable, ...). Pinned: 680_001 (enforce, conforming), 680_002 (violation message shape), 680_003 (check-as-dispatch).

enforce

comptimetransform koru_std/trellis.kz:68

check

comptimetransform koru_std/trellis.kz:238