feat(parallel): support nested parallel tasks with automatic flattening#150
feat(parallel): support nested parallel tasks with automatic flattening#150rileyhilliard merged 1 commit intomainfrom
Conversation
Allow parallel tasks to reference other parallel tasks. When rr encounters
a nested parallel reference, it flattens the task tree before execution.
Example:
test-opendata: {parallel: [opendata-1, opendata-2, opendata-3]}
test-backend: {parallel: [backend-1, backend-2, backend-3]}
test: {parallel: [test-opendata, test-backend, frontend]}
Running `rr test` expands to 7 tasks: opendata-1, opendata-2, opendata-3,
backend-1, backend-2, backend-3, frontend.
Features:
- Cycle detection prevents infinite recursion (A -> B -> A)
- Diamond dependencies are deduplicated (shared task runs once)
- --dry-run shows expanded task list
- No depth limit on nesting
This makes maintaining large parallel task groups much easier - add splits
to a subtask and parent tasks automatically include them.
Fixes #145
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Caution Review failedAn error occurred during the review process. Please try again later. WalkthroughThis PR introduces support for nested parallel tasks—allowing parallel tasks to reference other parallel tasks with automatic flattening. It includes cycle detection to prevent circular references, modifies the CLI to use flattened task lists, enhances dry-run visualization to show task expansion, and adds comprehensive documentation and tests. Changes
Sequence DiagramsequenceDiagram
actor User
participant CLI
participant Validator
participant Executor
User->>CLI: Execute parallel task (nested refs)
CLI->>Validator: ValidateParallelTasks() + detectParallelCycle()
Validator->>Validator: DFS cycle detection
alt Cycle detected
Validator-->>CLI: Error (circular reference)
CLI-->>User: Fail with guidance
else Valid config
Validator-->>CLI: ✓ Validation passed
CLI->>Validator: FlattenParallelTasks(task)
Validator->>Validator: Recursively expand nested refs
Validator->>Validator: Deduplicate expanded list
Validator-->>CLI: Flattened task list
CLI->>CLI: Build TaskInfo from flattened tasks
alt Dry-run mode
CLI->>CLI: Render expansion details<br/>(original refs + nested subtasks)
CLI-->>User: Display expansion preview
else Execute
CLI->>Executor: Execute flattened tasks in parallel
Executor->>Executor: Run all expanded tasks
Executor-->>User: Results
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes The changes introduce substantial new logic in the validation layer (cycle detection via DFS, recursive flattening with deduplication), modify CLI execution flow to integrate flattened results, and affect both happy-path and error-handling routes. While well-tested, the cycle detection algorithm and flattening correctness require careful verification, especially around edge cases like diamond dependencies and circular references. Possibly related PRs
Comment |
Summary
Example
Running
rr testexpands to:opendata-1,opendata-2,opendata-3,backend-1,backend-2,backend-3,frontendBenefits
rr test-opendatafor just opendata splitsrr testfor everythingtest-opendataandtestautomatically includes it--dry-runshows the expanded task listTest plan
FlattenParallelTasksfunctionFixes #145
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.