MCPcopy
hub / github.com/simstudioai/sim / initializeQueue

Method initializeQueue

apps/sim/executor/execution/engine.ts:268–368  ·  view source on GitHub ↗
(triggerBlockId?: string)

Source from the content-addressed store, hash-verified

266 }
267
268 private initializeQueue(triggerBlockId?: string): void {
269 if (this.context.runFromBlockContext) {
270 const { startBlockId } = this.context.runFromBlockContext
271 this.execLogger.info('Initializing queue for run-from-block mode', {
272 startBlockId,
273 dirtySetSize: this.context.runFromBlockContext.dirtySet.size,
274 })
275 this.addToQueue(startBlockId)
276 return
277 }
278
279 const pendingBlocks = this.context.metadata.pendingBlocks
280 const remainingEdges = (this.context.metadata as any).remainingEdges
281
282 if (remainingEdges && Array.isArray(remainingEdges) && remainingEdges.length > 0) {
283 this.execLogger.info('Removing edges from resumed pause blocks', {
284 edgeCount: remainingEdges.length,
285 edges: remainingEdges,
286 })
287
288 for (const edge of remainingEdges) {
289 const targetNode = this.dag.nodes.get(edge.target)
290 if (!targetNode) continue
291
292 const sourceHandle = this.resolveRemainingEdgeHandle(edge)
293 if (sourceHandle === EDGE.ERROR) {
294 this.edgeManager.deactivateResumedEdge(edge.source, targetNode.id, sourceHandle)
295
296 if (
297 this.edgeManager.hasActivatedEdge(targetNode.id) &&
298 this.edgeManager.isNodeReady(targetNode)
299 ) {
300 this.execLogger.info('Convergence node ready after pruning resumed error edge', {
301 nodeId: targetNode.id,
302 })
303 this.addToQueue(targetNode.id)
304 }
305 continue
306 }
307
308 const hadEdge = targetNode.incomingEdges.has(edge.source)
309 targetNode.incomingEdges.delete(edge.source)
310 if (hadEdge) {
311 this.edgeManager.markNodeWithActivatedEdge(targetNode.id)
312 }
313
314 if (this.edgeManager.isNodeReady(targetNode)) {
315 this.execLogger.info('Node became ready after edge removal', { nodeId: targetNode.id })
316 this.addToQueue(targetNode.id)
317 }
318 }
319
320 this.execLogger.info('Edge removal complete, queued ready nodes', {
321 queueLength: this.readyQueue.length,
322 queuedNodes: this.readyQueue,
323 })
324
325 return

Callers 1

runMethod · 0.95

Calls 10

addToQueueMethod · 0.95
infoMethod · 0.80
deactivateResumedEdgeMethod · 0.80
hasActivatedEdgeMethod · 0.80
isNodeReadyMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected