Experimental Livebook-friendly DSL for sketching decision trees.
This Lab DSL compiles to the stable, pipe-first Choreo.DecisionTree builders
and returns an ordinary %Choreo.DecisionTree{}. It is useful for interview
decision policies, routing rules, fallback strategies, and tradeoff walkthroughs.
Examples
iex> import Choreo.Lab.DSL.DecisionTree
...> tree = decision_tree do
...> traffic = root("Traffic Source", feature: "source")
...> authenticated = decision("Authenticated?", feature: "auth")
...> reject = outcome("Reject", class: "403")
...> route = outcome("Route Request", class: "route")
...>
...> traffic ~> authenticated |> when_("api")
...> edge authenticated ~> reject, "no"
...> branch authenticated ~> route, "yes"
...> end
iex> Choreo.DecisionTree.root(tree)
:traffic
iex> Choreo.DecisionTree.condition(tree, :authenticated, :route)
"yes"Branch conditions can use pipe modifiers or explicit branch forms:
root ~> decision |> when_("api")
decision ~> outcome |> condition("yes")
edge decision ~> outcome, "yes"
branch decision ~> outcome, "yes"
Summary
Functions
Builds a %Choreo.DecisionTree{} from a compact Lab DSL block.
Returns the vocabulary supported by the decision-tree DSL.
Compatibility alias for taxonomy/0.
Types
@type branch_decl() :: %{ from: Yog.node_id(), to: Yog.node_id(), condition: String.t() }
@type node_decl() :: %{id: Yog.node_id(), builder: atom(), opts: keyword()}
Functions
Builds a %Choreo.DecisionTree{} from a compact Lab DSL block.
Returns the vocabulary supported by the decision-tree DSL.
iex> taxonomy = Choreo.Lab.DSL.DecisionTree.taxonomy()
iex> :root in taxonomy.nodes
true
iex> :branch in taxonomy.edges
true
iex> :when_ in taxonomy.modifiers
true
@spec verbs() :: map()
Compatibility alias for taxonomy/0.