@nodetool-ai/kernel 0.7.0-rc.22 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/actor.d.ts +381 -20
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +1619 -184
- package/dist/actor.js.map +1 -1
- package/dist/correlation-analysis.d.ts +104 -0
- package/dist/correlation-analysis.d.ts.map +1 -0
- package/dist/correlation-analysis.js +833 -0
- package/dist/correlation-analysis.js.map +1 -0
- package/dist/durable-inbox.d.ts +9 -0
- package/dist/durable-inbox.d.ts.map +1 -1
- package/dist/durable-inbox.js +55 -2
- package/dist/durable-inbox.js.map +1 -1
- package/dist/dynamic-slots.d.ts +58 -0
- package/dist/dynamic-slots.d.ts.map +1 -0
- package/dist/dynamic-slots.js +182 -0
- package/dist/dynamic-slots.js.map +1 -0
- package/dist/edge-ids.d.ts +11 -0
- package/dist/edge-ids.d.ts.map +1 -0
- package/dist/edge-ids.js +15 -0
- package/dist/edge-ids.js.map +1 -0
- package/dist/graph-utils.d.ts +12 -0
- package/dist/graph-utils.d.ts.map +1 -1
- package/dist/graph-utils.js +51 -16
- package/dist/graph-utils.js.map +1 -1
- package/dist/graph.d.ts +50 -9
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +308 -101
- package/dist/graph.js.map +1 -1
- package/dist/inbox.d.ts +158 -2
- package/dist/inbox.d.ts.map +1 -1
- package/dist/inbox.js +253 -11
- package/dist/inbox.js.map +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +103 -6
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +123 -12
- package/dist/io.js.map +1 -1
- package/dist/loop.d.ts +36 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +166 -0
- package/dist/loop.js.map +1 -0
- package/dist/predicates.d.ts +8 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +8 -0
- package/dist/predicates.js.map +1 -0
- package/dist/run-state.d.ts +65 -0
- package/dist/run-state.d.ts.map +1 -0
- package/dist/run-state.js +42 -0
- package/dist/run-state.js.map +1 -0
- package/dist/runner.d.ts +312 -15
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1219 -156
- package/dist/runner.js.map +1 -1
- package/dist/substitute-validator.d.ts +44 -0
- package/dist/substitute-validator.d.ts.map +1 -0
- package/dist/substitute-validator.js +169 -0
- package/dist/substitute-validator.js.map +1 -0
- package/dist/supervisor.d.ts +148 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +287 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/trigger-wakeup.d.ts +74 -5
- package/dist/trigger-wakeup.d.ts.map +1 -1
- package/dist/trigger-wakeup.js +167 -45
- package/dist/trigger-wakeup.js.map +1 -1
- package/package.json +27 -9
- package/dist/channel.d.ts +0 -46
- package/dist/channel.d.ts.map +0 -1
- package/dist/channel.js +0 -191
- package/dist/channel.js.map +0 -1
- package/dist/suspendable.d.ts +0 -68
- package/dist/suspendable.d.ts.map +0 -1
- package/dist/suspendable.js +0 -108
- package/dist/suspendable.js.map +0 -1
- package/dist/trigger-manager.d.ts +0 -107
- package/dist/trigger-manager.d.ts.map +0 -1
- package/dist/trigger-manager.js +0 -214
- package/dist/trigger-manager.js.map +0 -1
- package/dist/trigger.d.ts +0 -57
- package/dist/trigger.d.ts.map +0 -1
- package/dist/trigger.js +0 -145
- package/dist/trigger.js.map +0 -1
package/dist/graph.js
CHANGED
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
* - Streaming upstream computation
|
|
10
10
|
*/
|
|
11
11
|
import { createLogger } from "@nodetool-ai/config";
|
|
12
|
+
// Stryker disable next-line StringLiteral: logger name is a diagnostic label, not a behavioural contract
|
|
12
13
|
const log = createLogger("nodetool.kernel.graph");
|
|
13
|
-
import { isControlEdge, isDataEdge, TypeMetadata } from "@nodetool-ai/protocol";
|
|
14
|
+
import { isControlEdge, isDataEdge, isLoopBackEdge, migrateGraphNodeTypes, TypeMetadata } from "@nodetool-ai/protocol";
|
|
15
|
+
import { syntheticEdgeId } from "./edge-ids.js";
|
|
16
|
+
import { dynamicSlotPropertyTypes } from "./dynamic-slots.js";
|
|
17
|
+
import { isCallable, isObjectValue, isString } from "./predicates.js";
|
|
14
18
|
export class GraphValidationError extends Error {
|
|
15
19
|
issues;
|
|
16
20
|
constructor(message, issues = []) {
|
|
@@ -23,6 +27,7 @@ export class GraphValidationError extends Error {
|
|
|
23
27
|
// Helpers
|
|
24
28
|
// ---------------------------------------------------------------------------
|
|
25
29
|
function nodeTypeToJsonSchema(typeStr) {
|
|
30
|
+
// Stryker disable next-line ConditionalExpression: equivalent — a falsy typeStr falls through to the default case, which also returns "string"
|
|
26
31
|
if (!typeStr)
|
|
27
32
|
return "string";
|
|
28
33
|
switch (typeStr) {
|
|
@@ -30,8 +35,10 @@ function nodeTypeToJsonSchema(typeStr) {
|
|
|
30
35
|
case "float":
|
|
31
36
|
case "number":
|
|
32
37
|
return "number";
|
|
38
|
+
// Stryker disable StringLiteral: equivalent — both labels return "string", the same value as the default branch
|
|
33
39
|
case "str":
|
|
34
40
|
case "string":
|
|
41
|
+
// Stryker restore StringLiteral
|
|
35
42
|
return "string";
|
|
36
43
|
case "bool":
|
|
37
44
|
case "boolean":
|
|
@@ -41,7 +48,7 @@ function nodeTypeToJsonSchema(typeStr) {
|
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
function resolveNodeTypeWith(resolver, nodeType) {
|
|
44
|
-
if (
|
|
51
|
+
if (isCallable(resolver)) {
|
|
45
52
|
return resolver(nodeType);
|
|
46
53
|
}
|
|
47
54
|
return resolver.resolveNodeType(nodeType);
|
|
@@ -49,6 +56,28 @@ function resolveNodeTypeWith(resolver, nodeType) {
|
|
|
49
56
|
// ---------------------------------------------------------------------------
|
|
50
57
|
// Graph
|
|
51
58
|
// ---------------------------------------------------------------------------
|
|
59
|
+
/**
|
|
60
|
+
* Mark a code-constructed graph as hydrated by defaulting absent behavior
|
|
61
|
+
* flags to false. For graphs built in code (tests, DSL output) where the
|
|
62
|
+
* author already set the flags that matter. NOT a substitute for registry
|
|
63
|
+
* hydration of client/wire graphs — there an absent flag means "unknown",
|
|
64
|
+
* not "off"; use `Graph.loadFromDict` or node-sdk's `hydrateGraphNodeFlags`.
|
|
65
|
+
*/
|
|
66
|
+
export function withExplicitNodeFlags(graph) {
|
|
67
|
+
return {
|
|
68
|
+
nodes: graph.nodes.map((node) => ({
|
|
69
|
+
...node,
|
|
70
|
+
is_streaming_input: node.is_streaming_input ?? false,
|
|
71
|
+
is_streaming_output: node.is_streaming_output ?? false,
|
|
72
|
+
is_controlled: node.is_controlled ?? false,
|
|
73
|
+
is_join_node: node.is_join_node ?? false,
|
|
74
|
+
// Here — unlike `loadFromDict` — the descriptor's author is code, not a
|
|
75
|
+
// saved file, so a declared `retry_safe` is the class's own declaration.
|
|
76
|
+
retry_safe: node.retry_safe ?? false
|
|
77
|
+
})),
|
|
78
|
+
edges: [...graph.edges]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
52
81
|
export class Graph {
|
|
53
82
|
nodes;
|
|
54
83
|
edges;
|
|
@@ -63,16 +92,17 @@ export class Graph {
|
|
|
63
92
|
/** Cache: nodes that have streaming upstream */
|
|
64
93
|
_streamingUpstream = null;
|
|
65
94
|
constructor(data) {
|
|
66
|
-
|
|
95
|
+
// Auto-detect is_controlled from incoming control edges (Python parity:
|
|
96
|
+
// BaseNode.is_controlled() checks graph edges at runtime). Affected nodes
|
|
97
|
+
// are replaced with shallow copies rather than mutated in place, so a
|
|
98
|
+
// WorkflowRunner.run() never writes back onto the caller's graph data.
|
|
99
|
+
this.nodes = Graph._withControlledFlags(data.nodes, data.edges);
|
|
67
100
|
this.edges = data.edges;
|
|
68
101
|
this._nodeIndex = new Map();
|
|
69
102
|
this._incomingEdges = new Map();
|
|
70
103
|
this._outgoingEdges = new Map();
|
|
71
104
|
this._outgoingByHandle = new Map();
|
|
72
105
|
this._buildIndices();
|
|
73
|
-
// Auto-detect is_controlled from incoming control edges (Python parity:
|
|
74
|
-
// BaseNode.is_controlled() checks graph edges at runtime).
|
|
75
|
-
this._detectControlledNodes();
|
|
76
106
|
}
|
|
77
107
|
/**
|
|
78
108
|
* Create a Graph from a plain object, validating the input shape.
|
|
@@ -80,7 +110,7 @@ export class Graph {
|
|
|
80
110
|
*/
|
|
81
111
|
static fromDict(data, options = {}) {
|
|
82
112
|
const { skipErrors = true, allowUndefinedProperties = true, validateNodeType } = options;
|
|
83
|
-
if (!data
|
|
113
|
+
if (!isObjectValue(data)) {
|
|
84
114
|
throw new GraphValidationError("Graph data must be an object");
|
|
85
115
|
}
|
|
86
116
|
const obj = data;
|
|
@@ -93,38 +123,23 @@ export class Graph {
|
|
|
93
123
|
if (!Array.isArray(obj.edges)) {
|
|
94
124
|
throw new GraphValidationError("'edges' must be an array");
|
|
95
125
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
throw new GraphValidationError("Edge entries must be objects");
|
|
102
|
-
}
|
|
103
|
-
const edgeObj = edge;
|
|
104
|
-
const targetId = typeof edgeObj.target === "string" ? edgeObj.target : undefined;
|
|
105
|
-
const targetHandle = typeof edgeObj.targetHandle === "string"
|
|
106
|
-
? edgeObj.targetHandle
|
|
107
|
-
: undefined;
|
|
108
|
-
if (!targetId || !targetHandle)
|
|
109
|
-
continue;
|
|
110
|
-
let handles = propertiesWithEdges.get(targetId);
|
|
111
|
-
if (!handles) {
|
|
112
|
-
handles = new Set();
|
|
113
|
-
propertiesWithEdges.set(targetId, handles);
|
|
114
|
-
}
|
|
115
|
-
handles.add(targetHandle);
|
|
116
|
-
}
|
|
126
|
+
// Rewrite removed node types (e.g. FormatText -> Prompt) before validation
|
|
127
|
+
// so legacy workflows keep loading. See NODE_TYPE_MIGRATIONS in protocol.
|
|
128
|
+
const migrated = migrateGraphNodeTypes(obj);
|
|
129
|
+
const migratedNodes = migrated.nodes;
|
|
130
|
+
const migratedEdges = migrated.edges;
|
|
117
131
|
const validNodes = [];
|
|
118
132
|
const validNodeIds = new Set();
|
|
119
|
-
for (const node of
|
|
120
|
-
|
|
133
|
+
for (const node of migratedNodes) {
|
|
134
|
+
// Stryker disable next-line ConditionalExpression,LogicalOperator: the typeof/operator variants are equivalent — a non-object node yields {} after the spread below and is then dropped by the id/type guard
|
|
135
|
+
if (!isObjectValue(node)) {
|
|
121
136
|
if (skipErrors)
|
|
122
137
|
continue;
|
|
123
138
|
throw new GraphValidationError("Node entries must be objects");
|
|
124
139
|
}
|
|
125
140
|
const nodeObj = { ...node };
|
|
126
|
-
const id =
|
|
127
|
-
const type =
|
|
141
|
+
const id = isString(nodeObj.id) ? nodeObj.id : undefined;
|
|
142
|
+
const type = isString(nodeObj.type) ? nodeObj.type : undefined;
|
|
128
143
|
if (!id || !type) {
|
|
129
144
|
if (skipErrors)
|
|
130
145
|
continue;
|
|
@@ -135,24 +150,39 @@ export class Graph {
|
|
|
135
150
|
continue;
|
|
136
151
|
throw new GraphValidationError(`Invalid node type: ${type}`);
|
|
137
152
|
}
|
|
138
|
-
const rawProperties =
|
|
153
|
+
const rawProperties =
|
|
154
|
+
// Stryker disable next-line ConditionalExpression,LogicalOperator: equivalent — a non-object properties value spreads to {}, the same as falling through to data/{}
|
|
155
|
+
isObjectValue(nodeObj.properties)
|
|
139
156
|
? { ...nodeObj.properties }
|
|
140
|
-
:
|
|
141
|
-
|
|
142
|
-
|
|
157
|
+
: // Stryker disable next-line ConditionalExpression,LogicalOperator: equivalent — a non-object data value spreads to {}
|
|
158
|
+
isObjectValue(nodeObj.data)
|
|
159
|
+
? { ...nodeObj.data }
|
|
160
|
+
: {};
|
|
143
161
|
// Merge dynamic_properties into the node's properties so that
|
|
144
162
|
// dynamic nodes (e.g. WorkflowNode) receive user-provided values
|
|
145
163
|
// for inputs that aren't connected via edges.
|
|
146
|
-
if (nodeObj.dynamic_properties
|
|
147
|
-
typeof nodeObj.dynamic_properties === "object") {
|
|
164
|
+
if (isObjectValue(nodeObj.dynamic_properties)) {
|
|
148
165
|
Object.assign(rawProperties, nodeObj.dynamic_properties);
|
|
149
166
|
}
|
|
167
|
+
// Declared dynamic slots are real, typed handles: register their type
|
|
168
|
+
// in propertyTypes so the undefined-property guard below keeps them and
|
|
169
|
+
// downstream type lookups see a type instead of `any`. Only merged into
|
|
170
|
+
// an existing non-empty map — synthesizing propertyTypes here would
|
|
171
|
+
// switch the guard on for a node that had no type map at all.
|
|
172
|
+
const slotTypes = dynamicSlotPropertyTypes(nodeObj.dynamic_inputs);
|
|
173
|
+
if (Object.keys(slotTypes).length > 0 &&
|
|
174
|
+
isObjectValue(nodeObj.propertyTypes) &&
|
|
175
|
+
Object.keys(nodeObj.propertyTypes).length > 0) {
|
|
176
|
+
nodeObj.propertyTypes = {
|
|
177
|
+
...slotTypes,
|
|
178
|
+
...nodeObj.propertyTypes
|
|
179
|
+
};
|
|
180
|
+
}
|
|
150
181
|
if (!allowUndefinedProperties) {
|
|
151
182
|
// Only validate against propertyTypes when it is explicitly provided.
|
|
152
183
|
// Using properties itself as a source of truth would defeat the purpose
|
|
153
184
|
// of this check, since every property key would always be "defined".
|
|
154
|
-
const hasPropertyTypes = nodeObj.propertyTypes
|
|
155
|
-
typeof nodeObj.propertyTypes === "object" &&
|
|
185
|
+
const hasPropertyTypes = isObjectValue(nodeObj.propertyTypes) &&
|
|
156
186
|
Object.keys(nodeObj.propertyTypes).length >
|
|
157
187
|
0;
|
|
158
188
|
if (hasPropertyTypes) {
|
|
@@ -169,26 +199,25 @@ export class Graph {
|
|
|
169
199
|
}
|
|
170
200
|
}
|
|
171
201
|
}
|
|
172
|
-
for (const handle of propertiesWithEdges.get(id) ?? []) {
|
|
173
|
-
delete rawProperties[handle];
|
|
174
|
-
}
|
|
175
202
|
nodeObj.properties = rawProperties;
|
|
176
203
|
delete nodeObj.data;
|
|
177
|
-
|
|
204
|
+
// SAFETY: `properties` was just set, and `id`/`type` were proved to be
|
|
205
|
+
// strings by the guard above; they are re-stated so the compiler sees it.
|
|
206
|
+
validNodes.push({ ...nodeObj, id, type });
|
|
178
207
|
validNodeIds.add(id);
|
|
179
208
|
}
|
|
180
209
|
const validEdges = [];
|
|
181
|
-
for (const edge of
|
|
182
|
-
if (!edge
|
|
210
|
+
for (const edge of migratedEdges) {
|
|
211
|
+
if (!isObjectValue(edge)) {
|
|
183
212
|
if (skipErrors)
|
|
184
213
|
continue;
|
|
185
214
|
throw new GraphValidationError("Edge entries must be objects");
|
|
186
215
|
}
|
|
187
216
|
const edgeObj = edge;
|
|
188
|
-
const hasRequiredFields =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
217
|
+
const hasRequiredFields = isString(edgeObj.source) &&
|
|
218
|
+
isString(edgeObj.sourceHandle) &&
|
|
219
|
+
isString(edgeObj.target) &&
|
|
220
|
+
isString(edgeObj.targetHandle);
|
|
192
221
|
if (!hasRequiredFields) {
|
|
193
222
|
if (skipErrors)
|
|
194
223
|
continue;
|
|
@@ -200,6 +229,8 @@ export class Graph {
|
|
|
200
229
|
(!validNodeIds.has(source) || !validNodeIds.has(target))) {
|
|
201
230
|
continue;
|
|
202
231
|
}
|
|
232
|
+
// SAFETY: `hasRequiredFields` above proved source/sourceHandle/target/
|
|
233
|
+
// targetHandle are all strings.
|
|
203
234
|
validEdges.push(edgeObj);
|
|
204
235
|
}
|
|
205
236
|
return new Graph({ nodes: validNodes, edges: validEdges });
|
|
@@ -208,6 +239,7 @@ export class Graph {
|
|
|
208
239
|
const { resolver, skipErrors = true, allowUndefinedProperties = true } = options;
|
|
209
240
|
const normalized = Graph.fromDict(data, {
|
|
210
241
|
skipErrors,
|
|
242
|
+
// Stryker disable next-line BooleanLiteral: must stay true — property validation happens later against the RESOLVED types, not the saved cache (see comment in loadFromDict)
|
|
211
243
|
allowUndefinedProperties: true
|
|
212
244
|
});
|
|
213
245
|
const resolvedNodes = [];
|
|
@@ -224,7 +256,7 @@ export class Graph {
|
|
|
224
256
|
const mergedProperties = {
|
|
225
257
|
...(node.properties ?? {})
|
|
226
258
|
};
|
|
227
|
-
const effectiveAllowUndefined = resolved.
|
|
259
|
+
const effectiveAllowUndefined = resolved.supportsDynamicInputs || allowUndefinedProperties;
|
|
228
260
|
if (!effectiveAllowUndefined) {
|
|
229
261
|
for (const key of Object.keys(mergedProperties)) {
|
|
230
262
|
if (!allowedProperties.has(key)) {
|
|
@@ -238,6 +270,9 @@ export class Graph {
|
|
|
238
270
|
}
|
|
239
271
|
}
|
|
240
272
|
const descriptorDefaults = resolved.descriptorDefaults ?? {};
|
|
273
|
+
// A per-instance answer, when the resolver has one for this type, is read
|
|
274
|
+
// from the node as saved — the same properties the node will run with.
|
|
275
|
+
const instanceFlags = resolved.resolveInstanceFlags?.(node) ?? {};
|
|
241
276
|
const hydratedNode = {
|
|
242
277
|
...descriptorDefaults,
|
|
243
278
|
...node,
|
|
@@ -245,33 +280,66 @@ export class Graph {
|
|
|
245
280
|
properties: mergedProperties,
|
|
246
281
|
propertyTypes: {
|
|
247
282
|
...resolvedPropertyTypes,
|
|
283
|
+
// Declared dynamic slots type their handles, but never shadow a
|
|
284
|
+
// static property the registry already declares.
|
|
285
|
+
...Object.fromEntries(Object.entries(dynamicSlotPropertyTypes(node.dynamic_inputs)).filter(([name]) => !Object.hasOwn(resolvedPropertyTypes, name))),
|
|
248
286
|
...(node.propertyTypes ?? {})
|
|
249
287
|
},
|
|
250
288
|
outputs: {
|
|
251
289
|
...(resolved.outputs ?? {}),
|
|
252
290
|
...(node.outputs ?? {})
|
|
253
291
|
},
|
|
254
|
-
sync_mode: node.sync_mode ??
|
|
255
|
-
node.properties
|
|
256
|
-
?.sync_mode ??
|
|
257
|
-
descriptorDefaults.sync_mode ??
|
|
258
|
-
"on_any",
|
|
259
292
|
// Streaming/control flags: registry metadata (descriptorDefaults) is
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
|
|
263
|
-
|
|
293
|
+
// authoritative when it speaks. An explicit registry boolean — true OR
|
|
294
|
+
// false — wins; the saved value applies only when the resolver omits
|
|
295
|
+
// the flag (undefined), e.g. for unresolved/dynamic types. OR-ing here
|
|
296
|
+
// would let a stale saved `true` survive a registry that migrated the
|
|
297
|
+
// type to buffered/uncontrolled, silently running the wrong mode.
|
|
298
|
+
// A per-instance answer takes the slot the per-type default holds: it
|
|
299
|
+
// was resolved from this node's own properties, so it is the more
|
|
300
|
+
// specific registry opinion, not a saved claim.
|
|
301
|
+
is_streaming_input: instanceFlags.is_streaming_input ??
|
|
302
|
+
descriptorDefaults.is_streaming_input ??
|
|
303
|
+
node.is_streaming_input ??
|
|
264
304
|
false,
|
|
265
|
-
is_streaming_output: descriptorDefaults.is_streaming_output
|
|
266
|
-
node.is_streaming_output
|
|
305
|
+
is_streaming_output: descriptorDefaults.is_streaming_output ??
|
|
306
|
+
node.is_streaming_output ??
|
|
267
307
|
false,
|
|
268
|
-
|
|
308
|
+
// Correlation metadata is authoritative from the registry. Saved JSON
|
|
309
|
+
// is treated as a cache and overwritten — including when the resolver
|
|
310
|
+
// intentionally returns undefined for a node type that no longer
|
|
311
|
+
// declares correlation. See docs/correlation-design.md §1.
|
|
312
|
+
input_mode: descriptorDefaults.input_mode,
|
|
313
|
+
output_correlation: descriptorDefaults.output_correlation,
|
|
314
|
+
is_controlled: descriptorDefaults.is_controlled ?? node.is_controlled ?? false,
|
|
315
|
+
is_join_node: descriptorDefaults.is_join_node ?? node.is_join_node ?? false,
|
|
316
|
+
// Without this the flag is dropped, because saved workflow JSON never
|
|
317
|
+
// carries it and only the registry knows. `actor.ts` gates the trigger
|
|
318
|
+
// entry point on `node.is_trigger`, so a webhook/manual/file-watch
|
|
319
|
+
// event delivered to a graph hydrated here was accepted and then
|
|
320
|
+
// silently ignored — the node fell through to `genProcess()`, waited
|
|
321
|
+
// for a live adapter that a delivered-event run does not have, and
|
|
322
|
+
// emitted nothing. Every host that passes `resolveNodeType` took this
|
|
323
|
+
// path, including the websocket server.
|
|
324
|
+
is_trigger: descriptorDefaults.is_trigger ?? node.is_trigger ?? false,
|
|
325
|
+
// Retry safety comes from the registry or not at all — note there is
|
|
326
|
+
// no `?? node.retry_safe` here, unlike every flag above. Whether
|
|
327
|
+
// re-running a node duplicates a payment or a publish is a property of
|
|
328
|
+
// its implementation, not of a file: a saved graph asserting
|
|
329
|
+
// `retry_safe: true` for a node whose class never declared it would
|
|
330
|
+
// hand the supervisor a retry on a side-effecting node. An unresolved
|
|
331
|
+
// type therefore gets no retry rather than the saved claim.
|
|
332
|
+
retry_safe: descriptorDefaults.retry_safe ?? false
|
|
269
333
|
};
|
|
270
334
|
resolvedNodes.push(hydratedNode);
|
|
271
335
|
validNodeIds.add(hydratedNode.id);
|
|
272
336
|
}
|
|
273
337
|
const validEdges = normalized.edges.filter((edge) => validNodeIds.has(edge.source) && validNodeIds.has(edge.target));
|
|
274
|
-
|
|
338
|
+
// Sound: resolvedNodes were built as HydratedNodeDescriptor above.
|
|
339
|
+
return new Graph({
|
|
340
|
+
nodes: resolvedNodes,
|
|
341
|
+
edges: validEdges
|
|
342
|
+
});
|
|
275
343
|
}
|
|
276
344
|
// -----------------------------------------------------------------------
|
|
277
345
|
// Index building
|
|
@@ -309,21 +377,28 @@ export class Graph {
|
|
|
309
377
|
}
|
|
310
378
|
}
|
|
311
379
|
/**
|
|
312
|
-
*
|
|
313
|
-
* In Python, BaseNode.is_controlled() is a runtime method that checks
|
|
314
|
-
*
|
|
315
|
-
*
|
|
380
|
+
* Return the node list with is_controlled set on every control-edge target.
|
|
381
|
+
* In Python, BaseNode.is_controlled() is a runtime method that checks the
|
|
382
|
+
* graph context; in TS we set the flag on the descriptor so the actor knows
|
|
383
|
+
* to use _runControlled(). Node objects are caller-owned (the runner passes
|
|
384
|
+
* `graphData.nodes` straight through), so a target lacking the flag is
|
|
385
|
+
* replaced with a shallow copy — the original is left untouched. Every other
|
|
386
|
+
* node keeps its identity.
|
|
316
387
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (target && !target.is_controlled) {
|
|
323
|
-
// NodeDescriptor is readonly in the type, but we own the instances
|
|
324
|
-
target.is_controlled = true;
|
|
325
|
-
}
|
|
388
|
+
static _withControlledFlags(nodes, edges) {
|
|
389
|
+
const controlledIds = new Set();
|
|
390
|
+
for (const edge of edges) {
|
|
391
|
+
if (isControlEdge(edge))
|
|
392
|
+
controlledIds.add(edge.target);
|
|
326
393
|
}
|
|
394
|
+
// Stryker disable next-line ConditionalExpression: equivalent — with no control edges the map below returns every node unchanged, so the early return only avoids allocating a new array
|
|
395
|
+
if (controlledIds.size === 0)
|
|
396
|
+
return nodes;
|
|
397
|
+
return nodes.map((node) =>
|
|
398
|
+
// Stryker disable next-line ConditionalExpression,LogicalOperator,BooleanLiteral: equivalent — re-copying an already-controlled node yields the same is_controlled value; the guard only preserves object identity (a micro-optimization)
|
|
399
|
+
controlledIds.has(node.id) && !node.is_controlled
|
|
400
|
+
? { ...node, is_controlled: true }
|
|
401
|
+
: node);
|
|
327
402
|
}
|
|
328
403
|
// -----------------------------------------------------------------------
|
|
329
404
|
// Lookups
|
|
@@ -361,9 +436,12 @@ export class Graph {
|
|
|
361
436
|
(targetId === undefined || edge.target === targetId));
|
|
362
437
|
}
|
|
363
438
|
getControllerNodes(targetId) {
|
|
364
|
-
const
|
|
439
|
+
const controlEdges =
|
|
440
|
+
// Stryker disable next-line ConditionalExpression: redundant ternary — getControlEdges(undefined) already returns all control edges, identical to getControlEdges()
|
|
441
|
+
targetId === undefined
|
|
365
442
|
? this.getControlEdges()
|
|
366
|
-
: this.getControlEdges(targetId)
|
|
443
|
+
: this.getControlEdges(targetId);
|
|
444
|
+
const ids = new Set(controlEdges.map((e) => e.source));
|
|
367
445
|
return this.nodes.filter((n) => ids.has(n.id));
|
|
368
446
|
}
|
|
369
447
|
getControlledNodes(sourceId) {
|
|
@@ -382,13 +460,25 @@ export class Graph {
|
|
|
382
460
|
* Return nodes that have no incoming data edges (source nodes).
|
|
383
461
|
*/
|
|
384
462
|
inputNodes() {
|
|
385
|
-
|
|
463
|
+
const hasIncomingData = new Set();
|
|
464
|
+
for (const edge of this.edges) {
|
|
465
|
+
if (isDataEdge(edge)) {
|
|
466
|
+
hasIncomingData.add(edge.target);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return this.nodes.filter((n) => !hasIncomingData.has(n.id));
|
|
386
470
|
}
|
|
387
471
|
/**
|
|
388
472
|
* Return nodes that have no outgoing data edges (sink nodes).
|
|
389
473
|
*/
|
|
390
474
|
outputNodes() {
|
|
391
|
-
|
|
475
|
+
const hasOutgoingData = new Set();
|
|
476
|
+
for (const edge of this.edges) {
|
|
477
|
+
if (isDataEdge(edge)) {
|
|
478
|
+
hasOutgoingData.add(edge.source);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return this.nodes.filter((n) => !hasOutgoingData.has(n.id));
|
|
392
482
|
}
|
|
393
483
|
// -----------------------------------------------------------------------
|
|
394
484
|
// Streaming upstream detection
|
|
@@ -398,6 +488,7 @@ export class Graph {
|
|
|
398
488
|
* of a streaming-output node via data edges).
|
|
399
489
|
*/
|
|
400
490
|
hasStreamingUpstream(nodeId) {
|
|
491
|
+
// Stryker disable next-line ConditionalExpression: caching optimization — recomputing yields the same set
|
|
401
492
|
if (!this._streamingUpstream) {
|
|
402
493
|
this._streamingUpstream = this._computeStreamingUpstream();
|
|
403
494
|
}
|
|
@@ -407,6 +498,7 @@ export class Graph {
|
|
|
407
498
|
const result = new Set();
|
|
408
499
|
// BFS from every streaming-output node along data edges
|
|
409
500
|
const streamingSources = this.nodes.filter((n) => n.is_streaming_output);
|
|
501
|
+
// Stryker disable next-line ArrayDeclaration: a non-empty seed is equivalent — a bogus node id has no outgoing edges, so BFS adds nothing
|
|
410
502
|
const queue = [];
|
|
411
503
|
for (const src of streamingSources) {
|
|
412
504
|
for (const edge of this.findOutgoingEdges(src.id)) {
|
|
@@ -441,19 +533,37 @@ export class Graph {
|
|
|
441
533
|
.filter((node) => node.type === "GroupNode" || node.type.endsWith(".GroupNode"))
|
|
442
534
|
.map((node) => node.id))
|
|
443
535
|
: new Set();
|
|
444
|
-
const
|
|
445
|
-
(node.parent_id
|
|
536
|
+
const isInScope = (node) => {
|
|
537
|
+
const directlyInScope = (node.parent_id ?? null) === parentId;
|
|
538
|
+
const inScopedGroup =
|
|
539
|
+
// Stryker disable next-line ConditionalExpression: the `!= null` guard is redundant — groupNodeIds only holds real node-id strings, so has(null/undefined) is already false
|
|
540
|
+
node.parent_id != null && groupNodeIds.has(node.parent_id);
|
|
541
|
+
return directlyInScope || inScopedGroup;
|
|
542
|
+
};
|
|
543
|
+
const filteredNodes = this.nodes.filter(isInScope);
|
|
446
544
|
const filteredNodeIds = new Set(filteredNodes.map((node) => node.id));
|
|
447
|
-
|
|
545
|
+
// Only data edges define the ordering (see docstring). Including control
|
|
546
|
+
// edges would turn a legal data-A→B + control-B→A controller feedback
|
|
547
|
+
// pattern into a mixed cycle, silently dropping both nodes from the
|
|
548
|
+
// returned levels.
|
|
549
|
+
// Loop back edges close the only cycles a graph may contain; leaving them
|
|
550
|
+
// out keeps loop bodies in the levels (docs/workflow-loops.md).
|
|
551
|
+
const nodeTypeOf = (id) => this.findNode(id)?.type;
|
|
552
|
+
const filteredEdges = this.edges.filter((edge) => isDataEdge(edge) &&
|
|
553
|
+
!isLoopBackEdge(edge, nodeTypeOf) &&
|
|
554
|
+
filteredNodeIds.has(edge.source) &&
|
|
555
|
+
filteredNodeIds.has(edge.target));
|
|
448
556
|
// In-degree count across filtered edges.
|
|
449
557
|
const inDeg = new Map();
|
|
450
558
|
for (const node of filteredNodes) {
|
|
451
559
|
inDeg.set(node.id, 0);
|
|
452
560
|
}
|
|
453
561
|
for (const edge of filteredEdges) {
|
|
562
|
+
// Stryker disable next-line LogicalOperator: equivalent — same-level nodes are all processed before the next level, so an off-by-one in-degree count does not change the produced levels
|
|
454
563
|
inDeg.set(edge.target, (inDeg.get(edge.target) ?? 0) + 1);
|
|
455
564
|
}
|
|
456
565
|
// Seed with zero-in-degree nodes
|
|
566
|
+
// Stryker disable next-line ArrayDeclaration: a non-empty seed is equivalent — a bogus id matches no node/edge and is dropped
|
|
457
567
|
let currentLevel = [];
|
|
458
568
|
for (const [id, deg] of inDeg) {
|
|
459
569
|
if (deg === 0)
|
|
@@ -467,11 +577,13 @@ export class Graph {
|
|
|
467
577
|
for (const id of currentLevel) {
|
|
468
578
|
visited.add(id);
|
|
469
579
|
const node = this.findNode(id);
|
|
580
|
+
// Stryker disable next-line ConditionalExpression: equivalent — ids come from filteredNodes, so findNode always returns a node
|
|
470
581
|
if (node)
|
|
471
582
|
levelNodes.push(node);
|
|
472
583
|
for (const edge of filteredEdges) {
|
|
473
584
|
if (edge.source !== id)
|
|
474
585
|
continue;
|
|
586
|
+
// Stryker disable next-line LogicalOperator: equivalent — every edge target was seeded in inDeg, and same-level processing means the decrement order does not change the produced levels
|
|
475
587
|
const newDeg = (inDeg.get(edge.target) ?? 1) - 1;
|
|
476
588
|
inDeg.set(edge.target, newDeg);
|
|
477
589
|
if (newDeg === 0 && !visited.has(edge.target)) {
|
|
@@ -479,11 +591,14 @@ export class Graph {
|
|
|
479
591
|
}
|
|
480
592
|
}
|
|
481
593
|
}
|
|
594
|
+
// Stryker disable next-line ConditionalExpression,EqualityOperator: equivalent — currentLevel ids all resolve to nodes, so levelNodes is never empty when currentLevel is non-empty
|
|
482
595
|
if (levelNodes.length > 0)
|
|
483
596
|
levels.push(levelNodes);
|
|
484
597
|
currentLevel = nextLevel;
|
|
485
598
|
}
|
|
599
|
+
// Stryker disable next-line ConditionalExpression,EqualityOperator,BlockStatement: this only emits a diagnostic warning; the returned levels are unaffected
|
|
486
600
|
if (visited.size !== filteredNodes.length) {
|
|
601
|
+
// Stryker disable next-line StringLiteral,ObjectLiteral: diagnostic log args only
|
|
487
602
|
log.warn("Graph contains at least one cycle", {
|
|
488
603
|
visited: visited.size,
|
|
489
604
|
total: filteredNodes.length
|
|
@@ -499,13 +614,20 @@ export class Graph {
|
|
|
499
614
|
* Each input node contributes a property named after node.name (or node.id).
|
|
500
615
|
*/
|
|
501
616
|
getInputSchema() {
|
|
502
|
-
|
|
617
|
+
// Match the input-node namespace, not any type merely CONTAINING "Input":
|
|
618
|
+
// a loose substring pulled in mid-graph nodes like
|
|
619
|
+
// `nodetool.test.StreamingInputProcessor` (phantom required input) and
|
|
620
|
+
// missed real ones like `nodetool.input.MessageDeconstructor`.
|
|
621
|
+
return this._buildSchema((n) => n.type.startsWith("nodetool.input."));
|
|
503
622
|
}
|
|
504
623
|
/**
|
|
505
|
-
* Build a JSON Schema object from output nodes (
|
|
624
|
+
* Build a JSON Schema object from output nodes (`nodetool.output.*`).
|
|
506
625
|
*/
|
|
507
626
|
getOutputSchema() {
|
|
508
|
-
|
|
627
|
+
// Namespace match, not a substring: `nodetool.generators.
|
|
628
|
+
// StructuredOutputGenerator` / `nodetool.audio.realtime.AudioOutput`
|
|
629
|
+
// contain "Output" but are not workflow output nodes.
|
|
630
|
+
return this._buildSchema((n) => n.type.startsWith("nodetool.output."));
|
|
509
631
|
}
|
|
510
632
|
_buildSchema(filter) {
|
|
511
633
|
const properties = {};
|
|
@@ -532,21 +654,82 @@ export class Graph {
|
|
|
532
654
|
*/
|
|
533
655
|
validate() {
|
|
534
656
|
this.validateEdgeEndpoints();
|
|
657
|
+
this.validateDataEdgeSourceHandles();
|
|
535
658
|
this.validateControlEdges();
|
|
536
659
|
this.validateEdgeTypes();
|
|
537
660
|
}
|
|
661
|
+
/**
|
|
662
|
+
* Verify that every data edge's `sourceHandle` is a declared output of its
|
|
663
|
+
* source node. Without this, an edge wired to a nonexistent output handle
|
|
664
|
+
* passes validation and then silently never delivers a value at runtime
|
|
665
|
+
* (`validateEdgeTypes` skips it for lack of a source type), leaving the
|
|
666
|
+
* target node waiting forever.
|
|
667
|
+
*
|
|
668
|
+
* Only enforced when the source node declares a non-empty static `outputs`
|
|
669
|
+
* map and does not produce dynamic outputs (whose handles aren't known
|
|
670
|
+
* statically). Nodes without output metadata are left untouched.
|
|
671
|
+
*/
|
|
672
|
+
validateDataEdgeSourceHandles() {
|
|
673
|
+
for (const edge of this.edges) {
|
|
674
|
+
if (!isDataEdge(edge))
|
|
675
|
+
continue;
|
|
676
|
+
const sourceNode = this._nodeIndex.get(edge.source);
|
|
677
|
+
// Endpoint existence is enforced by validateEdgeEndpoints().
|
|
678
|
+
if (!sourceNode)
|
|
679
|
+
continue;
|
|
680
|
+
const outputs = sourceNode.outputs;
|
|
681
|
+
if (!outputs || Object.keys(outputs).length === 0)
|
|
682
|
+
continue;
|
|
683
|
+
if (sourceNode.dynamic_outputs &&
|
|
684
|
+
Object.keys(sourceNode.dynamic_outputs).length > 0) {
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
// Own-property check, not `in`: `in` walks the prototype chain, so a
|
|
688
|
+
// sourceHandle named after an Object.prototype member ("toString",
|
|
689
|
+
// "constructor", …) would spuriously pass this guard and then hang at
|
|
690
|
+
// runtime when the source node emits nothing on that handle.
|
|
691
|
+
if (!Object.hasOwn(outputs, edge.sourceHandle)) {
|
|
692
|
+
throw new GraphValidationError(`Edge ${edge.id ?? syntheticEdgeId(edge.source, edge.sourceHandle, edge.target, edge.targetHandle)} ` +
|
|
693
|
+
`references unknown output "${edge.sourceHandle}" on node "${edge.source}"` +
|
|
694
|
+
`${sourceNode.type ? ` (${sourceNode.type})` : ""}`, [
|
|
695
|
+
{
|
|
696
|
+
nodeId: edge.source,
|
|
697
|
+
nodeType: sourceNode.type,
|
|
698
|
+
property: edge.sourceHandle,
|
|
699
|
+
message: `Unknown output "${edge.sourceHandle}"`
|
|
700
|
+
}
|
|
701
|
+
]);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
538
705
|
/**
|
|
539
706
|
* Verify that every edge references existing nodes.
|
|
540
707
|
*/
|
|
541
708
|
validateEdgeEndpoints() {
|
|
542
709
|
for (const edge of this.edges) {
|
|
710
|
+
// Self-loops pass control-cycle detection and deadlock at runtime:
|
|
711
|
+
// the node waits on an input handle that only the node itself can
|
|
712
|
+
// close. The correlation analyzer reports data self-loops as cycles;
|
|
713
|
+
// this guard also covers direct validate() callers and control edges.
|
|
714
|
+
if (edge.source === edge.target) {
|
|
715
|
+
throw new GraphValidationError(`Edge ${edge.id ?? syntheticEdgeId(edge.source, edge.sourceHandle, edge.target, edge.targetHandle)} ` +
|
|
716
|
+
`connects node "${edge.source}" to itself; self-loop edges are not supported`, [
|
|
717
|
+
{
|
|
718
|
+
nodeId: edge.source,
|
|
719
|
+
property: edge.targetHandle,
|
|
720
|
+
message: "Self-loop edges are not supported"
|
|
721
|
+
}
|
|
722
|
+
]);
|
|
723
|
+
}
|
|
543
724
|
if (!this._nodeIndex.has(edge.source)) {
|
|
725
|
+
// Stryker disable next-line StringLiteral,ObjectLiteral: diagnostic log args only
|
|
544
726
|
log.error("Edge references unknown source node", {
|
|
545
727
|
source: edge.source
|
|
546
728
|
});
|
|
547
729
|
throw new GraphValidationError(`Edge references unknown source node: ${edge.source}`);
|
|
548
730
|
}
|
|
549
731
|
if (!this._nodeIndex.has(edge.target)) {
|
|
732
|
+
// Stryker disable next-line StringLiteral,ObjectLiteral: diagnostic log args only
|
|
550
733
|
log.error("Edge references unknown target node", {
|
|
551
734
|
target: edge.target
|
|
552
735
|
});
|
|
@@ -579,40 +762,61 @@ export class Graph {
|
|
|
579
762
|
*/
|
|
580
763
|
validateEdgeTypes() {
|
|
581
764
|
for (const edge of this.edges) {
|
|
765
|
+
// Stryker disable next-line ConditionalExpression: equivalent — a control edge has no source output type for its handle and is skipped by the !sourceType guard below anyway
|
|
582
766
|
if (isControlEdge(edge))
|
|
583
767
|
continue;
|
|
584
768
|
const sourceNode = this._nodeIndex.get(edge.source);
|
|
585
769
|
const targetNode = this._nodeIndex.get(edge.target);
|
|
586
770
|
if (!sourceNode || !targetNode)
|
|
587
771
|
continue;
|
|
588
|
-
// Get source output type from node.outputs[sourceHandle]
|
|
589
|
-
|
|
772
|
+
// Get source output type from node.outputs[sourceHandle]. Own-property
|
|
773
|
+
// guard: a prototype-named handle ("toString", "constructor", …) would
|
|
774
|
+
// otherwise read an inherited Object.prototype member (a truthy function)
|
|
775
|
+
// and pass it to TypeMetadata.fromString, crashing on a runnable graph.
|
|
776
|
+
const sourceType = sourceNode.outputs &&
|
|
777
|
+
Object.hasOwn(sourceNode.outputs, edge.sourceHandle)
|
|
778
|
+
? sourceNode.outputs[edge.sourceHandle]
|
|
779
|
+
: undefined;
|
|
590
780
|
if (!sourceType)
|
|
591
781
|
continue; // no type info, skip
|
|
592
|
-
// Get target input type
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
782
|
+
// Get target input type: propertyTypes is the authoritative map after
|
|
783
|
+
// graph load. Fall back to a property value carrying an explicit
|
|
784
|
+
// `type` descriptor for raw payloads. Plain string property values
|
|
785
|
+
// are runtime data (e.g. saved literals), never type names.
|
|
786
|
+
let targetType = targetNode.propertyTypes &&
|
|
787
|
+
Object.hasOwn(targetNode.propertyTypes, edge.targetHandle)
|
|
788
|
+
? targetNode.propertyTypes[edge.targetHandle]
|
|
789
|
+
: undefined;
|
|
790
|
+
if (!targetType) {
|
|
791
|
+
const targetProp = targetNode.properties?.[edge.targetHandle];
|
|
792
|
+
if (isObjectValue(targetProp) &&
|
|
793
|
+
"type" in targetProp &&
|
|
794
|
+
isString(targetProp.type)) {
|
|
795
|
+
targetType = targetProp.type;
|
|
796
|
+
}
|
|
602
797
|
}
|
|
603
798
|
if (!targetType)
|
|
604
799
|
continue; // no type info, skip
|
|
605
800
|
// Use TypeMetadata for full compatibility check (handles list[X], union, numeric widening)
|
|
606
801
|
const sourceMeta = TypeMetadata.fromString(sourceType);
|
|
607
802
|
const targetMeta = TypeMetadata.fromString(targetType);
|
|
608
|
-
|
|
803
|
+
// Scalar-into-list aggregation: a value edge may feed a list-typed
|
|
804
|
+
// input (multi-edge list inputs collect items into a list, and a
|
|
805
|
+
// single item edge wraps). Accept when the source is compatible with
|
|
806
|
+
// the list's element type.
|
|
807
|
+
const elementCompatible = targetMeta.isListType() &&
|
|
808
|
+
!sourceMeta.isListType() &&
|
|
809
|
+
(targetMeta.args.length === 0 ||
|
|
810
|
+
sourceMeta.isCompatibleWith(targetMeta.args[0]));
|
|
811
|
+
if (!sourceMeta.isCompatibleWith(targetMeta) && !elementCompatible) {
|
|
812
|
+
// Stryker disable next-line StringLiteral,ObjectLiteral: diagnostic log args only
|
|
609
813
|
log.warn("Type mismatch on edge", {
|
|
610
814
|
source: edge.source,
|
|
611
815
|
target: edge.target,
|
|
612
816
|
sourceType,
|
|
613
817
|
targetType
|
|
614
818
|
});
|
|
615
|
-
throw new GraphValidationError(`Type mismatch on edge ${edge.id ??
|
|
819
|
+
throw new GraphValidationError(`Type mismatch on edge ${edge.id ?? syntheticEdgeId(edge.source, edge.sourceHandle, edge.target, edge.targetHandle)}: ` +
|
|
616
820
|
`source outputs "${sourceType}" but target expects "${targetType}"`);
|
|
617
821
|
}
|
|
618
822
|
}
|
|
@@ -637,6 +841,7 @@ export class Graph {
|
|
|
637
841
|
const c = color.get(neighbor) ?? WHITE;
|
|
638
842
|
if (c === GRAY)
|
|
639
843
|
return true; // back edge → cycle
|
|
844
|
+
// Stryker disable next-line ConditionalExpression,EqualityOperator: the `c === WHITE` guard only avoids redundant re-visits; cycles are still caught by the GRAY check above, so the detection result is unchanged
|
|
640
845
|
if (c === WHITE && dfs(neighbor))
|
|
641
846
|
return true;
|
|
642
847
|
}
|
|
@@ -644,8 +849,10 @@ export class Graph {
|
|
|
644
849
|
return false;
|
|
645
850
|
};
|
|
646
851
|
for (const node of adj.keys()) {
|
|
852
|
+
// Stryker disable next-line ConditionalExpression: equivalent — re-running dfs on an already-coloured node is redundant work with the same cycle-detection result
|
|
647
853
|
if ((color.get(node) ?? WHITE) === WHITE) {
|
|
648
854
|
if (dfs(node)) {
|
|
855
|
+
// Stryker disable next-line StringLiteral: diagnostic log message only
|
|
649
856
|
log.error("Graph contains a cycle in control edges");
|
|
650
857
|
throw new GraphValidationError("Graph contains a cycle in control edges");
|
|
651
858
|
}
|