( mgr: AgentManager, rootName: string )
| 250 | } |
| 251 | |
| 252 | export function collectCascadeVictims( |
| 253 | mgr: AgentManager, |
| 254 | rootName: string |
| 255 | ): TaskState[] { |
| 256 | const start = mgr.getTask(rootName); |
| 257 | if (!start) return []; |
| 258 | const out: TaskState[] = [start]; |
| 259 | const seen = new Set([rootName]); |
| 260 | const frontier = [rootName]; |
| 261 | while (frontier.length > 0) { |
| 262 | const cur = frontier.shift(); |
| 263 | if (cur === undefined) break; |
| 264 | for (const t of mgr.tasks) { |
| 265 | if (seen.has(t.name)) continue; |
| 266 | if (!t.dependsOn.includes(cur)) continue; |
| 267 | if (t.status !== "pending" && t.status !== "running") continue; |
| 268 | seen.add(t.name); |
| 269 | frontier.push(t.name); |
| 270 | out.push(t); |
| 271 | } |
| 272 | } |
| 273 | return out; |
| 274 | } |
| 275 | |
| 276 | export function collect(value: string, previous: string[]): string[] { |
| 277 | return [...previous, value]; |
no test coverage detected