Files
mempalace/tests
Igor Lins e Silva c16332f68f feat(mcp): stdio servers proxy to a live palace hub
With a hub owning the palace, a stdio mempalace-mcp spawned by an agent
harness could only ever be a read-only peer (writer lease #1818) — and
harnesses that hardcode stdio in plugin manifests (Claude Code plugins,
desktop apps) cannot be pointed at HTTP per-install. Racing stdio
writers are also exactly what corrupted a real palace's FTS5 index
(repaired 2026-07-01 via the isolated in-place rebuild).

Now the stdio loop checks the server registry per request: when a live
hub serves this palace, the request is forwarded verbatim over HTTP
with the local bearer token; the response streams back over stdio. The
stdio process holds no Chroma handles, so any number of harnesses can
spawn it against a shared palace safely.

Semantics:
- Per-request discovery: a hub that starts, moves ports, or dies
  mid-session is picked up without restarting the stdio process.
- No hub → local handling, exactly as before (and the resilience
  fallback if the hub is briefly down).
- Unreachable hub: read requests fall back locally; mutating tool
  calls are NOT replayed (the hub may still be executing them) and
  surface as a JSON-RPC error with a hint.
- The hub never proxies to itself (pid guard); MEMPALACE_HUB_FORWARD=0
  disables proxying, same kill switch as the CLI mine forwarder.

Verified live: `mempalace-mcp` under a running launchd hub logs "Live
palace hub detected ... proxying stdio requests" and serves initialize
+ search through the hub against the real palace.

3318 tests pass (7 new proxy tests), ruff clean.

(cherry picked from commit 83cd097595b205f148b474f78fc511fbede5f9b8)
2026-08-05 23:48:43 -03:00
..
2026-08-02 05:34:29 -03:00