Skip to content

[Story 5.1] Cross-epic integration test suite #378

@edelauna

Description

@edelauna

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_taskTaskScheduler 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:

  1. Parallel read tools: [read_file, list_files] → both start concurrently (wave 1). Assert executionLog has both start events before either end event.

  2. Mixed parallel + sequential: [read_file, execute_command]read_file in wave 1, execute_command in wave 2 after wave 1 completes.

  3. 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.

  4. Child completion resumes parent: From scenario 3, child completes → scheduler releases permit → parent resumes with tool_result in userMessageContent.

  5. 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.

  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions