{"record":{"id":"2bc1cc3b120cd5ab","repo":"ruvnet/ruflo","slug":"tunedistillation-source-db-checksum-changed-durin","errorCode":null,"errorMessage":"tuneDistillation: source DB checksum changed during tuning — refusing to report a result","messagePattern":"tuneDistillation: source DB checksum changed during tuning — refusing to report a result","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/distill-tuning.ts","lineNumber":338,"sourceCode":"  });\n  const baseline = scoreQuerySet(heldOutBaselineIndex, heldOutQuerySet, topK);\n\n  const heldOut: HeldOutScore = {\n    mrrAt10: winnerFull.mrrAtK,\n    recallAt10: winnerFull.recallAtK,\n    queryCount: winnerFull.queryCount,\n    baselineMrrAt10: baseline.mrrAtK,\n    baselineRecallAt10: baseline.recallAtK,\n  };\n  // Overfit: held-out MRR is more than 20% (relative) worse than the winner's\n  // own train score. Guard divide-by-zero — a zero train score can't overfit.\n  const overfit = winner.trainScore > 0 && heldOut.mrrAt10 < winner.trainScore * 0.8;\n\n  const sourceChecksumAfter = sha256File(dbPath);\n  if (sourceChecksumAfter !== sourceChecksumBefore) {\n    // This must be structurally impossible (dbPath is never opened with a DB\n    // connection anywhere above) — a mismatch means an invariant was broken.\n    throw new Error('tuneDistillation: source DB checksum changed during tuning — refusing to report a result');\n  }\n\n  return {\n    candidates,\n    winner,\n    heldOut,\n    overfit,\n    provenance: {\n      gridSize: configs.length,\n      corpusSize: outerSplit.totalRows,\n      trainSize: outerSplit.trainRowids.length,\n      heldOutSize: outerSplit.heldOutRowids.length,\n      metric: 'mrr@10',\n      tunedAt: now ?? Date.now(),\n      sourceDbPath: dbPath,\n      sourceChecksumSha256: sourceChecksumAfter,\n    },\n  };","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/distill-tuning.ts#L320-L356","documentation":"tuneDistillation detects via before/after SHA-256 checksums that the source database changed while tuning ran on copies; scores from a mutated source would be unsound, so it refuses to report a result.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/services/distill-tuning.ts:338 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Stop other writers to the source DB and re-run tuning","Take a snapshot/copy of the DB and tune against the copy"],"exampleFix":"Do not modify the source DB while tuning runs. Take a stable snapshot copy of the database and point tuneDistillation at the snapshot.","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}