ruvnet/ruflo · error · RangeError
testIndex must be a positive integer
Error message
testIndex must be a positive integer
What it means
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.
Solutions
- Pass a positive integer (>= 1) as testIndex
Example fix
Pass a positive integer testIndex (1-based) to the sequential evidence routine.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts:79 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/c11c8fa2a31580a3.
Report an issue: GitHub.
Appendix: source
Thrown at v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts:79
export interface SequentialEvidenceVerdict {
significant: boolean;
eValue: number;
threshold: number; // 1 / alphaAllocated
alphaAllocated: number; // this test's share of the family-wise budget
testIndex: number; // 1-based position in the lineage's test stream
informativePairs: number; // discordant pairs — the only ones carrying signal
totalPairs: number;
version: typeof SEQUENTIAL_EVIDENCE_VERSION;
}
/**
* Alpha share for the k-th test in the stream: alphaTotal * 6/(pi^2 k^2).
* Chosen over 2^-k because it decays polynomially — test 10 still gets a
* workable ~0.6% of a 5% budget instead of ~0.005%.
*/
export function alphaForTest(testIndex: number, alphaTotal = DEFAULT_ALPHA_TOTAL): number {
if (!Number.isInteger(testIndex) || testIndex < 1) throw new RangeError('testIndex must be a positive integer');
if (!(alphaTotal > 0 && alphaTotal < 1)) throw new RangeError('alphaTotal must be in (0, 1)');
return (alphaTotal * 6) / (Math.PI * Math.PI * testIndex * testIndex);
}
/**
* Fold paired outcomes into an anytime-valid e-value and judge it against the
* k-th test's allocated alpha. Deterministic; order of outcomes does not
* change the final e-value (the product commutes).
*/
export function sequentialEvidenceVerdict(
outcomes: PairedTaskOutcome[],
testIndex: number,
config: SequentialEvidenceConfig = {},
): SequentialEvidenceVerdict {
const alphaTotal = config.alphaTotal ?? DEFAULT_ALPHA_TOTAL;
const lambda = config.lambda ?? DEFAULT_LAMBDA;
const epsilon = config.epsilon ?? DEFAULT_SCORE_EPSILON;
if (!(lambda > 0 && lambda < 1)) throw new RangeError('lambda must be in (0, 1)');View on GitHub (pinned to fa13ee4ad6)