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,125 @@
/**
* Custom error types for Brainy operations
* Provides better error classification and handling
*/
/**
* Custom error class for Brainy operations
* Provides error type classification and retry information
*/
export class BrainyError extends Error {
constructor(message, type, retryable = false, originalError, attemptNumber, maxRetries) {
super(message);
this.name = 'BrainyError';
this.type = type;
this.retryable = retryable;
this.originalError = originalError;
this.attemptNumber = attemptNumber;
this.maxRetries = maxRetries;
// Maintain proper stack trace for where our error was thrown (only available on V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, BrainyError);
}
}
/**
* Create a timeout error
*/
static timeout(operation, timeoutMs, originalError) {
return new BrainyError(`Operation '${operation}' timed out after ${timeoutMs}ms`, 'TIMEOUT', true, originalError);
}
/**
* Create a network error
*/
static network(message, originalError) {
return new BrainyError(`Network error: ${message}`, 'NETWORK', true, originalError);
}
/**
* Create a storage error
*/
static storage(message, originalError) {
return new BrainyError(`Storage error: ${message}`, 'STORAGE', true, originalError);
}
/**
* Create a not found error
*/
static notFound(resource) {
return new BrainyError(`Resource not found: ${resource}`, 'NOT_FOUND', false);
}
/**
* Create a retry exhausted error
*/
static retryExhausted(operation, maxRetries, lastError) {
return new BrainyError(`Operation '${operation}' failed after ${maxRetries} retry attempts`, 'RETRY_EXHAUSTED', false, lastError, maxRetries, maxRetries);
}
/**
* Create a validation error
*/
static validation(parameter, constraint, value) {
return new BrainyError(`Invalid ${parameter}: ${constraint}`, 'VALIDATION', false);
}
/**
* Check if an error is retryable
*/
static isRetryable(error) {
if (error instanceof BrainyError) {
return error.retryable;
}
// Check for common retryable error patterns
const message = error.message.toLowerCase();
const name = error.name.toLowerCase();
// Network-related errors that are typically retryable
if (message.includes('timeout') ||
message.includes('network') ||
message.includes('connection') ||
message.includes('econnreset') ||
message.includes('enotfound') ||
message.includes('etimedout') ||
name.includes('timeout')) {
return true;
}
// AWS SDK specific retryable errors
if (message.includes('throttling') ||
message.includes('rate limit') ||
message.includes('service unavailable') ||
message.includes('internal server error') ||
message.includes('bad gateway') ||
message.includes('gateway timeout')) {
return true;
}
return false;
}
/**
* Convert a generic error to a BrainyError with appropriate classification
*/
static fromError(error, operation) {
if (error instanceof BrainyError) {
return error;
}
const message = error.message.toLowerCase();
const name = error.name.toLowerCase();
// Classify the error based on common patterns
if (message.includes('timeout') || name.includes('timeout')) {
return BrainyError.timeout(operation || 'unknown', 0, error);
}
if (message.includes('network') ||
message.includes('connection') ||
message.includes('econnreset') ||
message.includes('enotfound') ||
message.includes('etimedout')) {
return BrainyError.network(error.message, error);
}
if (message.includes('nosuchkey') ||
message.includes('not found') ||
message.includes('does not exist')) {
return BrainyError.notFound(operation || 'resource');
}
if (message.includes('invalid') ||
message.includes('validation') ||
message.includes('cannot be null') ||
message.includes('must be')) {
return new BrainyError(error.message, 'VALIDATION', false, error);
}
// Default to storage error for unclassified errors
return BrainyError.storage(error.message, error);
}
}
//# sourceMappingURL=brainyError.js.map