Skip to content

feat(learning-engine): Q-Table & RL state not persisted across MCP restarts #280

@dmoellenbeck

Description

@dmoellenbeck

Is your feature request related to a problem?

The LearningEngine stores Q-values, algorithm configs, and RL state only in RAM. On MCP server restart, all trained Q-values are lost. hooks_learning_config settings vanish (causing epsilon error). Users must re-bootstrap every session.

Root Cause

  1. export() incomplete — missing eligibilityTraces, actorWeights
  2. import() incomplete — doesn't restore the above Maps
  3. No dedicated persistence file — learning state mixed into intelligence.json
  4. No auto-recovery on MCP startup
  5. rewardHistory unbounded

Describe the solution you'd like

Phase 1: Fix export/import + dedicated learning-state.json

  • Complete export() to serialize all internal Maps
  • Complete import() to restore all Maps with graceful defaults
  • Persist to .ruvector/learning-state.json (atomic write: tmp → rename)
  • Auto-load on MCP startup
  • Cap rewardHistory at 500

Phase 2 (future): RVF POLICY_KERNEL persistence

Store Q-tables in POLICY_KERNEL (0x31) segment, extending its semantics beyond Thompson Sampling to include tabular RL (Q-Learning, SARSA, Double-Q, Actor-Critic). This aligns with ADR-029 (RVF Canonical Format) and ADR-036 (AGI Cognitive Container).

PR

Phase 1 implementation: dmoellenbeck#2 (pending)

Environment

  • ruvector 0.2.x (npm), Node.js 22.5+, macOS
  • Real-world use case: endurance coaching with 200+ Q-learning experiences, daily training adaptation

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