fix(sona): trajectory counter always 0 + state persistence (#273, #274)#284
Merged
fix(sona): trajectory counter always 0 + state persistence (#273, #274)#284
Conversation
…274) #273: trajectoriesRecorded always returns 0 Root cause: Rust CoordinatorStats serializes as trajectories_buffered but TypeScript expects trajectoriesRecorded. Added trajectories_recorded field and mapped snake_case → camelCase in TypeScript wrapper. #274: Save/load learned state for persistence across restarts Added serialize_state() to LoopCoordinator and saveState() to NAPI + TypeScript wrapper. Co-Authored-By: claude-flow <ruv@ruv.net>
This was referenced Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #273 and #274 — SONA trajectory counter always returns 0 and learned state lost on restart.
Changes
Fix #273:
getStats().trajectoriesRecordedalways returns 0Root cause: Rust
CoordinatorStatsserializes astrajectories_buffered(snake_case) but the TypeScriptSonaStatsinterface expectstrajectoriesRecorded(camelCase). The JSON field name mismatch meant the value was alwaysundefined, coerced to0.Fix:
trajectories_recordedfield toCoordinatorStats(=trajectories_buffered + trajectories_dropped)patterns_learnedalias forpatterns_storedgetStats()to map snake_case Rust fields to camelCase with fallbacksFix #274: Save/load learned state for persistence
Root cause: All SONA state (reasoning bank patterns, EWC tasks, trajectory buffer) lives only in memory. Cloud Run deploys or process restarts lose all accumulated learning.
Fix:
serialize_state()toLoopCoordinator— returns JSON with reasoning bank patterns, EWC task count, enabled flagssaveState()to NAPI layer and TypeScript wrapperengine.saveState()to persist to disk/database and restore on next startupFiles Changed
crates/sona/src/loops/coordinator.rstrajectories_recorded,patterns_learned,serialize_state()crates/sona/src/engine.rscoordinator()accessorcrates/sona/src/napi.rssaveState()NAPI bindingnpm/packages/ruvector/src/core/sona-wrapper.tssaveState()Test plan
cargo checkpasses for sona crategetStats().trajectoriesRecorded > 0after recording trajectories🤖 Generated with claude-flow