Compare commits
1 Commits
fix/548
...
burn/672-1
| Author | SHA1 | Date | |
|---|---|---|---|
| 4582653bb4 |
@@ -1,61 +0,0 @@
|
||||
# [PHASE-1] Survival - Keep the Lights On
|
||||
|
||||
Phase 1 is the manual-clicker stage of the fleet. The machines exist. The services exist. The human is still the automation loop.
|
||||
|
||||
## Phase Definition
|
||||
|
||||
- Current state: fleet exists, agents run, everything important still depends on human vigilance.
|
||||
- Resources tracked here: Capacity, Uptime.
|
||||
- Next phase: [PHASE-2] Automation - Self-Healing Infrastructure
|
||||
|
||||
## Current Buildings
|
||||
|
||||
- VPS hosts: Ezra, Allegro, Bezalel
|
||||
- Agents: Timmy harness, Code Claw heartbeat, Gemini AI Studio worker
|
||||
- Gitea forge
|
||||
- Evennia worlds
|
||||
|
||||
## Current Resource Snapshot
|
||||
|
||||
- Fleet operational: yes
|
||||
- Uptime baseline: 0.0%
|
||||
- Days at or above 95% uptime: 0
|
||||
- Capacity utilization: 0.0%
|
||||
|
||||
## Next Phase Trigger
|
||||
|
||||
To unlock [PHASE-2] Automation - Self-Healing Infrastructure, the fleet must hold both of these conditions at once:
|
||||
- Uptime >= 95% for 30 consecutive days
|
||||
- Capacity utilization > 60%
|
||||
- Current trigger state: NOT READY
|
||||
|
||||
## Missing Requirements
|
||||
|
||||
- Uptime 0.0% / 95.0%
|
||||
- Days at or above 95% uptime: 0/30
|
||||
- Capacity utilization 0.0% / >60.0%
|
||||
|
||||
## Manual Clicker Interpretation
|
||||
|
||||
Paperclips analogy: Phase 1 = Manual clicker. You ARE the automation.
|
||||
Every restart, every SSH, every check is a manual click.
|
||||
|
||||
## Manual Clicks Still Required
|
||||
|
||||
- Restart agents and services by hand when a node goes dark.
|
||||
- SSH into machines to verify health, disk, and memory.
|
||||
- Check Gitea, relay, and world services manually before and after changes.
|
||||
- Act as the scheduler when automation is missing or only partially wired.
|
||||
|
||||
## Repo Signals Already Present
|
||||
|
||||
- `scripts/fleet_health_probe.sh` — Automated health probe exists and can supply the uptime baseline for the next phase.
|
||||
- `scripts/fleet_milestones.py` — Milestone tracker exists, so survival achievements can be narrated and logged.
|
||||
- `scripts/auto_restart_agent.sh` — Auto-restart tooling already exists as phase-2 groundwork.
|
||||
- `scripts/backup_pipeline.sh` — Backup pipeline scaffold exists for post-survival automation work.
|
||||
- `infrastructure/timmy-bridge/reports/generate_report.py` — Bridge reporting exists and can summarize heartbeat-driven uptime.
|
||||
|
||||
## Notes
|
||||
|
||||
- The fleet is alive, but the human is still the control loop.
|
||||
- Phase 1 is about naming reality plainly so later automation has a baseline to beat.
|
||||
@@ -12,7 +12,6 @@ Quick-reference index for common operational tasks across the Timmy Foundation i
|
||||
| Check fleet health | fleet-ops | `python3 scripts/fleet_readiness.py` |
|
||||
| Agent scorecard | fleet-ops | `python3 scripts/agent_scorecard.py` |
|
||||
| View fleet manifest | fleet-ops | `cat manifest.yaml` |
|
||||
| Render Phase-1 survival report | timmy-home | `python3 scripts/fleet_phase_status.py --output docs/FLEET_PHASE_1_SURVIVAL.md` |
|
||||
|
||||
## the-nexus (Frontend + Brain)
|
||||
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render the current fleet survival phase as a durable report."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
PHASE_NAME = "[PHASE-1] Survival - Keep the Lights On"
|
||||
NEXT_PHASE_NAME = "[PHASE-2] Automation - Self-Healing Infrastructure"
|
||||
TARGET_UPTIME_PERCENT = 95.0
|
||||
TARGET_UPTIME_DAYS = 30
|
||||
TARGET_CAPACITY_PERCENT = 60.0
|
||||
|
||||
DEFAULT_BUILDINGS = [
|
||||
"VPS hosts: Ezra, Allegro, Bezalel",
|
||||
"Agents: Timmy harness, Code Claw heartbeat, Gemini AI Studio worker",
|
||||
"Gitea forge",
|
||||
"Evennia worlds",
|
||||
]
|
||||
|
||||
DEFAULT_MANUAL_CLICKS = [
|
||||
"Restart agents and services by hand when a node goes dark.",
|
||||
"SSH into machines to verify health, disk, and memory.",
|
||||
"Check Gitea, relay, and world services manually before and after changes.",
|
||||
"Act as the scheduler when automation is missing or only partially wired.",
|
||||
]
|
||||
|
||||
REPO_SIGNAL_FILES = {
|
||||
"scripts/fleet_health_probe.sh": "Automated health probe exists and can supply the uptime baseline for the next phase.",
|
||||
"scripts/fleet_milestones.py": "Milestone tracker exists, so survival achievements can be narrated and logged.",
|
||||
"scripts/auto_restart_agent.sh": "Auto-restart tooling already exists as phase-2 groundwork.",
|
||||
"scripts/backup_pipeline.sh": "Backup pipeline scaffold exists for post-survival automation work.",
|
||||
"infrastructure/timmy-bridge/reports/generate_report.py": "Bridge reporting exists and can summarize heartbeat-driven uptime.",
|
||||
}
|
||||
|
||||
DEFAULT_SNAPSHOT = {
|
||||
"fleet_operational": True,
|
||||
"resources": {
|
||||
"uptime_percent": 0.0,
|
||||
"days_at_or_above_95_percent": 0,
|
||||
"capacity_utilization_percent": 0.0,
|
||||
},
|
||||
"current_buildings": DEFAULT_BUILDINGS,
|
||||
"manual_clicks": DEFAULT_MANUAL_CLICKS,
|
||||
"notes": [
|
||||
"The fleet is alive, but the human is still the control loop.",
|
||||
"Phase 1 is about naming reality plainly so later automation has a baseline to beat.",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def default_snapshot() -> dict[str, Any]:
|
||||
return deepcopy(DEFAULT_SNAPSHOT)
|
||||
|
||||
|
||||
def _deep_merge(base: dict[str, Any], override: dict[str, Any]) -> dict[str, Any]:
|
||||
result = deepcopy(base)
|
||||
for key, value in override.items():
|
||||
if isinstance(value, dict) and isinstance(result.get(key), dict):
|
||||
result[key] = _deep_merge(result[key], value)
|
||||
else:
|
||||
result[key] = value
|
||||
return result
|
||||
|
||||
|
||||
def load_snapshot(snapshot_path: Path | None = None) -> dict[str, Any]:
|
||||
snapshot = default_snapshot()
|
||||
if snapshot_path is None:
|
||||
return snapshot
|
||||
override = json.loads(snapshot_path.read_text(encoding="utf-8"))
|
||||
return _deep_merge(snapshot, override)
|
||||
|
||||
|
||||
def collect_repo_signals(repo_root: Path) -> list[str]:
|
||||
signals: list[str] = []
|
||||
for rel_path, description in REPO_SIGNAL_FILES.items():
|
||||
if (repo_root / rel_path).exists():
|
||||
signals.append(f"`{rel_path}` — {description}")
|
||||
return signals
|
||||
|
||||
|
||||
def compute_phase_status(snapshot: dict[str, Any], repo_root: Path | None = None) -> dict[str, Any]:
|
||||
repo_root = repo_root or Path(__file__).resolve().parents[1]
|
||||
resources = snapshot.get("resources", {})
|
||||
uptime_percent = float(resources.get("uptime_percent", 0.0))
|
||||
uptime_days = int(resources.get("days_at_or_above_95_percent", 0))
|
||||
capacity_percent = float(resources.get("capacity_utilization_percent", 0.0))
|
||||
fleet_operational = bool(snapshot.get("fleet_operational", False))
|
||||
|
||||
missing: list[str] = []
|
||||
if not fleet_operational:
|
||||
missing.append("Fleet operational flag is false.")
|
||||
if uptime_percent < TARGET_UPTIME_PERCENT:
|
||||
missing.append(f"Uptime {uptime_percent:.1f}% / {TARGET_UPTIME_PERCENT:.1f}%")
|
||||
if uptime_days < TARGET_UPTIME_DAYS:
|
||||
missing.append(f"Days at or above 95% uptime: {uptime_days}/{TARGET_UPTIME_DAYS}")
|
||||
if capacity_percent <= TARGET_CAPACITY_PERCENT:
|
||||
missing.append(f"Capacity utilization {capacity_percent:.1f}% / >{TARGET_CAPACITY_PERCENT:.1f}%")
|
||||
|
||||
return {
|
||||
"title": PHASE_NAME,
|
||||
"current_phase": "PHASE-1 Survival",
|
||||
"fleet_operational": fleet_operational,
|
||||
"resources": {
|
||||
"uptime_percent": uptime_percent,
|
||||
"days_at_or_above_95_percent": uptime_days,
|
||||
"capacity_utilization_percent": capacity_percent,
|
||||
},
|
||||
"current_buildings": list(snapshot.get("current_buildings", DEFAULT_BUILDINGS)),
|
||||
"manual_clicks": list(snapshot.get("manual_clicks", DEFAULT_MANUAL_CLICKS)),
|
||||
"notes": list(snapshot.get("notes", [])),
|
||||
"repo_signals": collect_repo_signals(repo_root),
|
||||
"next_phase": NEXT_PHASE_NAME,
|
||||
"next_phase_ready": fleet_operational and not missing,
|
||||
"missing_requirements": missing,
|
||||
}
|
||||
|
||||
|
||||
def render_markdown(status: dict[str, Any]) -> str:
|
||||
resources = status["resources"]
|
||||
missing = status["missing_requirements"]
|
||||
ready_line = "READY" if status["next_phase_ready"] else "NOT READY"
|
||||
|
||||
lines = [
|
||||
f"# {status['title']}",
|
||||
"",
|
||||
"Phase 1 is the manual-clicker stage of the fleet. The machines exist. The services exist. The human is still the automation loop.",
|
||||
"",
|
||||
"## Phase Definition",
|
||||
"",
|
||||
"- Current state: fleet exists, agents run, everything important still depends on human vigilance.",
|
||||
"- Resources tracked here: Capacity, Uptime.",
|
||||
f"- Next phase: {status['next_phase']}",
|
||||
"",
|
||||
"## Current Buildings",
|
||||
"",
|
||||
]
|
||||
lines.extend(f"- {item}" for item in status["current_buildings"])
|
||||
|
||||
lines.extend([
|
||||
"",
|
||||
"## Current Resource Snapshot",
|
||||
"",
|
||||
f"- Fleet operational: {'yes' if status['fleet_operational'] else 'no'}",
|
||||
f"- Uptime baseline: {resources['uptime_percent']:.1f}%",
|
||||
f"- Days at or above 95% uptime: {resources['days_at_or_above_95_percent']}",
|
||||
f"- Capacity utilization: {resources['capacity_utilization_percent']:.1f}%",
|
||||
"",
|
||||
"## Next Phase Trigger",
|
||||
"",
|
||||
f"To unlock {status['next_phase']}, the fleet must hold both of these conditions at once:",
|
||||
f"- Uptime >= {TARGET_UPTIME_PERCENT:.0f}% for {TARGET_UPTIME_DAYS} consecutive days",
|
||||
f"- Capacity utilization > {TARGET_CAPACITY_PERCENT:.0f}%",
|
||||
f"- Current trigger state: {ready_line}",
|
||||
"",
|
||||
"## Missing Requirements",
|
||||
"",
|
||||
])
|
||||
if missing:
|
||||
lines.extend(f"- {item}" for item in missing)
|
||||
else:
|
||||
lines.append("- None. Phase 2 can unlock now.")
|
||||
|
||||
lines.extend([
|
||||
"",
|
||||
"## Manual Clicker Interpretation",
|
||||
"",
|
||||
"Paperclips analogy: Phase 1 = Manual clicker. You ARE the automation.",
|
||||
"Every restart, every SSH, every check is a manual click.",
|
||||
"",
|
||||
"## Manual Clicks Still Required",
|
||||
"",
|
||||
])
|
||||
lines.extend(f"- {item}" for item in status["manual_clicks"])
|
||||
|
||||
lines.extend([
|
||||
"",
|
||||
"## Repo Signals Already Present",
|
||||
"",
|
||||
])
|
||||
if status["repo_signals"]:
|
||||
lines.extend(f"- {item}" for item in status["repo_signals"])
|
||||
else:
|
||||
lines.append("- No survival-adjacent repo signals detected.")
|
||||
|
||||
if status["notes"]:
|
||||
lines.extend(["", "## Notes", ""])
|
||||
lines.extend(f"- {item}" for item in status["notes"])
|
||||
|
||||
return "\n".join(lines).rstrip() + "\n"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Render the fleet phase-1 survival report")
|
||||
parser.add_argument("--snapshot", help="Optional JSON snapshot overriding the default phase-1 baseline")
|
||||
parser.add_argument("--output", help="Write markdown report to this path")
|
||||
parser.add_argument("--json", action="store_true", help="Print computed status as JSON instead of markdown")
|
||||
args = parser.parse_args()
|
||||
|
||||
snapshot = load_snapshot(Path(args.snapshot).expanduser() if args.snapshot else None)
|
||||
repo_root = Path(__file__).resolve().parents[1]
|
||||
status = compute_phase_status(snapshot, repo_root=repo_root)
|
||||
|
||||
if args.json:
|
||||
rendered = json.dumps(status, indent=2)
|
||||
else:
|
||||
rendered = render_markdown(status)
|
||||
|
||||
if args.output:
|
||||
output_path = Path(args.output).expanduser()
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
output_path.write_text(rendered, encoding="utf-8")
|
||||
print(f"Phase status written to {output_path}")
|
||||
else:
|
||||
print(rendered)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,67 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT_PATH = ROOT / "scripts" / "fleet_phase_status.py"
|
||||
DOC_PATH = ROOT / "docs" / "FLEET_PHASE_1_SURVIVAL.md"
|
||||
|
||||
|
||||
def _load_module(path: Path, name: str):
|
||||
assert path.exists(), f"missing {path.relative_to(ROOT)}"
|
||||
spec = importlib.util.spec_from_file_location(name, path)
|
||||
assert spec and spec.loader
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def test_compute_phase_status_tracks_survival_gate_requirements() -> None:
|
||||
mod = _load_module(SCRIPT_PATH, "fleet_phase_status")
|
||||
|
||||
status = mod.compute_phase_status(
|
||||
{
|
||||
"fleet_operational": True,
|
||||
"resources": {
|
||||
"uptime_percent": 94.5,
|
||||
"days_at_or_above_95_percent": 12,
|
||||
"capacity_utilization_percent": 45.0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
assert status["current_phase"] == "PHASE-1 Survival"
|
||||
assert status["next_phase_ready"] is False
|
||||
assert any("94.5% / 95.0%" in item for item in status["missing_requirements"])
|
||||
assert any("12/30" in item for item in status["missing_requirements"])
|
||||
assert any("45.0% / >60.0%" in item for item in status["missing_requirements"])
|
||||
|
||||
|
||||
def test_render_markdown_preserves_phase_buildings_and_manual_clicker_language() -> None:
|
||||
mod = _load_module(SCRIPT_PATH, "fleet_phase_status")
|
||||
status = mod.compute_phase_status(mod.default_snapshot())
|
||||
report = mod.render_markdown(status)
|
||||
|
||||
for snippet in (
|
||||
"# [PHASE-1] Survival - Keep the Lights On",
|
||||
"VPS hosts: Ezra, Allegro, Bezalel",
|
||||
"Timmy harness",
|
||||
"Gitea forge",
|
||||
"Evennia worlds",
|
||||
"Every restart, every SSH, every check is a manual click.",
|
||||
):
|
||||
assert snippet in report
|
||||
|
||||
|
||||
def test_repo_contains_generated_phase_1_doc() -> None:
|
||||
assert DOC_PATH.exists(), "missing committed phase-1 survival doc"
|
||||
text = DOC_PATH.read_text(encoding="utf-8")
|
||||
for snippet in (
|
||||
"# [PHASE-1] Survival - Keep the Lights On",
|
||||
"## Current Buildings",
|
||||
"## Next Phase Trigger",
|
||||
"## Manual Clicker Interpretation",
|
||||
):
|
||||
assert snippet in text
|
||||
319
the-nexus-GENOME.md
Normal file
319
the-nexus-GENOME.md
Normal file
@@ -0,0 +1,319 @@
|
||||
# GENOME.md — the-nexus
|
||||
|
||||
**Generated:** 2026-04-14
|
||||
**Repo:** Timmy_Foundation/the-nexus
|
||||
**Analysis:** Codebase Genome #672
|
||||
|
||||
---
|
||||
|
||||
## Project Overview
|
||||
|
||||
The Nexus is Timmy's canonical 3D home-world — a browser-based Three.js application that serves as:
|
||||
1. **Local-first training ground** for Timmy (the sovereign AI)
|
||||
2. **Wizardly visualization surface** for the fleet system
|
||||
3. **Portal architecture** connecting to other worlds and services
|
||||
|
||||
The app is a real-time 3D environment with spatial memory, GOFAI reasoning, agent presence, and portal-based navigation.
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph Browser["BROWSER LAYER"]
|
||||
HTML[index.html]
|
||||
APP[app.js - 4082 lines]
|
||||
CSS[style.css]
|
||||
Worker[gofai_worker.js]
|
||||
end
|
||||
|
||||
subgraph ThreeJS["THREE.JS RENDERING"]
|
||||
Scene[Scene Management]
|
||||
Camera[Camera System]
|
||||
Renderer[WebGL Renderer]
|
||||
Post[Post-processing<br/>Bloom, SMAA]
|
||||
Physics[Physics/Player]
|
||||
end
|
||||
|
||||
subgraph Nexus["NEXUS COMPONENTS"]
|
||||
SM[SpatialMemory]
|
||||
SA[SpatialAudio]
|
||||
MB[MemoryBirth]
|
||||
MO[MemoryOptimizer]
|
||||
MI[MemoryInspect]
|
||||
MP[MemoryPulse]
|
||||
RT[ReasoningTrace]
|
||||
RV[ResonanceVisualizer]
|
||||
end
|
||||
|
||||
subgraph GOFAI["GOFAI REASONING"]
|
||||
Worker2[Web Worker]
|
||||
Rules[Rule Engine]
|
||||
Facts[Fact Store]
|
||||
Inference[Inference Loop]
|
||||
end
|
||||
|
||||
subgraph Backend["BACKEND SERVICES"]
|
||||
Server[server.py<br/>WebSocket Bridge]
|
||||
L402[L402 Cost API]
|
||||
Portal[Portal Registry]
|
||||
end
|
||||
|
||||
subgraph Data["DATA/PERSISTENCE"]
|
||||
Local[localStorage]
|
||||
IDB[IndexedDB]
|
||||
JSON[portals.json]
|
||||
Vision[vision.json]
|
||||
end
|
||||
|
||||
HTML --> APP
|
||||
APP --> ThreeJS
|
||||
APP --> Nexus
|
||||
APP --> GOFAI
|
||||
APP --> Backend
|
||||
APP --> Data
|
||||
|
||||
Worker2 --> APP
|
||||
Server --> APP
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Entry Points
|
||||
|
||||
### Primary Entry
|
||||
- **`index.html`** — Main HTML shell, loads app.js
|
||||
- **`app.js`** — Main application (4082 lines), Three.js scene setup
|
||||
|
||||
### Secondary Entry Points
|
||||
- **`boot.js`** — Bootstrap sequence
|
||||
- **`bootstrap.mjs`** — ES module bootstrap
|
||||
- **`server.py`** — WebSocket bridge server
|
||||
|
||||
### Configuration Entry Points
|
||||
- **`portals.json`** — Portal definitions and destinations
|
||||
- **`vision.json`** — Vision/agent configuration
|
||||
- **`config/fleet_agents.json`** — Fleet agent definitions
|
||||
|
||||
---
|
||||
|
||||
## Data Flow
|
||||
|
||||
```
|
||||
User Input
|
||||
↓
|
||||
app.js (Event Loop)
|
||||
↓
|
||||
┌─────────────────────────────────────┐
|
||||
│ Three.js Scene │
|
||||
│ - Player movement │
|
||||
│ - Camera controls │
|
||||
│ - Physics simulation │
|
||||
│ - Portal detection │
|
||||
└─────────────────────────────────────┘
|
||||
↓
|
||||
┌─────────────────────────────────────┐
|
||||
│ Nexus Components │
|
||||
│ - SpatialMemory (room/context) │
|
||||
│ - MemoryBirth (new memories) │
|
||||
│ - MemoryPulse (heartbeat) │
|
||||
│ - ReasoningTrace (GOFAI output) │
|
||||
└─────────────────────────────────────┘
|
||||
↓
|
||||
┌─────────────────────────────────────┐
|
||||
│ GOFAI Worker (off-thread) │
|
||||
│ - Rule evaluation │
|
||||
│ - Fact inference │
|
||||
│ - Decision making │
|
||||
└─────────────────────────────────────┘
|
||||
↓
|
||||
┌─────────────────────────────────────┐
|
||||
│ Backend Services │
|
||||
│ - WebSocket (server.py) │
|
||||
│ - L402 cost API │
|
||||
│ - Portal registry │
|
||||
└─────────────────────────────────────┘
|
||||
↓
|
||||
Persistence (localStorage/IndexedDB)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Abstractions
|
||||
|
||||
### 1. Nexus Object (`NEXUS`)
|
||||
Central configuration and state object containing:
|
||||
- Color palette
|
||||
- Room definitions
|
||||
- Portal configurations
|
||||
- Agent settings
|
||||
|
||||
### 2. SpatialMemory
|
||||
Manages room-based context for the AI agent:
|
||||
- Room transitions trigger context switches
|
||||
- Facts are stored per-room
|
||||
- NPCs have location awareness
|
||||
|
||||
### 3. Portal System
|
||||
Connects the 3D world to external services:
|
||||
- Portals defined in `portals.json`
|
||||
- Each portal links to a service/endpoint
|
||||
- Visual indicators in 3D space
|
||||
|
||||
### 4. GOFAI Worker
|
||||
Off-thread reasoning engine:
|
||||
- Rule-based inference
|
||||
- Fact store with persistence
|
||||
- Decision making for agent behavior
|
||||
|
||||
### 5. Memory Components
|
||||
- **MemoryBirth**: Creates new memories from interactions
|
||||
- **MemoryOptimizer**: Compresses and deduplicates memories
|
||||
- **MemoryPulse**: Heartbeat system for memory health
|
||||
- **MemoryInspect**: Debug/inspection interface
|
||||
|
||||
---
|
||||
|
||||
## API Surface
|
||||
|
||||
### Internal APIs (JavaScript)
|
||||
|
||||
| Module | Export | Purpose |
|
||||
|--------|--------|---------|
|
||||
| `app.js` | `NEXUS` | Main config/state object |
|
||||
| `SpatialMemory` | class | Room-based context management |
|
||||
| `SpatialAudio` | class | 3D positional audio |
|
||||
| `MemoryBirth` | class | Memory creation |
|
||||
| `MemoryOptimizer` | class | Memory compression |
|
||||
| `ReasoningTrace` | class | GOFAI reasoning visualization |
|
||||
|
||||
### External APIs (HTTP/WebSocket)
|
||||
|
||||
| Endpoint | Protocol | Purpose |
|
||||
|----------|----------|---------|
|
||||
| `ws://localhost:PORT` | WebSocket | Real-time bridge to backend |
|
||||
| `http://localhost:8080/api/cost-estimate` | HTTP | L402 cost estimation |
|
||||
| Portal endpoints | Various | External service connections |
|
||||
|
||||
---
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Runtime Dependencies
|
||||
- **Three.js** — 3D rendering engine
|
||||
- **Three.js Addons** — Post-processing (Bloom, SMAA)
|
||||
|
||||
### Build Dependencies
|
||||
- **ES Modules** — Native browser modules
|
||||
- **No bundler** — Direct script loading
|
||||
|
||||
### Backend Dependencies
|
||||
- **Python 3.x** — server.py
|
||||
- **WebSocket** — Real-time communication
|
||||
|
||||
---
|
||||
|
||||
## Test Coverage
|
||||
|
||||
### Existing Tests
|
||||
- `tests/boot.test.js` — Bootstrap sequence tests
|
||||
|
||||
### Test Gaps
|
||||
1. **Three.js scene initialization** — No tests
|
||||
2. **Portal system** — No tests
|
||||
3. **Memory components** — No tests
|
||||
4. **GOFAI worker** — No tests
|
||||
5. **WebSocket communication** — No tests
|
||||
6. **Spatial memory transitions** — No tests
|
||||
7. **Physics/player movement** — No tests
|
||||
|
||||
### Recommended Test Priorities
|
||||
1. Portal detection and activation
|
||||
2. Spatial memory room transitions
|
||||
3. GOFAI worker message passing
|
||||
4. WebSocket connection handling
|
||||
5. Memory persistence (localStorage/IndexedDB)
|
||||
|
||||
---
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Current Risks
|
||||
1. **WebSocket without auth** — server.py has no authentication
|
||||
2. **localStorage sensitive data** — Memories stored unencrypted
|
||||
3. **CORS open** — No origin restrictions on WebSocket
|
||||
4. **L402 endpoint** — Cost API may expose internal state
|
||||
|
||||
### Mitigations
|
||||
1. Add WebSocket authentication
|
||||
2. Encrypt sensitive memories
|
||||
3. Restrict CORS origins
|
||||
4. Rate limit L402 endpoint
|
||||
|
||||
---
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
the-nexus/
|
||||
├── app.js # Main app (4082 lines)
|
||||
├── index.html # HTML shell
|
||||
├── style.css # Styles
|
||||
├── server.py # WebSocket bridge
|
||||
├── boot.js # Bootstrap
|
||||
├── bootstrap.mjs # ES module bootstrap
|
||||
├── gofai_worker.js # GOFAI web worker
|
||||
├── portals.json # Portal definitions
|
||||
├── vision.json # Vision config
|
||||
├── nexus/ # Nexus components
|
||||
│ └── components/
|
||||
│ ├── spatial-memory.js
|
||||
│ ├── spatial-audio.js
|
||||
│ ├── memory-birth.js
|
||||
│ ├── memory-optimizer.js
|
||||
│ ├── memory-inspect.js
|
||||
│ ├── memory-pulse.js
|
||||
│ ├── reasoning-trace.js
|
||||
│ └── resonance-visualizer.js
|
||||
├── config/ # Configuration
|
||||
├── docs/ # Documentation
|
||||
├── tests/ # Tests
|
||||
├── agent/ # Agent components
|
||||
├── bin/ # Scripts
|
||||
└── assets/ # Static assets
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Technical Debt
|
||||
|
||||
1. **Large app.js** (4082 lines) — Should be split into modules
|
||||
2. **No TypeScript** — Pure JavaScript, no type safety
|
||||
3. **Manual DOM manipulation** — Could use a framework
|
||||
4. **No build system** — Direct ES modules, no optimization
|
||||
5. **Limited error handling** — Minimal try/catch coverage
|
||||
|
||||
---
|
||||
|
||||
## Migration Notes
|
||||
|
||||
From CLAUDE.md:
|
||||
- Current `main` does NOT ship the old root frontend files
|
||||
- A clean checkout serves a directory listing
|
||||
- The live browser shell exists in legacy form at `/Users/apayne/the-matrix`
|
||||
- Migration priorities: #684 (docs), #685 (legacy audit), #686 (smoke tests), #687 (restore shell)
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. **Restore browser shell** — Bring frontend back to main
|
||||
2. **Add tests** — Cover critical paths (portals, memory, GOFAI)
|
||||
3. **Split app.js** — Modularize the 4082-line file
|
||||
4. **Add authentication** — Secure WebSocket and APIs
|
||||
5. **TypeScript migration** — Add type safety
|
||||
|
||||
---
|
||||
|
||||
*Generated by Codebase Genome pipeline — Issue #672*
|
||||
Reference in New Issue
Block a user