ruvnet/ruflo · error · RangeError

alphaTotal must be in (0, 1)

Error message

alphaTotal must be in (0, 1)

What it means

RangeError guard on alphaTotal, the family-wise significance budget from which each test's share is carved. It must lie strictly in (0,1) — zero would allocate no alpha to any test and 1 (or more) is not a valid significance level.

Source

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

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)');
  const alphaAllocated = alphaForTest(testIndex, alphaTotal);

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Choose alphaTotal strictly between 0 and 1, e.g. 0.05

Example fix

Set alphaTotal to a value strictly between 0 and 1 (e.g. 0.05).
Defensive patterns

Strategy: validation

When it happens

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