Skip to content

bug(sona): getStats().trajectoriesRecorded always returns 0 #273

@dmoellenbeck

Description

@dmoellenbeck

Describe the bug

SonaEngine.getStats() reports trajectoriesRecorded: 0 even after successfully recording and processing trajectories via beginTrajectoryaddTrajectoryStependTrajectory.

Environment

  • @ruvector/sona: v0.1.5
  • Node.js: v22.x (NAPI bindings)
  • Platform: macOS Apple Silicon (darwin-arm64)

To Reproduce

const { SonaEngine } = require('@ruvector/sona');
const engine = new SonaEngine(256);

// Record 120 trajectories
for (let i = 0; i < 120; i++) {
  const tid = engine.beginTrajectory(new Array(256).fill(Math.random()));
  engine.addTrajectoryStep(tid, new Array(256).fill(0.5), new Array(256).fill(0.1), 0.8);
  engine.endTrajectory(tid, 0.9);
}

console.log(engine.getStats());
// CoordinatorStats { trajectories_buffered: 120, ... }
// BUT: trajectoriesRecorded is always 0 in the JSON stats

const result = engine.forceLearn();
console.log(result);
// "Forced learning: 120 trajectories -> 0 patterns, status: completed"
// ^^^ forceLearn WORKS — confirms trajectories are buffered and processed

console.log(engine.getStats());
// trajectories_buffered: 0 (cleared after forceLearn)
// trajectoriesRecorded: still 0

Expected behavior

getStats() should report the actual number of trajectories recorded (120 in this case), matching trajectories_buffered before processing.

Actual behavior

trajectoriesRecorded is always 0, even though:

  • trajectories_buffered correctly shows 120
  • forceLearn() successfully processes them (status: completed)

The counter appears to never be incremented in the Rust code when endTrajectory is called.

Additional context

Using SONA via ruvector MCP server (v0.2.16) for a coaching application. The IntelligenceEngine wrapper also shows 0 because it reads from getStats(). This makes it impossible to monitor SONA learning progress from the outside.

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