refactor: remove 3,700+ LOC of unused HNSW implementations

Delete dead code island that was never instantiated in production:
- OptimizedHNSWIndex (430 LOC)
- PartitionedHNSWIndex (412 LOC)
- DistributedSearchSystem (635 LOC)
- ScaledHNSWSystem (744 LOC)
- HNSWIndexOptimized (585 LOC)
- brainy-backup.ts stale example (903 LOC)

Also upgrades entry point recovery from O(n) to O(1) using existing
highLevelNodes index structure.

Production uses only: HNSWIndex (memory) and TypeAwareHNSWIndex (persistent)
This commit is contained in:
David Snelling 2025-11-25 15:36:49 -08:00
parent 52eae67cb8
commit e3146ce11d
10 changed files with 47 additions and 3774 deletions

View file

@ -7,7 +7,6 @@
import { v4 as uuidv4 } from './universal/uuid.js'
import { HNSWIndex } from './hnsw/hnswIndex.js'
import { HNSWIndexOptimized } from './hnsw/hnswIndexOptimized.js'
import { TypeAwareHNSWIndex } from './hnsw/typeAwareHNSWIndex.js'
import { createStorage } from './storage/storageFactory.js'
import { BaseStorage } from './storage/baseStorage.js'
@ -90,7 +89,7 @@ export class Brainy<T = any> implements BrainyInterface<T> {
private static instances: Brainy[] = []
// Core components
private index!: HNSWIndex | HNSWIndexOptimized | TypeAwareHNSWIndex
private index!: HNSWIndex | TypeAwareHNSWIndex
private storage!: BaseStorage
private metadataIndex!: MetadataIndexManager
private graphIndex!: GraphAdjacencyIndex
@ -1010,7 +1009,7 @@ export class Brainy<T = any> implements BrainyInterface<T> {
metadata.noun as any
)
)
} else if (this.index instanceof HNSWIndex || this.index instanceof HNSWIndexOptimized) {
} else if (this.index instanceof HNSWIndex) {
tx.addOperation(
new RemoveFromHNSWOperation(this.index, id, noun.vector)
)
@ -2253,7 +2252,7 @@ export class Brainy<T = any> implements BrainyInterface<T> {
metadata.noun as any
)
)
} else if (this.index instanceof HNSWIndex || this.index instanceof HNSWIndexOptimized) {
} else if (this.index instanceof HNSWIndex) {
tx.addOperation(
new RemoveFromHNSWOperation(this.index, id, noun.vector)
)
@ -4770,7 +4769,7 @@ export class Brainy<T = any> implements BrainyInterface<T> {
* - 10x faster type-specific queries
* - Automatic type routing
*/
private setupIndex(): HNSWIndex | HNSWIndexOptimized | TypeAwareHNSWIndex {
private setupIndex(): HNSWIndex | TypeAwareHNSWIndex {
const indexConfig = {
...this.config.index,
distanceFunction: this.distance