@sparkleideas/testing 3.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +547 -0
  2. package/__tests__/framework.test.ts +21 -0
  3. package/package.json +61 -0
  4. package/src/fixtures/agent-fixtures.ts +793 -0
  5. package/src/fixtures/agents.ts +212 -0
  6. package/src/fixtures/configurations.ts +491 -0
  7. package/src/fixtures/index.ts +21 -0
  8. package/src/fixtures/mcp-fixtures.ts +1030 -0
  9. package/src/fixtures/memory-entries.ts +328 -0
  10. package/src/fixtures/memory-fixtures.ts +750 -0
  11. package/src/fixtures/swarm-fixtures.ts +837 -0
  12. package/src/fixtures/tasks.ts +309 -0
  13. package/src/helpers/assertion-helpers.ts +616 -0
  14. package/src/helpers/assertions.ts +286 -0
  15. package/src/helpers/create-mock.ts +200 -0
  16. package/src/helpers/index.ts +182 -0
  17. package/src/helpers/mock-factory.ts +711 -0
  18. package/src/helpers/setup-teardown.ts +678 -0
  19. package/src/helpers/swarm-instance.ts +326 -0
  20. package/src/helpers/test-application.ts +310 -0
  21. package/src/helpers/test-utils.ts +670 -0
  22. package/src/index.ts +232 -0
  23. package/src/mocks/index.ts +29 -0
  24. package/src/mocks/mock-mcp-client.ts +723 -0
  25. package/src/mocks/mock-services.ts +793 -0
  26. package/src/regression/api-contract.ts +473 -0
  27. package/src/regression/index.ts +46 -0
  28. package/src/regression/integration-regression.ts +416 -0
  29. package/src/regression/performance-baseline.ts +356 -0
  30. package/src/regression/regression-runner.ts +339 -0
  31. package/src/regression/security-regression.ts +331 -0
  32. package/src/setup.ts +127 -0
  33. package/src/v2-compat/api-compat.test.ts +590 -0
  34. package/src/v2-compat/cli-compat.test.ts +484 -0
  35. package/src/v2-compat/compatibility-validator.ts +1072 -0
  36. package/src/v2-compat/hooks-compat.test.ts +602 -0
  37. package/src/v2-compat/index.ts +58 -0
  38. package/src/v2-compat/mcp-compat.test.ts +557 -0
  39. package/src/v2-compat/report-generator.ts +441 -0
  40. package/tmp.json +0 -0
  41. package/tsconfig.json +20 -0
  42. package/vitest.config.ts +12 -0
@@ -0,0 +1,793 @@
1
+ /**
2
+ * @sparkleideas/testing - Agent Fixtures
3
+ *
4
+ * Comprehensive mock agents and agent configurations for testing V3 modules.
5
+ * Supports all 15 V3 specialized swarm agents plus core development agents.
6
+ *
7
+ * Based on ADR-002 (Domain-Driven Design) and V3 agent specifications.
8
+ */
9
+ import { vi, type Mock } from 'vitest';
10
+
11
+ /**
12
+ * Agent types for V3 15-agent swarm
13
+ */
14
+ export type V3AgentType =
15
+ | 'queen-coordinator'
16
+ | 'security-architect'
17
+ | 'security-auditor'
18
+ | 'memory-specialist'
19
+ | 'swarm-specialist'
20
+ | 'integration-architect'
21
+ | 'performance-engineer'
22
+ | 'core-architect'
23
+ | 'test-architect'
24
+ | 'project-coordinator'
25
+ | 'coder'
26
+ | 'reviewer'
27
+ | 'tester'
28
+ | 'planner'
29
+ | 'researcher';
30
+
31
+ /**
32
+ * Agent status type
33
+ */
34
+ export type AgentStatus = 'idle' | 'busy' | 'terminated' | 'error' | 'starting';
35
+
36
+ /**
37
+ * Agent configuration interface
38
+ */
39
+ export interface AgentConfig {
40
+ type: V3AgentType;
41
+ name: string;
42
+ capabilities: string[];
43
+ priority?: number;
44
+ metadata?: Record<string, unknown>;
45
+ systemPrompt?: string;
46
+ tools?: string[];
47
+ maxConcurrentTasks?: number;
48
+ timeout?: number;
49
+ }
50
+
51
+ /**
52
+ * Agent instance interface
53
+ */
54
+ export interface AgentInstance {
55
+ id: string;
56
+ type: V3AgentType;
57
+ name: string;
58
+ status: AgentStatus;
59
+ capabilities: string[];
60
+ createdAt: Date;
61
+ lastActiveAt?: Date;
62
+ currentTaskId?: string;
63
+ metrics?: AgentMetrics;
64
+ }
65
+
66
+ /**
67
+ * Agent metrics interface
68
+ */
69
+ export interface AgentMetrics {
70
+ tasksCompleted: number;
71
+ tasksFailed: number;
72
+ avgTaskDuration: number;
73
+ totalDuration: number;
74
+ errorRate: number;
75
+ memoryUsageMb: number;
76
+ }
77
+
78
+ /**
79
+ * Agent permissions interface
80
+ */
81
+ export interface AgentPermissions {
82
+ canSpawnAgents: boolean;
83
+ canTerminateAgents: boolean;
84
+ canAccessFiles: boolean;
85
+ canExecuteCommands: boolean;
86
+ canAccessNetwork: boolean;
87
+ canAccessMemory: boolean;
88
+ maxMemoryMb?: number;
89
+ maxCpuPercent?: number;
90
+ allowedPaths?: string[];
91
+ blockedPaths?: string[];
92
+ }
93
+
94
+ /**
95
+ * Agent spawn result interface
96
+ */
97
+ export interface AgentSpawnResult {
98
+ agent: AgentInstance;
99
+ sessionId: string;
100
+ startupTime: number;
101
+ success: boolean;
102
+ error?: Error;
103
+ }
104
+
105
+ /**
106
+ * Agent termination result interface
107
+ */
108
+ export interface AgentTerminationResult {
109
+ agentId: string;
110
+ success: boolean;
111
+ duration: number;
112
+ tasksTerminated: number;
113
+ error?: Error;
114
+ }
115
+
116
+ /**
117
+ * Agent health check result interface
118
+ */
119
+ export interface AgentHealthCheckResult {
120
+ agentId: string;
121
+ status: AgentStatus;
122
+ healthy: boolean;
123
+ lastActivity: Date;
124
+ metrics: AgentMetrics;
125
+ issues?: string[];
126
+ }
127
+
128
+ /**
129
+ * Capability definitions for each agent type
130
+ */
131
+ export const agentCapabilities: Record<V3AgentType, string[]> = {
132
+ 'queen-coordinator': [
133
+ 'orchestration',
134
+ 'task-distribution',
135
+ 'agent-management',
136
+ 'priority-scheduling',
137
+ 'conflict-resolution',
138
+ 'github-issue-management',
139
+ ],
140
+ 'security-architect': [
141
+ 'security-design',
142
+ 'threat-modeling',
143
+ 'security-review',
144
+ 'architecture-security',
145
+ 'compliance-verification',
146
+ ],
147
+ 'security-auditor': [
148
+ 'cve-detection',
149
+ 'vulnerability-scanning',
150
+ 'security-testing',
151
+ 'penetration-testing',
152
+ 'audit-reporting',
153
+ ],
154
+ 'memory-specialist': [
155
+ 'memory-optimization',
156
+ 'agentdb-integration',
157
+ 'caching',
158
+ 'vector-search',
159
+ 'hnsw-indexing',
160
+ 'quantization',
161
+ ],
162
+ 'swarm-specialist': [
163
+ 'coordination',
164
+ 'consensus',
165
+ 'communication',
166
+ 'topology-management',
167
+ 'load-balancing',
168
+ ],
169
+ 'integration-architect': [
170
+ 'api-design',
171
+ 'system-integration',
172
+ 'compatibility',
173
+ 'agentic-flow-bridge',
174
+ 'mcp-integration',
175
+ ],
176
+ 'performance-engineer': [
177
+ 'optimization',
178
+ 'benchmarking',
179
+ 'profiling',
180
+ 'flash-attention',
181
+ 'memory-reduction',
182
+ ],
183
+ 'core-architect': [
184
+ 'ddd-design',
185
+ 'architecture',
186
+ 'domain-modeling',
187
+ 'bounded-contexts',
188
+ 'clean-architecture',
189
+ ],
190
+ 'test-architect': [
191
+ 'tdd',
192
+ 'test-design',
193
+ 'quality-assurance',
194
+ 'coverage-analysis',
195
+ 'london-school',
196
+ ],
197
+ 'project-coordinator': [
198
+ 'project-management',
199
+ 'scheduling',
200
+ 'reporting',
201
+ 'cross-domain-coordination',
202
+ 'milestone-tracking',
203
+ ],
204
+ 'coder': [
205
+ 'coding',
206
+ 'implementation',
207
+ 'debugging',
208
+ 'refactoring',
209
+ 'code-generation',
210
+ ],
211
+ 'reviewer': [
212
+ 'code-review',
213
+ 'quality-check',
214
+ 'suggestions',
215
+ 'best-practices',
216
+ 'security-review',
217
+ ],
218
+ 'tester': [
219
+ 'testing',
220
+ 'test-execution',
221
+ 'coverage',
222
+ 'regression-testing',
223
+ 'integration-testing',
224
+ ],
225
+ 'planner': [
226
+ 'planning',
227
+ 'estimation',
228
+ 'roadmap',
229
+ 'task-breakdown',
230
+ 'dependency-analysis',
231
+ ],
232
+ 'researcher': [
233
+ 'research',
234
+ 'analysis',
235
+ 'documentation',
236
+ 'pattern-discovery',
237
+ 'knowledge-synthesis',
238
+ ],
239
+ };
240
+
241
+ /**
242
+ * Pre-defined agent configurations for testing
243
+ */
244
+ export const agentConfigs: Record<string, AgentConfig> = {
245
+ // V3 Specialized Agents
246
+ queenCoordinator: {
247
+ type: 'queen-coordinator',
248
+ name: 'Queen Alpha',
249
+ capabilities: agentCapabilities['queen-coordinator'],
250
+ priority: 100,
251
+ metadata: { isLeader: true, domain: 'orchestration' },
252
+ maxConcurrentTasks: 10,
253
+ timeout: 60000,
254
+ },
255
+
256
+ securityArchitect: {
257
+ type: 'security-architect',
258
+ name: 'Security Architect',
259
+ capabilities: agentCapabilities['security-architect'],
260
+ priority: 95,
261
+ metadata: { specialization: 'cve-prevention', domain: 'security' },
262
+ maxConcurrentTasks: 3,
263
+ },
264
+
265
+ securityAuditor: {
266
+ type: 'security-auditor',
267
+ name: 'Security Auditor',
268
+ capabilities: agentCapabilities['security-auditor'],
269
+ priority: 95,
270
+ metadata: { specialization: 'penetration-testing', domain: 'security' },
271
+ maxConcurrentTasks: 2,
272
+ },
273
+
274
+ memorySpecialist: {
275
+ type: 'memory-specialist',
276
+ name: 'Memory Specialist',
277
+ capabilities: agentCapabilities['memory-specialist'],
278
+ priority: 85,
279
+ metadata: { backend: '@sparkleideas/agentdb', domain: 'memory' },
280
+ maxConcurrentTasks: 5,
281
+ },
282
+
283
+ swarmSpecialist: {
284
+ type: 'swarm-specialist',
285
+ name: 'Swarm Specialist',
286
+ capabilities: agentCapabilities['swarm-specialist'],
287
+ priority: 90,
288
+ metadata: { topology: 'hierarchical-mesh', domain: 'coordination' },
289
+ maxConcurrentTasks: 5,
290
+ },
291
+
292
+ integrationArchitect: {
293
+ type: 'integration-architect',
294
+ name: 'Integration Architect',
295
+ capabilities: agentCapabilities['integration-architect'],
296
+ priority: 85,
297
+ metadata: { agentic: true, domain: 'integration' },
298
+ },
299
+
300
+ performanceEngineer: {
301
+ type: 'performance-engineer',
302
+ name: 'Performance Engineer',
303
+ capabilities: agentCapabilities['performance-engineer'],
304
+ priority: 80,
305
+ metadata: { targets: { flashAttention: '2.49x-7.47x' }, domain: 'performance' },
306
+ },
307
+
308
+ coreArchitect: {
309
+ type: 'core-architect',
310
+ name: 'Core Architect',
311
+ capabilities: agentCapabilities['core-architect'],
312
+ priority: 85,
313
+ metadata: { pattern: 'ddd', domain: 'core' },
314
+ },
315
+
316
+ testArchitect: {
317
+ type: 'test-architect',
318
+ name: 'Test Architect',
319
+ capabilities: agentCapabilities['test-architect'],
320
+ priority: 80,
321
+ metadata: { methodology: 'london-school', domain: 'testing' },
322
+ },
323
+
324
+ projectCoordinator: {
325
+ type: 'project-coordinator',
326
+ name: 'Project Coordinator',
327
+ capabilities: agentCapabilities['project-coordinator'],
328
+ priority: 75,
329
+ metadata: { domain: 'project-management' },
330
+ },
331
+
332
+ // Core Development Agents
333
+ coder: {
334
+ type: 'coder',
335
+ name: 'Coder Agent',
336
+ capabilities: agentCapabilities['coder'],
337
+ priority: 70,
338
+ },
339
+
340
+ tester: {
341
+ type: 'tester',
342
+ name: 'Tester Agent',
343
+ capabilities: agentCapabilities['tester'],
344
+ priority: 70,
345
+ },
346
+
347
+ reviewer: {
348
+ type: 'reviewer',
349
+ name: 'Reviewer Agent',
350
+ capabilities: agentCapabilities['reviewer'],
351
+ priority: 75,
352
+ },
353
+
354
+ planner: {
355
+ type: 'planner',
356
+ name: 'Planner Agent',
357
+ capabilities: agentCapabilities['planner'],
358
+ priority: 75,
359
+ },
360
+
361
+ researcher: {
362
+ type: 'researcher',
363
+ name: 'Researcher Agent',
364
+ capabilities: agentCapabilities['researcher'],
365
+ priority: 65,
366
+ },
367
+ };
368
+
369
+ /**
370
+ * Pre-defined agent instances for testing
371
+ */
372
+ export const agentInstances: Record<string, AgentInstance> = {
373
+ idleQueen: {
374
+ id: 'agent-queen-001',
375
+ type: 'queen-coordinator',
376
+ name: 'Queen Alpha',
377
+ status: 'idle',
378
+ capabilities: agentCapabilities['queen-coordinator'],
379
+ createdAt: new Date('2024-01-01T00:00:00Z'),
380
+ metrics: {
381
+ tasksCompleted: 150,
382
+ tasksFailed: 2,
383
+ avgTaskDuration: 250,
384
+ totalDuration: 37500,
385
+ errorRate: 0.013,
386
+ memoryUsageMb: 128,
387
+ },
388
+ },
389
+
390
+ busySecurityArchitect: {
391
+ id: 'agent-security-001',
392
+ type: 'security-architect',
393
+ name: 'Security Architect',
394
+ status: 'busy',
395
+ capabilities: agentCapabilities['security-architect'],
396
+ createdAt: new Date('2024-01-01T00:00:00Z'),
397
+ lastActiveAt: new Date('2024-01-15T12:00:00Z'),
398
+ currentTaskId: 'task-security-audit-001',
399
+ metrics: {
400
+ tasksCompleted: 45,
401
+ tasksFailed: 0,
402
+ avgTaskDuration: 5000,
403
+ totalDuration: 225000,
404
+ errorRate: 0,
405
+ memoryUsageMb: 256,
406
+ },
407
+ },
408
+
409
+ idleMemorySpecialist: {
410
+ id: 'agent-memory-001',
411
+ type: 'memory-specialist',
412
+ name: 'Memory Specialist',
413
+ status: 'idle',
414
+ capabilities: agentCapabilities['memory-specialist'],
415
+ createdAt: new Date('2024-01-01T00:00:00Z'),
416
+ metrics: {
417
+ tasksCompleted: 200,
418
+ tasksFailed: 5,
419
+ avgTaskDuration: 100,
420
+ totalDuration: 20000,
421
+ errorRate: 0.025,
422
+ memoryUsageMb: 512,
423
+ },
424
+ },
425
+
426
+ terminatedCoder: {
427
+ id: 'agent-coder-001',
428
+ type: 'coder',
429
+ name: 'Coder Agent',
430
+ status: 'terminated',
431
+ capabilities: agentCapabilities['coder'],
432
+ createdAt: new Date('2024-01-01T00:00:00Z'),
433
+ lastActiveAt: new Date('2024-01-10T08:00:00Z'),
434
+ metrics: {
435
+ tasksCompleted: 80,
436
+ tasksFailed: 3,
437
+ avgTaskDuration: 3000,
438
+ totalDuration: 240000,
439
+ errorRate: 0.036,
440
+ memoryUsageMb: 0,
441
+ },
442
+ },
443
+
444
+ errorPerformanceEngineer: {
445
+ id: 'agent-perf-001',
446
+ type: 'performance-engineer',
447
+ name: 'Performance Engineer',
448
+ status: 'error',
449
+ capabilities: agentCapabilities['performance-engineer'],
450
+ createdAt: new Date('2024-01-01T00:00:00Z'),
451
+ lastActiveAt: new Date('2024-01-15T10:00:00Z'),
452
+ currentTaskId: 'task-benchmark-001',
453
+ metrics: {
454
+ tasksCompleted: 30,
455
+ tasksFailed: 5,
456
+ avgTaskDuration: 10000,
457
+ totalDuration: 300000,
458
+ errorRate: 0.143,
459
+ memoryUsageMb: 1024,
460
+ },
461
+ },
462
+
463
+ startingSwarmSpecialist: {
464
+ id: 'agent-swarm-001',
465
+ type: 'swarm-specialist',
466
+ name: 'Swarm Specialist',
467
+ status: 'starting',
468
+ capabilities: agentCapabilities['swarm-specialist'],
469
+ createdAt: new Date(),
470
+ },
471
+ };
472
+
473
+ /**
474
+ * Default agent permissions for testing
475
+ */
476
+ export const agentPermissions: Record<string, AgentPermissions> = {
477
+ full: {
478
+ canSpawnAgents: true,
479
+ canTerminateAgents: true,
480
+ canAccessFiles: true,
481
+ canExecuteCommands: true,
482
+ canAccessNetwork: true,
483
+ canAccessMemory: true,
484
+ },
485
+
486
+ restricted: {
487
+ canSpawnAgents: false,
488
+ canTerminateAgents: false,
489
+ canAccessFiles: true,
490
+ canExecuteCommands: false,
491
+ canAccessNetwork: false,
492
+ canAccessMemory: true,
493
+ allowedPaths: ['./v3/', './src/'],
494
+ blockedPaths: ['/etc/', '/tmp/', '~/', '../'],
495
+ },
496
+
497
+ readOnly: {
498
+ canSpawnAgents: false,
499
+ canTerminateAgents: false,
500
+ canAccessFiles: true,
501
+ canExecuteCommands: false,
502
+ canAccessNetwork: false,
503
+ canAccessMemory: true,
504
+ maxMemoryMb: 256,
505
+ },
506
+
507
+ coordinator: {
508
+ canSpawnAgents: true,
509
+ canTerminateAgents: true,
510
+ canAccessFiles: true,
511
+ canExecuteCommands: true,
512
+ canAccessNetwork: true,
513
+ canAccessMemory: true,
514
+ maxMemoryMb: 2048,
515
+ maxCpuPercent: 50,
516
+ },
517
+ };
518
+
519
+ /**
520
+ * Factory function to create agent config with overrides
521
+ */
522
+ export function createAgentConfig(
523
+ base: keyof typeof agentConfigs | V3AgentType,
524
+ overrides?: Partial<AgentConfig>
525
+ ): AgentConfig {
526
+ const baseConfig = typeof base === 'string' && base in agentConfigs
527
+ ? agentConfigs[base]
528
+ : {
529
+ type: base as V3AgentType,
530
+ name: `${base} Agent`,
531
+ capabilities: agentCapabilities[base as V3AgentType] ?? [],
532
+ };
533
+
534
+ return {
535
+ ...baseConfig,
536
+ ...overrides,
537
+ };
538
+ }
539
+
540
+ /**
541
+ * Factory function to create agent instance with overrides
542
+ */
543
+ export function createAgentInstance(
544
+ base: keyof typeof agentInstances | V3AgentType,
545
+ overrides?: Partial<AgentInstance>
546
+ ): AgentInstance {
547
+ const baseInstance = typeof base === 'string' && base in agentInstances
548
+ ? agentInstances[base]
549
+ : {
550
+ id: `agent-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
551
+ type: base as V3AgentType,
552
+ name: `${base} Agent`,
553
+ status: 'idle' as AgentStatus,
554
+ capabilities: agentCapabilities[base as V3AgentType] ?? [],
555
+ createdAt: new Date(),
556
+ };
557
+
558
+ return {
559
+ ...baseInstance,
560
+ ...overrides,
561
+ id: overrides?.id ?? baseInstance.id ?? `agent-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
562
+ createdAt: overrides?.createdAt ?? baseInstance.createdAt ?? new Date(),
563
+ };
564
+ }
565
+
566
+ /**
567
+ * Factory function to create spawn result
568
+ */
569
+ export function createAgentSpawnResult(
570
+ agent: Partial<AgentInstance>,
571
+ overrides?: Partial<AgentSpawnResult>
572
+ ): AgentSpawnResult {
573
+ const fullAgent = createAgentInstance(agent.type ?? 'coder', agent);
574
+
575
+ return {
576
+ agent: fullAgent,
577
+ sessionId: `session-${Date.now()}`,
578
+ startupTime: Math.random() * 100 + 50,
579
+ success: true,
580
+ ...overrides,
581
+ };
582
+ }
583
+
584
+ /**
585
+ * Factory function to create termination result
586
+ */
587
+ export function createAgentTerminationResult(
588
+ agentId: string,
589
+ overrides?: Partial<AgentTerminationResult>
590
+ ): AgentTerminationResult {
591
+ return {
592
+ agentId,
593
+ success: true,
594
+ duration: Math.random() * 50 + 10,
595
+ tasksTerminated: 0,
596
+ ...overrides,
597
+ };
598
+ }
599
+
600
+ /**
601
+ * Factory function to create health check result
602
+ */
603
+ export function createAgentHealthCheckResult(
604
+ agentId: string,
605
+ overrides?: Partial<AgentHealthCheckResult>
606
+ ): AgentHealthCheckResult {
607
+ return {
608
+ agentId,
609
+ status: 'idle',
610
+ healthy: true,
611
+ lastActivity: new Date(),
612
+ metrics: {
613
+ tasksCompleted: 50,
614
+ tasksFailed: 1,
615
+ avgTaskDuration: 200,
616
+ totalDuration: 10000,
617
+ errorRate: 0.02,
618
+ memoryUsageMb: 128,
619
+ },
620
+ ...overrides,
621
+ };
622
+ }
623
+
624
+ /**
625
+ * Create a full 15-agent V3 swarm configuration
626
+ */
627
+ export function createV3SwarmAgentConfigs(): AgentConfig[] {
628
+ return [
629
+ agentConfigs.queenCoordinator,
630
+ agentConfigs.securityArchitect,
631
+ agentConfigs.securityAuditor,
632
+ agentConfigs.memorySpecialist,
633
+ agentConfigs.swarmSpecialist,
634
+ agentConfigs.integrationArchitect,
635
+ agentConfigs.performanceEngineer,
636
+ agentConfigs.coreArchitect,
637
+ agentConfigs.testArchitect,
638
+ agentConfigs.projectCoordinator,
639
+ agentConfigs.coder,
640
+ agentConfigs.reviewer,
641
+ agentConfigs.tester,
642
+ agentConfigs.planner,
643
+ agentConfigs.researcher,
644
+ ];
645
+ }
646
+
647
+ /**
648
+ * Create instances for all 15 V3 agents
649
+ */
650
+ export function createV3SwarmAgentInstances(): AgentInstance[] {
651
+ return createV3SwarmAgentConfigs().map((config, index) =>
652
+ createAgentInstance(config.type, {
653
+ id: `v3-agent-${config.type}-${index}`,
654
+ name: config.name,
655
+ status: 'idle',
656
+ capabilities: config.capabilities,
657
+ })
658
+ );
659
+ }
660
+
661
+ /**
662
+ * Create agents grouped by domain
663
+ */
664
+ export function createAgentsByDomain(): Record<string, AgentConfig[]> {
665
+ return {
666
+ security: [agentConfigs.securityArchitect, agentConfigs.securityAuditor],
667
+ core: [agentConfigs.coreArchitect, agentConfigs.coder, agentConfigs.reviewer],
668
+ memory: [agentConfigs.memorySpecialist],
669
+ coordination: [agentConfigs.queenCoordinator, agentConfigs.swarmSpecialist],
670
+ integration: [agentConfigs.integrationArchitect],
671
+ performance: [agentConfigs.performanceEngineer],
672
+ testing: [agentConfigs.testArchitect, agentConfigs.tester],
673
+ planning: [agentConfigs.projectCoordinator, agentConfigs.planner, agentConfigs.researcher],
674
+ };
675
+ }
676
+
677
+ /**
678
+ * Invalid agent configurations for error testing
679
+ */
680
+ export const invalidAgentConfigs = {
681
+ emptyName: {
682
+ type: 'coder' as V3AgentType,
683
+ name: '',
684
+ capabilities: ['coding'],
685
+ },
686
+
687
+ noCapabilities: {
688
+ type: 'coder' as V3AgentType,
689
+ name: 'Invalid Agent',
690
+ capabilities: [],
691
+ },
692
+
693
+ invalidType: {
694
+ type: 'invalid-type' as V3AgentType,
695
+ name: 'Invalid Agent',
696
+ capabilities: ['something'],
697
+ },
698
+
699
+ negativePriority: {
700
+ type: 'coder' as V3AgentType,
701
+ name: 'Invalid Agent',
702
+ capabilities: ['coding'],
703
+ priority: -1,
704
+ },
705
+
706
+ zeroTimeout: {
707
+ type: 'coder' as V3AgentType,
708
+ name: 'Invalid Agent',
709
+ capabilities: ['coding'],
710
+ timeout: 0,
711
+ },
712
+
713
+ excessiveConcurrency: {
714
+ type: 'coder' as V3AgentType,
715
+ name: 'Invalid Agent',
716
+ capabilities: ['coding'],
717
+ maxConcurrentTasks: 1000,
718
+ },
719
+ };
720
+
721
+ /**
722
+ * Mock agent interface for behavior testing
723
+ */
724
+ export interface MockAgent {
725
+ id: string;
726
+ type: V3AgentType;
727
+ status: AgentStatus;
728
+ capabilities: string[];
729
+ execute: Mock<(task: unknown) => Promise<unknown>>;
730
+ communicate: Mock<(message: unknown) => Promise<void>>;
731
+ terminate: Mock<() => Promise<void>>;
732
+ getMetrics: Mock<() => AgentMetrics>;
733
+ }
734
+
735
+ /**
736
+ * Create a mock agent for testing
737
+ */
738
+ export function createMockAgent(
739
+ type: V3AgentType = 'coder',
740
+ overrides?: Partial<AgentInstance>
741
+ ): MockAgent {
742
+ const instance = createAgentInstance(type, overrides);
743
+
744
+ return {
745
+ id: instance.id,
746
+ type: instance.type,
747
+ status: instance.status,
748
+ capabilities: instance.capabilities,
749
+ execute: vi.fn().mockResolvedValue({ success: true }),
750
+ communicate: vi.fn().mockResolvedValue(undefined),
751
+ terminate: vi.fn().mockResolvedValue(undefined),
752
+ getMetrics: vi.fn().mockReturnValue(instance.metrics ?? {
753
+ tasksCompleted: 0,
754
+ tasksFailed: 0,
755
+ avgTaskDuration: 0,
756
+ totalDuration: 0,
757
+ errorRate: 0,
758
+ memoryUsageMb: 64,
759
+ }),
760
+ };
761
+ }
762
+
763
+ /**
764
+ * Create multiple mock agents
765
+ */
766
+ export function createMockAgents(types: V3AgentType[]): MockAgent[] {
767
+ return types.map(type => createMockAgent(type));
768
+ }
769
+
770
+ /**
771
+ * Create a mock V3 15-agent swarm
772
+ */
773
+ export function createMockV3Swarm(): MockAgent[] {
774
+ const types: V3AgentType[] = [
775
+ 'queen-coordinator',
776
+ 'security-architect',
777
+ 'security-auditor',
778
+ 'memory-specialist',
779
+ 'swarm-specialist',
780
+ 'integration-architect',
781
+ 'performance-engineer',
782
+ 'core-architect',
783
+ 'test-architect',
784
+ 'project-coordinator',
785
+ 'coder',
786
+ 'reviewer',
787
+ 'tester',
788
+ 'planner',
789
+ 'researcher',
790
+ ];
791
+
792
+ return createMockAgents(types);
793
+ }