Skip to content

feat(brain): auto-persist SONA state to Firestore after training (#274)#286

Open
ruvnet wants to merge 1 commit intomainfrom
feat/sona-auto-persist-firestore
Open

feat(brain): auto-persist SONA state to Firestore after training (#274)#286
ruvnet wants to merge 1 commit intomainfrom
feat/sona-auto-persist-firestore

Conversation

@ruvnet
Copy link
Owner

@ruvnet ruvnet commented Mar 23, 2026

Summary

Wires SONA state persistence into the brain server's training cycle and startup, completing the server-side integration for #274.

Changes

After each training cycle (run_training_cycle):

  • If SONA has patterns, persist stats to Firestore (sona_state/latest)
  • Async write — doesn't block the training response
  • Runs every 5 minutes via brain-train scheduler

On startup (create_router):

Dependency

This PR works now but full pattern-level persistence requires:

What this solves

Before: Every Cloud Run deploy reset SONA to 0 patterns.
After: SONA stats auto-saved to Firestore every 5 min. Once PR #285 merges, patterns will be fully restored on cold start.

Contributes to #274

🤖 Generated with claude-flow

- After each training cycle, if patterns exist, persist SONA stats
  to Firestore collection 'sona_state' (doc 'latest')
- On startup, check Firestore for persisted state and log
- Full pattern restore (load_state) will activate once sona >= 0.1.8
  merges (PR #285)

This ensures SONA learning survives Cloud Run deploys by writing
to durable storage after every train cycle (every 5 minutes).

Co-Authored-By: claude-flow <ruv@ruv.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant