{"record":{"id":"be39b563397e9c99","repo":"ruvnet/ruflo","slug":"cannot-judge-incomplete-trajectory","errorCode":null,"errorMessage":"Cannot judge incomplete trajectory","messagePattern":"Cannot judge incomplete trajectory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/neural/src/reasoning-bank.ts","lineNumber":407,"sourceCode":"\n  // ==========================================================================\n  // STEP 2: JUDGE - LLM-as-judge trajectory evaluation\n  // ==========================================================================\n\n  /**\n   * Judge a trajectory and produce a verdict\n   *\n   * Uses rule-based evaluation to assess trajectory quality.\n   * In production, this could be enhanced with LLM-as-judge.\n   *\n   * @param trajectory - Completed trajectory to judge\n   * @returns Verdict with success status and analysis\n   */\n  async judge(trajectory: Trajectory): Promise<TrajectoryVerdict> {\n    const startTime = performance.now();\n\n    if (!trajectory.isComplete) {\n      throw new Error('Cannot judge incomplete trajectory');\n    }\n\n    // Analyze trajectory steps\n    const stepAnalysis = this.analyzeSteps(trajectory.steps);\n\n    // Compute success based on quality and step analysis\n    const success = trajectory.qualityScore >= this.config.distillationThreshold &&\n      stepAnalysis.positiveRatio > 0.6;\n\n    // Identify strengths and weaknesses\n    const strengths = this.identifyStrengths(trajectory, stepAnalysis);\n    const weaknesses = this.identifyWeaknesses(trajectory, stepAnalysis);\n\n    // Generate improvement suggestions\n    const improvements = this.generateImprovements(weaknesses);\n\n    // Compute relevance for similar future tasks\n    const relevanceScore = this.computeRelevanceScore(trajectory);","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/neural/src/reasoning-bank.ts#L389-L425","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom trajectory objects in tests; porting code that assumed judge() auto-completes; judge/distill steps wired in the wrong order.","solutions":["Complete the trajectory first: call SONAManager.completeTrajectory(id, quality) or set trajectory.isComplete = true","Validate isComplete before judge() and skip or queue incomplete trajectories","Prefer ReasoningBank.distill() where appropriate — it checks completeness itself and returns null instead of throwing"],"exampleFix":"// before\nconst verdict = await bank.judge(trajectory); // isComplete still false\n\n// after\nif (!trajectory.isComplete) {\n  trajectory.isComplete = true; // or completeTrajectory(trajectoryId, quality) upstream\n}\nconst verdict = await bank.judge(trajectory);","handlingStrategy":"validation","validationCode":"if (!trajectory.isComplete) {\n  trajectory.isComplete = true; // or call completeTrajectory(trajectoryId, quality) upstream\n}\nconst verdict = await bank.judge(trajectory);","typeGuard":"type CompleteTrajectory = Trajectory & { isComplete: true };\nfunction isJudgeableTrajectory(t: Trajectory): t is CompleteTrajectory {\n  return t.isComplete === true;\n}","tryCatchPattern":null,"preventionTips":["Always complete trajectories (completeTrajectory / isComplete = true) before judge()","Validate isComplete at the pipeline step boundary and queue incomplete ones","Prefer distill() where null-return tolerance is acceptable"],"tags":["neural","reasoning-bank","state-machine","validation"],"backgroundTag":"invalid-state-transition","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}