{"record":{"id":"3fd3511a9513e8db","repo":"ruvnet/ruflo","slug":"swarmadapter-not-initialized-call-initialize-fi","errorCode":null,"errorMessage":"SwarmAdapter not initialized. Call initialize() first.","messagePattern":"SwarmAdapter not initialized\\. Call initialize\\(\\) first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/swarm-adapter.ts","lineNumber":1058,"sourceCode":"\n    // Apply rotary encoding (simplified)\n    for (let i = 0; i < dim - 1; i += 2) {\n      const cos = position[i];\n      const sin = position[i + 1] ?? 0;\n\n      const x1 = embedding[i];\n      const x2 = embedding[i + 1] ?? 0;\n\n      result[i] = x1 * cos - x2 * sin;\n      result[i + 1] = x1 * sin + x2 * cos;\n    }\n\n    return result;\n  }\n\n  private ensureInitialized(): void {\n    if (!this.initialized) {\n      throw new Error('SwarmAdapter not initialized. Call initialize() first.');\n    }\n  }\n\n  private logDebug(message: string, data?: unknown): void {\n    if (this.config.debug) {\n      console.debug(`[SwarmAdapter] ${message}`, data || '');\n    }\n  }\n}\n\n// ============================================================================\n// Factory Functions\n// ============================================================================\n\n/**\n * Create and initialize a SwarmAdapter\n */\nexport async function createSwarmAdapter(","sourceCodeStart":1040,"sourceCodeEnd":1076,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/swarm-adapter.ts#L1040-L1076","documentation":"SwarmAdapter's ensureInitialized guard: coordinated swarm operations require a completed initialize(). The throw means the adapter's topology/config was never initialized — or its initialization failed — before the first swarm call.","triggerScenarios":"Invoking swarm operations on a new SwarmAdapter instance before await initialize() resolves, or after a failed init left this.initialized false.","commonSituations":"Un-awaited init promise; per-module instantiation where the used instance was never initialized; an earlier initialization error being swallowed before first use.","solutions":["Use the swarm adapter's factory function (createSwarmAdapter), which constructs and initializes","Otherwise make await adapter.initialize() the first statement of your bootstrap, before any swarm call","Diagnose and fix any swallowed initialization error — this guard only reflects it"],"exampleFix":"// before\nconst swarm = new SwarmAdapter(config);\nswarm.coordinate(task); // throws: initialize() not called\n\n// after\nconst swarm = await createSwarmAdapter(config);\nswarm.coordinate(task);","handlingStrategy":"validation","validationCode":"// One initialized swarm instance for the app lifetime\nlet swarmPromise: Promise<SwarmAdapter> | null = null;\nfunction getSwarm(): Promise<SwarmAdapter> {\n  swarmPromise ??= createSwarmAdapter(config);\n  return swarmPromise;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await swarm.coordinate(task);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('SwarmAdapter not initialized')) {\n    // initialize (or use the factory) and retry once — otherwise fix the swallowed init error\n  }\n  throw e;\n}","preventionTips":["Initialize the swarm adapter during bootstrap, before any task dispatch","Use the factory function so construction and initialization can't diverge","Log and abort on init failure instead of continuing with an unusable adapter"],"tags":["initialization","lifecycle","swarm","async"],"backgroundTag":"not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}