fix(core): resolve TypeScript compilation errors and test failures

- Add missing 'level' property to HNSWNoun objects in storage adapters
- Fix HNSWVerb type compatibility in CacheManager imports
- Clear statistics cache when clearing storage to prevent stale data
- Update test expectations to match actual HNSW index behavior (includes both nouns and verbs)
- Add StatisticsCollector utility for enhanced metrics tracking
- Improve statistics comparison in tests to handle volatile fields
This commit is contained in:
David Snelling 2025-08-04 20:00:38 -07:00
parent 8c1c9a08d3
commit ba890170bf
12 changed files with 668 additions and 112 deletions

View file

@ -224,7 +224,8 @@ export class OPFSStorage extends BaseStorage {
return {
id: data.id,
vector: data.vector,
connections
connections,
level: data.level || 0
}
} catch (error) {
// Noun not found or other error
@ -258,7 +259,8 @@ export class OPFSStorage extends BaseStorage {
allNouns.push({
id: data.id,
vector: data.vector,
connections
connections,
level: data.level || 0
})
} catch (error) {
console.error(`Error reading noun file ${name}:`, error)
@ -315,7 +317,8 @@ export class OPFSStorage extends BaseStorage {
nodes.push({
id: data.id,
vector: data.vector,
connections
connections,
level: data.level || 0
})
}
} catch (error) {
@ -732,6 +735,10 @@ export class OPFSStorage extends BaseStorage {
// Remove all files in the index directory
await removeDirectoryContents(this.indexDir!)
// Clear the statistics cache
this.statisticsCache = null
this.statisticsModified = false
} catch (error) {
console.error('Error clearing storage:', error)
throw error