Compare commits

..

1 Commits

Author SHA1 Message Date
Alexander Whitestone
8cdae49f48 fix(#553): eliminate hardcoded home-directory paths in Phase-6 infrastructure scripts
Some checks failed
Agent PR Gate / gate (pull_request) Failing after 1m2s
Self-Healing Smoke / self-healing-smoke (pull_request) Failing after 27s
Smoke Test / smoke (pull_request) Failing after 28s
Agent PR Gate / report (pull_request) Successful in 12s
Migrates hardcoded ~/.timmy, ~/.config, and Path.home() references across
the autonomous infrastructure stack to use environment variables with
sensible defaults:

- scripts/autonomous_issue_creator.py:
  - DEFAULT_TOKEN_FILE → XDG_CONFIG_HOME fallback
  - DEFAULT_FAILOVER_STATUS → TIMMY_HOME fallback

- scripts/failover_monitor.py:
  - STATUS_FILE → TIMMY_HOME fallback

- scripts/dynamic_dispatch_optimizer.py:
  - STATUS_FILE, SPEC_FILE, OUTPUT_FILE → TIMMY_HOME fallback

- scripts/backlog_cleanup.py:
  - token path → XDG_CONFIG_HOME fallback

- scripts/backlog_triage.py:
  - TOKEN_PATH → XDG_CONFIG_HOME fallback

- scripts/burn_lane_issue_audit.py:
  - DEFAULT_TOKEN_PATH → XDG_CONFIG_HOME fallback

- scripts/cross-repo-qa.py:
  - GITEA_TOKEN_PATH → XDG_CONFIG_HOME fallback

This makes the Phase-6 buildings (self-healing fleet, autonomous issue
creation, community pipeline, global mesh) portable across different
user accounts and deployment environments.
2026-04-22 03:05:16 -04:00
11 changed files with 16 additions and 195 deletions

View File

@@ -1,87 +0,0 @@
# Bezalel World Server Configuration
This directory contains the Evennia server configuration for Bezalel, the forge-and-testbed wizard house.
## Quick Start
To fix the Evennia settings on the Bezalel VPS (104.131.15.18):
```bash
# SSH to Bezalel and run the fix script
ssh root@104.131.15.18 'bash -s' < scripts/fix_evennia_settings.sh
```
Or manually:
```bash
cd /root/wizards/bezalel/evennia/bezalel_world/server/conf
# Copy the fixed settings
cp ~/timmy-home/evennia/bezalel_world/server/conf/settings.py ./settings.py
# Clean and reinitialize DB
cd /root/wizards/bezalel/evennia/bezalel_world
rm -f server/evennia.db3
/root/wizards/bezalel/evennia/venv/bin/evennia migrate
# Create superuser
/root/wizards/bezalel/evennia/venv/bin/python3 -c "
import sys, os
sys.setrecursionlimit(5000)
os.environ['DJANGO_SETTINGS_MODULE'] = 'server.conf.settings'
import django
django.setup()
from evennia.accounts.accounts import AccountDB
AccountDB.objects.create_superuser('Timmy', 'timmy@tower.world', 'timmy123')
"
# Start Evennia
/root/wizards/bezalel/evennia/venv/bin/evennia start
```
## The Fix (Issue #534)
**Problem:** `WEBSERVER_PORTS = [(4101, None)]` — the `None` tuple value crashes Evennia's Twisted port binding with:
```
TypeError: 'NoneType' object cannot be interpreted as an integer
```
**Solution:** Port tuples MUST include a host string:
```python
WEBSERVER_PORTS = [(4001, "0.0.0.0")]
TELNET_PORTS = [(4000, "0.0.0.0")]
WEBSOCKET_PORTS = [(4002, "0.0.0.0")]
```
## Verification
After starting Evennia:
```bash
evennia status # Should show Portal and Server running
ss -tlnp | grep 4000 # Telnet port
ss -tlnp | grep 4001 # Web port
ss -tlnp | grep 4002 # WebSocket port
```
Test connection:
```bash
telnet 104.131.15.18 4000
```
## File Structure
```
server/
├── conf/
│ ├── __init__.py
│ └── settings.py # Main settings file (FIXED for #534)
├── logs/ # Evennia logs
└── evennia.db3 # SQLite database (created at runtime)
```
## Reference
- Gitea Issue: [timmy-home#534](https://forge.alexanderwhitestone.com/Timmy_Foundation/timmy-home/issues/534)
- Evennia Docs: https://www.evennia.com/docs/latest/Setup/Settings-Default.html
- World Plan: docs/BEZALEL_EVENNIA_WORLD.md

View File

@@ -1,87 +0,0 @@
r"""
Evennia settings file for Bezalel World.
This is the sovereign Evennia configuration for the Bezalel forge-and-testbed wizard.
Reference: timmy-home#534
The available options are found in the default settings file found here:
https://www.evennia.com/docs/latest/Setup/Settings-Default.html
"""
# Use the defaults from Evennia unless explicitly overridden
from evennia.settings_default import *
######################################################################
# Evennia base server config
######################################################################
# Server name
SERVERNAME = "bezalel_world"
######################################################################
# Network ports - FIXED for #534
# Port tuples MUST include a host string, not None
######################################################################
# Web server port (HTTP)
WEBSERVER_PORTS = [(4001, "0.0.0.0")]
# Telnet server port
TELNET_PORTS = [(4000, "0.0.0.0")]
# WebSocket port for webclient
WEBSOCKET_PORTS = [(4002, "0.0.0.0")]
######################################################################
# Database configuration
# Using SQLite for sovereign local deployment
######################################################################
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(GAME_DIR, 'server', 'evennia.db3'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': ''
}
}
######################################################################
# Security settings
######################################################################
# Lockdown mode for VPS - only bind to localhost unless needed
# To allow external connections, use 0.0.0.0 in port tuples above
ALLOWED_HOSTS = ['*'] # VPS needs this for external access
######################################################################
# Game world defaults
######################################################################
# Start location for new characters
DEFAULT_HOME = "#2" # Limbo
# Start location for guests
GUEST_HOME = "#2"
######################################################################
# Telnet settings
######################################################################
TELNET_INTERFACES = ['0.0.0.0']
######################################################################
# Web server settings
######################################################################
WEBSERVER_INTERFACES = ['0.0.0.0']
######################################################################
# Settings given in secret_settings.py override those in this file.
######################################################################
try:
from server.conf.secret_settings import *
except ImportError:
print("secret_settings.py file not found or failed to import.")

View File

@@ -18,8 +18,8 @@ from urllib import request
DEFAULT_BASE_URL = "https://forge.alexanderwhitestone.com/api/v1"
DEFAULT_OWNER = "Timmy_Foundation"
DEFAULT_REPO = "timmy-home"
DEFAULT_TOKEN_FILE = Path.home() / ".config" / "gitea" / "token"
DEFAULT_FAILOVER_STATUS = Path.home() / ".timmy" / "failover_status.json"
DEFAULT_TOKEN_FILE = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "gitea" / "token"
DEFAULT_FAILOVER_STATUS = Path(os.environ.get("TIMMY_HOME", Path.home() / ".timmy")) / "failover_status.json"
DEFAULT_RESTART_STATE_DIR = Path("/var/lib/timmy/restarts")
DEFAULT_HEARTBEAT_FILE = Path("/var/lib/timmy/heartbeats/fleet_health.last")

View File

@@ -18,7 +18,7 @@ from pathlib import Path
def get_token():
f = Path.home() / ".config" / "gitea" / "token"
f = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "gitea" / "token"
if f.exists():
return f.read_text().strip()
return os.environ.get("GITEA_TOKEN", "")

View File

@@ -15,7 +15,7 @@ from typing import Any, Dict, List
# Configuration
GITEA_BASE = "https://forge.alexanderwhitestone.com/api/v1"
TOKEN_PATH = os.path.expanduser("~/.config/gitea/token")
TOKEN_PATH = os.path.join(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), "gitea", "token")
ORG = "Timmy_Foundation"
REPO = "timmy-home"

View File

@@ -13,7 +13,7 @@ from urllib.request import Request, urlopen
API_BASE = "https://forge.alexanderwhitestone.com/api/v1"
ORG = "Timmy_Foundation"
DEFAULT_TOKEN_PATH = os.path.expanduser("~/.config/gitea/token")
DEFAULT_TOKEN_PATH = os.path.join(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), "gitea", "token")
@dataclass(frozen=True)

View File

@@ -27,7 +27,7 @@ from pathlib import Path
import re
GITEA_URL = "https://forge.alexanderwhitestone.com"
GITEA_TOKEN_PATH = Path.home() / ".config" / "gitea" / "token"
GITEA_TOKEN_PATH = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "gitea" / "token"
ORG = "Timmy_Foundation"
REPOS = [

View File

@@ -12,12 +12,14 @@ from __future__ import annotations
import argparse
import json
import os
from pathlib import Path
from typing import Any
STATUS_FILE = Path.home() / ".timmy" / "failover_status.json"
SPEC_FILE = Path.home() / ".timmy" / "fleet_dispatch.json"
OUTPUT_FILE = Path.home() / ".timmy" / "dispatch_plan.json"
TIMMY_HOME = Path(os.environ.get("TIMMY_HOME", Path.home() / ".timmy"))
STATUS_FILE = TIMMY_HOME / "failover_status.json"
SPEC_FILE = TIMMY_HOME / "fleet_dispatch.json"
OUTPUT_FILE = TIMMY_HOME / "dispatch_plan.json"
def load_json(path: Path, default: Any):

View File

@@ -13,7 +13,7 @@ FLEET = {
"bezalel": "167.99.126.228"
}
STATUS_FILE = Path.home() / ".timmy" / "failover_status.json"
STATUS_FILE = Path(os.environ.get("TIMMY_HOME", Path.home() / ".timmy")) / "failover_status.json"
def check_health(host):
try:

View File

@@ -15,20 +15,13 @@ EVENNIA_DIR="/root/wizards/bezalel/evennia/bezalel_world"
SETTINGS="${EVENNIA_DIR}/server/conf/settings.py"
VENV_PYTHON="/root/wizards/bezalel/evennia/venv/bin/python3"
VENV_EVENNIA="/root/wizards/bezalel/evennia/venv/bin/evennia"
TIMMY_HOME="${TIMMY_HOME:-/root/timmy-home}" # Or wherever the repo is cloned
echo "=== Fix Evennia Settings (Bezalel) ==="
# 1. Fix settings.py — prefer repo version, fallback to sed patch
# 1. Fix settings.py — remove bad port tuples
echo "Fixing settings.py..."
if [ -f "${TIMMY_HOME}/evennia/bezalel_world/server/conf/settings.py" ]; then
# Use the fixed settings from the repo
mkdir -p "$(dirname "$SETTINGS")"
cp "${TIMMY_HOME}/evennia/bezalel_world/server/conf/settings.py" "$SETTINGS"
echo "Copied fixed settings from timmy-home repo."
elif [ -f "$SETTINGS" ]; then
# Fallback: patch in place
echo "Patching existing settings..."
if [ -f "$SETTINGS" ]; then
# Remove broken port lines
sed -i '/WEBSERVER_PORTS/d' "$SETTINGS"
sed -i '/TELNET_PORTS/d' "$SETTINGS"
sed -i '/WEBSOCKET_PORTS/d' "$SETTINGS"
@@ -42,7 +35,7 @@ elif [ -f "$SETTINGS" ]; then
echo 'TELNET_PORTS = [(4000, "0.0.0.0")]' >> "$SETTINGS"
echo 'WEBSOCKET_PORTS = [(4002, "0.0.0.0")]' >> "$SETTINGS"
echo "Patched existing settings file."
echo "Settings fixed."
else
echo "ERROR: Settings file not found at $SETTINGS"
exit 1