{"record":{"id":"dbbf36ae36399cfb","repo":"ruvnet/ruflo","slug":"ruvllm-bridge-not-initialized-call-with-config-fi","errorCode":null,"errorMessage":"ruvLLM bridge not initialized. Call with config first.","messagePattern":"ruvLLM bridge not initialized\\. Call with config first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/ruvllm-bridge.ts","lineNumber":335,"sourceCode":"    if (/^(convert|change)\\s+(var|let)\\s+to\\s+const$/i.test(t)) {\n      return 'Use the Edit tool to replace `var`/`let` declarations with `const`.';\n    }\n    if (/^remove\\s+console\\.(log|warn|error|debug|info)$/i.test(t)) {\n      const m = t.toLowerCase().match(/console\\.(\\w+)/)?.[1] ?? 'log';\n      return `Use the Edit tool to remove all \\`console.${m}\\` calls.`;\n    }\n    return null;\n  }\n}\n\n// ── Singleton accessor ──────────────────────────────────────\n\nlet instance: RuvllmBridge | null = null;\n\n/** Get or create the singleton RuvllmBridge. Config required on first call. */\nexport function getRuvllmBridge(config?: RuvllmConfig): RuvllmBridge {\n  if (!instance && config) instance = new RuvllmBridge(config);\n  if (!instance) throw new Error('ruvLLM bridge not initialized. Call with config first.');\n  return instance;\n}\n\n/** Reset the singleton (useful for tests). */\nexport function resetRuvllmBridge(): void { instance = null; }\n\n/** Check whether @ruvector/core is importable without loading the bridge. */\nexport async function isRuvllmAvailable(): Promise<boolean> {\n  try { await import('@ruvector/core'); return true; } catch { return false; }\n}\n","sourceCodeStart":317,"sourceCodeEnd":346,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/ruvllm-bridge.ts#L317-L346","documentation":"Thrown by getRuvllmBridge when the singleton instance is null and no config argument was supplied. The singleton is created lazily on the first call (which must pass config); subsequent calls return the instance without config. Calling getRuvllmBridge() with no config before any config-bearing call has bootstrapped it triggers this.","triggerScenarios":"A module calls getRuvllmBridge() (no args) during startup before the bootstrap code has run getRuvllmBridge(config). Also fires after resetRuvllmBridge() if a no-arg accessor runs before re-initialization, or when the bootstrapping call itself was skipped due to a config-load failure.","commonSituations":"Import-order problems where a consumer module is evaluated before the bootstrap module; conditional bootstrap (only runs in certain modes) leaving the singleton null in others; tests that resetRuvllmBridge() and forget to re-initialize before the next accessor call.","solutions":["Ensure getRuvllmBridge(config) runs once at startup, before any getRuvllmBridge() calls — move bootstrap to the application entrypoint.","After resetRuvllmBridge() in tests, immediately re-initialize with getRuvllmBridge(testConfig).","Have consumers accept the bridge via dependency injection rather than calling the singleton accessor directly, so init order is explicit.","If accessors may run pre-bootstrap, guard with isRuvllmAvailable() or a flag and initialize lazily at that point."],"exampleFix":"// before\n// somewhere in a route handler:\nconst bridge = getRuvllmBridge(); // throws if not yet bootstrapped\n\n// after\n// in app entrypoint:\ngetRuvllmBridge({ modelsDir: process.env.RUV_MODELS_DIR! });\n// then anywhere:\nconst bridge = getRuvllmBridge();","handlingStrategy":"validation","validationCode":"// Bootstrap once at app entrypoint before any no-arg accessor:\ngetRuvllmBridge({ modelsDir: process.env.RUV_MODELS_DIR! });\n// subsequent calls are safe:\nconst bridge = getRuvllmBridge();","typeGuard":"function isBridgeInitialized(b: RuvllmBridge | null): b is RuvllmBridge {\n  return b !== null;\n}","tryCatchPattern":"try {\n  return getRuvllmBridge();\n} catch (e) {\n  if (e instanceof Error && /not initialized/.test(e.message)) {\n    throw new Error('call getRuvllmBridge(config) at startup first');\n  }\n  throw e;\n}","preventionTips":["Bootstrap the singleton at the application entrypoint.","Inject the bridge via DI instead of scattered singleton accessors.","Re-initialize immediately after resetRuvllmBridge() in tests.","Guard consumers with an availability check before access."],"tags":["ruvllm","singleton","bootstrap","appliance"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}