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
Executable
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# DHARMA network — stop all running soul Engrams.
# Reads PIDs from /tmp/dharma-pids written by launch_dharma.sh.
# Falls back to killing by port if PID file is missing.
#
# Usage:
# ./stop_dharma.sh stop all soul Engrams
# ./stop_dharma.sh <slug> stop a single soul by slug
set -euo pipefail
PID_FILE=/tmp/dharma-pids
FILTER="${1:-}"
stopped=0
missed=0
# Kill via PID file if it exists
if [ -f "$PID_FILE" ]; then
while IFS=' ' read -r pid slug port; do
[ -z "$pid" ] && continue
if [ -n "$FILTER" ] && [ "$slug" != "$FILTER" ]; then
continue
fi
if kill -0 "$pid" 2>/dev/null; then
kill "$pid"
echo "[dharma] stopped $slug (pid=$pid port=$port)"
stopped=$((stopped + 1))
else
echo "[dharma] $slug (pid=$pid) already gone"
fi
done < "$PID_FILE"
if [ -z "$FILTER" ]; then
rm -f "$PID_FILE"
fi
else
echo "[dharma] no PID file at $PID_FILE — killing by port scan"
# Fall back: kill anything on ports 88018819
for port in $(seq 8801 8819); do
pids=$(lsof -ti tcp:"$port" 2>/dev/null || true)
if [ -n "$pids" ]; then
echo "[dharma] killing port $port (pids: $pids)"
echo "$pids" | xargs kill 2>/dev/null || true
stopped=$((stopped + 1))
fi
done
fi
echo ""
echo "[dharma] stopped=$stopped missed=$missed"