Validation
Validation ensures workflow integrity before execution by detecting cycles, verifying dependencies, and checking configuration.Core Concept
The validation system performs comprehensive pre-execution checks to catch errors early:Quick Validation
validate_sequence()
Validate a workflow with default validators:raise_if_invalid()
Automatically raise exception on validation failure:Validation Result
ValidationResult Structure
get_summary()
Get formatted validation report:Built-in Validators
CycleDetectionValidator
Detects circular dependencies in workflow graphs:- Uses DFS (Depth-First Search) with color coding (WHITE, GRAY, BLACK)
- WHITE: Unvisited nodes
- GRAY: Currently being explored (in recursion stack)
- BLACK: Fully explored
- Back edge from GRAY to GRAY = cycle detected
DependencyValidator
Validates node dependencies and structure:- Parallel nodes have at least one child
- No duplicate names in parallel branches
- Valid concurrency limits (positive integers)
- Decision nodes have at least one pattern
- Structural warnings for dead-end nodes
SchemaValidator
Validates workflow configuration and schema:- Sequence has a start node
- Sequence contains executable nodes
- Meaningful workflow structure
- Basic configuration validity
Custom Validators
Create Custom Validator
ImplementBaseValidator to create custom validation rules:
Use Custom Validator
Validation Pipeline
SequenceValidator
Coordinate multiple validators:create_default_validator()
Create validator with all default validators:Validation Severity
Severity Levels
ERROR - Prevents execution:Common Patterns
Pre-Execution Validation
Development vs Production
CI/CD Integration
Validation Report
Best Practices
Always validate before production deployment
Always validate before production deployment
Use validation in tests
Use validation in tests
Create custom validators for domain rules
Create custom validators for domain rules
Log validation results
Log validation results
Handle warnings appropriately
Handle warnings appropriately
Performance Considerations
Validation Overhead
- Cycle detection: O(V + E) where V=nodes, E=edges
- Dependency validation: O(V) node traversal
- Schema validation: O(1) basic checks
- Total: Typically less than 10ms for workflows with less than 100 nodes

