Compare commits
9 Commits
mimo/build
...
mimo/code/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0694fa6167 | ||
| aab3e607eb | |||
| fe56ece1ad | |||
| bf477382ba | |||
| fba972f8be | |||
| 6786e65f3d | |||
| 62a6581827 | |||
| 797f32a7fe | |||
| 80eb4ff7ea |
6
app.js
6
app.js
@@ -1,4 +1,4 @@
|
|||||||
import * as THREE from 'three';
|
import ResonanceVisualizer from './nexus/components/resonance-visualizer.js';\nimport * as THREE from 'three';
|
||||||
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
||||||
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
|
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
|
||||||
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
|
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
|
||||||
@@ -597,7 +597,7 @@ class PSELayer {
|
|||||||
|
|
||||||
let pseLayer;
|
let pseLayer;
|
||||||
|
|
||||||
let metaLayer, neuroBridge, cbr, symbolicPlanner, knowledgeGraph, blackboard, symbolicEngine, calibrator;
|
let resonanceViz, metaLayer, neuroBridge, cbr, symbolicPlanner, knowledgeGraph, blackboard, symbolicEngine, calibrator;
|
||||||
let agentFSMs = {};
|
let agentFSMs = {};
|
||||||
|
|
||||||
function setupGOFAI() {
|
function setupGOFAI() {
|
||||||
@@ -666,7 +666,7 @@ async function init() {
|
|||||||
scene = new THREE.Scene();
|
scene = new THREE.Scene();
|
||||||
scene.fog = new THREE.FogExp2(0x050510, 0.012);
|
scene.fog = new THREE.FogExp2(0x050510, 0.012);
|
||||||
|
|
||||||
setupGOFAI();
|
setupGOFAI();\n resonanceViz = new ResonanceVisualizer(scene);
|
||||||
camera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 1000);
|
camera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||||
camera.position.copy(playerPos);
|
camera.position.copy(playerPos);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
|
|
||||||
class MemoryOptimizer {
|
class MemoryOptimizer {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
this.threshold = options.threshold || 0.8;
|
this.threshold = options.threshold || 0.3;
|
||||||
this.decayRate = options.decayRate || 0.05;
|
this.decayRate = options.decayRate || 0.01;
|
||||||
|
this.lastRun = Date.now();
|
||||||
}
|
}
|
||||||
optimize(memory) {
|
optimize(memories) {
|
||||||
console.log('Optimizing memory...');
|
const now = Date.now();
|
||||||
// Heuristic-based pruning
|
const elapsed = (now - this.lastRun) / 1000;
|
||||||
return memory.filter(m => m.strength > this.threshold);
|
this.lastRun = now;
|
||||||
|
return memories.map(m => {
|
||||||
|
const decay = (m.importance || 1) * this.decayRate * elapsed;
|
||||||
|
return { ...m, strength: Math.max(0, (m.strength || 1) - decay) };
|
||||||
|
}).filter(m => m.strength > this.threshold || m.locked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default MemoryOptimizer;
|
export default MemoryOptimizer;
|
||||||
|
|||||||
14
nexus/mnemosyne/reasoner.py
Normal file
14
nexus/mnemosyne/reasoner.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
class Reasoner:
|
||||||
|
def __init__(self, rules):
|
||||||
|
self.rules = rules
|
||||||
|
def evaluate(self, entries):
|
||||||
|
return [r['action'] for r in self.rules if self._check(r['condition'], entries)]
|
||||||
|
def _check(self, cond, entries):
|
||||||
|
if cond.startswith('count'):
|
||||||
|
# e.g. count(type=anomaly)>3
|
||||||
|
p = cond.replace('count(', '').split(')')
|
||||||
|
key, val = p[0].split('=')
|
||||||
|
count = sum(1 for e in entries if e.get(key) == val)
|
||||||
|
return eval(f"{count}{p[1]}")
|
||||||
|
return False
|
||||||
22
nexus/mnemosyne/resonance_linker.py
Normal file
22
nexus/mnemosyne/resonance_linker.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
"""Resonance Linker — Finds second-degree connections in the holographic graph."""
|
||||||
|
|
||||||
|
class ResonanceLinker:
|
||||||
|
def __init__(self, archive):
|
||||||
|
self.archive = archive
|
||||||
|
|
||||||
|
def find_resonance(self, entry_id, depth=2):
|
||||||
|
"""Find entries that are connected via shared neighbors."""
|
||||||
|
if entry_id not in self.archive._entries: return []
|
||||||
|
|
||||||
|
entry = self.archive._entries[entry_id]
|
||||||
|
neighbors = set(entry.links)
|
||||||
|
resonance = {}
|
||||||
|
|
||||||
|
for neighbor_id in neighbors:
|
||||||
|
if neighbor_id in self.archive._entries:
|
||||||
|
for second_neighbor in self.archive._entries[neighbor_id].links:
|
||||||
|
if second_neighbor != entry_id and second_neighbor not in neighbors:
|
||||||
|
resonance[second_neighbor] = resonance.get(second_neighbor, 0) + 1
|
||||||
|
|
||||||
|
return sorted(resonance.items(), key=lambda x: x[1], reverse=True)
|
||||||
6
nexus/mnemosyne/rules.json
Normal file
6
nexus/mnemosyne/rules.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"condition": "count(type=anomaly)>3",
|
||||||
|
"action": "alert"
|
||||||
|
}
|
||||||
|
]
|
||||||
23
server.py
23
server.py
@@ -48,24 +48,21 @@ async def broadcast_handler(websocket: websockets.WebSocketServerProtocol):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Broadcast to all OTHER clients
|
# Broadcast to all OTHER clients
|
||||||
if not clients:
|
|
||||||
continue
|
|
||||||
|
|
||||||
disconnected = set()
|
disconnected = set()
|
||||||
# Create broadcast tasks for efficiency
|
# Create broadcast tasks paired with their target client
|
||||||
tasks = []
|
task_client_pairs = []
|
||||||
for client in clients:
|
for client in clients:
|
||||||
if client != websocket and client.open:
|
if client != websocket and client.open:
|
||||||
tasks.append(asyncio.create_task(client.send(message)))
|
task = asyncio.create_task(client.send(message))
|
||||||
|
task_client_pairs.append((task, client))
|
||||||
if tasks:
|
|
||||||
|
if task_client_pairs:
|
||||||
|
tasks = [t for t, _ in task_client_pairs]
|
||||||
results = await asyncio.gather(*tasks, return_exceptions=True)
|
results = await asyncio.gather(*tasks, return_exceptions=True)
|
||||||
for i, result in enumerate(results):
|
for (task, client), result in zip(task_client_pairs, results):
|
||||||
if isinstance(result, Exception):
|
if isinstance(result, Exception):
|
||||||
# Find the client that failed
|
logger.error(f"Failed to send to a client {client.remote_address}: {result}")
|
||||||
target_client = [c for c in clients if c != websocket][i]
|
disconnected.add(client)
|
||||||
logger.error(f"Failed to send to a client {target_client.remote_address}: {result}")
|
|
||||||
disconnected.add(target_client)
|
|
||||||
|
|
||||||
if disconnected:
|
if disconnected:
|
||||||
clients.difference_update(disconnected)
|
clients.difference_update(disconnected)
|
||||||
|
|||||||
Reference in New Issue
Block a user