feat(java): sub-workflow steps#333
Conversation
A step can submit a child workflow as a child run and complete when the child finalizes (failing if the child fails). The child is serialized into the node's metadata; the tracker submits it with a parent link and resolves the parent node when the child's run reaches a terminal state.
Child completes then parent continues; child failure fails the parent.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds nested sub-workflow support to Taskito. ChangesSub-workflow feature
Sequence Diagram(s)sequenceDiagram
participant WorkflowTracker
participant backend
participant ChildRun
WorkflowTracker->>WorkflowTracker: promote successor node (subWorkflow)
WorkflowTracker->>backend: submitWorkflow(childSpec)
backend-->>WorkflowTracker: childRunId
WorkflowTracker->>WorkflowTracker: store childRunPayloads and childToParent
ChildRun-->>WorkflowTracker: terminal state
WorkflowTracker->>WorkflowTracker: resolveSubWorkflowParent(parentRunId, parentNodeName, state)
WorkflowTracker->>WorkflowTracker: promote parent successors / finalize parent run
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.java`:
- Around line 479-503: encodeChild() currently serializes only step.payload
bytes and the wire condition string, so child workflows that rely on submit-time
payload injection via Workflow.stepAfter(...) or on condition(Condition) can
lose required runtime state. Update DefaultTaskito.encodeChild() to fail fast
when a child Step has payload == null or any non-wire condition metadata that
ChildSpec/tracker cannot preserve, using the existing encodeChild(), stepSpec(),
and deferredNodes() flow to locate the check. If support is intended, extend
ChildSpec and the tracker submission path to carry the missing payload/condition
metadata instead of silently dropping it.
In `@sdks/java/src/main/java/org/byteveda/taskito/workflows/WorkflowTracker.java`:
- Around line 286-299: The deferred payload registration in submitSubWorkflow()
is keyed by child.name, but lookup later flows through workflowName(runId), so
concurrent runs can overwrite each other and mix payload state. Update
WorkflowTracker to store child runtime/deferred payload state under the child
run id returned by backend.submitWorkflow (or another run-scoped key), and make
the deferred-node promotion path read from that run-scoped mapping instead of
the workflow name.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 120d76e7-4b3d-4158-84a2-4f0decc13e52
📒 Files selected for processing (6)
sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.javasdks/java/src/main/java/org/byteveda/taskito/workflows/PlanNode.javasdks/java/src/main/java/org/byteveda/taskito/workflows/Step.javasdks/java/src/main/java/org/byteveda/taskito/workflows/Workflow.javasdks/java/src/main/java/org/byteveda/taskito/workflows/WorkflowTracker.javasdks/java/src/test/java/org/byteveda/taskito/WorkflowSubWorkflowTest.java
3842dd2 to
dab4f88
Compare
Adds nested workflows to the Java SDK: a step can submit another
Workflowas a child run and complete (or fail) when that child finalizes.
API
Step.Builder.subWorkflow(Workflow child)— turns a step into a sub-workflow node.Workflow.subWorkflow(name, child, deps...)builder shortcut.Mechanics (host tracker, no new Rust seam)
a
ChildSpeccarrying the child's steps JSON + per-node payloads + deferred set.submitWorkflow(..., parentRunId, parentNodeName)seam) and parks the parentnode
RUNNING.finalizeIfTerminalresolves theparent node via
resolveWorkflowGate(succeeded)and advances the parent —same in-process resolution path gates use. No event bus, no Rust change.
Tests
WorkflowSubWorkflowTestcovers a child run completing the parent node and afailing child failing the parent.
Stacked on #332 (conditions); rebased onto master now that it merged.
Summary by CodeRabbit
New Features
subWorkflowstep option.Bug Fixes
Tests