Skip to content

test(mcp): add integration tests for subagent vs taskmaestro dispatch strategies #712

@JeremyDev87

Description

@JeremyDev87

Task 7 of 7 — TaskMaestro Specialist Strategy

Spec: docs/superpowers/specs/2026-03-19-taskmaestro-specialist-strategy-design.md
Depends on: Task 4 (dispatch logic)


Goal

Add integration tests verifying the full flow for both strategies end-to-end, and ensure backward compatibility.

Files to Modify

1. apps/mcp-server/src/agent/agent.service.spec.ts

Add integration test suite:

describe('execution strategy integration', () => {
  it('subagent strategy returns parallelAgents with dispatchParams and run_in_background', async () => {
    const result = await service.dispatchAgents({
      mode: 'EVAL',
      specialists: ['security-specialist', 'performance-specialist'],
      executionStrategy: 'subagent',
      includeParallel: true,
    });

    expect(result.executionStrategy).toBe('subagent');
    expect(result.parallelAgents).toBeDefined();
    expect(result.parallelAgents!.length).toBe(2);
    result.parallelAgents!.forEach(agent => {
      expect(agent.dispatchParams).toBeDefined();
      expect(agent.dispatchParams.subagent_type).toBe('general-purpose');
      expect(agent.dispatchParams.run_in_background).toBe(true);
      expect(agent.dispatchParams.prompt).toBeTruthy();
    });
    expect(result.taskmaestro).toBeUndefined();
  });

  it('taskmaestro strategy returns assignments without dispatchParams', async () => {
    const result = await service.dispatchAgents({
      mode: 'EVAL',
      specialists: ['security-specialist', 'performance-specialist'],
      executionStrategy: 'taskmaestro',
    });

    expect(result.executionStrategy).toBe('taskmaestro');
    expect(result.taskmaestro).toBeDefined();
    expect(result.taskmaestro!.paneCount).toBe(2);
    expect(result.taskmaestro!.assignments).toHaveLength(2);
    result.taskmaestro!.assignments.forEach(assignment => {
      expect(assignment.name).toBeTruthy();
      expect(assignment.displayName).toBeTruthy();
      expect(assignment.prompt).toBeTruthy();
    });
    expect(result.parallelAgents).toBeUndefined();
  });

  it('backward compatibility: no executionStrategy defaults to subagent behavior', async () => {
    const result = await service.dispatchAgents({
      mode: 'EVAL',
      specialists: ['security-specialist'],
      includeParallel: true,
      // NO executionStrategy — must default to subagent
    });

    expect(result.executionStrategy).toBe('subagent');
    expect(result.parallelAgents).toBeDefined();
    expect(result.taskmaestro).toBeUndefined();
  });

  it('taskmaestro sessionName reflects the mode', async () => {
    const modes = ['PLAN', 'ACT', 'EVAL', 'AUTO'];
    for (const mode of modes) {
      const result = await service.dispatchAgents({
        mode,
        specialists: ['security-specialist'],
        executionStrategy: 'taskmaestro',
      });
      expect(result.taskmaestro!.sessionName).toBe(`${mode.toLowerCase()}-specialists`);
    }
  });

  it('taskmaestro prompt includes Output Format instructions', async () => {
    const result = await service.dispatchAgents({
      mode: 'EVAL',
      specialists: ['security-specialist'],
      executionStrategy: 'taskmaestro',
    });

    const prompt = result.taskmaestro!.assignments[0].prompt;
    expect(prompt).toContain('Severity: CRITICAL / HIGH / MEDIUM / LOW / INFO');
    expect(prompt).toContain('File reference');
    expect(prompt).toContain('Recommendation');
  });

  it('taskmaestro executionHint includes all required commands', async () => {
    const result = await service.dispatchAgents({
      mode: 'EVAL',
      specialists: ['security-specialist', 'performance-specialist'],
      executionStrategy: 'taskmaestro',
    });

    expect(result.executionHint).toContain('/taskmaestro start --panes 2');
    expect(result.executionHint).toContain('/taskmaestro assign');
    expect(result.executionHint).toContain('/taskmaestro status');
    expect(result.executionHint).toContain('/taskmaestro stop all');
  });
});

Verification

cd /Users/pjw/workspace/codingbuddy
yarn workspace codingbuddy test -- --grep "execution strategy integration" 2>&1 | tail -15
# Expected: 6 tests pass

# Full suite regression check:
yarn workspace codingbuddy test 2>&1 | tail -5
# Expected: All 4810+ tests pass

Commit

git add apps/mcp-server/src/agent/agent.service.spec.ts
git commit -m "test: add integration tests for subagent vs taskmaestro dispatch strategies"

Dependency Graph (all 7 tasks)

Task 1 (Types) ──→ Task 2 (Detection) ──→ Task 5 (Wire parse_mode)
               ──→ Task 3 (Tool Input) ──→ Task 4 (Dispatch Logic) ──→ Task 6 (Docs)
                                                                    ──→ Task 7 (Integration Tests)

Parallelizable: Tasks 2+3 after Task 1. Tasks 5+6+7 after Task 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions