fix(tasks): forkTaskJoin generates a JOIN with empty joinOn - #161
Open
samarth70 wants to merge 1 commit into
Open
fix(tasks): forkTaskJoin generates a JOIN with empty joinOn#161samarth70 wants to merge 1 commit into
samarth70 wants to merge 1 commit into
Conversation
forkTaskJoin() built its JOIN via generateJoinTask() without passing joinOn, so the task shipped with joinOn: []. The server evaluates the join with joinOn.stream().allMatch(...), and allMatch() short-circuits to true on an empty stream, so the JOIN reached COMPLETED on its first evaluation without waiting for any fork branch. Downstream tasks then ran while the branches were still in progress. Derive joinOn from the generated fork branches, taking the last task reference of each branch, so the JOIN blocks until every branch has finished. Reading it back off the ForkJoinTaskDef keeps it correct if forkTask() later emits more than one branch. factory.test.ts asserted joinOn: [] and so locked in the broken behaviour; it now expects the branch's last task reference. Added cases for a multi-task branch and for an empty fork task list. Fixes conductor-oss#135
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #135.
Problem
forkTaskJoin()builds its JOIN throughgenerateJoinTask()without passingjoinOn, so the generated task carriesjoinOn: []:The server evaluates a JOIN with
joinOn.stream().allMatch(...), andallMatch()short-circuits totrueon an empty stream. So the JOIN reachesCOMPLETEDthe first time it is evaluated, without waiting for any fork branch. The branches keep running, but the workflow moves on past the join, which is the one thing a JOIN exists to prevent.As reported in #135, against Conductor OSS 3.32.0-rc.9 with a 10s WAIT branch:
Fix
Derive
joinOnfrom the fork branches that were just generated, taking the last task reference of each branch:Reading the branches back off the
ForkJoinTaskDefrather than off the flatforkTasksargument means this stays correct ifforkTask()later emits more than one branch (the multi-branch limitation tracked in #94) - no second fix needed there.An empty fork task list still yields
joinOn: [], since there is nothing to wait for.Tests
factory.test.tsassertedjoinOn: []and therefore locked in the broken behaviour; it now expects the branch's last task reference. Two cases added: a multi-task branch, and an empty fork task list.Verified both directions:
Should return a tuple with both fork and joinandShould join on the last task of each fork branchfail (Expected ["forkTaskJoin"],Received []).npm run test:unit-> 1568 passed. The single failure insrc/agents/__tests__/skill.test.ts(read_skill_file worker) reproduces on a clean checkout ofmainand is unrelated to this change.npx eslintclean on both touched files.Diff is +26/-5 across two files.