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
77 lines
1.8 KiB
TypeScript
77 lines
1.8 KiB
TypeScript
/**
|
|
* Domain Detector
|
|
* Automatically detects and manages data domains for logical separation
|
|
*/
|
|
import { DomainMetadata } from '../types/distributedTypes.js';
|
|
export interface DomainPattern {
|
|
domain: string;
|
|
patterns: {
|
|
fields?: string[];
|
|
keywords?: string[];
|
|
regex?: RegExp;
|
|
};
|
|
priority?: number;
|
|
}
|
|
export declare class DomainDetector {
|
|
private domainPatterns;
|
|
private customPatterns;
|
|
private domainStats;
|
|
/**
|
|
* Detect domain from data object
|
|
* @param data - The data object to analyze
|
|
* @returns The detected domain and metadata
|
|
*/
|
|
detectDomain(data: any): DomainMetadata;
|
|
/**
|
|
* Score a data object against a domain pattern
|
|
*/
|
|
private scorePattern;
|
|
/**
|
|
* Extract domain-specific metadata
|
|
*/
|
|
private extractDomainMetadata;
|
|
/**
|
|
* Calculate detection confidence
|
|
*/
|
|
private calculateConfidence;
|
|
/**
|
|
* Categorize price ranges
|
|
*/
|
|
private getPriceRange;
|
|
/**
|
|
* Categorize customer value
|
|
*/
|
|
private getValueCategory;
|
|
/**
|
|
* Categorize amount ranges
|
|
*/
|
|
private getAmountRange;
|
|
/**
|
|
* Add custom domain pattern
|
|
* @param pattern - Custom domain pattern to add
|
|
*/
|
|
addCustomPattern(pattern: DomainPattern): void;
|
|
/**
|
|
* Remove custom domain pattern
|
|
* @param domain - Domain to remove pattern for
|
|
*/
|
|
removeCustomPattern(domain: string): void;
|
|
/**
|
|
* Update domain statistics
|
|
*/
|
|
private updateStats;
|
|
/**
|
|
* Get domain statistics
|
|
* @returns Map of domain to count
|
|
*/
|
|
getDomainStats(): Map<string, number>;
|
|
/**
|
|
* Clear domain statistics
|
|
*/
|
|
clearStats(): void;
|
|
/**
|
|
* Get all configured domains
|
|
* @returns Array of domain names
|
|
*/
|
|
getConfiguredDomains(): string[];
|
|
}
|