Wolo/workflow fanin#819
Draft
wolo-lab wants to merge 1 commit into
Draft
Conversation
…i-activation
Adds explicit fan-in support to the workflow engine while preserving
adk-python's semantics for ordinary nodes (multiple incoming edges
on a non-Join node still fire it once per upstream completion).
Engine changes:
* Scheduler keys per-task state by a monotonically increasing
activationID instead of node name, so a node can have multiple
concurrent activations without overwriting each other's bookkeeping.
* Per-name FIFO trigger buffer serialises activations of the same
node, so JoinNode (and any custom WaitForOutput=true node) sees
per-predecessor activations one at a time and can safely
accumulate state.
* WaitForOutput honoured in handleCompletion: a completed activation
that produced no "output" event lands in NodeWaiting and skips
successor scheduling, deferring the join to the next predecessor.
* Per-(run,name) joinAccumulator created lazily on first activation
and cleared once the fan-in node emits its terminal output.
API additions:
* workflow.JoinNode + workflow.NewJoinNode: aggregates per-predecessor
inputs into a single map[string]any output once every predecessor
declared in the graph has fired. Forces Config().WaitForOutput=true
regardless of caller input.
* (*nodeContext).InNodes() exposes the static predecessor-name set
derived from the graph at construction; mirrors adk-python's
Context.in_nodes.
* graph.inNodeNamesOf for engine-internal predecessor lookup.
Validation:
* validateJoinNodesHaveIncoming + ErrJoinNodeNoIncoming reject
graphs whose JoinNode has zero incoming edges. adk-python defers
this to runtime; we surface it at workflow.New so misconstructed
graphs fail to build.
Tests:
* TestScheduler_MultiActivation_NonJoinNode_RunsTwice locks in the
Python-parity "no automatic merge" behaviour for ordinary nodes.
* TestScheduler_WaitForOutput_{StaysWaitingWithoutOutput,
EmittingOutputSchedulesSuccessors} cover both branches of the new
WaitForOutput path.
* TestScheduler_TriggerBuffer_SerialisesSameNameActivations asserts
the per-name FIFO contract JoinNode relies on.
* TestJoinNode_E2E_FanIn{Two,Three}Branches exercise the canonical
fan-in graph shapes from the API design doc.
* TestJoinNode_Run_DetachedYieldsDegenerateOutput keeps the node
usable in unit tests that exercise Run() outside the engine.
* TestJoinNode_Run_RejectsUnknownPredecessor + the validation tests
cover the error paths.
All existing tests still pass; the suite is race-free under
go test -race.
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
If applicable, please follow the issue templates to provide as much detail as
possible.
Problem:
A clear and concise description of what the problem is.
Solution:
A clear and concise description of what you want to happen and why you choose
this solution.
Testing Plan
Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.
Unit Tests:
Please include a summary of passed go test results.
Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.
Checklist
Additional context
Add any other context or screenshots about the feature request here.