mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-31 05:13:39 +00:00
fix: handle undefined stats in sessionEnd (v0.1.67)
- Add defensive check for this.data.stats - Initialize with defaults if missing - Fixes "Cannot read properties of undefined (reading 'last_session')" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8e8f952133
commit
3b99b3efb7
3 changed files with 16 additions and 3 deletions
|
|
@ -121,5 +121,13 @@
|
|||
"rewardHistory": [
|
||||
1
|
||||
]
|
||||
},
|
||||
"stats": {
|
||||
"total_patterns": 0,
|
||||
"total_memories": 0,
|
||||
"total_trajectories": 0,
|
||||
"total_errors": 0,
|
||||
"session_count": 0,
|
||||
"last_session": 0
|
||||
}
|
||||
}
|
||||
|
|
@ -2609,8 +2609,13 @@ class Intelligence {
|
|||
}
|
||||
|
||||
sessionEnd() {
|
||||
const duration = this.now() - (this.sessionStartTime || this.data.stats.last_session);
|
||||
const actions = this.data.trajectories.filter(t => t.timestamp >= this.data.stats.last_session).length;
|
||||
// Ensure stats exists with defaults
|
||||
if (!this.data.stats) {
|
||||
this.data.stats = { total_patterns: 0, total_memories: 0, total_trajectories: 0, total_errors: 0, session_count: 0, last_session: 0 };
|
||||
}
|
||||
const lastSession = this.data.stats.last_session || 0;
|
||||
const duration = this.now() - (this.sessionStartTime || lastSession);
|
||||
const actions = (this.data.trajectories || []).filter(t => t.timestamp >= lastSession).length;
|
||||
|
||||
// Force learning cycle (only if engine already initialized)
|
||||
const eng = this.getEngineIfReady();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ruvector",
|
||||
"version": "0.1.66",
|
||||
"version": "0.1.67",
|
||||
"description": "High-performance vector database for Node.js with automatic native/WASM fallback",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue