{"record":{"id":"fef28d9b014956d9","repo":"ruvnet/ruflo","slug":"hard-negative-miner-not-initialized","errorCode":null,"errorMessage":"Hard negative miner not initialized","messagePattern":"Hard negative miner not initialized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/ruvector-training.ts","lineNumber":678,"sourceCode":" * Get curriculum difficulty for current step\n */\nexport function getCurriculumDifficulty(step: number): number {\n  if (!curriculum) {\n    return 1.0; // Full difficulty if no curriculum\n  }\n\n  return curriculum.getDifficulty(step);\n}\n\n/**\n * Mine hard negatives for better training\n */\nexport function mineHardNegatives(\n  anchor: Float32Array,\n  candidates: Float32Array[]\n): number[] {\n  if (!hardMiner) {\n    throw new Error('Hard negative miner not initialized');\n  }\n\n  return hardMiner.mine(anchor, candidates);\n}\n\n/**\n * Benchmark the training system\n */\nexport async function benchmarkTraining(\n  dim?: number,\n  iterations?: number\n): Promise<BenchmarkResult[]> {\n  const attention: any = await importWithInterop('@ruvector/attention');\n  lastBenchmark = attention.benchmarkAttention(dim || 256, 100, iterations || 1000);\n  return lastBenchmark ?? [];\n}\n\n// ============================================","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/ruvector-training.ts#L660-L696","documentation":"Thrown by mineHardNegatives() when hardMiner is null. This is the most fragile of the attention features: initializeTraining() constructs HardNegativeMiner(5, 'semi_hard') inside its own try/catch, so hardMiner stays null both when the whole @ruvector/attention package is missing AND when the package exists but lacks HardNegativeMiner or its constructor throws (older/incompatible version) — init continues either way, listing 'Hard Negative Mining' in features only on success.","triggerScenarios":"Init without @ruvector/attention installed; a version of @ruvector/attention that predates or renames HardNegativeMiner (constructor throws, swallowed silently); mining called before init or after cleanup().","commonSituations":"Version skew after upgrading the attention package (API changed, mining silently dropped); optional-dep pruning in production installs; relying on mining without checking the features array because flash attention worked fine.","solutions":["Await initializeTraining() and assert features includes 'Hard Negative Mining' — this is the only reliable signal, since construction failures are swallowed.","Pin a @ruvector/attention version whose HardNegativeMiner(5, 'semi_hard') constructor matches this API.","If mining stays unavailable, fall back to random or hardest-negative selection implemented locally.","Re-initialize after cleanup()."],"exampleFix":"// before\nconst idxs = mineHardNegatives(anchor, candidates); // throws if miner silently absent\n\n// after\nconst init = await initializeTraining();\nconst canMine = init.features.includes('Hard Negative Mining');\nconst idxs = canMine\n  ? mineHardNegatives(anchor, candidates)\n  : pickRandomNegatives(candidates, 5); // local fallback","handlingStrategy":"validation","validationCode":"const init = await initializeTraining();\nconst canMine = init.features.includes('Hard Negative Mining'); // only reliable signal — constructor failures are swallowed\nconst idxs = canMine\n  ? mineHardNegatives(anchor, candidates)\n  : pickRandomNegatives(candidates, 5); // local fallback","typeGuard":"async function miningReady(): Promise<boolean> {\n  const init = await initializeTraining();\n  return init.features.includes('Hard Negative Mining');\n}","tryCatchPattern":"try {\n  return mineHardNegatives(anchor, candidates);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Hard negative miner not initialized') {\n    return pickRandomNegatives(candidates, 5); // degrade to random negatives\n  }\n  throw e;\n}","preventionTips":["Check the features string for 'Hard Negative Mining' — construction failures are silently swallowed by init's inner try/catch, so flags alone can't tell you it's live.","Pin a @ruvector/attention version compatible with HardNegativeMiner(5, 'semi_hard').","Always implement a random/hardest-negative fallback so mining availability never blocks training.","Re-probe features after upgrading the attention package."],"tags":["initialization","ruvector","hard-negative-mining","attention","optional-dependency"],"backgroundTag":"component-not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}