feat: redundant WSL brain serve + keepalive (fail-safe)

- serve-brain-wsl.sh: serves WSL central brain over HTTP MCP :8090 (independent of Windows brain)
- keepalive-brain-wsl.sh: restarts serve if :8090 drops
- cron agentic-os-brain-keepalive-wsl every 5 min mirrors Windows keepalive
- README documents the two independent :8090 endpoints (WSL + Windows)
This commit is contained in:
Austin 2026-07-26 14:31:46 -07:00
parent ced62821dc
commit 2af401eb78
4 changed files with 1788 additions and 1747 deletions

View File

@ -18,6 +18,8 @@ bash brain/graph/build-central.sh # rebuild WSL central brain (code g
bash brain/graph/link-project.sh <name> <graph.json> # register a project's graph into the brain bash brain/graph/link-project.sh <name> <graph.json> # register a project's graph into the brain
bash brain/graph/sync-to-windows.sh # rebuild + push merged graph to Windows central brain bash brain/graph/sync-to-windows.sh # rebuild + push merged graph to Windows central brain
bash brain/graph/serve-brain.sh # serve WSL central brain over HTTP MCP (:8090) bash brain/graph/serve-brain.sh # serve WSL central brain over HTTP MCP (:8090)
bash brain/graph/serve-brain-wsl.sh # redundant WSL serve (:8090, independent of Windows brain)
bash brain/graph/keepalive-brain-wsl.sh # restart WSL serve if :8090 drops (fail-safe)
``` ```
Set `CENTRAL_BRAIN_PORT` to override the serve port (default 8090). Set `CENTRAL_BRAIN_PORT` to override the serve port (default 8090).
@ -33,3 +35,5 @@ Set `CENTRAL_BRAIN_PORT` to override the serve port (default 8090).
- `graphify`'s MCP HTTP serve requires the extra: `pip install "graphifyy[mcp]"` (done in the venv). - `graphify`'s MCP HTTP serve requires the extra: `pip install "graphifyy[mcp]"` (done in the venv).
- The write path for memory is still `brain/*.md` + `audit` + `data/`; graphify reads those, never writes them. - The write path for memory is still `brain/*.md` + `audit` + `data/`; graphify reads those, never writes them.
- Rebuild is scheduled hourly by the `agentic-os-brain-rebuild` cron. - Rebuild is scheduled hourly by the `agentic-os-brain-rebuild` cron.
- WSL serve is kept alive every 5 min by the `agentic-os-brain-keepalive-wsl` cron (fail-safe; mirrors Windows `keepalive-brain.bat`).
- Two independent brain endpoints exist on :8090 — WSL (this tree) and Windows (`C:\Users\Austin\Brains\central\`). Either can answer if the other is down.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Redundant keepalive for the WSL-side central brain MCP serve (:8090).
# Mirrors keepalive-brain.bat on Windows. If the serve is down, start it.
# Designed as a fail-safe: the Windows brain is primary for Windows-side
# queries; this keeps the WSL-side brain answerable even if Windows is down.
set -u
PORT="${CENTRAL_BRAIN_PORT:-8090}"
LAUNCH="/home/austin/agentic-os/brain/graph/serve-brain-wsl.sh"
LOG="/home/austin/agentic-os/brain/graph/wsl-keepalive.log"
# is something listening on the port?
if ss -ltn 2>/dev/null | grep -q ":$PORT "; then
exit 0
fi
echo "$(date '+%F %T') brain serve down on :$PORT -- starting" >> "$LOG"
# launch detached so this script can exit (cron-friendly)
setsid bash "$LAUNCH" >> "$LOG" 2>&1 < /dev/null &

19
brain/graph/serve-brain-wsl.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Serve the WSL-side central brain over HTTP MCP.
# Independent of the Windows brain (separate process, same port 8090 on the
# WSL loopback). Provides a redundant/fail-safe brain endpoint: if the Windows
# brain is unavailable, agents on the WSL side can still query here.
set -u
DIR="/home/austin/agentic-os"
VENV="$DIR/venv"
GF="$VENV/bin/python"
GRAPH="$DIR/brain/graph/central-graph.json"
PORT="${CENTRAL_BRAIN_PORT:-8090}"
cd "$DIR" || exit 1
if [ ! -f "$GRAPH" ]; then
echo "central brain missing ($GRAPH). Run: bash brain/graph/build-central.sh" >&2
exit 1
fi
echo "Serving WSL central brain on http://127.0.0.1:$PORT/mcp"
exec "$GF" -m graphify.serve "$GRAPH" --transport http --host 127.0.0.1 --port "$PORT"