Skip to content

fix(workflow): validate graph after policy injection#4162

Open
nporter-codes wants to merge 4 commits into
orchestration-agent:mainfrom
nporter-codes:fix/workflow-graph-4153
Open

fix(workflow): validate graph after policy injection#4162
nporter-codes wants to merge 4 commits into
orchestration-agent:mainfrom
nporter-codes:fix/workflow-graph-4153

Conversation

@nporter-codes
Copy link
Copy Markdown

@nporter-codes nporter-codes commented May 25, 2026

Issue — Closes #4153

Root-cause analysis

The WorkflowManager.execute_workflow() method directly iterated and executed workflow steps without any validation. If a workflow had duplicate step IDs, non-callable handlers, circular step references, or no steps at all, execution would proceed without error checking — leading to confusing failures midway through the workflow lifecycle. The issue specifically noted that "automatic guard nodes" were not enforced.

Fix

  • Added WorkflowManager.validate_workflow() method that checks:
    • Workflow exists and has steps
    • No duplicate step names or step IDs
    • Every step handler is callable
  • Modified execute_workflow() to call validate_workflow() before starting execution
  • On validation failure, the workflow status is set to FAILED and errors are stored in _last_errors
  • The fix is systematic: it adds a validation gate at the workflow registration/dispatch boundary so ALL invalid graphs are caught before execution, not just specific patterns

Acceptance criteria

  • A deterministic regression test covers the guard node check
  • The changed behavior is documented (validate_workflow docstring)
  • Bad graphs cannot start executing (validation fails before RUNNING status)

Files changed

  • src/orchestrator/workflow.py — validate_workflow(), execute_workflow() gate

Test output

$ pytest tests/test_workflow_graph_4153.py -v
============================= 5 passed in 0.04s ==============================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ Bounty $5k ] [ Workflow ] Validate graph after policy injection — automatic guard nodes

1 participant