MCPcopy Create free account
hub / github.com/ShipSecAI/studio / validateWorkflowGraph

Function validateWorkflowGraph

backend/src/dsl/validator.ts:40–152  ·  view source on GitHub ↗
(
  graph: WorkflowGraphDto,
  compiledDefinition: WorkflowDefinition,
)

Source from the content-addressed store, hash-verified

38 * Comprehensive DSL validation for workflow graphs
39 */
40export function validateWorkflowGraph(
41 graph: WorkflowGraphDto,
42 compiledDefinition: WorkflowDefinition,
43): ValidationResult {
44 const errors: ValidationError[] = [];
45 const warnings: ValidationError[] = [];
46 const actionPorts = new Map<string, ActionPortSnapshot>();
47
48 // 1. Validate all components exist
49 for (const node of graph.nodes) {
50 const component = componentRegistry.get(node.type);
51 if (!component) {
52 errors.push({
53 node: node.id,
54 field: 'type',
55 message: `Unknown component type: ${node.type}`,
56 severity: 'error',
57 suggestion:
58 'Available components: ' +
59 componentRegistry
60 .list()
61 .map((entry) => entry.id)
62 .join(', '),
63 });
64 }
65 }
66
67 // 2. Validate component parameters against schemas
68 for (const action of compiledDefinition.actions) {
69 const component = componentRegistry.get(action.componentId);
70 if (!component) continue; // Already reported above
71
72 const portSnapshot = resolveActionPortSnapshot(action, component);
73 actionPorts.set(action.ref, portSnapshot);
74
75 const paramsForValidation = { ...(action.params ?? {}) } as Record<string, unknown>;
76 const inputOverrides = { ...(action.inputOverrides ?? {}) } as Record<string, unknown>;
77 const placeholderFields = new Set<string>();
78
79 for (const inputPort of portSnapshot.inputs) {
80 const hasStaticValue =
81 Object.prototype.hasOwnProperty.call(inputOverrides, inputPort.id) &&
82 inputOverrides[inputPort.id] !== undefined;
83 const hasMapping = Object.prototype.hasOwnProperty.call(
84 action.inputMappings ?? {},
85 inputPort.id,
86 );
87
88 if (!hasStaticValue && hasMapping) {
89 const connectionType = getPortConnectionType(inputPort);
90 inputOverrides[inputPort.id] = createPlaceholderForConnectionType(connectionType);
91 placeholderFields.add(inputPort.id);
92 }
93 }
94
95 const paramValidation = component.parameters
96 ? component.parameters.safeParse(paramsForValidation)
97 : {

Callers 1

compileWorkflowGraphFunction · 0.90

Calls 12

getPortConnectionTypeFunction · 0.85
isPlaceholderIssueFunction · 0.85
validateSecretParametersFunction · 0.85
validateInputMappingsFunction · 0.85
getMethod · 0.65
pushMethod · 0.65
listMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected