Skip to content

Explicit tunnels stored at hardcoded ~/.mempalace/tunnels.json, ignoring palace_path config #1467

Description

@yonefive71

Summary

palace_graph._TUNNEL_FILE is a module-level constant initialised from os.path.expanduser("~") + "/.mempalace/tunnels.json". It ignores MempalaceConfig.palace_path (and MEMPALACE_PALACE_PATH). Every other piece of palace state — drawers, KG, people map — honours palace_path, so when $HOME and the configured palace diverge, tunnels write to a different file from drawers.

Impact

Worst case is the agentic one. A subagent with an isolated $HOME (profile sandbox, container, multi-tenant worker) sets MEMPALACE_PALACE_PATH=/shared/palace so its drawers go to the shared palace. Its tunnel writes still go to ~/.mempalace/tunnels.json inside the isolated home — invisible to every other process touching the shared palace. The same isolated list_tunnels() reads back the worker's own write, so the worker self-confirms a tunnel that doesn't exist anywhere except its own bubble and reports completion to its orchestrator.

We hit this on a real task: Hephaestus subagent created a "tunnel" pointing at a phantom room, list_tunnels confirmed it from the bubble, and the completion report shipped to the parent. The tunnel never existed in the shared palace.

Reproduction

import os, tempfile
import mempalace.mcp_server as ms
shared = tempfile.mkdtemp()
os.environ["MEMPALACE_PALACE_PATH"] = shared
os.environ["HOME"] = tempfile.mkdtemp()  # simulate profile isolation
ms.tool_add_drawer("wing_test", "room_a", "content a")
ms.tool_add_drawer("wing_test", "room_b", "content b")
ms.tool_create_tunnel("wing_test", "room_a", "wing_test", "room_b")
# The tunnel writes to $HOME/.mempalace/tunnels.json, not to the configured palace.
# Reading tunnels from a fresh process that doesn't share $HOME returns nothing.

Fix

PR #TBD. _TUNNEL_FILE becomes _get_tunnel_file() deriving the path from a new MempalaceConfig.tunnel_file property (sibling of palace_path). Default install unchanged. Legacy-file detection emits a one-line WARNING when the configured tunnel file is missing but the pre-fix path has one — no auto-migration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2mediumarea/mcpMCP server and toolsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions