{"record":{"id":"f0060f62e501579d","repo":"ruvnet/ruflo","slug":"domain-pool-domain-not-found","errorCode":null,"errorMessage":"Domain pool ${domain} not found","messagePattern":"Domain pool (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/swarm/src/unified-coordinator.ts","lineNumber":1111,"sourceCode":"  // =============================================================================\n  // DOMAIN-BASED TASK ROUTING (15-Agent Hierarchy Support)\n  // =============================================================================\n\n  /**\n   * Assign a task to a specific domain\n   * Routes the task to the most suitable agent within that domain\n   */\n  async assignTaskToDomain(taskId: string, domain: AgentDomain): Promise<string | undefined> {\n    const startTime = performance.now();\n    const task = this.state.tasks.get(taskId);\n\n    if (!task) {\n      throw new Error(`Task ${taskId} not found`);\n    }\n\n    const pool = this.domainPools.get(domain);\n    if (!pool) {\n      throw new Error(`Domain pool ${domain} not found`);\n    }\n\n    // Try to acquire an agent from the domain pool\n    const agent = await pool.acquire();\n    if (!agent) {\n      // Add to domain queue if no agents available\n      const queue = this.domainTaskQueues.get(domain) || [];\n      queue.push(taskId);\n      this.domainTaskQueues.set(domain, queue);\n      task.status = 'queued';\n\n      this.emitEvent('task.queued', {\n        taskId,\n        domain,\n        queuePosition: queue.length,\n        reason: 'no_available_agents'\n      });\n","sourceCodeStart":1093,"sourceCodeEnd":1129,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/swarm/src/unified-coordinator.ts#L1093-L1129","documentation":"assignTaskToDomain() resolves the domain to a pre-built AgentPool from domainPools; the set of domains is fixed by DOMAIN_CONFIGS and the pools are created during coordinator initialization. An unknown domain string throws after the task check passes, meaning the task is fine but routing cannot proceed.","triggerScenarios":"Passing a domain value outside the AgentDomain union (a typo like dev or Developement, or a custom domain added to the type but not to DOMAIN_CONFIGS); calling assignTaskToDomain() before initialize() finished building the pools.","commonSituations":"Extending AgentDomain without registering a config and pool; string literals drifting from the union; tests racing initialization.","solutions":["Use only literal AgentDomain values; fix typos against the union definition","Await initialize() before any assignTaskToDomain() call so the pools exist","When adding a new domain, register it in DOMAIN_CONFIGS so a pool is created for it"],"exampleFix":"// before\nawait coordinator.assignTaskToDomain(taskId, 'dev' as AgentDomain); // throws: no such pool\n\n// after\nawait coordinator.initialize(); // pools built here\nawait coordinator.assignTaskToDomain(taskId, 'development');","handlingStrategy":"type-guard","validationCode":"// Derive the valid set from the same source the coordinator uses\nimport { DOMAIN_CONFIGS } from '@claude-flow/swarm';\nconst VALID_DOMAINS = new Set(DOMAIN_CONFIGS.map(c => c.name));\n\nif (!VALID_DOMAINS.has(domain)) {\n  throw new Error(`Unknown domain '${domain}'; known: ${[...VALID_DOMAINS].join(', ')}`);\n}\nawait coordinator.assignTaskToDomain(taskId, domain);","typeGuard":"const VALID_DOMAINS = new Set(DOMAIN_CONFIGS.map(c => c.name)) as Set<AgentDomain>;\nfunction isValidAgentDomain(d: string): d is AgentDomain {\n  return VALID_DOMAINS.has(d as AgentDomain);\n}","tryCatchPattern":"try {\n  await coordinator.assignTaskToDomain(taskId, domain);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Domain pool')) {\n    // no dedicated pool: fall back to default task assignment\n    return coordinator.assignTask(taskId);\n  }\n  throw err;\n}","preventionTips":["Never cast arbitrary strings to AgentDomain; the cast hides typos from the compiler","Derive the valid-domain list from DOMAIN_CONFIGS instead of a hand-copied literal","Await initialize() before any domain routing in startup sequences"],"tags":["unified-coordinator","task-routing","domain","invalid-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}