feat: Connect dispatch queue to agent spawning via auto-dispatch
ExecutionOrchestrator now listens for phase:queued and agent:stopped events to drive the dispatch cycle, closing the gap between queueing phases (Execute button) and actually spawning agents. Coalesced scheduling prevents reentrancy with synchronous EventEmitter.
This commit is contained in:
@@ -96,3 +96,24 @@ AccountCredentialsRefreshedEvent { accountId, expiresAt, previousExpiresAt? }
|
||||
| `completePhase(phaseId)` | Mark phase complete |
|
||||
| `blockPhase(phaseId, reason)` | Block phase |
|
||||
| `getPhaseQueueState()` | Return queued, ready, blocked phases |
|
||||
|
||||
## Auto-Dispatch (ExecutionOrchestrator)
|
||||
|
||||
`apps/server/execution/orchestrator.ts` — Connects the queue to agent spawning via event-driven auto-dispatch.
|
||||
|
||||
### Trigger Events
|
||||
|
||||
| Event | Action |
|
||||
|-------|--------|
|
||||
| `phase:queued` | Dispatch ready phases → dispatch their tasks to idle agents |
|
||||
| `agent:stopped` | Re-dispatch queued tasks (freed agent slot) |
|
||||
| `task:completed` | Merge task branch, then dispatch next queued task |
|
||||
|
||||
### Coalesced Scheduling
|
||||
|
||||
Multiple rapid events (e.g. several `phase:queued` from `queueAllPhases`) are coalesced into a single async dispatch cycle via `scheduleDispatch()`. The cycle loops `dispatchNextPhase()` + `dispatchNext()` until both queues are drained, then re-runs if new events arrived during execution.
|
||||
|
||||
### Execution Mode Behavior
|
||||
|
||||
- **YOLO**: phase completes → auto-merge → auto-dispatch next phase → auto-dispatch tasks
|
||||
- **review_per_phase**: phase completes → set `pending_review` → STOP. User approves → `approveAndMergePhase()` → merge → dispatch next phase → dispatch tasks
|
||||
|
||||
Reference in New Issue
Block a user