ruvnet/ruflo · error

Cannot judge incomplete trajectory

Error message

Cannot judge incomplete trajectory

What it means

ReasoningBank.judge() evaluates a finished trajectory and requires trajectory.isComplete === true; judging one still open throws 'Cannot judge incomplete trajectory'. Completeness is a field on the Trajectory object — set by SONAManager.completeTrajectory(id, quality) or by the caller when building the object — and judge() deliberately does not set it for you, because judging mid-flight steps would produce a garbage verdict.

Source

Thrown at v3/@claude-flow/neural/src/reasoning-bank.ts:407

  // ==========================================================================
  // STEP 2: JUDGE - LLM-as-judge trajectory evaluation
  // ==========================================================================

  /**
   * Judge a trajectory and produce a verdict
   *
   * Uses rule-based evaluation to assess trajectory quality.
   * In production, this could be enhanced with LLM-as-judge.
   *
   * @param trajectory - Completed trajectory to judge
   * @returns Verdict with success status and analysis
   */
  async judge(trajectory: Trajectory): Promise<TrajectoryVerdict> {
    const startTime = performance.now();

    if (!trajectory.isComplete) {
      throw new Error('Cannot judge incomplete trajectory');
    }

    // Analyze trajectory steps
    const stepAnalysis = this.analyzeSteps(trajectory.steps);

    // Compute success based on quality and step analysis
    const success = trajectory.qualityScore >= this.config.distillationThreshold &&
      stepAnalysis.positiveRatio > 0.6;

    // Identify strengths and weaknesses
    const strengths = this.identifyStrengths(trajectory, stepAnalysis);
    const weaknesses = this.identifyWeaknesses(trajectory, stepAnalysis);

    // Generate improvement suggestions
    const improvements = this.generateImprovements(weaknesses);

    // Compute relevance for similar future tasks
    const relevanceScore = this.computeRelevanceScore(trajectory);

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Complete the trajectory first: call SONAManager.completeTrajectory(id, quality) or set trajectory.isComplete = true
  2. Validate isComplete before judge() and skip or queue incomplete trajectories
  3. Prefer ReasoningBank.distill() where appropriate — it checks completeness itself and returns null instead of throwing

Example fix

// before
const verdict = await bank.judge(trajectory); // isComplete still false

// after
if (!trajectory.isComplete) {
  trajectory.isComplete = true; // or completeTrajectory(trajectoryId, quality) upstream
}
const verdict = await bank.judge(trajectory);
Defensive patterns

Strategy: validation

Validate before calling

if (!trajectory.isComplete) {
  trajectory.isComplete = true; // or call completeTrajectory(trajectoryId, quality) upstream
}
const verdict = await bank.judge(trajectory);

Type guard

type CompleteTrajectory = Trajectory & { isComplete: true };
function isJudgeableTrajectory(t: Trajectory): t is CompleteTrajectory {
  return t.isComplete === true;
}

Prevention

When it happens

Trigger: Calling judge() right after recordStep()s without completing the trajectory; constructing a Trajectory literal by hand and forgetting isComplete: true; a pipeline reordered so judge runs before the completion step.

Common situations: Custom trajectory objects in tests; porting code that assumed judge() auto-completes; judge/distill steps wired in the wrong order.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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