Skip to content
docsv0.17.1

Route

A conditional edge, named by the enum case that chooses it. This is the whole idea of this SDK in one attribute: **an edge is an edge whether a model or a human chose it.** `Route(when: Verdict::Failed, …)` is what a grader's structured output picks; `Route(when: EditorCall::OneMoreRound, …)` is what a person picks at a gate. Same syntax, and the only difference is who produced the enum value and what authority that spent. The origin is DERIVED: exactly one node returns a `Verdict`, so `from:` is only written when two nodes return the same enum and the answer is genuinely ambiguous. `atMost` is the loop budget, and it is what makes a cycle legal. The engine refuses a cycle of ungated transitions because such a cycle has no escape; a declared budget IS an escape, and when it runs out `thenAsk` hands the decision to a human instead of simply stopping — which is the difference between a graph library and a governed one.

Route::__construct()

public function __construct(UnitEnum $when, string $to, ?string $from = null, ?int $atMost = null, ?string $thenAsk = null):

Parameters

Parameters of __construct()
NameTypeDescription
$when\UnitEnumThe case that takes this edge; its enum is the node's return contract.
$toclass-stringThe node this edge leads to.
$from(class-string | null)Only when two nodes return the same enum.
$atMost(int | null)How many times this edge may be taken before the budget is spent.
$thenAsk(class-string | null)The options enum offered to a human once the budget is spent.