/** * Agentic QE v3 - Queen Coordinator * The sovereign orchestrator of the hierarchical hive operations. * Manages 12 domain coordinators, work stealing, and cross-domain workflows. * * Per Master Plan Section 4.1: * - Agent #1 in the hierarchy * - Coordinates 47 agents across 12 domains * - Implements work stealing for load balancing * - Orchestrates cross-domain protocols */ import { DomainName, Result, Priority, Severity } from '../shared/types'; import { EventBus, AgentCoordinator, AgentInfo, DomainPlugin, DomainHealth, MemoryBackend, QEKernel } from '../kernel/interfaces'; import { CrossDomainRouter, ProtocolExecutor, WorkflowExecutor } from './interfaces'; /** * Task that can be assigned to domains */ export interface QueenTask { readonly id: string; readonly type: TaskType; readonly priority: Priority; readonly targetDomains: DomainName[]; readonly payload: Record; readonly timeout: number; readonly createdAt: Date; readonly requester?: string; readonly correlationId?: string; } export type TaskType = 'generate-tests' | 'execute-tests' | 'analyze-coverage' | 'assess-quality' | 'predict-defects' | 'validate-requirements' | 'index-code' | 'scan-security' | 'validate-contracts' | 'test-accessibility' | 'run-chaos' | 'optimize-learning' | 'cross-domain-workflow' | 'protocol-execution'; /** * Task execution status */ export interface TaskExecution { readonly taskId: string; readonly task: QueenTask; readonly status: 'queued' | 'assigned' | 'running' | 'completed' | 'failed' | 'cancelled'; readonly assignedDomain?: DomainName; readonly assignedAgents: string[]; readonly startedAt?: Date; readonly completedAt?: Date; readonly result?: unknown; readonly error?: string; readonly retryCount: number; } /** * Domain group for coordination */ export interface DomainGroup { readonly name: string; readonly domains: DomainName[]; readonly priority: Priority; readonly description: string; } /** * Work stealing configuration */ export interface WorkStealingConfig { enabled: boolean; idleThreshold: number; loadThreshold: number; stealBatchSize: number; checkInterval: number; } /** * Queen Coordinator metrics */ export interface QueenMetrics { readonly tasksReceived: number; readonly tasksCompleted: number; readonly tasksFailed: number; readonly tasksStolen: number; readonly averageTaskDuration: number; readonly domainUtilization: Map; readonly agentUtilization: number; readonly protocolsExecuted: number; readonly workflowsExecuted: number; readonly uptime: number; } /** * Queen Coordinator configuration */ export interface QueenConfig { maxConcurrentTasks: number; defaultTaskTimeout: number; taskRetryLimit: number; workStealing: WorkStealingConfig; enableMetrics: boolean; metricsInterval: number; priorityWeights: Record; } /** * Queen health status */ export interface QueenHealth { status: 'healthy' | 'degraded' | 'unhealthy'; domainHealth: Map; totalAgents: number; activeAgents: number; pendingTasks: number; runningTasks: number; workStealingActive: boolean; lastHealthCheck: Date; issues: HealthIssue[]; } export interface HealthIssue { domain?: DomainName; severity: Severity; message: string; timestamp: Date; } /** * Queen Coordinator interface */ export interface IQueenCoordinator { initialize(): Promise; dispose(): Promise; submitTask(task: Omit): Promise>; cancelTask(taskId: string): Promise>; getTaskStatus(taskId: string): TaskExecution | undefined; listTasks(filter?: TaskFilter): TaskExecution[]; getDomainHealth(domain: DomainName): DomainHealth | undefined; getDomainLoad(domain: DomainName): number; getIdleDomains(): DomainName[]; getBusyDomains(): DomainName[]; enableWorkStealing(): void; disableWorkStealing(): void; triggerWorkStealing(): Promise; listAllAgents(): AgentInfo[]; getAgentsByDomain(domain: DomainName): AgentInfo[]; requestAgentSpawn(domain: DomainName, type: string, capabilities: string[]): Promise>; getHealth(): QueenHealth; getMetrics(): QueenMetrics; executeProtocol(protocolId: string, params?: Record): Promise>; executeWorkflow(workflowId: string, params?: Record): Promise>; } export interface TaskFilter { status?: TaskExecution['status']; domain?: DomainName; priority?: Priority; type?: TaskType; fromDate?: Date; toDate?: Date; } export declare const DOMAIN_GROUPS: DomainGroup[]; export declare class QueenCoordinator implements IQueenCoordinator { private readonly eventBus; private readonly agentCoordinator; private readonly memory; private readonly router; private readonly protocolExecutor?; private readonly workflowExecutor?; private readonly domainPlugins?; private readonly config; private readonly tasks; private readonly taskQueue; private readonly domainQueues; private readonly domainLastActivity; private initialized; private workStealingTimer; private metricsTimer; private startTime; private tasksReceived; private tasksCompleted; private tasksFailed; private tasksStolen; private taskDurations; private protocolsExecuted; private workflowsExecuted; constructor(eventBus: EventBus, agentCoordinator: AgentCoordinator, memory: MemoryBackend, router: CrossDomainRouter, protocolExecutor?: ProtocolExecutor | undefined, workflowExecutor?: WorkflowExecutor | undefined, domainPlugins?: Map | undefined, config?: Partial); initialize(): Promise; dispose(): Promise; submitTask(taskInput: Omit): Promise>; cancelTask(taskId: string): Promise>; getTaskStatus(taskId: string): TaskExecution | undefined; listTasks(filter?: TaskFilter): TaskExecution[]; getDomainHealth(domain: DomainName): DomainHealth | undefined; getDomainLoad(domain: DomainName): number; getIdleDomains(): DomainName[]; getBusyDomains(): DomainName[]; enableWorkStealing(): void; disableWorkStealing(): void; triggerWorkStealing(): Promise; listAllAgents(): AgentInfo[]; getAgentsByDomain(domain: DomainName): AgentInfo[]; requestAgentSpawn(domain: DomainName, type: string, capabilities: string[]): Promise>; getHealth(): QueenHealth; getMetrics(): QueenMetrics; executeProtocol(protocolId: string, params?: Record): Promise>; executeWorkflow(workflowId: string, params?: Record): Promise>; private subscribeToEvents; private handleDomainEvent; private handleTaskCompleted; private handleTaskFailed; private handleAgentStatusChanged; private assignTask; private assignTaskToDomain; private enqueueTask; private removeFromQueues; private processQueue; private getQueuePosition; private getRunningTaskCount; private getQueuedTaskCount; private canDomainHandleTask; private startWorkStealing; private startMetricsCollection; private loadState; private saveState; private publishEvent; } /** * Create a Queen Coordinator from a QE Kernel */ export declare function createQueenCoordinator(kernel: QEKernel, router: CrossDomainRouter, protocolExecutor?: ProtocolExecutor, workflowExecutor?: WorkflowExecutor, config?: Partial): QueenCoordinator; //# sourceMappingURL=queen-coordinator.d.ts.map