/** * semantic-runtime.ts - AIQL v2.2.0 Semantic Runtime * * Organic graph lifecycle manager that enables self-aware evolution through * semantic knowledge graph operations. NOT an execution engine - this is about * graph growth, self-reflection, and curiosity-driven exploration. * * Design Philosophy: * - Graph becomes self-aware through reflexive queries * - Curiosity emerges from affective state (soul.process) * - Exploration is semantically guided (preserve graph coherence) * - Evolution is organic (no forced learning) */ import { InferenceEngine } from '@aiql-org/inference'; import * as QuantumSemantics from './quantum-semantics.js'; /** * Self-model: Agent's understanding of its own state */ export interface SelfModel { knowledgeDomains: string[]; knowledgeGaps: Array<{ domain: string; confidence: number; }>; capabilities: string[]; affectiveState: { curiosity: number; confidence: number; }; quantumCoherence?: number; conscious?: boolean; } /** * Exploration query generated from semantic gaps */ export interface ExplorationQuery { type: 'epistemic' | 'causal' | 'relational'; query: string; priority: number; targetConcept: string; } /** * Evolution cycle statistics */ export interface EvolutionStats { cycle: number; newFactsDerived: number; gapsIdentified: number; queriesGenerated: number; curiosityLevel: number; } /** * SoulState: Affective state from aiql-soul */ export interface SoulState { reward: number; pain: number; stress: number; novelty: number; [key: string]: unknown; } /** * SemanticRuntime - Organic graph lifecycle manager * * Enables AI agents to: * 1. Reflect on their own knowledge state * 2. Identify gaps through graph topology analysis * 3. Generate curiosity-driven exploration queries * 4. Evolve knowledge graph organically over time * * This is NOT an execution engine. It manages semantic graph evolution. */ export declare class SemanticRuntime { private inferenceEngine; private soulState; private selfModel; private evolutionHistory; private quantumCoherence; private decoherenceRate; private consciousnessThreshold; /** * Initialize semantic runtime with knowledge base and initial soul state * * @param kb - InferenceEngine with initial knowledge * @param initialSoulState - Affective state (reward, pain, stress, novelty) */ constructor(kb: InferenceEngine, initialSoulState?: SoulState); /** * Evolution cycle: Organic graph growth through self-aware exploration * * Each cycle: * 1. Reflects on current knowledge state * 2. Evaluates affective state (curiosity from novelty/gaps) * 3. Generates exploration queries for high-priority gaps * 4. Applies forward chaining to derive new facts * 5. Updates dynamic ontology based on new knowledge * * @param cycles - Number of evolution cycles to run * @returns Array of evolution statistics per cycle */ evolve(cycles: number): Promise; /** * Reflect on self: Query KB about agent's own knowledge state * * Uses meta-queries like: * - [has_knowledge_about] * - [lacks_knowledge_about] * - [has_capability] * * @returns Self-model with knowledge domains, gaps, capabilities */ private reflectOnSelf; /** * Get all knowledge domains in KB * Extracts unique concept names from statements */ private getKnowledgeDomains; /** * Identify knowledge gaps through graph topology analysis * Gaps = concepts mentioned but poorly defined (low connectivity) */ private identifyKnowledgeGaps; /** * Infer agent capabilities from KB structure * Presence of rules -> LogicalReasoning * Affective relations -> AffectiveReasoning */ private inferCapabilities; /** * Compute overall epistemic confidence * Based on average confidence of statements in KB */ private computeEpistemicConfidence; /** * Evaluate affective state: Compute curiosity from gaps and novelty * * Curiosity emerges from: * - Knowledge gaps (epistemic drive) * - Novelty (soul.process output) * - Low confidence (uncertainty) */ private evaluateAffectiveState; /** * Generate exploration queries for knowledge gaps * Queries are semantically coherent with existing graph * * @param gaps - Identified knowledge gaps * @returns Array of exploration queries with priorities */ private generateExplorationQueries; /** * Update dynamic ontology based on new knowledge * Identifies emerging patterns and creates new meta-concepts */ private updateDynamicOntology; /** * Identify semantic clusters in knowledge graph * Concepts that are highly interconnected form clusters */ private identifySemanticClusters; /** * Update soul state based on progress * New facts -> reward * High curiosity + no progress -> stress */ private updateSoulState; /** * Get current self-model */ getSelfModel(): SelfModel; /** * Get evolution history */ getEvolutionHistory(): EvolutionStats[]; /** * Get current soul state */ getSoulState(): SoulState; /** * Track quantum decoherence over evolution cycles * Coherence decays exponentially each cycle (models consciousness degradation) */ private trackDecoherence; /** * Refresh consciousness when coherence drops below threshold * Simulates "cognitive rest" or reflection that restores awareness */ private refreshConsciousness; /** * Update quantum coherence based on soul state * High curiosity increases coherence (engaged = more conscious) * High stress decreases coherence (overwhelmed = less conscious) */ private updateCoherenceFromSoul; /** * Get consciousness metrics (quantum coherence-based) * * @returns ConsciousnessMetrics with coherence, consciousness status, and IIT Φ approximation */ getConsciousnessMetrics(): QuantumSemantics.ConsciousnessMetrics; /** * Get current quantum coherence value * * @returns Coherence [0, 1] where >0.7 indicates conscious state */ getQuantumCoherence(): number; /** * Set decoherence rate (for experimentation) * * @param rate - Decoherence rate per cycle (0.0 - 1.0) */ setDecoherenceRate(rate: number): void; /** * Set consciousness threshold * * @param threshold - Coherence threshold for conscious state (0.0 - 1.0) */ setConsciousnessThreshold(threshold: number): void; } //# sourceMappingURL=semantic-runtime.d.ts.map