Module agentforge4j.config.loader
Class WorkflowValidator
java.lang.Object
com.agentforge4j.config.loader.validation.WorkflowValidator
Structural and cross-reference validation checks run against loaded workflow and agent
definitions.
-
Constructor Summary
ConstructorsConstructorDescriptionWorkflowValidator(int maxTraversalDepth) Creates a validator whose traversal-based checks fail fast pastmaxTraversalDepthlevels of branch, retry-fallback, blueprint, or inline nested-workflow nesting. -
Method Summary
Modifier and TypeMethodDescriptionvoidvalidateAgentRefs(Map<String, WorkflowDefinition> workflows, Map<String, AgentDefinition> agents) Verifies that every agent reference in every workflow resolves to a known agent id.voidvalidateArtifactRefs(Map<String, WorkflowDefinition> workflows) Verifies that artifact references point to declared artifacts in the same workflow.voidvalidateBlueprintRefs(Map<String, WorkflowDefinition> workflows) Verifies that blueprint references point to declared blueprints in the same workflow and that no blueprint nesting chain is circular.voidvalidateCircularRefs(Map<String, WorkflowDefinition> workflows) Verifies that workflow reference graphs do not contain cycles.voidvalidateNoCollectionSteps(Map<String, WorkflowDefinition> workflows) Verifies that no step in any workflow usesCollectionBehaviour.voidvalidateReachableStepIdUniqueness(Map<String, WorkflowDefinition> workflows) Verifies that, for every workflow treated as a run root, no step id is reachable from more than one structural location across the reachable graph — the root, the blueprints it references, and the sub-workflows itsWORKFLOWsteps reach.voidvalidateRequirements(Map<String, WorkflowDefinition> workflows) Verifies the structural integrity of each workflow'srequirementsdeclarations: requirement-id uniqueness, that a targetedstepIdresolves to a real step, and that no two requirements of the same type target the same site.voidvalidateRetryStepRefs(Map<String, WorkflowDefinition> workflows) Verifies thatRetryPreviousBehaviourreferences target a known step reachable within the retry step's own enclosing scope (the root workflow, or the nearest inline nestedWorkflowDefinition— blueprint bodies share their enclosing workflow's scope).voidVerifies that everyVALIDATEstep's context-equality contracts reference an artifact in that step's ownrequiredArtifactsallowlist.voidvalidateWorkflowRefs(Map<String, WorkflowDefinition> workflows) Verifies that workflow references point to known workflows.
-
Constructor Details
-
WorkflowValidator
public WorkflowValidator(int maxTraversalDepth) Creates a validator whose traversal-based checks fail fast pastmaxTraversalDepthlevels of branch, retry-fallback, blueprint, or inline nested-workflow nesting.- Parameters:
maxTraversalDepth- the maximum nesting depth to traverse before failing fast; must be greater than zero. Callers with no reason to diverge from the traversal engine's own default should passWorkflowTreeWalker.MAX_TRAVERSAL_DEPTH.
-
-
Method Details
-
validateWorkflowRefs
Verifies that workflow references point to known workflows.- Parameters:
workflows- workflows to validate- Throws:
IllegalArgumentException- when a workflow reference targets an unknown workflow
-
validateBlueprintRefs
Verifies that blueprint references point to declared blueprints in the same workflow and that no blueprint nesting chain is circular.- Parameters:
workflows- workflows to validate- Throws:
BlueprintStructureException- when a blueprint reference targets an unknown blueprint, or nesting exceeds the configured traversal depth
-
validateArtifactRefs
Verifies that artifact references point to declared artifacts in the same workflow.- Parameters:
workflows- workflows to validate- Throws:
IllegalArgumentException- when an artifact reference targets an unknown artifact
-
validateCircularRefs
Verifies that workflow reference graphs do not contain cycles.- Parameters:
workflows- workflows to validate- Throws:
IllegalStateException- when a circular workflow reference is detected
-
validateRetryStepRefs
Verifies thatRetryPreviousBehaviourreferences target a known step reachable within the retry step's own enclosing scope (the root workflow, or the nearest inline nestedWorkflowDefinition— blueprint bodies share their enclosing workflow's scope).- Parameters:
workflows- workflows to validate- Throws:
IllegalArgumentException- when a retry step reference targets an unknown step id
-
validateReachableStepIdUniqueness
Verifies that, for every workflow treated as a run root, no step id is reachable from more than one structural location across the reachable graph — the root, the blueprints it references, and the sub-workflows itsWORKFLOWsteps reach. This is the exact graph the runtime resolves a step against at a gate or input submission; rejecting the ambiguity here turns an otherwise mid-runIllegalStateExceptioninto a load-time error.Validation is per-root: the same id appearing in two different root workflows is fine (they are separate runs), while a single sub-workflow or blueprint reached by more than one path within one root collapses to a single location and is not ambiguous.
- Parameters:
workflows- workflows to validate- Throws:
IllegalStateException- when a reachable step id resolves to two or more structural locations
-
validateValidateBehaviourContracts
Verifies that everyVALIDATEstep's context-equality contracts reference an artifact in that step's ownrequiredArtifactsallowlist. A contract pointing at a path outside the allowlist can never be satisfied at runtime (that artifact is never captured for the step), so it is a config error caught here at load time.- Parameters:
workflows- workflows to validate- Throws:
IllegalArgumentException- when a contract references an artifact outside the step's allowlist
-
validateRequirements
Verifies the structural integrity of each workflow'srequirementsdeclarations: requirement-id uniqueness, that a targetedstepIdresolves to a real step, and that no two requirements of the same type target the same site. Requirementtype,actionvalues, anddefaultpayloads are opaque and are not interpreted here.- Parameters:
workflows- workflows to validate- Throws:
IllegalArgumentException- when a requirement declaration is structurally invalid
-
validateNoCollectionSteps
Verifies that no step in any workflow usesCollectionBehaviour. TheCOLLECTIONstep type is a half-landed public surface: its sealed permit, state, and event types are kept intact for a planned future completion, but no runtimeBehaviourHandleris registered for it, so a run reaching such a step can only fail deep inside execution. The JSON schema's step-type enum already omitsCOLLECTION, so this check only ever fires against a programmatically-constructedWorkflowDefinitiontree; it exists as defense-in-depth alongside that schema gate so a future schema change cannot silently reopen the load path.- Parameters:
workflows- workflows to validate- Throws:
IllegalArgumentException- when a step usesCollectionBehaviour
-
validateAgentRefs
public void validateAgentRefs(Map<String, WorkflowDefinition> workflows, Map<String, AgentDefinition> agents) Verifies that every agent reference in every workflow resolves to a known agent id.- Parameters:
workflows- workflows whose agent references are checkedagents- available agents keyed by id- Throws:
UnresolvedAgentReferenceException- when one or more agent references are unresolved
-