{"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":null,"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/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/appliance/ruvllm-bridge.ts#L317-L346","documentation":"getRuvllmBridge() is a lazy singleton: the first call must carry a RuvllmConfig (with modelsDir) to construct the instance; subsequent argument-less calls return it. This throw means the getter ran with no argument while `instance` is still null — no module ever performed the configuring call, or resetRuvllmBridge() cleared it (typical between tests) and a later bare getter call had no config.","triggerScenarios":"`getRuvllmBridge()` before any `getRuvllmBridge(config)`; calling the getter after `resetRuvllmBridge()` (test teardown) without re-creating; a consumer module invoking the getter at import time before the bootstrap module configures it.","commonSituations":"Tests that reset the singleton per case but forget to rebuild it in beforeEach; import-order problems where consumer code loads before configuration; refactors that removed the one configuring call site.","solutions":["Create the singleton explicitly at boot: getRuvllmBridge({ modelsDir: '...' }) before any consumer runs","In tests, call getRuvllmBridge(config) inside beforeEach after resetRuvllmBridge()","Keep a single bootstrap module that owns the configuring call and is imported first","If it appears mid-session, search for resetRuvllmBridge() calls that may have cleared the instance"],"exampleFix":"// before — consumer assumes the singleton exists\nconst bridge = getRuvllmBridge(); // throws if nothing configured it\n\n// after — always hand the config through; first call configures, later calls reuse\nconst bridge = getRuvllmBridge({ modelsDir: process.env.MODELS_DIR ?? './models' });","handlingStrategy":"validation","validationCode":"import { getRuvllmBridge, type RuvllmConfig, type RuvllmBridge } from './ruvllm-bridge.js';\n\nlet configured = false;\nexport function ensureBridge(config: RuvllmConfig): RuvllmBridge {\n  if (!configured) {\n    getRuvllmBridge(config); // first call constructs the singleton\n    configured = true;\n  }\n  return getRuvllmBridge(); // safe now — instance exists\n}","typeGuard":null,"tryCatchPattern":"let bridge: RuvllmBridge;\ntry {\n  bridge = getRuvllmBridge();\n} catch {\n  // nothing configured the singleton yet — this call carries the config\n  bridge = getRuvllmBridge({ modelsDir: process.env.MODELS_DIR ?? './models' });\n}","preventionTips":["Call getRuvllmBridge(config) once during application bootstrap, before any consumer module runs","After every resetRuvllmBridge() in tests, re-create with config in beforeEach","Keep one owning module for singleton creation; consumers should only read the instance"],"tags":["ruvllm-bridge","singleton","initialization","lifecycle"],"backgroundTag":"singleton-not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}