mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-28 18:13:33 +00:00
fix: robust sessionEnd with full data structure validation (v0.1.68)
- Check this.data exists before accessing properties - Initialize trajectories array if missing - Add try/catch around engine and save operations - Null-check trajectory objects in filter 🤖 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
3b99b3efb7
commit
cff643136a
3 changed files with 26 additions and 10 deletions
|
|
@ -127,7 +127,8 @@
|
|||
"total_memories": 0,
|
||||
"total_trajectories": 0,
|
||||
"total_errors": 0,
|
||||
"session_count": 0,
|
||||
"last_session": 0
|
||||
}
|
||||
"session_count": 1,
|
||||
"last_session": 1767194227
|
||||
},
|
||||
"trajectories": []
|
||||
}
|
||||
|
|
@ -2609,22 +2609,37 @@ class Intelligence {
|
|||
}
|
||||
|
||||
sessionEnd() {
|
||||
// Ensure stats exists with defaults
|
||||
// Ensure data structure exists with defaults
|
||||
if (!this.data) {
|
||||
this.data = { patterns: {}, memories: [], trajectories: [], errors: [], agents: {}, edges: [], stats: {} };
|
||||
}
|
||||
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 };
|
||||
}
|
||||
if (!this.data.trajectories) {
|
||||
this.data.trajectories = [];
|
||||
}
|
||||
|
||||
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;
|
||||
const actions = this.data.trajectories.filter(t => t && t.timestamp >= lastSession).length;
|
||||
|
||||
// Force learning cycle (only if engine already initialized)
|
||||
const eng = this.getEngineIfReady();
|
||||
if (eng) {
|
||||
eng.forceLearn();
|
||||
try {
|
||||
const eng = this.getEngineIfReady();
|
||||
if (eng) {
|
||||
eng.forceLearn();
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore engine errors on session end
|
||||
}
|
||||
|
||||
// Save all data
|
||||
this.save();
|
||||
try {
|
||||
this.save();
|
||||
} catch (e) {
|
||||
// Ignore save errors on session end
|
||||
}
|
||||
|
||||
return { duration, actions };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ruvector",
|
||||
"version": "0.1.67",
|
||||
"version": "0.1.68",
|
||||
"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