/** * Concurrent-construct execution (spec §3.4/§3.5/§3.6/§8.6/§9.5, P3): `.parallel` and * `.foreach(concurrency > 1)`. Split out of execute.ts purely for file size — this is the mutually * recursive OTHER half of the same node walker. It needs to recurse back into execute.ts's * `runNodeSequence`/`runStepNode`/`leafNameOf` (a foreach item's/parallel arm's body is walked by the * former; a parallel arm itself by the latter), which execute.ts passes in as a `NodeWalker` (see * context.ts) rather than this file importing them — keeping the dependency one-directional * (execute.ts → here) instead of an import cycle. * * Every arm/item runs through the scheduler seam (scheduler.ts), bounded by this construct's own local * cap (a foreach's declared `concurrency`; the run's ceiling for a parallel, which declares none). The * run-wide ceiling itself is held one level down, by each STEP (`runStepNode`, execute.ts), so that * constructs can nest without a construct ever waiting for a slot it is itself occupying — see * scheduler.ts's header. Blocking (spec §8.6) suspends only its own arm — settling immediately with * its `questionnaire-asked` already recorded — while siblings keep running through the SAME pool. A * crash drains (spec §9.5): no new arms start, in-flight ones finish naturally, and any sibling that is * ALREADY blocked in the same round is abandoned (`step-cancelled`), not waited on. Resuming into a * construct with several simultaneously-blocked arms re-enters exactly the target, leaves every OTHER * still-blocked sibling untouched, and reports the next pending one (if any) rather than the whole * construct's assembled output. * * `.foreach(concurrency === 1)` (the default) keeps its EXACT pre-P3 sequential code path — spec * requires concurrency-1 behaviour stay unchanged, so it is not a degenerate case of the concurrent * path below, it is the same code that shipped before this phase. * * Zero imports from PI, `node:fs`, or any network lib — see src/engine/types.ts. */ import type { ForeachNode, ParallelNode } from "../flow/types.ts"; import { type ExecOutcome, type NodeWalker, type Reentry, type RunState } from "./context.ts"; import { type NodePath } from "./node-path.ts"; import type { HostPort } from "./types.ts"; /** * Foreach: run the body once per selected item, with the item as input. Output is the per-item outputs * in order, regardless of completion order. Per-item checkpoint (spec §8.2): `state.foreachItemHistory` * (built once at resume start from `foreach-item-completed` events) lets THIS foreach — wherever it * sits in the tree — skip every item already recorded, whether resuming node-atomically (no `reentry`, * spec §8.2/§8.3) or re-entering a deeper block inside a still-in-flight item (spec §8.5). */ export declare function runForeachNode(walker: NodeWalker, node: ForeachNode, host: HostPort, state: RunState, signal: AbortSignal, parentPath: NodePath, reentry?: Reentry): Promise; /** * Parallel: structural fan-out over independent steps, all run concurrently through the shared run-wide * gate (spec §3.6) — no local cap beyond the arm count itself. Output is keyed by each arm's own step * name, independent of completion order. Arms nest under the parallel's own path segment * (`parallelName/armName`), like a loop/foreach body — not peers, unlike branch arms. Re-entry (a * blocked arm being answered) mirrors the concurrent-foreach re-entry: recover completed siblings from * `stepOutputs`, leave still-blocked ones (`state.pendingBlocks`) untouched, resolve the target, and * report the next pending sibling (if any) rather than the whole construct's output. */ export declare function runParallelNode(walker: NodeWalker, node: ParallelNode, input: unknown, host: HostPort, state: RunState, signal: AbortSignal, parentPath: NodePath, reentry?: Reentry): Promise; //# sourceMappingURL=concurrent-nodes.d.ts.map