chore: recovery checkpoint - v3.0 API successfully recovered

CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
This commit is contained in:
David Snelling 2025-09-10 15:18:04 -07:00
parent f65455fb22
commit 8ff382ca3b
895 changed files with 143654 additions and 28268 deletions

View file

@ -0,0 +1,101 @@
/**
* Partitioned HNSW Index for Large-Scale Vector Search
* Implements sharding strategies to handle millions of vectors efficiently
*/
import { DistanceFunction, HNSWConfig, Vector, VectorDocument } from '../coreTypes.js';
export interface PartitionConfig {
maxNodesPerPartition: number;
partitionStrategy: 'semantic' | 'hash';
semanticClusters?: number;
autoTuneSemanticClusters?: boolean;
}
export interface PartitionMetadata {
id: string;
nodeCount: number;
bounds?: {
centroid: Vector;
radius: number;
};
strategy: string;
created: Date;
}
/**
* Partitioned HNSW Index that splits large datasets across multiple smaller indices
* This enables efficient search across millions of vectors by reducing memory usage
* and parallelizing search operations
*/
export declare class PartitionedHNSWIndex {
private partitions;
private partitionMetadata;
private config;
private hnswConfig;
private distanceFunction;
private dimension;
private nextPartitionId;
constructor(partitionConfig?: Partial<PartitionConfig>, hnswConfig?: Partial<HNSWConfig>, distanceFunction?: DistanceFunction);
/**
* Add a vector to the partitioned index
*/
addItem(item: VectorDocument): Promise<string>;
/**
* Search across all partitions for nearest neighbors
*/
search(queryVector: Vector, k?: number, searchScope?: {
partitionIds?: string[];
maxPartitions?: number;
}): Promise<Array<[string, number]>>;
/**
* Select the appropriate partition for a new item
* Automatically chooses semantic partitioning when beneficial, falls back to hash
*/
private selectPartition;
/**
* Hash-based partitioning for even distribution
*/
private hashPartition;
/**
* Semantic clustering partitioning
*/
private semanticPartition;
/**
* Auto-tune semantic clusters based on dataset size and performance
*/
private autoTuneSemanticClusters;
/**
* Select which partitions to search based on query
*/
private selectSearchPartitions;
/**
* Update partition bounds for semantic clustering
*/
private updatePartitionBounds;
/**
* Split an overgrown partition into smaller partitions
*/
private splitPartition;
/**
* Simple hash function for consistent partitioning
*/
private simpleHash;
/**
* Get partition statistics
*/
getPartitionStats(): {
totalPartitions: number;
totalNodes: number;
averageNodesPerPartition: number;
partitionDetails: PartitionMetadata[];
};
/**
* Remove an item from the index
*/
removeItem(id: string): Promise<boolean>;
/**
* Clear all partitions
*/
clear(): void;
/**
* Get total size across all partitions
*/
size(): number;
}