Workflow Validation
Layered across a 5-stage compilation pipeline. See /workflow-compiler skill for full architecture.
Compilation Pipeline
- Parse (
compiler/parse.py) β JSON β WorkflowSpec; raises ValidationPhaseError
- Type Environment (
compiler/type_env.py) β builds type env; raises TypeEnvironmentError
- Validate References (
compiler/validate_refs.py) β checks ${...} expressions; raises ValidationPhaseError
- Lower (
compiler/lower_control_flow.py) β execution plan; raises LoweringError
- Emit (
compiler/emit_langgraph.py) β LangGraph StateGraph
Runtime: input_validation.py coerces inputs Β· validate_output.py checks node outputs against OutputContract
Error Hierarchy
WorkflowCompilerError β ValidationPhaseError Β· TypeEnvironmentError Β· LoweringError Β· ExecutionError β EvaluationError
Key Validation Components
- Input coercion (
input_validation.py) β lenient (stringβnumberβbool, JSON strings β object/array). Applies InputDef defaults. Preserves undeclared inputs.
- Reference validation (
validate_refs.py) β resolves ${...} order: locals β state β inputs β config. Loop vars (item_var, index_var) scoped to body.
- Expression evaluation (
expr/evaluator.py) β runtime ${node.field}, ${array[0]}, nested. Context: state, inputs, locals, config.
- Schema models (
schema/models.py) β StrictModel (extra="forbid"). Key types: WorkflowSpec, Node, InputDef, OutputContract, SchemaRef, InlineSchema.
- JSON Schema utils (
schema/jsonschema_adapter.py) β Draft 2020-12. get_validator(), validate_instance(), dereference_schema(), format_validation_error().
- Output validation (
validate_output.py) β post tool/LLM when OutputContract mode=json. Raises ExecutionError.
When Adding a New Block Type
- Extend
Node in schema/models.py, add to Node union
- Add
${...} reference validation in validate_refs.py
- Add input coercion in
input_validation.py if needed
- Write tests: valid config, invalid inputs, edge cases
Quick Checklist