ruvnet/ruflo · error · RangeError

testsRun must be a non-negative integer

Error message

testsRun must be a non-negative integer

What it means

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.

Solutions

  1. Pass a non-negative integer count of tests run

Example fix

Pass a non-negative integer for testsRun (0 or greater).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts:142 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/02deebf5cabaae93. Report an issue: GitHub.

Appendix: source

Thrown at v3/@claude-flow/cli/src/services/flywheel-sequential-evidence.ts:142

/**
 * Minimum number of INFORMATIVE (discordant) pairs a candidate must win —
 * with zero losses — to clear the k-th test's threshold: the smallest n with
 * (1+lambda)^n >= 1/alpha_k. The pre-flight power check (ADR-381 §4): an
 * evaluation whose promotion holdout is smaller than this cannot promote even
 * on a perfect sweep, so it should be refused BEFORE compute is spent and
 * before a doomed receipt can be presented to the gate (spending alpha).
 */
export function minInformativePairsToClear(testIndex: number, config: SequentialEvidenceConfig = {}): number {
  const alphaTotal = config.alphaTotal ?? DEFAULT_ALPHA_TOTAL;
  const lambda = config.lambda ?? DEFAULT_LAMBDA;
  if (!(lambda > 0 && lambda < 1)) throw new RangeError('lambda must be in (0, 1)');
  const threshold = 1 / alphaForTest(testIndex, alphaTotal);
  return Math.ceil(Math.log(threshold) / Math.log(1 + lambda));
}

/** Family-wise budget left after `testsRun` allocated tests: alphaTotal - Σ alpha_k. */
export function remainingAlphaBudget(testsRun: number, alphaTotal = DEFAULT_ALPHA_TOTAL): number {
  if (!Number.isInteger(testsRun) || testsRun < 0) throw new RangeError('testsRun must be a non-negative integer');
  let spent = 0;
  for (let k = 1; k <= testsRun; k++) spent += alphaForTest(k, alphaTotal);
  return Math.max(0, alphaTotal - spent);
}

export interface PairedEvidenceCheck {
  ok: boolean;
  reasons: string[];
}

/**
 * Structural consistency between a receipt's paired outcomes and its
 * aggregate heldOutDeltas: same length and order, unique non-empty task IDs,
 * and each delta must equal candidateScore - baselineScore. This is what makes
 * paired outcomes EVIDENCE rather than decoration — an aggregate that cannot
 * be reproduced from its own per-task rows is refused.
 */
export function checkPairedOutcomesConsistency(

View on GitHub (pinned to fa13ee4ad6)