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

@ -42,7 +42,8 @@ export class MemoryStorage extends BaseStorage {
const nounCopy: HNSWNoun = {
id: noun.id,
vector: [...noun.vector],
connections: new Map()
connections: new Map(),
level: noun.level || 0
}
// Copy connections
@ -70,7 +71,8 @@ export class MemoryStorage extends BaseStorage {
const nounCopy: HNSWNoun = {
id: noun.id,
vector: [...noun.vector],
connections: new Map()
connections: new Map(),
level: noun.level || 0
}
// Copy connections
@ -93,7 +95,8 @@ export class MemoryStorage extends BaseStorage {
const nounCopy: HNSWNoun = {
id: noun.id,
vector: [...noun.vector],
connections: new Map()
connections: new Map(),
level: noun.level || 0
}
// Copy connections
@ -193,7 +196,8 @@ export class MemoryStorage extends BaseStorage {
const nounCopy: HNSWNoun = {
id: noun.id,
vector: [...noun.vector],
connections: new Map()
connections: new Map(),
level: noun.level || 0
}
// Copy connections
@ -578,6 +582,10 @@ export class MemoryStorage extends BaseStorage {
this.nounMetadata.clear()
this.verbMetadata.clear()
this.statistics = null
// Clear the statistics cache
this.statisticsCache = null
this.statisticsModified = false
}
/**