{"record":{"id":"02deebf5cabaae93","repo":"ruvnet/ruflo","slug":"testsrun-must-be-a-non-negative-integer","errorCode":null,"errorMessage":"testsRun must be a non-negative integer","messagePattern":"testsRun must be a non-negative integer","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts","lineNumber":142,"sourceCode":"/**\n * Minimum number of INFORMATIVE (discordant) pairs a candidate must win —\n * with zero losses — to clear the k-th test's threshold: the smallest n with\n * (1+lambda)^n >= 1/alpha_k. The pre-flight power check (ADR-381 §4): an\n * evaluation whose promotion holdout is smaller than this cannot promote even\n * on a perfect sweep, so it should be refused BEFORE compute is spent and\n * before a doomed receipt can be presented to the gate (spending alpha).\n */\nexport function minInformativePairsToClear(testIndex: number, config: SequentialEvidenceConfig = {}): number {\n  const alphaTotal = config.alphaTotal ?? DEFAULT_ALPHA_TOTAL;\n  const lambda = config.lambda ?? DEFAULT_LAMBDA;\n  if (!(lambda > 0 && lambda < 1)) throw new RangeError('lambda must be in (0, 1)');\n  const threshold = 1 / alphaForTest(testIndex, alphaTotal);\n  return Math.ceil(Math.log(threshold) / Math.log(1 + lambda));\n}\n\n/** Family-wise budget left after `testsRun` allocated tests: alphaTotal - Σ alpha_k. */\nexport function remainingAlphaBudget(testsRun: number, alphaTotal = DEFAULT_ALPHA_TOTAL): number {\n  if (!Number.isInteger(testsRun) || testsRun < 0) throw new RangeError('testsRun must be a non-negative integer');\n  let spent = 0;\n  for (let k = 1; k <= testsRun; k++) spent += alphaForTest(k, alphaTotal);\n  return Math.max(0, alphaTotal - spent);\n}\n\nexport interface PairedEvidenceCheck {\n  ok: boolean;\n  reasons: string[];\n}\n\n/**\n * Structural consistency between a receipt's paired outcomes and its\n * aggregate heldOutDeltas: same length and order, unique non-empty task IDs,\n * and each delta must equal candidateScore - baselineScore. This is what makes\n * paired outcomes EVIDENCE rather than decoration — an aggregate that cannot\n * be reproduced from its own per-task rows is refused.\n */\nexport function checkPairedOutcomesConsistency(","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts#L124-L160","documentation":"RangeError guard on testsRun in the remaining-alpha-budget calculation: the number of tests already executed in the lineage must be a non-negative integer because it indexes how far through the alpha-spending series the lineage has progressed.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts:142 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-negative integer count of tests run"],"exampleFix":"Pass a non-negative integer for testsRun (0 or greater).","handlingStrategy":"validation","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"}