Compare commits
3 Commits
fix/1644
...
fix/1536-h
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c9f4310d0 | |||
| 15b9a4398c | |||
|
|
11175e72c0 |
234
GENOME.md
234
GENOME.md
@@ -1,234 +0,0 @@
|
||||
# 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.*
|
||||
3
app.js
3
app.js
@@ -734,6 +734,9 @@ async function init() {
|
||||
const response = await fetch('./portals.json');
|
||||
const portalData = await response.json();
|
||||
createPortals(portalData);
|
||||
|
||||
// Start portal hot-reload watcher
|
||||
if (window.PortalHotReload) PortalHotReload.start(5000);
|
||||
} catch (e) {
|
||||
console.error('Failed to load portals.json:', e);
|
||||
addChatMessage('error', 'Portal registry offline. Check logs.');
|
||||
|
||||
@@ -397,6 +397,7 @@
|
||||
<script src="./boot.js"></script>
|
||||
<script src="./avatar-customization.js"></script>
|
||||
<script src="./lod-system.js"></script>
|
||||
<script src="./portal-hot-reload.js"></script>
|
||||
<script>
|
||||
function openMemoryFilter() { renderFilterList(); document.getElementById('memory-filter').style.display = 'flex'; }
|
||||
function closeMemoryFilter() { document.getElementById('memory-filter').style.display = 'none'; }
|
||||
|
||||
105
portal-hot-reload.js
Normal file
105
portal-hot-reload.js
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Portal Hot-Reload for The Nexus
|
||||
*
|
||||
* Watches portals.json for changes and hot-reloads portal list
|
||||
* without server restart. Existing connections unaffected.
|
||||
*
|
||||
* Usage:
|
||||
* PortalHotReload.start(intervalMs);
|
||||
* PortalHotReload.stop();
|
||||
* PortalHotReload.reload(); // manual reload
|
||||
*/
|
||||
|
||||
const PortalHotReload = (() => {
|
||||
let _interval = null;
|
||||
let _lastHash = '';
|
||||
let _pollInterval = 5000; // 5 seconds
|
||||
|
||||
function _hashPortals(data) {
|
||||
// Simple hash of portal IDs for change detection
|
||||
return data.map(p => p.id || p.name).sort().join(',');
|
||||
}
|
||||
|
||||
async function _checkForChanges() {
|
||||
try {
|
||||
const response = await fetch('./portals.json?t=' + Date.now());
|
||||
if (!response.ok) return;
|
||||
|
||||
const data = await response.json();
|
||||
const hash = _hashPortals(data);
|
||||
|
||||
if (hash !== _lastHash) {
|
||||
console.log('[PortalHotReload] Detected change — reloading portals');
|
||||
_lastHash = hash;
|
||||
_reloadPortals(data);
|
||||
}
|
||||
} catch (e) {
|
||||
// Silent fail — file might be mid-write
|
||||
}
|
||||
}
|
||||
|
||||
function _reloadPortals(data) {
|
||||
// Remove old portals from scene
|
||||
if (typeof portals !== 'undefined' && Array.isArray(portals)) {
|
||||
portals.forEach(p => {
|
||||
if (p.group && typeof scene !== 'undefined' && scene) {
|
||||
scene.remove(p.group);
|
||||
}
|
||||
});
|
||||
portals.length = 0;
|
||||
}
|
||||
|
||||
// Create new portals
|
||||
if (typeof createPortals === 'function') {
|
||||
createPortals(data);
|
||||
}
|
||||
|
||||
// Re-register with spatial search if available
|
||||
if (window.SpatialSearch && typeof portals !== 'undefined') {
|
||||
portals.forEach(p => {
|
||||
if (p.config && p.config.name && p.group) {
|
||||
SpatialSearch.register('portal', p, p.config.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Notify
|
||||
if (typeof addChatMessage === 'function') {
|
||||
addChatMessage('system', `Portals reloaded: ${data.length} portals active`);
|
||||
}
|
||||
|
||||
console.log(`[PortalHotReload] Reloaded ${data.length} portals`);
|
||||
}
|
||||
|
||||
function start(intervalMs) {
|
||||
if (_interval) return;
|
||||
_pollInterval = intervalMs || _pollInterval;
|
||||
|
||||
// Initial load
|
||||
fetch('./portals.json').then(r => r.json()).then(data => {
|
||||
_lastHash = _hashPortals(data);
|
||||
}).catch(() => {});
|
||||
|
||||
_interval = setInterval(_checkForChanges, _pollInterval);
|
||||
console.log(`[PortalHotReload] Watching portals.json every ${_pollInterval}ms`);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (_interval) {
|
||||
clearInterval(_interval);
|
||||
_interval = null;
|
||||
console.log('[PortalHotReload] Stopped');
|
||||
}
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
const response = await fetch('./portals.json?t=' + Date.now());
|
||||
const data = await response.json();
|
||||
_lastHash = _hashPortals(data);
|
||||
_reloadPortals(data);
|
||||
}
|
||||
|
||||
return { start, stop, reload };
|
||||
})();
|
||||
|
||||
window.PortalHotReload = PortalHotReload;
|
||||
Reference in New Issue
Block a user