Compare commits
3 Commits
fix/1539-1
...
fix/1644
| Author | SHA1 | Date | |
|---|---|---|---|
| b87e83875e | |||
| e2299514b1 | |||
|
|
c2003e258f |
234
GENOME.md
Normal file
234
GENOME.md
Normal file
@@ -0,0 +1,234 @@
|
||||
# GENOME.md — The Nexus Codebase Architecture Map
|
||||
|
||||
**Generated**: 2026-04-20
|
||||
**Repository**: Timmy_Foundation/the-nexus
|
||||
**Purpose**: Comprehensive map of the Nexus codebase for developers and AI agents.
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
The Nexus is Timmy's canonical 3D/world repository — a sovereign AI agent visualization surface and local-first training ground. It combines a Three.js 3D browser world with Python cognition components, WebSocket bridges, and fleet orchestration tools.
|
||||
|
||||
**Key Stats**:
|
||||
- ~357 source files
|
||||
- 201 Python files
|
||||
- 23 JavaScript files
|
||||
- 107 Markdown docs
|
||||
- 24 Shell scripts
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
the-nexus/
|
||||
├── app.js # Main Three.js 3D world (frontend entry)
|
||||
├── index.html # HTML shell
|
||||
├── style.css # Global styles
|
||||
├── server.py # WebSocket gateway
|
||||
├── gofai_worker.js # GOFAI web worker
|
||||
├── portals.json # Portal registry
|
||||
├── vision.json # Vision points config
|
||||
├── provenance.json # File integrity hashes
|
||||
│
|
||||
├── nexus/ # Python cognition layer
|
||||
│ ├── components/ # Frontend JS modules
|
||||
│ ├── mnemosyne/ # Memory system
|
||||
│ ├── mempalace/ # Long-term memory
|
||||
│ └── symbolic-engine.js # GOFAI rules
|
||||
│
|
||||
├── scripts/ # Operational scripts
|
||||
├── bin/ # CLI tools
|
||||
├── tests/ # Test suite
|
||||
├── docs/ # Documentation
|
||||
└── config/ # Configuration files
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Frontend (Browser World)
|
||||
|
||||
### Entry Points
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `index.html` | HTML shell, HUD layout |
|
||||
| `app.js` | Main Three.js app (~141K lines) |
|
||||
| `style.css` | All styles (~61K) |
|
||||
| `gofai_worker.js` | Off-thread GOFAI reasoning |
|
||||
|
||||
### Core Systems
|
||||
| System | File | Description |
|
||||
|--------|------|-------------|
|
||||
| 3D World | `app.js` | Three.js scene, camera, rendering |
|
||||
| GOFAI | `app.js` | Symbolic rules, blackboard, planner |
|
||||
| Memory | `nexus/components/spatial-memory.js` | 3D memory crystals |
|
||||
| Audio | `nexus/components/spatial-audio.js` | Spatial sound system |
|
||||
| Portals | `portals.json` | External service links |
|
||||
| Chat | `app.js` | Chat panel and messaging |
|
||||
| HUD | `app.js` + `style.css` | Heads-up display |
|
||||
|
||||
### Components (`nexus/components/`)
|
||||
| Component | Purpose |
|
||||
|-----------|---------|
|
||||
| `spatial-memory.js` | 3D memory crystal visualization |
|
||||
| `spatial-audio.js` | Spatial sound for memories |
|
||||
| `memory-birth.js` | Memory creation animation |
|
||||
| `memory-pulse.js` | BFS pulse wave on click |
|
||||
| `memory-inspect.js` | Memory detail panel |
|
||||
| `memory-connections.js` | Connection graph |
|
||||
| `memory-particles.js` | Particle effects |
|
||||
| `memory-optimizer.js` | Memory cleanup |
|
||||
| `session-rooms.js` | Evennia room snapshots |
|
||||
| `timeline-scrubber.js` | Time navigation |
|
||||
| `resonance-visualizer.js` | Pattern visualization |
|
||||
| `portal-health-check.js` | Portal status monitoring |
|
||||
| `spatial-chat.js` | 3D audio chat notifications |
|
||||
|
||||
---
|
||||
|
||||
## Backend (Python)
|
||||
|
||||
### Core Services
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `server.py` | WebSocket gateway for real-time comms |
|
||||
| `multi_user_bridge.py` | Multi-user MUD bridge |
|
||||
| `gitea_api/` | Gitea API helpers |
|
||||
|
||||
### Scripts (`scripts/`)
|
||||
| Script | Purpose |
|
||||
|--------|---------|
|
||||
| `cleanup-duplicate-prs.sh` | Close duplicate PRs |
|
||||
| `check-existing-prs.sh` | Pre-flight PR check |
|
||||
| `pr_backlog_analyzer.py` | PR backlog analysis |
|
||||
| `audit_mempalace_privacy.py` | Privacy audit |
|
||||
| `provision-runner.sh` | Runner setup |
|
||||
| `runner_health_probe.sh` | Health monitoring |
|
||||
|
||||
### Bin Tools (`bin/`)
|
||||
| Tool | Purpose |
|
||||
|------|---------|
|
||||
| `enforce_branch_protection.py` | Branch protection enforcement |
|
||||
| `check_duplicate_milestones.py` | Milestone cleanup |
|
||||
| `generate_provenance.py` | Provenance hash generation |
|
||||
|
||||
---
|
||||
|
||||
## Data Files
|
||||
|
||||
| File | Format | Purpose |
|
||||
|------|--------|---------|
|
||||
| `portals.json` | JSON | Portal registry (8 portals) |
|
||||
| `vision.json` | JSON | Vision points |
|
||||
| `world_state.json` | JSON | World state snapshot |
|
||||
| `provenance.json` | JSON | File integrity hashes |
|
||||
| `manifest.json` | JSON | PWA manifest |
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `.gitea/branch-protection/` | Branch protection rules |
|
||||
| `.github/workflows/` | CI/CD workflows |
|
||||
| `config/` | Runtime configuration |
|
||||
| `pytest.ini` | Test configuration |
|
||||
|
||||
---
|
||||
|
||||
## Testing
|
||||
|
||||
| Directory | Coverage |
|
||||
|-----------|----------|
|
||||
| `tests/` | Unit and integration tests |
|
||||
| `tests/test_provenance.py` | File integrity tests |
|
||||
| `tests/test_spatial_search.js` | Spatial search tests |
|
||||
|
||||
Run tests:
|
||||
```bash
|
||||
python3 -m pytest tests/ -v
|
||||
node --test tests/*.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Patterns
|
||||
|
||||
### Component Pattern
|
||||
```javascript
|
||||
const ComponentName = (() => {
|
||||
let _state = null;
|
||||
|
||||
function init(config) { ... }
|
||||
function update(delta) { ... }
|
||||
|
||||
return { init, update };
|
||||
})();
|
||||
|
||||
export { ComponentName };
|
||||
```
|
||||
|
||||
### WebSocket Pattern
|
||||
```python
|
||||
async def handler(websocket):
|
||||
async for message in websocket:
|
||||
# Process and broadcast
|
||||
pass
|
||||
```
|
||||
|
||||
### Portal Schema
|
||||
```json
|
||||
{
|
||||
"id": "portal-id",
|
||||
"name": "Display Name",
|
||||
"portal_type": "game-world",
|
||||
"destination": { "url": "...", "type": "harness" }
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Security
|
||||
|
||||
- WebSocket gateway binds to `127.0.0.1` by default
|
||||
- Optional token authentication via `NEXUS_WS_TOKEN`
|
||||
- Rate limiting on connections and messages
|
||||
- Branch protection on `main`
|
||||
- Provenance hash verification
|
||||
|
||||
See `SECURITY.md` for full details.
|
||||
|
||||
---
|
||||
|
||||
## Related Repos
|
||||
|
||||
| Repo | Relationship |
|
||||
|------|--------------|
|
||||
| `timmy-config` | Configuration and fleet management |
|
||||
| `hermes-agent` | Agent runtime |
|
||||
| `timmy-home` | SOUL.md and core docs |
|
||||
| `the-door` | Crisis detection system |
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Clone
|
||||
git clone https://forge.alexanderwhitestone.com/Timmy_Foundation/the-nexus.git
|
||||
|
||||
# Run WebSocket gateway
|
||||
python3 server.py
|
||||
|
||||
# Open browser world
|
||||
open index.html
|
||||
|
||||
# Run tests
|
||||
python3 -m pytest tests/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*This GENOME.md is auto-maintained. Update when adding major new systems.*
|
||||
6
app.js
6
app.js
@@ -734,8 +734,6 @@ async function init() {
|
||||
const response = await fetch('./portals.json');
|
||||
const portalData = await response.json();
|
||||
createPortals(portalData);
|
||||
// Initialize portal health checks (#1539)
|
||||
if (window.PortalHealthCheck) window.PortalHealthCheck.init(portals);
|
||||
} catch (e) {
|
||||
console.error('Failed to load portals.json:', e);
|
||||
addChatMessage('error', 'Portal registry offline. Check logs.');
|
||||
@@ -3574,9 +3572,7 @@ function gameLoop() {
|
||||
animateMemoryOrbs(delta);
|
||||
}
|
||||
|
||||
updatePortalTunnel(delta, elapsed);
|
||||
// Update portal health visuals (#1539)
|
||||
if (window.PortalHealthCheck) window.PortalHealthCheck.update(portals);
|
||||
updatePortalTunnel(delta, elapsed);
|
||||
|
||||
if (workshopScanMat) workshopScanMat.uniforms.uTime.value = clock.getElapsedTime();
|
||||
if (activePortal !== lastFocusedPortal) {
|
||||
|
||||
@@ -396,7 +396,6 @@
|
||||
|
||||
<script src="./boot.js"></script>
|
||||
<script src="./avatar-customization.js"></script>
|
||||
<script src="./portal-health-check.js"></script>
|
||||
<script src="./lod-system.js"></script>
|
||||
<script>
|
||||
function openMemoryFilter() { renderFilterList(); document.getElementById('memory-filter').style.display = 'flex'; }
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
/**
|
||||
* Portal Health Check Module (#1539)
|
||||
*
|
||||
* Monitors portal status and updates visuals:
|
||||
* - Dims offline/blocked portals
|
||||
* - Shows "Offline" tooltip
|
||||
* - Auto-re-enables when status changes to online
|
||||
* - Runs check every 5 minutes
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const CHECK_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
||||
const DIM_OPACITY = 0.15;
|
||||
const NORMAL_OPACITY = 1.0;
|
||||
const FADE_SPEED = 0.02;
|
||||
|
||||
let portalHealthStates = {}; // portal_id -> { healthy, fading, currentOpacity, targetOpacity }
|
||||
let checkTimer = null;
|
||||
|
||||
// ═══ Health Check ═══════════════════════════════════════════
|
||||
function checkPortalHealth(portals, wsConnected) {
|
||||
for (const portal of portals) {
|
||||
const id = portal.config.id;
|
||||
const status = portal.config.status || 'unknown';
|
||||
const blocked = portal.config.blocked_reason;
|
||||
const interactionReady = portal.config.interaction_ready !== false;
|
||||
|
||||
// Determine health
|
||||
const healthy = status === 'online' && !blocked && interactionReady && wsConnected;
|
||||
|
||||
if (!portalHealthStates[id]) {
|
||||
portalHealthStates[id] = { healthy: true, currentOpacity: NORMAL_OPACITY, targetOpacity: NORMAL_OPACITY };
|
||||
}
|
||||
|
||||
const state = portalHealthStates[id];
|
||||
const wasHealthy = state.healthy;
|
||||
state.healthy = healthy;
|
||||
state.targetOpacity = healthy ? NORMAL_OPACITY : DIM_OPACITY;
|
||||
|
||||
// Log state changes
|
||||
if (wasHealthy !== healthy) {
|
||||
const label = portal.config.name || id;
|
||||
if (healthy) {
|
||||
console.log(`[PortalHealth] ${label} — back online`);
|
||||
} else {
|
||||
const reason = blocked || (!wsConnected ? 'bridge offline' : `status: ${status}`);
|
||||
console.log(`[PortalHealth] ${label} — offline (${reason})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ═══ Visual Update ══════════════════════════════════════════
|
||||
function updatePortalVisuals(portals) {
|
||||
for (const portal of portals) {
|
||||
const id = portal.config.id;
|
||||
const state = portalHealthStates[id];
|
||||
if (!state) continue;
|
||||
|
||||
// Smooth fade toward target opacity
|
||||
if (Math.abs(state.currentOpacity - state.targetOpacity) > 0.01) {
|
||||
state.currentOpacity += (state.targetOpacity - state.currentOpacity) * FADE_SPEED;
|
||||
} else {
|
||||
state.currentOpacity = state.targetOpacity;
|
||||
}
|
||||
|
||||
const opacity = state.currentOpacity;
|
||||
const dimmed = opacity < NORMAL_OPACITY * 0.5;
|
||||
|
||||
// Apply to portal meshes
|
||||
if (portal.ring) {
|
||||
portal.ring.material.opacity = opacity;
|
||||
portal.ring.material.transparent = true;
|
||||
portal.ring.material.emissiveIntensity = dimmed ? 0.2 : 1.5;
|
||||
}
|
||||
|
||||
if (portal.swirl) {
|
||||
portal.swirl.material.uniforms.uTime.value += dimmed ? 0.001 : 0.016; // Slow/stop swirl when offline
|
||||
portal.swirl.material.opacity = opacity;
|
||||
}
|
||||
|
||||
if (portal.pSystem) {
|
||||
portal.pSystem.material.opacity = opacity * 0.6;
|
||||
}
|
||||
|
||||
if (portal.light) {
|
||||
portal.light.intensity = dimmed ? 0.3 : 2;
|
||||
}
|
||||
|
||||
// Update label to show offline status
|
||||
if (portal.labelMesh && dimmed) {
|
||||
updatePortalLabel(portal, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updatePortalLabel(portal, state) {
|
||||
// Re-render label canvas with offline indicator
|
||||
const labelMesh = portal.labelMesh;
|
||||
if (!labelMesh || !labelMesh.material.map) return;
|
||||
|
||||
// We can't easily re-render a canvas texture each frame,
|
||||
// so we'll use a separate overlay sprite for offline status
|
||||
if (!portal.offlineLabel) {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 256;
|
||||
canvas.height = 64;
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(255, 68, 102, 0.8)';
|
||||
ctx.roundRect(0, 0, 256, 64, 8);
|
||||
ctx.fill();
|
||||
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.font = 'bold 20px monospace';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillText('⚠ OFFLINE', 128, 32);
|
||||
|
||||
const texture = new THREE.CanvasTexture(canvas);
|
||||
const material = new THREE.SpriteMaterial({ map: texture, transparent: true });
|
||||
const sprite = new THREE.Sprite(material);
|
||||
sprite.scale.set(2, 0.5, 1);
|
||||
sprite.position.y = 8.5;
|
||||
portal.group.add(sprite);
|
||||
portal.offlineLabel = sprite;
|
||||
}
|
||||
|
||||
portal.offlineLabel.visible = state.currentOpacity < NORMAL_OPACITY * 0.5;
|
||||
}
|
||||
|
||||
// ═══ Public API ═════════════════════════════════════════════
|
||||
window.PortalHealthCheck = {
|
||||
init(portalsRef) {
|
||||
// Initial check
|
||||
this.check(portalsRef, true);
|
||||
// Periodic checks
|
||||
if (checkTimer) clearInterval(checkTimer);
|
||||
checkTimer = setInterval(() => this.check(portalsRef, true), CHECK_INTERVAL);
|
||||
console.log('[PortalHealth] Initialized — checking every 5 minutes');
|
||||
},
|
||||
|
||||
check(portalsRef, wsConnected) {
|
||||
checkPortalHealth(portalsRef, wsConnected);
|
||||
},
|
||||
|
||||
update(portalsRef) {
|
||||
updatePortalVisuals(portalsRef);
|
||||
},
|
||||
|
||||
getStatus() {
|
||||
return { ...portalHealthStates };
|
||||
},
|
||||
|
||||
isHealthy(portalId) {
|
||||
return portalHealthStates[portalId]?.healthy !== false;
|
||||
},
|
||||
|
||||
destroy() {
|
||||
if (checkTimer) {
|
||||
clearInterval(checkTimer);
|
||||
checkTimer = null;
|
||||
}
|
||||
},
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user