ruvnet/ruflo · error

Invalid edge: [${u}, ${v}] for ${graph.nodes} nodes

Error message

Invalid edge: [${u}, ${v}] for ${graph.nodes} nodes

What it means

validateProblemGraph() found an edge [u,v] referencing a node index outside [0, graph.nodes). The edge list contains an out-of-range endpoint, which would index past allocated WASM memory during QAOA execution.

Source

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

    if (problem.linear.length !== problem.variables) {
      throw new Error(`Linear coefficients length mismatch: ${problem.linear.length} vs ${problem.variables}`);
    }

    const expectedQuadratic = (problem.variables * (problem.variables - 1)) / 2;
    if (problem.quadratic.length !== expectedQuadratic && problem.quadratic.length !== 0) {
      throw new Error(`Quadratic coefficients length mismatch: ${problem.quadratic.length} vs ${expectedQuadratic}`);
    }
  }

  private validateProblemGraph(graph: ProblemGraph): void {
    if (graph.nodes < 1 || graph.nodes > 1000) {
      throw new Error(`Invalid number of nodes: ${graph.nodes} (must be 1-1000)`);
    }

    for (const [u, v] of graph.edges) {
      if (u < 0 || u >= graph.nodes || v < 0 || v >= graph.nodes) {
        throw new Error(`Invalid edge: [${u}, ${v}] for ${graph.nodes} nodes`);
      }
    }
  }

  private simulatedAnnealing(problem: QUBOProblem, config: AnnealingConfig): QUBOSolution {
    const n = problem.variables;
    const assignment = new Uint8Array(n);

    // Random initial assignment
    for (let i = 0; i < n; i++) {
      assignment[i] = Math.random() < 0.5 ? 0 : 1;
    }

    let energy = this.computeEnergy(problem, assignment);
    let bestEnergy = energy;
    const bestAssignment = new Uint8Array(assignment);

    let temperature = config.temperature.initial;

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:351 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/01bcb6c887270cac. Report an issue: GitHub.