Skip to content

fix: SonaTrajectoryService does not use native @ruvector/sona API correctly #1243

@Andycodeman

Description

@Andycodeman

Bug Summary

SonaTrajectoryService (from the agentdb package) fails to properly integrate with the native @ruvector/sona engine, resulting in SONA trajectory learning being effectively disabled. The service stores the module object instead of instantiating a SonaEngine, and calls nonexistent methods (recordStep, record, addStep, predict, selectAction) instead of the actual native API.

This bug has existed since the file first appeared in agentdb@3.0.0-alpha.4 and is present in every version through alpha.10.

Source File Missing from Git

The SonaTrajectoryService TypeScript source file does not exist anywhere in the git source of ruvnet/agentic-flow (agentdb's repo) — not on main, not on any of the 18 feature branches, and not in the commit history. The file only exists in the npm-published dist/ directory.

This is part of a broader pattern: 4 service files and 5 controller files exist in the npm package but have no corresponding source in git.

Impact

  • SONA native learning is completely non-functional — trajectories are never recorded in the native engine
  • Pattern extraction failsfindPatterns is never called
  • The service silently falls back to a simple JavaScript frequency counter, giving the appearance of working while providing no actual RL-based learning
  • All Micro-LoRA, EWC++, and pattern clustering features of @ruvector/sona are bypassed
  • The service reports engineType: 'native' and available: true while doing nothing with the native engine

Root Cause (3 bugs)

Bug 1: initialize() — Module vs Instance

Looks for SONA/Sona class name instead of SonaEngine. Falls back to storing the raw module object.

Bug 2: recordTrajectory() — Nonexistent Methods

Calls recordStep(), record(), addStep() — none exist on SonaEngine. Silent catch {}.

Bug 3: predict() — Nonexistent Methods

Calls predict(), selectAction() — neither exist. Falls back to frequency counter.

Fix

PR submitted: ruvnet/agentic-flow#121

  • Uses SonaEngine.withConfig() for proper instantiation
  • Uses beginTrajectoryaddTrajectoryStependTrajectorytick() pipeline
  • Uses findPatterns() for pattern-based predictions
  • 54/54 test assertions passing across 10 test categories
  • Full backward compatibility maintained

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions