Compare commits

..

8 Commits

Author SHA1 Message Date
Alexander Whitestone
4706861619 fix: closes #1208
Some checks failed
CI / test (pull_request) Failing after 10s
CI / validate (pull_request) Failing after 17s
Review Approval Gate / verify-review (pull_request) Failing after 3s
2026-04-12 12:18:58 -04:00
6786e65f3d Merge pull request '[GOFAI] Layer 4 — Reasoning & Decay' (#1292) from feat/gofai-layer-4-v2 into main
Some checks failed
Deploy Nexus / deploy (push) Failing after 2s
Staging Verification Gate / verify-staging (push) Failing after 3s
2026-04-12 16:15:29 +00:00
62a6581827 Add rules
Some checks failed
CI / test (pull_request) Failing after 10s
CI / validate (pull_request) Failing after 15s
Review Approval Gate / verify-review (pull_request) Failing after 3s
2026-04-12 16:15:24 +00:00
797f32a7fe Add Reasoner 2026-04-12 16:15:23 +00:00
80eb4ff7ea Enhance MemoryOptimizer 2026-04-12 16:15:22 +00:00
b205f002ef Merge pull request '[GOFAI] Resonance Visualization' (#1284) from feat/resonance-viz-1775996553148 into main
Some checks failed
Deploy Nexus / deploy (push) Failing after 3s
Staging Verification Gate / verify-staging (push) Failing after 3s
2026-04-12 12:22:39 +00:00
2230c1c9fc Add ResonanceVisualizer
Some checks failed
CI / test (pull_request) Failing after 9s
CI / validate (pull_request) Failing after 15s
Review Approval Gate / verify-review (pull_request) Failing after 3s
2026-04-12 12:22:34 +00:00
d7bcadb8c1 Merge pull request '[GOFAI] Final Missing Files' (#1283) from feat/gofai-nexus-final-v2 into main
Some checks failed
Deploy Nexus / deploy (push) Failing after 3s
Staging Verification Gate / verify-staging (push) Failing after 3s
2026-04-12 12:22:20 +00:00
5 changed files with 84 additions and 7 deletions

View File

@@ -1,13 +1,18 @@
class MemoryOptimizer {
constructor(options = {}) {
this.threshold = options.threshold || 0.8;
this.decayRate = options.decayRate || 0.05;
this.threshold = options.threshold || 0.3;
this.decayRate = options.decayRate || 0.01;
this.lastRun = Date.now();
}
optimize(memory) {
console.log('Optimizing memory...');
// Heuristic-based pruning
return memory.filter(m => m.strength > this.threshold);
optimize(memories) {
const now = Date.now();
const elapsed = (now - this.lastRun) / 1000;
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;

View File

@@ -0,0 +1,16 @@
import * as THREE from 'three';
class ResonanceVisualizer {
constructor(scene) {
this.scene = scene;
this.links = [];
}
addLink(p1, p2, strength) {
const geometry = new THREE.BufferGeometry().setFromPoints([p1, p2]);
const material = new THREE.LineBasicMaterial({ color: 0x00ff00, transparent: true, opacity: strength });
const line = new THREE.Line(geometry, material);
this.scene.add(line);
this.links.push(line);
}
}
export default ResonanceVisualizer;

View File

@@ -815,6 +815,42 @@ const SpatialMemory = (() => {
return results.slice(0, maxResults);
}
// ─── CONTENT SEARCH ─────────────────────────────────
/**
* Search memories by text content — case-insensitive substring match.
* @param {string} query - Search text
* @param {object} [options] - Optional filters
* @param {string} [options.category] - Restrict to a specific region
* @param {number} [options.maxResults=20] - Cap results
* @returns {Array<{memory: object, score: number, position: THREE.Vector3}>}
*/
function searchByContent(query, options = {}) {
if (!query || !query.trim()) return [];
const { category, maxResults = 20 } = options;
const needle = query.trim().toLowerCase();
const results = [];
Object.values(_memoryObjects).forEach(obj => {
if (category && obj.region !== category) return;
const content = (obj.data.content || '').toLowerCase();
if (!content.includes(needle)) return;
// Score: number of occurrences + strength bonus
let matches = 0, idx = 0;
while ((idx = content.indexOf(needle, idx)) !== -1) { matches++; idx += needle.length; }
const score = matches + (obj.mesh.userData.strength || 0.7);
results.push({
memory: obj.data,
score,
position: obj.mesh.position.clone()
});
});
results.sort((a, b) => b.score - a.score);
return results.slice(0, maxResults);
}
// ─── CRYSTAL MESH COLLECTION (for raycasting) ────────
function getCrystalMeshes() {
@@ -864,7 +900,7 @@ const SpatialMemory = (() => {
init, placeMemory, removeMemory, update, importMemories, updateMemory,
getMemoryAtPosition, getRegionAtPosition, getMemoriesInRegion, getAllMemories,
getCrystalMeshes, getMemoryFromMesh, highlightMemory, clearHighlight, getSelectedId,
exportIndex, importIndex, searchNearby, REGIONS,
exportIndex, importIndex, searchNearby, searchByContent, REGIONS,
saveToStorage, loadFromStorage, clearStorage,
runGravityLayout, setCamera
};

View 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

View File

@@ -0,0 +1,6 @@
[
{
"condition": "count(type=anomaly)>3",
"action": "alert"
}
]