SKILL.md
Workflow Validation
Layered across a 5-stage compilation pipeline. See /workflow-compiler skill for full architecture.
Compilation Pipeline
- Parse (
compiler/parse.py) — JSON →WorkflowSpec; raisesValidationPhaseError - Type Environment (
compiler/type_env.py) — builds type env; raisesTypeEnvironmentError - Validate References (
compiler/validate_refs.py) — checks${...}expressions; raisesValidationPhaseError - Lower (
compiler/lowercontrolflow.py) — execution plan; raisesLoweringError - Emit (
compiler/emit_langgraph.py) — LangGraphStateGraph
Runtime: inputvalidation.py coerces inputs · validateoutput.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). AppliesInputDefdefaults. Preserves undeclared inputs. - Reference validation (
validaterefs.py) — resolves${...}order: locals → state →inputs→ config. Loop vars (itemvar,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/jsonschemaadapter.py) — Draft 2020-12.getvalidator(),validateinstance(),dereferenceschema(),formatvalidationerror(). - Output validation (
validate_output.py) — post tool/LLM whenOutputContractmode=json. RaisesExecutionError.
When Adding a New Block Type
- Extend
Nodeinschema/models.py, add toNodeunion - Add
${...}reference validation invalidate_refs.py - Add input coercion in
input_validation.pyif needed - Write tests: valid config, invalid inputs, edge cases
Quick Checklist
- Required fields present; input types match
InputDef - All
${...}references resolve; output contracts have schemas when mode=json - Nested blocks valid; loop vars scoped; tests cover success + error cases