From cda5bd83a98aa24f86c3b81f21e1cebd47dc8778 Mon Sep 17 00:00:00 2001 From: ziadarafat Date: Fri, 27 Nov 2026 21:14:57 -0700 Subject: [PATCH] mcp-lapis: never fork the store onto a client host The wrapper preferred a local LaPis checkout over the ssh bridge. That is fine on the host that owns the store and wrong everywhere else: a checkout appeared on the Deck today and, from that moment, the Deck wrote to a brand-new local DB while the 90 real observations stayed on arceus, invisible to it. A host now bridges when ~/.pi/memory/REMOTE_STORE names the store host (or when LAPIS_FORCE_REMOTE=1). Both are host-local state, so the owning host is unaffected and nothing has to be deleted to become a client again. --- bin/mcp-lapis | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/bin/mcp-lapis b/bin/mcp-lapis index dd71946..9ba7d06 100755 --- a/bin/mcp-lapis +++ b/bin/mcp-lapis @@ -20,11 +20,30 @@ node_bin() { return 1 } -if [ -f "$LAPIS/memory-store.js" ]; then +# One store, one host. The store lives on arceus; a host that merely has the +# checkout is a client. Without this, a fresh clone on a client host silently +# forks the memory: the wrapper would start writing to an empty local DB while +# every memory already made on arceus became invisible to that host. +# +# Set LAPIS_FORCE_REMOTE=1, or drop the remote's "user@host" into +# ~/.pi/memory/REMOTE_STORE, to force the bridge. Both are host-local: they +# never travel with dotfiles, so the host holding the store is unaffected. +FORCE_REMOTE=${LAPIS_FORCE_REMOTE:-0} +if [ -f "$HOME/.pi/memory/REMOTE_STORE" ]; then + FORCE_REMOTE=1 + STORE_HOST=$(tr -d ' \n' < "$HOME/.pi/memory/REMOTE_STORE") + [ -n "$STORE_HOST" ] && LAPIS_REMOTE="$STORE_HOST" +fi + +if [ "$FORCE_REMOTE" != 1 ] && [ -f "$LAPIS/memory-store.js" ]; then NODE=$(node_bin) || { echo "mcp-lapis: no node found for the local LaPis store" >&2; exit 1; } exec "$NODE" "$LAPIS/memory-store.js" mcp fi +if [ "$FORCE_REMOTE" = 1 ]; then + echo "mcp-lapis: using the shared store on ${LAPIS_REMOTE:-ziadarafat@10.0.0.23}" >&2 +fi + # No local store: bridge to the host that has one. LAPIS_REMOTE defaults to the # personal homelab host; keep it a plain "user@host" so ProxyJump/ssh config apply. REMOTE="${LAPIS_REMOTE:-ziadarafat@10.0.0.23}"