ruvnet/ruflo · error

Invalid character in oracle: ${char}

Error message

Invalid character in oracle: ${char}

What it means

parseOracle() encountered a character in the user-supplied oracle expression that is not in the whitelisted operator/operand set (comparison, boolean, arithmetic ops). The sanitizer strips anything not explicitly allowed for safe evaluation, and the offending character is reported so the caller can rewrite the oracle.

Source

Thrown at v3/plugins/quantum-optimizer/src/bridges/exotic-bridge.ts:541

    return gradient;
  }

  private estimateOptimalCut(graph: ProblemGraph): number {
    // Use Goemans-Williamson approximation bound
    const totalWeight = graph.weights?.reduce((s, w) => s + w, 0) ?? graph.edges.length;
    return -totalWeight * 0.878; // GW approximation ratio
  }

  private parseOracle(oracleStr: string): (input: Uint8Array) => boolean {
    // Safe oracle parsing - only allow specific operations
    const ALLOWED_OPS = ['==', '!=', '<', '>', '<=', '>=', '&&', '||', '!', '+', '-', '*', '/', '%', '.'];

    // Validate oracle string
    const sanitized = oracleStr.replace(/[a-zA-Z_$][a-zA-Z0-9_$]*/g, 'x');
    for (const char of sanitized) {
      if (!/[0-9\s\[\]()x]/.test(char) && !ALLOWED_OPS.some(op => op.includes(char))) {
        throw new Error(`Invalid character in oracle: ${char}`);
      }
    }

    // Return a simple oracle that checks if sum of bits equals a target
    const match = oracleStr.match(/sum\s*==\s*(\d+)/);
    if (match) {
      const target = parseInt(match[1]!, 10);
      return (input: Uint8Array) => input.reduce((s, b) => s + b, 0) === target;
    }

    // Default: check if first bit is 1
    return (input: Uint8Array) => input[0] === 1;
  }

  private weightedSample(weights: Float32Array): number {
    const total = weights.reduce((s, w) => s + Math.abs(w), 0);
    let r = Math.random() * total;

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Correct the invalid input element reported in the message; validate the full input against the documented schema before submitting.
  2. Add boundary validation so malformed input is rejected with a per-element diagnostic.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/plugins/quantum-optimizer/src/bridges/exotic-bridge.ts:541 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/7d0963ab2a80d4b3. Report an issue: GitHub.