From 0321b043229e753dbbb8620ebab676f79cbb0a59 Mon Sep 17 00:00:00 2001 From: rUv Date: Wed, 7 Jan 2026 05:50:46 +0000 Subject: [PATCH] Checkpoint: File edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatic checkpoint created by Claude Code - Branch: v3 - Timestamp: 2026-01-07T05:50:46Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../cli/src/ruvector/q-learning-router.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts b/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts index 347efb7be8..2fa18628f8 100644 --- a/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts +++ b/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts @@ -78,6 +78,48 @@ interface QEntry { qValues: Float32Array; visits: number; lastUpdate: number; + /** Eligibility trace for TD(lambda) */ + eligibility?: Float32Array; +} + +/** + * Experience tuple for replay buffer + */ +interface Experience { + stateKey: string; + actionIdx: number; + reward: number; + nextStateKey: string | null; + timestamp: number; + priority: number; +} + +/** + * Cache entry for route decisions + */ +interface CacheEntry { + decision: RouteDecision; + timestamp: number; + hits: number; +} + +/** + * Persisted model structure + */ +interface PersistedModel { + version: string; + config: Partial; + qTable: Record; + stats: { + stepCount: number; + updateCount: number; + avgTDError: number; + epsilon: number; + }; + metadata: { + savedAt: string; + totalExperiences: number; + }; } /** @@ -89,8 +131,17 @@ const DEFAULT_CONFIG: QLearningRouterConfig = { explorationInitial: 1.0, explorationFinal: 0.01, explorationDecay: 10000, + explorationDecayType: 'exponential', maxStates: 10000, numActions: 8, + replayBufferSize: 1000, + replayBatchSize: 32, + enableReplay: true, + cacheSize: 256, + cacheTTL: 300000, + modelPath: '.swarm/q-learning-model.json', + autoSaveInterval: 100, + stateSpaceDim: 64, }; /**