ruvnet/ruflo · error

Domain pool ${domain} not found

Error message

Domain pool ${domain} not found

What it means

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.

Source

Thrown at v3/@claude-flow/swarm/src/unified-coordinator.ts:1111

  // =============================================================================
  // DOMAIN-BASED TASK ROUTING (15-Agent Hierarchy Support)
  // =============================================================================

  /**
   * Assign a task to a specific domain
   * Routes the task to the most suitable agent within that domain
   */
  async assignTaskToDomain(taskId: string, domain: AgentDomain): Promise<string | undefined> {
    const startTime = performance.now();
    const task = this.state.tasks.get(taskId);

    if (!task) {
      throw new Error(`Task ${taskId} not found`);
    }

    const pool = this.domainPools.get(domain);
    if (!pool) {
      throw new Error(`Domain pool ${domain} not found`);
    }

    // Try to acquire an agent from the domain pool
    const agent = await pool.acquire();
    if (!agent) {
      // Add to domain queue if no agents available
      const queue = this.domainTaskQueues.get(domain) || [];
      queue.push(taskId);
      this.domainTaskQueues.set(domain, queue);
      task.status = 'queued';

      this.emitEvent('task.queued', {
        taskId,
        domain,
        queuePosition: queue.length,
        reason: 'no_available_agents'
      });

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Use only literal AgentDomain values; fix typos against the union definition
  2. Await initialize() before any assignTaskToDomain() call so the pools exist
  3. When adding a new domain, register it in DOMAIN_CONFIGS so a pool is created for it

Example fix

// before
await coordinator.assignTaskToDomain(taskId, 'dev' as AgentDomain); // throws: no such pool

// after
await coordinator.initialize(); // pools built here
await coordinator.assignTaskToDomain(taskId, 'development');
Defensive patterns

Strategy: type-guard

Validate before calling

// Derive the valid set from the same source the coordinator uses
import { DOMAIN_CONFIGS } from '@claude-flow/swarm';
const VALID_DOMAINS = new Set(DOMAIN_CONFIGS.map(c => c.name));

if (!VALID_DOMAINS.has(domain)) {
  throw new Error(`Unknown domain '${domain}'; known: ${[...VALID_DOMAINS].join(', ')}`);
}
await coordinator.assignTaskToDomain(taskId, domain);

Type guard

const VALID_DOMAINS = new Set(DOMAIN_CONFIGS.map(c => c.name)) as Set<AgentDomain>;
function isValidAgentDomain(d: string): d is AgentDomain {
  return VALID_DOMAINS.has(d as AgentDomain);
}

Try / catch

try {
  await coordinator.assignTaskToDomain(taskId, domain);
} catch (err) {
  if (err instanceof Error && err.message.startsWith('Domain pool')) {
    // no dedicated pool: fall back to default task assignment
    return coordinator.assignTask(taskId);
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: Extending AgentDomain without registering a config and pool; string literals drifting from the union; tests racing initialization.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/f0060f62e501579d. Report an issue: GitHub.