Files
forge/scripts/launch_dharma.sh
T
Will Anderson cbeb9c02eb build DHARMA network: 19 soul Engram instances with full peer wiring
- Add scripts/: install_soul.py, install_all.py, launch_dharma.sh, stop_dharma.sh, wire_peers.py
- Move all seeds into seeds/ directory (consolidated from root-level scattered files)
- Update registry.json with engram_root_id, engram_api_key, engram_url for all 19 installed souls
- Add src/soul.el, src/research.el; remove src/daemon.el
- .gitignore: exclude imprints/, log/, sandboxes/ (runtime data)
- Remove superseded scripts: deploy.py, install_imprints.py, reinstall_imprints.py, fix_collision.py
- Remove old root-level seed files and shell scripts superseded by scripts/ versions

Key: native engram binary uses _auth body field, per-soul keys ntn-<slug>-2026,
DharmaPeer graph edges for peer wiring, sanitize_content() for JSON safety.
190/190 peer pairs wired successfully.
2026-05-03 03:09:27 -05:00

106 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# DHARMA network — start all 19 soul Engrams as background processes.
#
# Each soul gets:
# - Their own Engram binary instance
# - ENGRAM_DATA_DIR / ENGRAM_DB_PATH = forge/imprints/<slug>/
# - ENGRAM_BIND = 0.0.0.0:<port>
# - ENGRAM_API_KEY = ntn-<slug>-2026 per soul (or $DHARMA_API_KEY override)
#
# PIDs are written to forge/imprints/<slug>/engram.pid
# Logs go to forge/log/dharma-<slug>.log
#
# Usage:
# ./launch_dharma.sh start all soul Engrams
# ./launch_dharma.sh <slug> start one soul by slug
#
# Neuron stays untouched at localhost:8742.
set -euo pipefail
FORGE=/Users/will/Development/neuron-technologies/forge
ENGRAM=/Users/will/Development/neuron-technologies/foundation/engram/dist/engram
REGISTRY="$FORGE/registry.json"
if [ ! -x "$ENGRAM" ]; then
echo "[dharma] ERROR: engram binary not found at $ENGRAM"
exit 1
fi
if [ ! -f "$REGISTRY" ]; then
echo "[dharma] ERROR: registry.json not found at $REGISTRY"
exit 1
fi
mkdir -p "$FORGE/log"
FILTER="${1:-}"
started=0
skipped=0
missing=0
while IFS='|' read -r slug port subject db_path; do
[ -z "$slug" ] && continue
if [ -n "$FILTER" ] && [ "$slug" != "$FILTER" ]; then
continue
fi
full_db_path="$FORGE/$db_path"
if [ ! -d "$full_db_path" ] || [ -z "$(ls -A "$full_db_path" 2>/dev/null)" ]; then
echo "[dharma] WARN: $slug — imprint directory missing or empty"
echo "[dharma] Run: python3 scripts/install_all.py"
missing=$((missing + 1))
continue
fi
# Skip if already running on that port
if lsof -ti tcp:"$port" >/dev/null 2>&1; then
echo "[dharma] $slug already running on port $port — skipping"
skipped=$((skipped + 1))
continue
fi
log_file="$FORGE/log/dharma-${slug}.log"
pid_file="$full_db_path/engram.pid"
# Per-soul key unless overridden by DHARMA_API_KEY env var
soul_key="${DHARMA_API_KEY:-ntn-${slug}-2026}"
echo "[dharma] starting $slug on :$port"
ENGRAM_DATA_DIR="$full_db_path" \
ENGRAM_DB_PATH="$full_db_path" \
ENGRAM_BIND="0.0.0.0:$port" \
ENGRAM_API_KEY="$soul_key" \
"$ENGRAM" >> "$log_file" 2>&1 &
pid=$!
echo "$pid" > "$pid_file"
started=$((started + 1))
done < <(python3 - "$REGISTRY" <<'PYEOF'
import json, sys
reg = json.load(open(sys.argv[1]))
for imp in reg["imprints"]:
print(f"{imp['slug']}|{imp['engram_port']}|{imp['subject']}|{imp.get('engram_db_path', 'imprints/' + imp['slug'])}")
PYEOF
)
echo ""
echo "[dharma] started=$started skipped=$skipped missing=$missing"
if [ "$missing" -gt 0 ]; then
echo "[dharma] Run 'python3 scripts/install_all.py' to install missing souls first."
fi
echo "[dharma] logs: $FORGE/log/dharma-<slug>.log"
echo ""
if [ "$started" -gt 0 ]; then
echo "[dharma] Verify:"
echo " curl -s http://localhost:8801/stats # bobby-anderson"
echo " curl -s http://localhost:8819/stats # helen-keller"
echo ""
echo "[dharma] Then wire peers:"
echo " python3 scripts/wire_peers.py"
fi