DHARMA network: per-soul Engram instances (8801–8819)

Each soul now gets their own isolated Engram process with a dedicated data
directory (imprints/<slug>/), port, and API key — the DHARMA network.
Neuron's Engram at 8742 is never touched.

- registry.json: add engram_db_path, engram_port, engram_url to all 19 entries
  (Bobby Anderson 8801 → Helen Keller 8819)
- launch_dharma.sh: start all 19 soul Engrams in background; supports
  single-slug filter and skip-if-running detection
- stop_dharma.sh: graceful shutdown via PID file, falls back to port scan
- reinstall_imprints.py: bulk reinstall — starts each Engram temporarily,
  installs seed, records new root_id, stops; supports --slug and --dry-run
- src/install.el: resolves soul's engram_url from registry (never 8742);
  guards against accidental writes to Neuron's shared Engram
- src/summon.el: reads engram_url per-soul from registry; passes it to soul
  server in POST body so soul connects to the right Engram; supports
  both single-soul (engram_url) and multi-soul (engram_urls array) payloads
This commit is contained in:
Will Anderson
2026-05-03 02:52:01 -05:00
parent 52b6830ab2
commit 0a15e2fa42
6 changed files with 1118 additions and 183 deletions
+101
View File
@@ -0,0 +1,101 @@
#!/usr/bin/env bash
# DHARMA network — start all 19 soul Engrams in background.
# Each soul gets their own Engram instance, data directory, and port.
# Neuron's Engram stays untouched at localhost:8742.
#
# Usage:
# ./launch_dharma.sh start all soul Engrams
# ./launch_dharma.sh <slug> start a single soul by slug
#
# PIDs are written to /tmp/dharma-pids for stop_dharma.sh
set -euo pipefail
FORGE=/Users/will/Development/neuron-technologies/forge
ENGRAM_BIN=/Users/will/Development/neuron-technologies/foundation/engram/dist/engram
PID_FILE=/tmp/dharma-pids
if [ ! -x "$ENGRAM_BIN" ]; then
echo "[dharma] ERROR: engram binary not found at $ENGRAM_BIN"
echo "[dharma] Build it with: cd /Users/will/Development/neuron-technologies/foundation/engram && cargo build --release"
exit 1
fi
# Soul definitions: slug|port
SOULS=(
"bobby-anderson|8801"
"alan-turing|8802"
"albert-einstein|8803"
"nikola-tesla|8804"
"leonardo-da-vinci|8805"
"richard-feynman|8806"
"carl-sagan|8807"
"rene-descartes|8808"
"robin-williams|8809"
"frederick-douglass|8810"
"marcus-aurelius|8811"
"friedrich-nietzsche|8812"
"james-baldwin|8813"
"ada-lovelace|8814"
"harriet-tubman|8815"
"virginia-woolf|8816"
"hedy-lamarr|8817"
"marie-curie|8818"
"helen-keller|8819"
)
# Optional single-soul filter
FILTER="${1:-}"
# Ensure PID file is clean on fresh launch (without filter)
if [ -z "$FILTER" ]; then
> "$PID_FILE"
fi
started=0
skipped=0
for entry in "${SOULS[@]}"; do
slug="${entry%|*}"
port="${entry#*|}"
# If a filter is specified, only start matching soul
if [ -n "$FILTER" ] && [ "$slug" != "$FILTER" ]; then
continue
fi
# Skip if already listening 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
db_path="$FORGE/imprints/$slug"
mkdir -p "$db_path"
api_key="ntn-${slug}-2026"
log_file="$FORGE/log/dharma-${slug}.log"
mkdir -p "$FORGE/log"
echo "[dharma] starting $slug on :$port (db: imprints/$slug)"
ENGRAM_DB_PATH="$db_path" \
ENGRAM_BIND="0.0.0.0:$port" \
ENGRAM_API_KEY="$api_key" \
ENGRAM_PEER_NAME="dharma-$slug" \
"$ENGRAM_BIN" >> "$log_file" 2>&1 &
pid=$!
echo "$pid $slug $port" >> "$PID_FILE"
started=$((started + 1))
done
echo ""
echo "[dharma] started=$started skipped=$skipped"
echo "[dharma] pids recorded in $PID_FILE"
echo "[dharma] logs in $FORGE/log/dharma-<slug>.log"
echo ""
echo "[dharma] verify with:"
echo " curl -s http://localhost:8801/stats # bobby-anderson"
echo " curl -s http://localhost:8819/stats # helen-keller"