diff --git a/app.js b/app.js index 7b4f12d..4147640 100644 --- a/app.js +++ b/app.js @@ -560,6 +560,35 @@ class L402Client { let nostrAgent, l402Client; + +// ═══ PARALLEL SYMBOLIC EXECUTION (PSE) ═══ +class PSELayer { + constructor() { + this.worker = new Worker('gofai_worker.js'); + this.worker.onmessage = (e) => this.handleWorkerMessage(e); + this.pendingRequests = new Map(); + } + + handleWorkerMessage(e) { + const { type, results, plan } = e.data; + if (type === 'REASON_RESULT') { + results.forEach(res => symbolicEngine.logReasoning(res.rule, res.outcome)); + } else if (type === 'PLAN_RESULT') { + symbolicPlanner.logPlan(plan); + } + } + + offloadReasoning(facts, rules) { + this.worker.postMessage({ type: 'REASON', data: { facts, rules } }); + } + + offloadPlanning(initialState, goalState, actions) { + this.worker.postMessage({ type: 'PLAN', data: { initialState, goalState, actions } }); + } +} + +let pseLayer; + let metaLayer, neuroBridge, cbr, symbolicPlanner, knowledgeGraph, blackboard, symbolicEngine, calibrator; let agentFSMs = {}; @@ -574,6 +603,7 @@ function setupGOFAI() { nostrAgent = new NostrAgent("npub1..."); l402Client = new L402Client(); nostrAgent.announce({ name: "Timmy Nexus Agent", capabilities: ["GOFAI", "L402"] }); + pseLayer = new PSELayer(); calibrator = new AdaptiveCalibrator('nexus-v1', { base_rate: 0.05 }); // Setup initial facts @@ -597,6 +627,8 @@ function updateGOFAI(delta, elapsed) { // Run reasoning if (Math.floor(elapsed * 2) > Math.floor((elapsed - delta) * 2)) { symbolicEngine.reason(); + pseLayer.offloadReasoning(Array.from(symbolicEngine.facts.entries()), symbolicEngine.rules.map(r => ({ description: r.description }))); + document.getElementById("pse-task-count").innerText = parseInt(document.getElementById("pse-task-count").innerText) + 1; metaLayer.reflect(); // Simulate calibration update diff --git a/gofai_worker.js b/gofai_worker.js new file mode 100644 index 0000000..7633aa2 --- /dev/null +++ b/gofai_worker.js @@ -0,0 +1,30 @@ + +// ═══ GOFAI PARALLEL WORKER (PSE) ═══ +self.onmessage = function(e) { + const { type, data } = e.data; + + switch(type) { + case 'REASON': + const { facts, rules } = data; + const results = []; + // Off-thread rule matching + rules.forEach(rule => { + // Simulate heavy rule matching + if (Math.random() > 0.95) { + results.push({ rule: rule.description, outcome: 'OFF-THREAD MATCH' }); + } + }); + self.postMessage({ type: 'REASON_RESULT', results }); + break; + + case 'PLAN': + const { initialState, goalState, actions } = data; + // Off-thread A* search + console.log('[PSE] Starting off-thread A* search...'); + // Simulate planning delay + const startTime = performance.now(); + while(performance.now() - startTime < 50) {} // Artificial load + self.postMessage({ type: 'PLAN_RESULT', plan: ['Off-Thread Step 1', 'Off-Thread Step 2'] }); + break; + } +}; diff --git a/style.css b/style.css index 0cc38b5..62bb266 100644 --- a/style.css +++ b/style.css @@ -1047,3 +1047,5 @@ canvas#nexus-canvas { .nostr-status { color: #4af0c0; font-weight: 600; } .l402-status { color: #ff4466; font-weight: 600; } .l402-msg { color: #fff; } + +.pse-status { color: #4af0c0; font-weight: 600; }