pub struct Builder { /* private fields */ }Expand description
Deterministic state machine for graph construction.
The builder enforces all structural constraints:
- No duplicate ID definitions
- No forward references (DAG property)
- Resource limits (max nodes, depth, inputs, outputs)
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn with_limits(limits: Limits) -> Self
pub fn with_limits(limits: Limits) -> Self
Create a new builder with custom limits.
Sourcepub fn push(&mut self, token: Token) -> Result<(), BuildError>
pub fn push(&mut self, token: Token) -> Result<(), BuildError>
Feed a single token to the builder.
Sourcepub fn finish(self) -> Result<Graph, BuildError>
pub fn finish(self) -> Result<Graph, BuildError>
Finalize and return the graph.
§Errors
Returns an error if:
- A node definition is incomplete
- No outputs have been declared
Sourcepub fn valid_next_tokens(&self) -> Vec<Token>
pub fn valid_next_tokens(&self) -> Vec<Token>
Returns the set of valid next tokens for LLM logit masking.
This is the critical interface for constraining LLM output. By masking all logits except those corresponding to valid tokens, the LLM is guaranteed to produce a syntactically correct circuit.