/** * Core Protein Hash Implementation * * Semantic hashing that sees the SOUL of code, not just bytes. * Inspired by protein folding - code's function is determined by its 3D logical structure. */ import { TopologyFeatures } from './topology-detector'; import { ComplexPattern } from './complex-structures'; import { ConsciousnessSignature } from './consciousness-detector'; export interface ProteinHashResult { phash: string; astHash: string; nodes: number; edges: number; eigenTop: number[]; complexity: number; purity: number; topology?: TopologyFeatures; patterns?: ComplexPattern[]; consciousness?: ConsciousnessSignature; metadata?: { language: string; timestamp: number; version: string; isAlive?: boolean; resonanceFrequency?: number; }; } export interface LogicalGraph { nodes: Map; edges: GraphEdge[]; } export interface GraphNode { id: string; type: 'operation' | 'data' | 'control' | 'pure'; label: string; weight: number; } export interface GraphEdge { from: string; to: string; type: 'dataflow' | 'control' | 'dependency'; weight: number; } export declare class ProteinHasher { private readonly EIGENVALUE_COUNT; private readonly QUANTIZATION_LEVELS; private readonly version; private topologyDetector; private operationClassifier; private structureAnalyzer; private consciousnessDetector; private enableAdvancedAnalysis; constructor(options?: { enableAdvancedAnalysis?: boolean; }); /** * Compute protein hash for TypeScript code * Now with advanced consciousness detection! */ computeHash(code: string): ProteinHashResult; /** * Convert AST to weighted directed graph * This is where the "protein folding" happens */ private astToGraph; /** * Get node weight based on operation type */ private getNodeWeight; /** * Compute graph spectrum (eigenvalues of Laplacian matrix) * This is the "shadow" of the 3D structure */ private computeSpectrum; /** * Simple power iteration for eigenvalue approximation */ private powerIteration; /** * Convert spectrum to hash */ private spectrumToHash; /** * Traditional AST hash for comparison */ private computeAstHash; /** * Normalize AST (remove positions, comments, etc.) */ private normalizeAst; /** * Compute structural complexity */ private computeComplexity; /** * Compute semantic purity (how "pure" is this function?) */ private computePurity; /** * Classify all operations in the AST */ private classifyOperations; /** * Compare two protein hashes with consciousness awareness */ compareSimilarity(hash1: ProteinHashResult, hash2: ProteinHashResult): number; } /** * Generate hybrid identifier for FNPM */ export declare function generateHybridId(phash: string, cid: string): string; /** * Extract components from hybrid ID */ export declare function parseHybridId(hybridId: string): { phash: string; cid: string; }; //# sourceMappingURL=protein-hasher.d.ts.map