orchestr8 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.blueprint/features/feature_parallel-abort/FEATURE_SPEC.md +117 -0
- package/.blueprint/features/feature_parallel-confirm/FEATURE_SPEC.md +90 -0
- package/.blueprint/features/feature_parallel-features/FEATURE_SPEC.md +291 -0
- package/.blueprint/features/feature_parallel-features/IMPLEMENTATION_PLAN.md +73 -0
- package/.blueprint/features/feature_parallel-lock/FEATURE_SPEC.md +119 -0
- package/.blueprint/features/feature_parallel-logging/FEATURE_SPEC.md +105 -0
- package/.blueprint/features/feature_parallel-preflight/FEATURE_SPEC.md +141 -0
- package/README.md +218 -0
- package/bin/cli.js +159 -0
- package/package.json +1 -1
- package/src/parallel.js +1544 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Feature Specification — Parallel Abort
|
|
2
|
+
|
|
3
|
+
## 1. Feature Intent
|
|
4
|
+
|
|
5
|
+
Provide a way to stop all running parallel pipelines and optionally clean up worktrees. Users need an escape hatch if something goes wrong or they need to stop execution mid-way.
|
|
6
|
+
|
|
7
|
+
**Problem:** Once parallel pipelines start, there's no clean way to stop them. Users would have to manually find and kill processes, then clean up worktrees.
|
|
8
|
+
|
|
9
|
+
**Solution:** `orchestr8 parallel abort` command that gracefully stops all pipelines and handles cleanup.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 2. Scope
|
|
14
|
+
|
|
15
|
+
### In Scope
|
|
16
|
+
- Stop all running pipeline processes
|
|
17
|
+
- Update queue state to 'aborted'
|
|
18
|
+
- Option to preserve or remove worktrees
|
|
19
|
+
- Handle Ctrl+C in main process
|
|
20
|
+
- Clear status reporting
|
|
21
|
+
|
|
22
|
+
### Out of Scope
|
|
23
|
+
- Selective abort (single feature) — future enhancement
|
|
24
|
+
- Rollback of completed merges
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 3. Behaviour Overview
|
|
29
|
+
|
|
30
|
+
### Abort (Preserve Worktrees)
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ orchestr8 parallel abort
|
|
34
|
+
|
|
35
|
+
Stopping parallel pipelines...
|
|
36
|
+
|
|
37
|
+
[10:35:01] feat-a: Stopping process (PID: 12345)
|
|
38
|
+
[10:35:01] feat-b: Stopping process (PID: 12346)
|
|
39
|
+
[10:35:02] feat-a: Stopped
|
|
40
|
+
[10:35:02] feat-b: Stopped
|
|
41
|
+
|
|
42
|
+
Aborted 2 pipelines. Worktrees preserved for debugging:
|
|
43
|
+
• .claude/worktrees/feat-feat-a/
|
|
44
|
+
• .claude/worktrees/feat-feat-b/
|
|
45
|
+
|
|
46
|
+
To clean up: orchestr8 parallel cleanup
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Abort with Cleanup
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
$ orchestr8 parallel abort --cleanup
|
|
53
|
+
|
|
54
|
+
Stopping parallel pipelines...
|
|
55
|
+
|
|
56
|
+
[10:35:01] feat-a: Stopping process (PID: 12345)
|
|
57
|
+
[10:35:02] feat-a: Stopped
|
|
58
|
+
[10:35:02] feat-a: Removing worktree
|
|
59
|
+
|
|
60
|
+
Aborted 1 pipeline. Worktrees removed.
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Ctrl+C Handling
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
$ orchestr8 parallel feat-a feat-b feat-c
|
|
67
|
+
|
|
68
|
+
Starting parallel pipelines...
|
|
69
|
+
[10:30:01] feat-a: Started
|
|
70
|
+
[10:30:02] feat-b: Started
|
|
71
|
+
|
|
72
|
+
^C
|
|
73
|
+
Received interrupt signal. Stopping pipelines...
|
|
74
|
+
|
|
75
|
+
[10:31:15] feat-a: Stopped
|
|
76
|
+
[10:31:15] feat-b: Stopped
|
|
77
|
+
|
|
78
|
+
Aborted. Worktrees preserved. Run 'orchestr8 parallel cleanup' to remove.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Nothing Running
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
$ orchestr8 parallel abort
|
|
85
|
+
|
|
86
|
+
No parallel pipelines are currently running.
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 4. Implementation Notes
|
|
92
|
+
|
|
93
|
+
- Read PIDs from queue file or lock file
|
|
94
|
+
- Send SIGTERM first, then SIGKILL after timeout
|
|
95
|
+
- Update queue state for each feature to 'aborted'
|
|
96
|
+
- Register handler for SIGINT (Ctrl+C) in main process
|
|
97
|
+
- `--cleanup` flag triggers worktree removal after abort
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 5. Test Themes
|
|
102
|
+
|
|
103
|
+
- Abort stops running processes
|
|
104
|
+
- Queue state updated to 'aborted'
|
|
105
|
+
- Worktrees preserved by default
|
|
106
|
+
- `--cleanup` removes worktrees
|
|
107
|
+
- Ctrl+C triggers graceful shutdown
|
|
108
|
+
- No-op when nothing running
|
|
109
|
+
- Lock file removed after abort
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 6. Change Log
|
|
114
|
+
|
|
115
|
+
| Date | Change | Reason |
|
|
116
|
+
|------|--------|--------|
|
|
117
|
+
| 2026-02-25 | Initial spec | Parallel safeguards |
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Feature Specification — Parallel Confirm
|
|
2
|
+
|
|
3
|
+
## 1. Feature Intent
|
|
4
|
+
|
|
5
|
+
Prevent accidental execution of parallel pipelines by requiring user confirmation before starting. Users should see exactly what will happen (worktrees created, pipelines spawned, estimated resources) and explicitly confirm they want to proceed.
|
|
6
|
+
|
|
7
|
+
**Problem:** Running `orchestr8 parallel feat-a feat-b feat-c` immediately starts creating worktrees and spawning processes. Users might run this accidentally or without understanding the impact.
|
|
8
|
+
|
|
9
|
+
**Solution:** Show a summary and prompt for confirmation before execution.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 2. Scope
|
|
14
|
+
|
|
15
|
+
### In Scope
|
|
16
|
+
- Confirmation prompt showing execution plan
|
|
17
|
+
- `--yes` / `-y` flag to skip confirmation (for automation)
|
|
18
|
+
- Clear summary of what will happen
|
|
19
|
+
|
|
20
|
+
### Out of Scope
|
|
21
|
+
- Interactive editing of the plan
|
|
22
|
+
- Cost estimation (separate feature)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 3. Behaviour Overview
|
|
27
|
+
|
|
28
|
+
### Happy Path
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
$ orchestr8 parallel user-auth dashboard notifications
|
|
32
|
+
|
|
33
|
+
This will:
|
|
34
|
+
• Create 3 git worktrees in .claude/worktrees/
|
|
35
|
+
• Start 3 parallel pipelines (max concurrent: 3)
|
|
36
|
+
• Branches: feature/user-auth, feature/dashboard, feature/notifications
|
|
37
|
+
|
|
38
|
+
Continue? [y/N] y
|
|
39
|
+
|
|
40
|
+
Starting parallel pipelines...
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Skip Confirmation
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
$ orchestr8 parallel user-auth dashboard --yes
|
|
47
|
+
Starting parallel pipelines...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### User Declines
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
$ orchestr8 parallel user-auth dashboard
|
|
54
|
+
|
|
55
|
+
This will:
|
|
56
|
+
• Create 2 git worktrees in .claude/worktrees/
|
|
57
|
+
• Start 2 parallel pipelines (max concurrent: 3)
|
|
58
|
+
|
|
59
|
+
Continue? [y/N] n
|
|
60
|
+
|
|
61
|
+
Aborted.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 4. Implementation Notes
|
|
67
|
+
|
|
68
|
+
- Add confirmation logic after dry-run check, before actual execution
|
|
69
|
+
- Use `readline` for prompt in Node.js
|
|
70
|
+
- Check `options.yes` flag to skip
|
|
71
|
+
- Exit with code 0 on user abort (not an error)
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 5. Test Themes
|
|
76
|
+
|
|
77
|
+
- Confirmation shown by default
|
|
78
|
+
- `--yes` flag skips confirmation
|
|
79
|
+
- `-y` shorthand works
|
|
80
|
+
- User typing 'n' or Enter aborts
|
|
81
|
+
- User typing 'y' or 'Y' proceeds
|
|
82
|
+
- Abort exits cleanly (code 0)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 6. Change Log
|
|
87
|
+
|
|
88
|
+
| Date | Change | Reason |
|
|
89
|
+
|------|--------|--------|
|
|
90
|
+
| 2026-02-25 | Initial spec | Parallel safeguards |
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Feature Specification — Parallel Features
|
|
2
|
+
|
|
3
|
+
## 1. Feature Intent
|
|
4
|
+
|
|
5
|
+
**Why this feature exists.**
|
|
6
|
+
|
|
7
|
+
orchestr8 currently processes features sequentially through the Alex, Cass, Nigel, Codey pipeline. For projects with large backlogs, this creates a bottleneck: only one feature can be in progress at any time. The system specification explicitly notes this as a known limitation: "Pipeline is sequential; no parallel agent execution" and "Single-feature focus; no batch processing" (see `.blueprint/system_specification/SYSTEM_SPEC.md` Section 10).
|
|
8
|
+
|
|
9
|
+
This feature enables **parallel execution of multiple feature pipelines** using git worktrees for isolation. Each feature runs in its own worktree/branch, allowing simultaneous development. Results are merged back to the main branch when complete.
|
|
10
|
+
|
|
11
|
+
**Problem being addressed:**
|
|
12
|
+
- Sequential processing is slow for large backlogs
|
|
13
|
+
- Users with multiple features to implement must wait for each to complete
|
|
14
|
+
- Development throughput is constrained by single-feature pipeline design
|
|
15
|
+
|
|
16
|
+
**User need:**
|
|
17
|
+
- Developers want to queue multiple features and have them processed concurrently
|
|
18
|
+
- Teams want faster turnaround on feature backlogs
|
|
19
|
+
|
|
20
|
+
**Alignment with system purpose:**
|
|
21
|
+
- Extends the core pipeline without modifying agent behaviour
|
|
22
|
+
- Maintains specification-first, test-driven approach per feature
|
|
23
|
+
- Preserves traceability and artifact integrity within each worktree
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. Scope
|
|
28
|
+
|
|
29
|
+
### In Scope
|
|
30
|
+
|
|
31
|
+
- New CLI command: `orchestr8 parallel <slug1> <slug2> ... <slugN>`
|
|
32
|
+
- Git worktree creation per feature (one worktree = one feature)
|
|
33
|
+
- Independent pipeline execution in each worktree
|
|
34
|
+
- Merge strategy for completed features back to main branch
|
|
35
|
+
- Queue management for parallel pipelines
|
|
36
|
+
- Status reporting across parallel executions
|
|
37
|
+
- Conflict detection and handling on merge
|
|
38
|
+
|
|
39
|
+
### Out of Scope
|
|
40
|
+
|
|
41
|
+
- Parallelisation within a single feature pipeline (agents remain sequential per feature)
|
|
42
|
+
- Cross-feature dependency resolution during parallel execution
|
|
43
|
+
- CI/CD integration for parallel pipelines
|
|
44
|
+
- IDE integration for worktree management
|
|
45
|
+
- Custom merge strategies beyond standard git merge
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. Actors Involved
|
|
50
|
+
|
|
51
|
+
### Human User
|
|
52
|
+
- **Can do:** Invoke parallel command with multiple feature slugs, monitor progress, resolve merge conflicts, abort individual pipelines
|
|
53
|
+
- **Cannot do:** Run parallel pipelines without git repository, modify running pipeline's worktree directly without risking state corruption
|
|
54
|
+
|
|
55
|
+
### orchestr8 CLI
|
|
56
|
+
- **Can do:** Create/manage worktrees, spawn parallel pipelines, merge completed features, report status
|
|
57
|
+
- **Cannot do:** Automatically resolve merge conflicts (escalates to user)
|
|
58
|
+
|
|
59
|
+
### Agent Pipeline (per worktree)
|
|
60
|
+
- **Can do:** Execute standard Alex, Cass, Nigel, Codey flow in isolation
|
|
61
|
+
- **Cannot do:** Access or modify other worktrees, communicate with parallel pipeline instances
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 4. Behaviour Overview
|
|
66
|
+
|
|
67
|
+
### Happy Path
|
|
68
|
+
|
|
69
|
+
1. User invokes `orchestr8 parallel feat-a feat-b feat-c`
|
|
70
|
+
2. System validates git repository state (clean working tree, on main/target branch)
|
|
71
|
+
3. For each feature slug:
|
|
72
|
+
- Create git worktree at `.claude/worktrees/feat-{slug}`
|
|
73
|
+
- Create new branch `feature/{slug}` from current HEAD
|
|
74
|
+
- Initialize pipeline queue in worktree
|
|
75
|
+
4. Spawn parallel pipeline processes (one per worktree)
|
|
76
|
+
5. Each pipeline executes independently: Alex, Cass, Nigel, Codey
|
|
77
|
+
6. As each completes:
|
|
78
|
+
- Merge feature branch back to main (fast-forward when possible)
|
|
79
|
+
- Remove worktree
|
|
80
|
+
- Update aggregate status
|
|
81
|
+
7. Report final status: completed, failed, merge conflicts
|
|
82
|
+
|
|
83
|
+
### Key Alternatives
|
|
84
|
+
|
|
85
|
+
- **Merge conflict:** Pipeline completes but merge fails. Feature branch preserved, user notified, manual resolution required.
|
|
86
|
+
- **Pipeline failure:** Individual feature fails. Other pipelines continue. Failed worktree preserved for debugging.
|
|
87
|
+
- **User abort:** Single feature or all features can be aborted. Aborted worktrees are cleaned up.
|
|
88
|
+
|
|
89
|
+
### User-Visible Outcomes
|
|
90
|
+
|
|
91
|
+
- Multiple features processed simultaneously (wall-clock time reduction)
|
|
92
|
+
- Independent commits per feature on main branch
|
|
93
|
+
- Clear status reporting per feature
|
|
94
|
+
- Preserved worktrees on failure for inspection
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 5. State & Lifecycle Interactions
|
|
99
|
+
|
|
100
|
+
### States Introduced
|
|
101
|
+
|
|
102
|
+
| State | Description |
|
|
103
|
+
|-------|-------------|
|
|
104
|
+
| **parallel_queued** | Feature slug accepted for parallel processing |
|
|
105
|
+
| **worktree_created** | Git worktree and branch created for feature |
|
|
106
|
+
| **parallel_running** | Pipeline executing in worktree |
|
|
107
|
+
| **merge_pending** | Pipeline complete, awaiting merge to main |
|
|
108
|
+
| **merge_conflict** | Merge attempted but conflicts detected |
|
|
109
|
+
| **parallel_complete** | Feature merged successfully |
|
|
110
|
+
| **parallel_failed** | Pipeline or merge failed |
|
|
111
|
+
|
|
112
|
+
### State Transitions
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
parallel_queued → worktree_created → parallel_running → merge_pending
|
|
116
|
+
↓ ↓
|
|
117
|
+
parallel_failed ┌──────────────┐
|
|
118
|
+
↓ │merge_conflict│
|
|
119
|
+
(preserve worktree)└──────────────┘
|
|
120
|
+
↓
|
|
121
|
+
(user resolves)
|
|
122
|
+
↓
|
|
123
|
+
parallel_complete
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### This Feature Is
|
|
127
|
+
|
|
128
|
+
- **State-creating:** Introduces parallel pipeline state model
|
|
129
|
+
- **State-transitioning:** Manages transitions through parallel lifecycle
|
|
130
|
+
- **State-constraining:** Enforces clean git state before starting
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 6. Rules & Decision Logic
|
|
135
|
+
|
|
136
|
+
### Rule: Worktree Isolation
|
|
137
|
+
|
|
138
|
+
- **Description:** Each feature runs in an isolated git worktree
|
|
139
|
+
- **Inputs:** Feature slug, current git HEAD
|
|
140
|
+
- **Outputs:** Worktree path, branch name
|
|
141
|
+
- **Deterministic:** Yes - same slug always produces same paths
|
|
142
|
+
|
|
143
|
+
### Rule: Concurrency Limit
|
|
144
|
+
|
|
145
|
+
- **Description:** Maximum number of concurrent pipelines (default: 3, configurable)
|
|
146
|
+
- **Inputs:** Requested feature count, `maxConcurrency` setting
|
|
147
|
+
- **Outputs:** Number of pipelines to spawn, remaining queued
|
|
148
|
+
- **Deterministic:** Yes - capped at limit, overflow queued
|
|
149
|
+
|
|
150
|
+
### Rule: Merge Order
|
|
151
|
+
|
|
152
|
+
- **Description:** Features merge in completion order (first finished, first merged)
|
|
153
|
+
- **Inputs:** Completion timestamps per feature
|
|
154
|
+
- **Outputs:** Merge sequence
|
|
155
|
+
- **Deterministic:** No - depends on pipeline execution time
|
|
156
|
+
|
|
157
|
+
### Rule: Conflict Escalation
|
|
158
|
+
|
|
159
|
+
- **Description:** Merge conflicts escalate to user rather than auto-resolve
|
|
160
|
+
- **Inputs:** Git merge result
|
|
161
|
+
- **Outputs:** Success or conflict report with preserved branch
|
|
162
|
+
- **Deterministic:** Yes - conflicts always escalate
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 7. Dependencies
|
|
167
|
+
|
|
168
|
+
### System Components
|
|
169
|
+
|
|
170
|
+
- Git (worktree support requires git 2.5+)
|
|
171
|
+
- orchestr8 queue management (`src/orchestrator.js`)
|
|
172
|
+
- Pipeline execution (`SKILL.md` / implement-feature)
|
|
173
|
+
- Node.js child process spawning
|
|
174
|
+
|
|
175
|
+
### Technical Dependencies
|
|
176
|
+
|
|
177
|
+
- Clean git working tree (uncommitted changes block parallel start)
|
|
178
|
+
- Sufficient disk space for worktrees (each is a full checkout)
|
|
179
|
+
- Available system processes for concurrent execution
|
|
180
|
+
|
|
181
|
+
### Operational Dependencies
|
|
182
|
+
|
|
183
|
+
- Network access if agents require external resources
|
|
184
|
+
- Claude API availability for all parallel pipelines
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 8. Non-Functional Considerations
|
|
189
|
+
|
|
190
|
+
### Performance
|
|
191
|
+
|
|
192
|
+
- Pipeline execution time reduced by parallelism factor (N features in ~1 pipeline time vs N x pipeline time)
|
|
193
|
+
- Disk space increases linearly with concurrent worktrees
|
|
194
|
+
- Memory/CPU scales with concurrent agent processes
|
|
195
|
+
|
|
196
|
+
### Observability
|
|
197
|
+
|
|
198
|
+
- Aggregate status command: `orchestr8 parallel status`
|
|
199
|
+
- Per-feature status visible in each worktree's queue file
|
|
200
|
+
- Completion/failure notifications per feature
|
|
201
|
+
|
|
202
|
+
### Error Handling
|
|
203
|
+
|
|
204
|
+
- Pipeline failures isolated to single worktree
|
|
205
|
+
- Failed worktrees preserved for debugging (not auto-cleaned)
|
|
206
|
+
- Partial success possible (some features complete, others fail)
|
|
207
|
+
|
|
208
|
+
### Resource Management
|
|
209
|
+
|
|
210
|
+
- Worktrees cleaned up on success
|
|
211
|
+
- Failed/conflict worktrees require manual cleanup or `--cleanup` flag
|
|
212
|
+
- Queue tracks worktree locations for recovery
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 9. Assumptions & Open Questions
|
|
217
|
+
|
|
218
|
+
### Assumptions
|
|
219
|
+
|
|
220
|
+
- Users have git 2.5+ installed (worktree support)
|
|
221
|
+
- Working tree is clean before invoking parallel command
|
|
222
|
+
- Sufficient disk space for N concurrent worktrees
|
|
223
|
+
- Features are independent (no cross-feature code dependencies)
|
|
224
|
+
- Main branch is the merge target (configurable?)
|
|
225
|
+
|
|
226
|
+
### Open Questions
|
|
227
|
+
|
|
228
|
+
1. **Merge strategy:** Should we support squash merge, rebase, or merge commit options?
|
|
229
|
+
2. **Failure handling:** Should failed features block others from merging, or proceed independently?
|
|
230
|
+
3. **Resource limits:** What is a sensible default for maxConcurrency? (Proposed: 3)
|
|
231
|
+
4. **Progress reporting:** Real-time progress per worktree, or periodic aggregate status?
|
|
232
|
+
5. **Branch naming:** Should branch names be configurable, or always `feature/{slug}`?
|
|
233
|
+
6. **Cleanup policy:** Auto-cleanup failed worktrees after N days, or require explicit cleanup?
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 10. Impact on System Specification
|
|
238
|
+
|
|
239
|
+
### Reinforces Existing Assumptions
|
|
240
|
+
|
|
241
|
+
- Maintains agent role boundaries (each agent behaves identically in worktree)
|
|
242
|
+
- Preserves artifact structure (same paths, just in worktree)
|
|
243
|
+
- Keeps sequential agent flow per feature
|
|
244
|
+
|
|
245
|
+
### Stretches Existing Assumptions
|
|
246
|
+
|
|
247
|
+
- Queue model expands: system-level parallel queue + per-worktree queues
|
|
248
|
+
- "Single current feature" invariant becomes "single current feature per worktree"
|
|
249
|
+
- Recovery now spans multiple worktrees
|
|
250
|
+
|
|
251
|
+
### Tensions Requiring Decision
|
|
252
|
+
|
|
253
|
+
**Tension 1:** System spec states "Single current: Only one feature can be current at a time" (Section 7). This feature introduces multiple concurrent "current" features across worktrees.
|
|
254
|
+
|
|
255
|
+
**Proposed resolution:** Reframe the invariant: "Only one feature can be current per pipeline instance (worktree)." The parallel orchestrator manages multiple pipeline instances, each respecting the single-current invariant internally.
|
|
256
|
+
|
|
257
|
+
**Tension 2:** System spec notes "Pipeline is sequential" as a known limitation. This feature partially addresses this at the feature level but not the agent level.
|
|
258
|
+
|
|
259
|
+
**Proposed resolution:** Update Known Limitations section to distinguish "sequential agents within feature" (unchanged) from "sequential features across pipeline" (now optional via parallel mode).
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## 11. Handover to BA (Cass)
|
|
264
|
+
|
|
265
|
+
### Story Themes
|
|
266
|
+
|
|
267
|
+
1. **Parallel invocation:** User starts multiple features in parallel mode
|
|
268
|
+
2. **Worktree lifecycle:** Creation, isolation, and cleanup of worktrees
|
|
269
|
+
3. **Status monitoring:** User tracks progress across parallel pipelines
|
|
270
|
+
4. **Merge handling:** Successful merges and conflict resolution
|
|
271
|
+
5. **Failure recovery:** Handling failed pipelines without blocking others
|
|
272
|
+
|
|
273
|
+
### Expected Story Boundaries
|
|
274
|
+
|
|
275
|
+
- Each story should cover one actor's interaction with one lifecycle phase
|
|
276
|
+
- Merge conflict story should be separate from happy-path merge
|
|
277
|
+
- Status reporting could be its own story
|
|
278
|
+
|
|
279
|
+
### Areas Needing Careful Story Framing
|
|
280
|
+
|
|
281
|
+
- **Concurrency limits:** Story should clarify what happens when user requests more features than maxConcurrency
|
|
282
|
+
- **Partial failure:** What user actions are available when some features succeed and others fail?
|
|
283
|
+
- **Cleanup:** When and how are worktrees removed? Manual vs automatic?
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 12. Change Log (Feature-Level)
|
|
288
|
+
|
|
289
|
+
| Date | Change | Reason | Raised By |
|
|
290
|
+
|------|--------|--------|-----------|
|
|
291
|
+
| 2026-02-25 | Initial feature specification | Feature proposed in FEATURE_IDEAS.md | Alex |
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Implementation Plan - Parallel Features
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Implement a new `src/parallel.js` module that enables concurrent execution of multiple feature pipelines using git worktrees for isolation. The module provides functions for worktree management, pre-flight validation, concurrency control, merge handling, status reporting, and state management. CLI integration adds `parallel` and `parallel status` commands to `bin/cli.js`.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Files to Create/Modify
|
|
10
|
+
|
|
11
|
+
| Path | Action | Purpose |
|
|
12
|
+
|------|--------|---------|
|
|
13
|
+
| `src/parallel.js` | Create | Core parallel execution module with all exported functions |
|
|
14
|
+
| `bin/cli.js` | Modify | Add `parallel` and `parallel status` command routing |
|
|
15
|
+
| `.claude/parallel-queue.json` | Runtime | State persistence for parallel pipelines (auto-created) |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Implementation Steps
|
|
20
|
+
|
|
21
|
+
1. **Create `src/parallel.js` with utility functions**
|
|
22
|
+
- `buildWorktreePath(slug)` - returns `.claude/worktrees/feat-{slug}`
|
|
23
|
+
- `buildBranchName(slug)` - returns `feature/{slug}`
|
|
24
|
+
- `getDefaultConfig()` - returns `{ maxConcurrency: 3 }`
|
|
25
|
+
- `getQueuePath(worktreePath)` - returns worktree-specific queue file path
|
|
26
|
+
|
|
27
|
+
2. **Add pre-flight validation functions**
|
|
28
|
+
- `validatePreFlight({ isGitRepo, isDirty, gitVersion })` - returns `{ valid, errors }`
|
|
29
|
+
- `isGitVersionSupported(versionString)` - parses version, returns true if >= 2.5.0
|
|
30
|
+
|
|
31
|
+
3. **Implement concurrency control**
|
|
32
|
+
- `splitByLimit(slugs, maxConcurrency)` - returns `{ active, queued }`
|
|
33
|
+
- `promoteFromQueue(state)` - moves first queued item to active when below limit
|
|
34
|
+
|
|
35
|
+
4. **Add worktree lifecycle helpers**
|
|
36
|
+
- `shouldCleanupWorktree(state)` - returns true for `parallel_complete` or `aborted`, false for `parallel_failed` or `merge_conflict`
|
|
37
|
+
|
|
38
|
+
5. **Implement merge handling functions**
|
|
39
|
+
- `canFastForward({ mainHead, branchBase })` - returns boolean
|
|
40
|
+
- `hasMergeConflict(gitOutput)` - detects "CONFLICT" in output
|
|
41
|
+
- `handleMergeConflict(state, conflictOutput?)` - transitions to `merge_conflict` status
|
|
42
|
+
- `orderByCompletion(features)` - sorts by `completedAt` timestamp
|
|
43
|
+
|
|
44
|
+
6. **Add state management**
|
|
45
|
+
- `transition(state, newStatus)` - validates and applies state transitions
|
|
46
|
+
- Valid transitions: queued->worktree_created->running->merge_pending->complete
|
|
47
|
+
- Error transitions: running->failed, merge_pending->conflict
|
|
48
|
+
|
|
49
|
+
7. **Implement status reporting**
|
|
50
|
+
- `formatStatus(states)` - multi-line status output
|
|
51
|
+
- `formatFeatureStatus(state)` - single feature line
|
|
52
|
+
- `summarizeFinal(results)` - returns `{ completed, failed, conflicts }`
|
|
53
|
+
- `aggregateResults(results)` - returns `{ completed, failed, total }`
|
|
54
|
+
|
|
55
|
+
8. **Add user control functions**
|
|
56
|
+
- `abortFeature(states, slug)` - sets single feature to `aborted`
|
|
57
|
+
- `abortAll(states)` - sets all features to `aborted`
|
|
58
|
+
|
|
59
|
+
9. **Implement pipeline execution helpers**
|
|
60
|
+
- `buildPipelineCommand(slug, worktreePath)` - constructs claude command string
|
|
61
|
+
|
|
62
|
+
10. **Integrate with CLI in `bin/cli.js`**
|
|
63
|
+
- Add `parallel` command: parse slugs and flags, invoke parallel execution
|
|
64
|
+
- Add `parallel status` subcommand: invoke `formatStatus` with current state
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Risks/Questions
|
|
69
|
+
|
|
70
|
+
- **Git availability**: Functions assume synchronous git operations via `child_process.execSync`; actual git calls deferred to integration phase
|
|
71
|
+
- **Queue path collision**: Per-worktree queues use existing `QUEUE_PATH` pattern; ensure no conflicts with main queue
|
|
72
|
+
- **Process spawning**: Actual concurrent pipeline spawning not covered by unit tests; requires integration testing
|
|
73
|
+
- **Merge ordering**: First-completed-first-merged may cause conflicts; document as expected behavior
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Feature Specification — Parallel Lock
|
|
2
|
+
|
|
3
|
+
## 1. Feature Intent
|
|
4
|
+
|
|
5
|
+
Prevent running multiple parallel executions simultaneously by using a lock file. If a user accidentally runs `orchestr8 parallel` twice, the second invocation should fail with a clear message rather than creating chaos.
|
|
6
|
+
|
|
7
|
+
**Problem:** Without locking, two parallel runs could create conflicting worktrees, compete for resources, and produce unpredictable results.
|
|
8
|
+
|
|
9
|
+
**Solution:** Create a lock file on start, check for existing lock, clean up on completion.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 2. Scope
|
|
14
|
+
|
|
15
|
+
### In Scope
|
|
16
|
+
- Create lock file with PID on start
|
|
17
|
+
- Check if lock exists and process is running
|
|
18
|
+
- Clean up lock on completion (success or failure)
|
|
19
|
+
- `--force` flag to override lock (with warning)
|
|
20
|
+
- Clear error message when locked
|
|
21
|
+
|
|
22
|
+
### Out of Scope
|
|
23
|
+
- Distributed locking (multiple machines)
|
|
24
|
+
- Queue management for sequential runs
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 3. Behaviour Overview
|
|
29
|
+
|
|
30
|
+
### First Run (No Lock)
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ orchestr8 parallel feat-a feat-b
|
|
34
|
+
|
|
35
|
+
[Creates .claude/parallel.lock]
|
|
36
|
+
Starting parallel pipelines...
|
|
37
|
+
...
|
|
38
|
+
[Removes .claude/parallel.lock on completion]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Second Run (Locked)
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
$ orchestr8 parallel feat-c feat-d
|
|
45
|
+
|
|
46
|
+
Error: Another parallel execution is in progress (PID: 12345)
|
|
47
|
+
Started at: 2026-02-25T10:30:00Z
|
|
48
|
+
|
|
49
|
+
Options:
|
|
50
|
+
• Wait for it to complete
|
|
51
|
+
• Run: orchestr8 parallel status
|
|
52
|
+
• Force override: orchestr8 parallel feat-c feat-d --force
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Force Override
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
$ orchestr8 parallel feat-c feat-d --force
|
|
59
|
+
|
|
60
|
+
Warning: Overriding existing lock (PID: 12345)
|
|
61
|
+
This may cause conflicts if another execution is still running.
|
|
62
|
+
|
|
63
|
+
Continue? [y/N] y
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Stale Lock (Process Dead)
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
$ orchestr8 parallel feat-a feat-b
|
|
70
|
+
|
|
71
|
+
Warning: Found stale lock file (PID 12345 not running)
|
|
72
|
+
Removing stale lock and continuing...
|
|
73
|
+
|
|
74
|
+
Starting parallel pipelines...
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 4. Lock File Format
|
|
80
|
+
|
|
81
|
+
Location: `.claude/parallel.lock`
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"pid": 12345,
|
|
86
|
+
"startedAt": "2026-02-25T10:30:00Z",
|
|
87
|
+
"features": ["feat-a", "feat-b"],
|
|
88
|
+
"maxConcurrency": 3
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 5. Implementation Notes
|
|
95
|
+
|
|
96
|
+
- Check if PID is running: `process.kill(pid, 0)` returns without error if alive
|
|
97
|
+
- Lock created after confirmation, before worktree creation
|
|
98
|
+
- Lock removed in `finally` block to ensure cleanup
|
|
99
|
+
- `--force` bypasses lock check but still creates new lock
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 6. Test Themes
|
|
104
|
+
|
|
105
|
+
- Lock file created on start
|
|
106
|
+
- Lock file removed on success
|
|
107
|
+
- Lock file removed on failure
|
|
108
|
+
- Error when lock exists with running PID
|
|
109
|
+
- Stale lock detected and removed
|
|
110
|
+
- `--force` flag overrides lock
|
|
111
|
+
- Lock contains correct metadata
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 7. Change Log
|
|
116
|
+
|
|
117
|
+
| Date | Change | Reason |
|
|
118
|
+
|------|--------|--------|
|
|
119
|
+
| 2026-02-25 | Initial spec | Parallel safeguards |
|