test: add 43 deep integration tests for OrchestratorLoop state machine

Covers full lifecycle: start → plan → approve → execute → verify → complete.
Tests state transitions, event emissions, persistence/recovery, pause/resume,
skip/retry, team phase execution, error handling, and edge cases.

Also fixes bugs found during review:
- Route context snapshot: use getter for orchestratorLoop (was null forever)
- Event listener stacking: guard setupEventForwarding with boolean flag
- Replan completion: create tracked TaskQueue task instead of raw sendInput
- Pause cleanup: call cleanupTaskHandlers() on pause
- Phase timeout: add phaseTimeoutTimer enforcement

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-03-21 15:33:02 +01:00
co-authored by Claude Opus 4.6
parent 61b5ec095c
commit d322f17f73
4 changed files with 1053 additions and 17 deletions
+3
View File
@@ -38,7 +38,10 @@ export function registerOrchestratorRoutes(app: FastifyInstance, ctx: Orchestrat
return loop;
}
let eventForwardingAttached = false;
function setupEventForwarding(loop: import('../../orchestrator-loop.js').OrchestratorLoop) {
if (eventForwardingAttached) return;
eventForwardingAttached = true;
loop.on('stateChanged', (state, prevState) => {
ctx.broadcast(SseEvent.OrchestratorStateChanged, { state, prevState });
});