All checks were successful
Forge CI / smoke-and-build (pull_request) Successful in 1m0s
- Add bezalel_topology.md: complete system architecture map - Add topology_scan.py: automated topology discovery script - Covers hardware, network, services, dependencies, fleet map, Evennia integration, MemPalace config, and emergency procedures Addresses #203
135 lines
4.9 KiB
Python
135 lines
4.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Bezalel Deep Self-Awareness Topology Scanner"""
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
|
|
OUT_DIR = Path("/root/wizards/bezalel/.topology")
|
|
OUT_DIR.mkdir(exist_ok=True)
|
|
|
|
|
|
def shell(cmd, timeout=30):
|
|
try:
|
|
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
|
|
return r.stdout.strip()
|
|
except Exception as e:
|
|
return str(e)
|
|
|
|
|
|
def write(name, content):
|
|
(OUT_DIR / f"{name}.txt").write_text(content)
|
|
|
|
|
|
# Timestamp
|
|
timestamp = datetime.now(timezone.utc).isoformat()
|
|
|
|
# 1. System Identity
|
|
system = f"""BEZALEL SYSTEM TOPOLOGY SCAN
|
|
Generated: {timestamp}
|
|
Hostname: {shell('hostname')}
|
|
User: {shell('whoami')}
|
|
Home: {os.path.expanduser('~')}
|
|
"""
|
|
write("00_system_identity", system)
|
|
|
|
# 2. OS & Hardware
|
|
os_info = shell("cat /etc/os-release")
|
|
kernel = shell("uname -a")
|
|
cpu = shell("nproc") + " cores\n" + shell("cat /proc/cpuinfo | grep 'model name' | head -1")
|
|
mem = shell("free -h")
|
|
disk = shell("df -h")
|
|
write("01_os_hardware", f"OS:\n{os_info}\n\nKernel:\n{kernel}\n\nCPU:\n{cpu}\n\nMemory:\n{mem}\n\nDisk:\n{disk}")
|
|
|
|
# 3. Network
|
|
net_interfaces = shell("ip addr")
|
|
net_routes = shell("ip route")
|
|
listening = shell("ss -tlnp")
|
|
public_ip = shell("curl -s ifconfig.me")
|
|
write("02_network", f"Interfaces:\n{net_interfaces}\n\nRoutes:\n{net_routes}\n\nListening ports:\n{listening}\n\nPublic IP: {public_ip}")
|
|
|
|
# 4. Services & Processes
|
|
services = shell("systemctl list-units --type=service --state=running --no-pager --no-legend 2>/dev/null | head -30")
|
|
processes = shell("ps aux | grep -E 'hermes|gitea|evennia|python' | grep -v grep")
|
|
write("03_services", f"Running services:\n{services}\n\nKey processes:\n{processes}")
|
|
|
|
# 5. Cron & Automation
|
|
cron = shell("crontab -l 2>/dev/null")
|
|
write("04_automation", f"Crontab:\n{cron}")
|
|
|
|
# 6. Storage Topology
|
|
bezalel_tree = shell("find /root/wizards/bezalel -maxdepth 2 -type d | sort")
|
|
write("05_storage", f"Bezalel workspace tree (depth 2):\n{bezalel_tree}")
|
|
|
|
# 7. Git Repositories
|
|
git_repos = []
|
|
for base in ["/root/wizards/bezalel/hermes", "/root/wizards/bezalel/evennia"]:
|
|
p = Path(base)
|
|
if (p / ".git").exists():
|
|
remote = shell(f"cd {base} && git remote -v")
|
|
branch = shell(f"cd {base} && git branch -v")
|
|
git_repos.append(f"Repo: {base}\nRemotes:\n{remote}\nBranches:\n{branch}\n{'='*40}")
|
|
write("06_git_repos", "\n".join(git_repos))
|
|
|
|
# 8. Python Dependencies
|
|
venv_pip = shell("/root/wizards/bezalel/hermes/venv/bin/pip freeze 2>/dev/null | head -80")
|
|
write("07_dependencies", f"Hermes venv packages (top 80):\n{venv_pip}")
|
|
|
|
# 9. External APIs & Endpoints
|
|
apis = """External API Dependencies:
|
|
- Gitea: https://forge.alexanderwhitestone.com (source of truth, CI, issues)
|
|
- Telegram: webhook-based messaging platform
|
|
- Kimi API: https://api.kimi.com/coding/v1 (primary model provider)
|
|
- Anthropic API: fallback model provider
|
|
- OpenRouter API: secondary fallback model provider
|
|
- DigitalOcean: infrastructure hosting (VPS Alpha/Beta)
|
|
"""
|
|
write("08_external_apis", apis)
|
|
|
|
# 10. Fleet Topology
|
|
fleet = """FLEET TOPOLOGY
|
|
- Alpha: 143.198.27.163 (Gitea + Ezra)
|
|
- Beta: 104.131.15.18 (Bezalel, current host)
|
|
- No SSH from Alpha to Beta
|
|
- Gitea Actions runner: bezalel-vps-runner on Beta (host mode)
|
|
"""
|
|
write("09_fleet_topology", fleet)
|
|
|
|
# 11. Evennia Topology
|
|
evennia = """EVENNIA MIND PALACE SETUP
|
|
- Location: /root/wizards/bezalel/evennia/bezalel_world/
|
|
- Server name: bezalel_world
|
|
- Custom typeclasses: PalaceRoom, MemoryObject
|
|
- Custom commands: CmdPalaceSearch (palace/search, palace/recall, palace/file, palace/status)
|
|
- Batch builder: world/batch_cmds_palace.ev
|
|
- Bridge script: /root/wizards/bezalel/evennia/palace_search.py
|
|
"""
|
|
write("10_evennia_topology", evennia)
|
|
|
|
# 12. MemPalace Topology
|
|
mempalace = f"""MEMPALACE CONFIGURATION
|
|
- Palace path: /root/wizards/bezalel/.mempalace/palace
|
|
- Identity: /root/.mempalace/identity.txt
|
|
- Config: /root/wizards/bezalel/mempalace.yaml
|
|
- Nightly re-mine: 03:00 UTC via /root/wizards/bezalel/mempalace_nightly.sh
|
|
- Miner binary: /root/wizards/bezalel/hermes/venv/bin/mempalace
|
|
- Current status: {shell('/root/wizards/bezalel/hermes/venv/bin/mempalace --palace /root/wizards/bezalel/.mempalace/palace status 2>/dev/null')}
|
|
"""
|
|
write("11_mempalace_topology", mempalace)
|
|
|
|
# 13. Active Blockers & Health
|
|
health = f"""ACTIVE OPERATIONAL STATE
|
|
- Hermes gateway: {shell("ps aux | grep 'hermes gateway run' | grep -v grep | awk '{print $11}'")}
|
|
- Gitea runner: {shell("ps aux | grep 'act_runner' | grep -v grep | awk '{print $11}'")}
|
|
- Nightly watch: /root/wizards/bezalel/nightly_watch.py (02:00 UTC)
|
|
- MemPalace re-mine: /root/wizards/bezalel/mempalace_nightly.sh (03:00 UTC)
|
|
- Disk usage: {shell("df -h / | tail -1")}
|
|
- Load average: {shell("uptime")}
|
|
"""
|
|
write("12_operational_health", health)
|
|
|
|
print(f"Topology scan complete. {len(list(OUT_DIR.glob('*.txt')))} files written to {OUT_DIR}")
|