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 is_completable(&self) -> bool
pub fn is_completable(&self) -> bool
Check if the graph is in a completable state.
Returns true when:
- At least one output has been declared
- No node definition is in progress
- We’re ready for another output (not mid-declaration)
This is useful for LLM decoding where we want to know if generation can stop, even though more outputs could be added.
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.