Repository navigation
Explore codebase loop task - #20
Merged
Merged
Conversation
- Add LoopTask.java implementing FlowTask interface with loopOver (collection) and loopCount (fixed iterations) modes - Register LOOP task type in SPI descriptor file - Add test-loop.json demo flow definition Agent-Logs-Url: https://github.com/mytang0/brook/sessions/d425aa55-1b21-4472-9d6b-a9f2e21d2b7c Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
…heck Agent-Logs-Url: https://github.com/mytang0/brook/sessions/d425aa55-1b21-4472-9d6b-a9f2e21d2b7c Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ual exclusivity, output size - Per-iteration unique names: next() now returns deep-copied TaskDefs with names suffixed by __LOOP_<index>, preventing FlowExecutor's name-based deduplication from filtering out subsequent iterations - Engine evaluation: only invoke engineActuator.compute() when loopOverRaw is a String, not when it's already resolved to a List - Mutual exclusivity: doVerify() now rejects configs with both loopOver and loopCount set simultaneously - Output size: removed full loopOverValue collection from task output; currentItem is now resolved from the task's input on each iteration Agent-Logs-Url: https://github.com/mytang0/brook/sessions/486c704d-d9ca-4c67-9cf7-6fbf906d83ad Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…d update demo - Normalize loopOver to List: accept List, Collection, Iterable, and arrays - Update demo flow description to document per-iteration naming scheme - Add currentIndex reference to demo flow input Agent-Logs-Url: https://github.com/mytang0/brook/sessions/ab678ddb-0163-4230-94fe-65be4add261c Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
- Use Array.getLength/Array.get for both object and primitive arrays - Add explicit null check before instanceof chain to prevent NPE Agent-Logs-Url: https://github.com/mytang0/brook/sessions/ab678ddb-0163-4230-94fe-65be4add261c Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
…ted TaskDef renaming - Write resolved loopOverValue back to task input in getMappedTasks() so updateCurrentItem() can reliably index into it on subsequent iterations, even when the original loopOver was an engine expression or a non-List collection/array that was normalized - createIterationTaskDef now recursively renames all nested child TaskDefs (e.g., inside IF/SWITCH branches) by walking the input tree and suffixing any Map with "name"+"type" keys, preventing name collisions across iterations Agent-Logs-Url: https://github.com/mytang0/brook/sessions/36aeca0d-0e20-4bc5-936d-0c0072b7c987 Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…traversal Replace name-only matching (findPositionInLoopBody) with findNextTaskFromChildren() that delegates to flowExecutor.getNextTask() per child, following the IFTask/SwitchTask pattern. This properly supports nested control-flow tasks (IF/SWITCH/SUB_FLOW) inside the loop body. Also fixes broken syntax (stray code from previous commit) that prevented compilation, and removes unused helper methods (renameIterationTaskDefs, renameIterationTaskDefsRecursively, isTerminalObject, stripIterationSuffix, findPositionInLoopBody). Agent-Logs-Url: https://github.com/mytang0/brook/sessions/58e258ef-bca8-4e09-86a7-6ddf71090f6f Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
…s data Agent-Logs-Url: https://github.com/mytang0/brook/sessions/e70145ee-2113-4543-ac92-856bd4f04953 Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
Add LOOP task type to flow orchestration engine
…eter mappings
ParameterUtils.flowContext() now scans task instances for __LOOP_N-suffixed
names and injects unsuffixed aliases pointing to the latest iteration context.
This lets loop-body tasks use ${processItem.output.result} instead of the
hardcoded ${processItem__LOOP_0.output.result}. Non-suffixed tasks are never
shadowed. LOOP_INDEX_SEPARATOR made public for cross-package access.
Agent-Logs-Url: https://github.com/mytang0/brook/sessions/0840b969-932d-4bbf-80c7-c7aa75b346ba
Co-authored-by: mytang0 <29346818+mytang0@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new LOOP task type to Brook’s core task registry, introduces a LoopTask implementation to iterate over collections / counts within flows, and provides a demo flow showing how loop-body task names are suffixed for uniqueness.
Changes:
- Registered
LOOPas a core task type via the SPI mapping file. - Implemented
LoopTaskto drive per-iteration scheduling by suffixing loop-body task names. - Updated
ParameterUtils.flowContext()to alias loop-suffixed task contexts back to their base (unsuffixed) names, plus added a demo flowtest-loop.json.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| brook-demo/brook-demo-spring/src/main/resources/META-INF/flows/test-loop.json | Adds a demo flow showcasing LOOP usage and name suffixing/aliasing behavior. |
| brook-core/src/main/resources/META-INF/brook/xyz.mytang0.brook.spi.task.FlowTask | Registers the new LOOP task type to load LoopTask. |
| brook-core/src/main/java/xyz/mytang0/brook/core/utils/ParameterUtils.java | Adds loop-suffix aliasing in flow context to enable ${baseTaskName.output...} references. |
| brook-core/src/main/java/xyz/mytang0/brook/core/tasks/LoopTask.java | Implements LOOP task mapping and iteration-aware “next task” traversal with per-iteration task renaming. |
| brook-common/src/main/java/xyz/mytang0/brook/common/constants/TaskConstants.java | Introduces a shared constant for the loop iteration name separator. |
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.
This pull request introduces support for a new LOOP task type in the core task definitions and demonstrates its usage with a new flow example. The main focus is on enabling iteration over lists within flows, allowing child tasks to be executed for each item.
Core task system enhancements:
Added the LOOP task type to the core task registration in FlowTask, enabling flows to define iterative logic over collections.
Demo and documentation:
Added a new flow definition test-loop.json demonstrating the LOOP task, showing how to process each item in a list and how child task names are automatically suffixed for uniqueness.