fix(parallel): remove broken node-counting completion in parallel blocks#4045
fix(parallel): remove broken node-counting completion in parallel blocks#4045waleedlatif1 wants to merge 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 8c7b975. Configure here. |
Greptile SummaryThis PR removes a broken node-counting completion mechanism from parallel block execution. Previously, parallel completion was detected by counting node executions against Key changes:
Confidence Score: 5/5Safe to merge — the fix is correct, the cleanup is thorough, and all 662 existing tests pass. The broken counting mechanism is fully excised and the sentinel-end trigger is the right and only completion signal. All callers in node.ts are updated, the interface types are consistent, and the test fixtures are cleaned up. The only remaining item is a P2 suggestion for an explicit regression test for the conditional-path scenario, which does not block merge. apps/sim/executor/orchestrators/parallel.test.ts — could benefit from a regression test for the conditional-path bug scenario described in the PR.
|
| Filename | Overview |
|---|---|
| apps/sim/executor/orchestrators/parallel.ts | Core fix: removed counting fields from scope initialisation and simplified handleParallelBranchCompletion to void; clean and correct |
| apps/sim/executor/orchestrators/node.ts | Call sites updated to drop nodesInParallel arg and the count-based aggregation trigger; sentinel-end path unchanged and still calls aggregateParallelResults correctly |
| apps/sim/executor/execution/state.ts | Removed completedCount and totalExpectedNodes from ParallelScope interface; remaining fields are correct |
| apps/sim/executor/types.ts | Removed same two fields from the inline parallelExecutions map type in ExecutionContext; consistent with state.ts |
| apps/sim/executor/orchestrators/parallel.test.ts | Updated call signature; no new regression test for the conditional-path bug scenario described in the PR |
| apps/sim/executor/utils/iteration-context.test.ts | Removed completedCount/totalExpectedNodes from all fixture objects; mechanical cleanup, correct |
| apps/sim/executor/variables/resolvers/parallel.test.ts | Removed the two fields from createParallelScope helper; mechanical cleanup, correct |
Sequence Diagram
sequenceDiagram
participant E as EdgeProcessor
participant N as NodeExecutionOrchestrator
participant P as ParallelOrchestrator
participant S as ExecutionState
Note over E,S: Branch node execution (per branch, per node)
E->>N: executeNode(branchNode)
N->>S: execute block
S-->>N: output
N->>N: handleNodeCompletion(branchNode)
N->>P: handleParallelBranchCompletion(parallelId, nodeId, output)
P->>P: branchOutputs.set(branchIndex, output)
Note right of P: void — no count check
Note over E,S: Sentinel-end reached (all branches finished via DAG edges)
E->>N: executeNode(sentinel-end)
N->>N: handleParallelSentinel(sentinelType=end)
N->>P: aggregateParallelResults(parallelId)
P->>P: collect branchOutputs[0..N]
P->>S: setBlockOutput(parallelId, results)
P-->>N: ParallelAggregationResult
N-->>E: { results, sentinelEnd, selectedRoute: PARALLEL_EXIT }
Comments Outside Diff (1)
-
apps/sim/executor/orchestrators/parallel.test.ts, line 110-121 (link)Missing regression test for the bug scenario
The PR description explains the exact failure mode: when a branch follows a conditional path (error edge, condition gate), it executes fewer nodes than a "full" branch, so
completedCountnever reachedtotalExpectedNodes. The existing tests exercise the empty-distribution and callback-failure paths, but there is no test that verifies:- A parallel with N branches where at least one branch takes an early exit (e.g. an error edge skips a downstream node), and
- Aggregation still fires correctly via the sentinel-end — not via counting.
Adding such a test would prevent a future regression if someone reintroduces count-based logic. Something like:
it('aggregates results even when branches execute different numbers of nodes', async () => { // set up a parallel with 2 branches where branch-1 has fewer nodes executed // call handleParallelBranchCompletion for each executed node // call aggregateParallelResults (simulating sentinel-end trigger) // verify results contain both branches regardless of node counts })
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (1): Last reviewed commit: "fix(parallel): remove broken node-counti..." | Re-trigger Greptile
Summary
totalExpectedNodes = branchCount * allNodesInParallelto detect completion, which is wrong when branches have conditional paths (error edges, conditions)Type of Change
Testing
All 662 executor tests pass. Tested with parallel blocks containing error edges.
Checklist