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,114 @@
/**
* Shard Manager for Horizontal Scaling
* Implements consistent hashing for data distribution across shards
*/
import { EventEmitter } from 'events';
export interface ShardConfig {
shardCount?: number;
replicationFactor?: number;
virtualNodes?: number;
autoRebalance?: boolean;
}
export interface Shard {
id: string;
nodeId: string;
virtualNodes: string[];
itemCount: number;
sizeBytes: number;
status: 'active' | 'rebalancing' | 'offline';
}
export interface ShardAssignment {
shardId: string;
nodeId: string;
replicas: string[];
}
/**
* Shard Manager for distributing data across multiple nodes
*/
export declare class ShardManager extends EventEmitter {
private hashRing;
private shards;
private nodeToShards;
private shardCount;
private replicationFactor;
private autoRebalance;
constructor(config?: ShardConfig);
/**
* Initialize shard configuration
*/
private initializeShards;
/**
* Add a node to the cluster
*/
addNode(nodeId: string): void;
/**
* Remove a node from the cluster
*/
removeNode(nodeId: string): void;
/**
* Get shard assignment for a key
*/
getShardForKey(key: string): ShardAssignment | null;
/**
* Get nodes responsible for a shard
*/
getNodesForShard(shardId: string): string[];
/**
* Get total number of shards
*/
getTotalShards(): number;
/**
* Update shard assignment to a new node
*/
updateShardAssignment(shardId: string, newNodeId: string): void;
/**
* Get shard ID for a key
*/
private getShardId;
/**
* Rebalance shards across nodes
*/
private rebalanceShards;
/**
* Get shard assignment for all shards
*/
getShardAssignments(): ShardAssignment[];
/**
* Get shard statistics
*/
getShardStats(): {
totalShards: number;
activeShards: number;
rebalancingShards: number;
offlineShards: number;
averageItemsPerShard: number;
};
/**
* Update shard metrics
*/
updateShardMetrics(shardId: string, itemCount: number, sizeBytes: number): void;
/**
* Get replication nodes for a shard
*/
getReplicationNodes(shardId: string): string[];
/**
* Check if rebalancing is needed
*/
needsRebalancing(): boolean;
/**
* Get cluster health
*/
getHealth(): {
healthy: boolean;
nodes: number;
shards: {
total: number;
active: number;
inactive: number;
};
};
}
/**
* Create a shard manager instance
*/
export declare function createShardManager(config?: ShardConfig): ShardManager;