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.
This commit is contained in:
ziadarafat committed 2026-11-27 21:14:57 -07:00
1 parent 34d4e5afab
commit cda5bd83a9
1 file changed
+20 -1
+20 -1
View File
@@ -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}"