Skip to main content

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

Access validation details:

get_summary()

Get formatted validation report:

Built-in Validators

CycleDetectionValidator

Detects circular dependencies in workflow graphs:
Cycle Detection Algorithm:
  • 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:
Checks performed:
  • 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:
Checks performed:
  • Sequence has a start node
  • Sequence contains executable nodes
  • Meaningful workflow structure
  • Basic configuration validity

Custom Validators

Create Custom Validator

Implement BaseValidator 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:
WARNING - Execution allowed but issues exist:
INFO - Suggestions for improvement:

Common Patterns

Pre-Execution Validation

Development vs Production

CI/CD Integration

Validation Report

Best Practices

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

When to Validate

Caching Validation Results

Error Messages

Common Validation Errors

Cycle detected:
Empty parallel node:
Duplicate names:
No start node:

What’s Next?

Type Safety

Type checking for workflows

Reporting

Track workflow performance

Best Practices

Workflow design patterns

Creating Nodes

Back to node creation