{"record":{"id":"c11c8fa2a31580a3","repo":"ruvnet/ruflo","slug":"testindex-must-be-a-positive-integer","errorCode":null,"errorMessage":"testIndex must be a positive integer","messagePattern":"testIndex must be a positive integer","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts","lineNumber":79,"sourceCode":"\nexport interface SequentialEvidenceVerdict {\n  significant: boolean;\n  eValue: number;\n  threshold: number;        // 1 / alphaAllocated\n  alphaAllocated: number;   // this test's share of the family-wise budget\n  testIndex: number;        // 1-based position in the lineage's test stream\n  informativePairs: number; // discordant pairs — the only ones carrying signal\n  totalPairs: number;\n  version: typeof SEQUENTIAL_EVIDENCE_VERSION;\n}\n\n/**\n * Alpha share for the k-th test in the stream: alphaTotal * 6/(pi^2 k^2).\n * Chosen over 2^-k because it decays polynomially — test 10 still gets a\n * workable ~0.6% of a 5% budget instead of ~0.005%.\n */\nexport function alphaForTest(testIndex: number, alphaTotal = DEFAULT_ALPHA_TOTAL): number {\n  if (!Number.isInteger(testIndex) || testIndex < 1) throw new RangeError('testIndex must be a positive integer');\n  if (!(alphaTotal > 0 && alphaTotal < 1)) throw new RangeError('alphaTotal must be in (0, 1)');\n  return (alphaTotal * 6) / (Math.PI * Math.PI * testIndex * testIndex);\n}\n\n/**\n * Fold paired outcomes into an anytime-valid e-value and judge it against the\n * k-th test's allocated alpha. Deterministic; order of outcomes does not\n * change the final e-value (the product commutes).\n */\nexport function sequentialEvidenceVerdict(\n  outcomes: PairedTaskOutcome[],\n  testIndex: number,\n  config: SequentialEvidenceConfig = {},\n): SequentialEvidenceVerdict {\n  const alphaTotal = config.alphaTotal ?? DEFAULT_ALPHA_TOTAL;\n  const lambda = config.lambda ?? DEFAULT_LAMBDA;\n  const epsilon = config.epsilon ?? DEFAULT_SCORE_EPSILON;\n  if (!(lambda > 0 && lambda < 1)) throw new RangeError('lambda must be in (0, 1)');","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts#L61-L97","documentation":"RangeError argument guard in the sequential-evidence alpha allocator: testIndex must be a 1-based integer because alpha shares are assigned by position k in the lineage's test stream (alpha * 6/(pi^2 k^2)). Zero, negative, fractional, or non-integer indices have no slot in that series.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a positive integer (>= 1) as testIndex"],"exampleFix":"Pass a positive integer testIndex (1-based) to the sequential evidence routine.","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"}