🧩 Core Components
This page is the validated reference for the public API surface. For
step-by-step recipes see the use cases index. For exact signatures
and docstrings, see the library reference (docs/lib) or the MCP bundle
(docs/mcp).
⚡ Execution Core
Node
Base class for all execution nodes. It is an abstract base class: subclasses
implement resolve() and declare an id (dotted snake_case).
Key facts:
- Singleton per subclass — stateless subclasses share one instance.
A() is A()isTrue. Subclasses that declare a custom__init__get one instance per construction (use this to inject per-run dependencies). fork()— convenience wrapper aroundState.fork()that records the node ID into state history.resolve()must yieldState— anything else raisesTypeError.node_id_to_name(node_id)— convertsentity.resolve.numeric_merchantintoEntity › Resolve › Numeric Merchant.name— auto-derived from the ID unless set explicitly.
AsyncNode
Base class for asynchronous nodes. Subclasses implement resolve_async() (an
async generator yielding State objects). See
use case 06.
A sync engine that hits an
AsyncNodetreats it as a no-op (yields no states). UseEngine.run_asyncwhen the graph containsAsyncNodes.
Graph
DAG topology container. Stores connectivity only — it never executes nodes.
- Cycle detection is automatic: adding an edge that would create a cycle raises
ValueError(self-edges too). - Nodes are registered implicitly by
add_edge/add_root. - The graph is mutable during construction but treated as immutable at runtime.
Engine
Orchestrator that runs a linear Sequence[Node] or a Graph.
- Linear mode — each node feeds every downstream state it receives, in order.
- Graph mode — BFS traversal from all roots; states fan out along edges and are collected as terminal states at nodes with no children.
- Also exposes
run_steps/run_steps_asyncand anodesproperty. - Never mutates
State,Node, orGraphinstances.
🧊 State & Data
State
Immutable execution snapshot at one point in traversal. Subclass and bind a
schema:
- Validates its
payloadagainstschemaat construction (SchemaErroron violation). fork()is the only supported mechanism for producing a new state. UseState.forkdirectly, or theNode.forkconvenience wrapper.- Tracks
confidence,parent,depth, andhistory(ordered node-ID lineage) for observability. lineage()— root-to-this ordered tuple.get(key)/has(key)read dot-paths from the underlyingPayload.
Payload
Immutable hierarchical container with dot-path access.
- Updates are atomic and cheap — only modified branches are copied.
Schema
Immutable hierarchical validation tree. Leaf nodes are types or PEP-604 unions;
nested Schema instances describe nested structure.
validate_payload— full structure check.validate_update— path existence check forfork()updates.
SchemaError
Raised when payload data violates the declared schema: invalid structure, undefined path, or invalid type. See Error Handling.
📜 Declarative Pipelines
Pipeline
Dataclass wrapping engine, state_cls, and initial_payload. Executes with
run(payload_override=None) and returns terminal states.
load_pipeline(path)
Factory that builds a Pipeline from one YAML file:
See use case 03 for the full walkthrough.
🔁 Progress Types
StepResult—(index, node_id, states, completed)for one executed step.ProgressMessage— keyword-only, optional fields (lines,blocks,count,unit,raw_ocr_line,error,step,status) plusas_dict(). Passed to step hooks for progress reporting.
Both are produced by Engine.run_steps / run_steps_async — see
use case 07.