Part of #360 (Epic 5: Cross-Epic Integration Validation).
Depends on: All of Epics 1–4 (#356, #357, #358, #359).
Context
Each story has unit tests against its own boundaries, but no test exercises the full path: parallel tool dispatch → one tool triggers new_task → TaskScheduler manages subtask → child completes → parent resumes with result. This is where cross-component bugs surface. Using Gemini CLI's wave-based execution log pattern: an executionLog: string[] array traces the full lifecycle and ordering invariants are asserted against it.
Developer Notes
Create src/__tests__/parallel-integration.spec.ts:
- Wire real implementations of
TaskScheduler, TaskRegistry, DispatchState, and ToolExecutionContext with mocked I/O (mock LLM responses, mock file system, in-memory TaskHistoryStore).
- Use sequential Vitest execution (not
test.concurrent) — these tests have inherent ordering dependencies.
- Use
vi.useFakeTimers() + controlled promises for deterministic scheduling.
Test scenarios:
-
Parallel read tools: [read_file, list_files] → both start concurrently (wave 1). Assert executionLog has both start events before either end event.
-
Mixed parallel + sequential: [read_file, execute_command] → read_file in wave 1, execute_command in wave 2 after wave 1 completes.
-
Parallel dispatch triggers subtask: [read_file, new_task] → read_file completes in wave 1, new_task dispatched sequentially in wave 2. Scheduler creates child task, parent suspends. Assert semaphore permit acquired.
-
Child completion resumes parent: From scenario 3, child completes → scheduler releases permit → parent resumes with tool_result in userMessageContent.
-
Rejection cancels unstarted tools: [read_file_A, read_file_B, write_to_file] with pLimit(2) → A and B dispatched, write_to_file queued. User rejects A → write_to_file cancelled. B finishes normally. Assert 3 results: tool_denied, tool_result, tool_cancelled.
-
maxConcurrency = 1 backward compatibility: Scenarios 1–4 with maxConcurrency = 1 and flag off. Assert strictly serial execution matching current behavior.
Files: src/__tests__/parallel-integration.spec.ts (new)
Acceptance Criteria
- All 6 scenarios pass.
maxConcurrency = 1 scenarios produce identical execution logs to current serial behavior.
- No flaky tests — all timing controlled via fake timers and controlled promises.
Part of #360 (Epic 5: Cross-Epic Integration Validation).
Depends on: All of Epics 1–4 (#356, #357, #358, #359).
Context
Each story has unit tests against its own boundaries, but no test exercises the full path: parallel tool dispatch → one tool triggers
new_task→TaskSchedulermanages subtask → child completes → parent resumes with result. This is where cross-component bugs surface. Using Gemini CLI's wave-based execution log pattern: anexecutionLog: string[]array traces the full lifecycle and ordering invariants are asserted against it.Developer Notes
Create
src/__tests__/parallel-integration.spec.ts:TaskScheduler,TaskRegistry,DispatchState, andToolExecutionContextwith mocked I/O (mock LLM responses, mock file system, in-memoryTaskHistoryStore).test.concurrent) — these tests have inherent ordering dependencies.vi.useFakeTimers()+ controlled promises for deterministic scheduling.Test scenarios:
Parallel read tools:
[read_file, list_files]→ both start concurrently (wave 1). AssertexecutionLoghas both start events before either end event.Mixed parallel + sequential:
[read_file, execute_command]→read_filein wave 1,execute_commandin wave 2 after wave 1 completes.Parallel dispatch triggers subtask:
[read_file, new_task]→read_filecompletes in wave 1,new_taskdispatched sequentially in wave 2. Scheduler creates child task, parent suspends. Assert semaphore permit acquired.Child completion resumes parent: From scenario 3, child completes → scheduler releases permit → parent resumes with
tool_resultinuserMessageContent.Rejection cancels unstarted tools:
[read_file_A, read_file_B, write_to_file]withpLimit(2)→ A and B dispatched, write_to_file queued. User rejects A → write_to_file cancelled. B finishes normally. Assert 3 results:tool_denied,tool_result,tool_cancelled.maxConcurrency = 1backward compatibility: Scenarios 1–4 withmaxConcurrency = 1and flag off. Assert strictly serial execution matching current behavior.Files:
src/__tests__/parallel-integration.spec.ts(new)Acceptance Criteria
maxConcurrency = 1scenarios produce identical execution logs to current serial behavior.