From e7dea39df2b2ca9facbae18e6750437b1d0d9176 Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Mon, 27 Apr 2026 05:20:24 -0700 Subject: [PATCH] fix: qualify all bare imports of runtime modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five `from import` statements in adapter.py + claude_sdk_executor.py were never qualified when the template was extracted to its own repo (#87). They worked when the runtime was bundled into workspace/ where bare imports resolved against sibling files; in the template repo they explode at startup with ModuleNotFoundError as soon as Python reaches the import. Caught by manual provision after pipeline-3 wire-real E2E. The plugins import was the first one tripped because it sits in adapter.setup() — earlier bare imports inside claude_sdk_executor.py are deferred until the executor is constructed. Pattern: any `from import Y` where X is a workspace/ module -> `from molecule_runtime.X import Y`. Fixes: - adapter.py:97 plugins - claude_sdk_executor.py executor_helpers, heartbeat, a2a_client, platform_auth Same class of bug as the runtime's TOP_LEVEL_MODULES drift but inverted — instead of forgetting to rewrite imports IN the wheel, the template authors forgot to qualify imports IN the template code (the build script's rewriter only runs on workspace/ -> wheel). Co-Authored-By: Claude Opus 4.7 (1M context) --- adapter.py | 2 +- claude_sdk_executor.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/adapter.py b/adapter.py index 469e919..af14ff5 100644 --- a/adapter.py +++ b/adapter.py @@ -94,7 +94,7 @@ class ClaudeCodeAdapter(BaseAdapter): ``CLAUDE.md`` and ``/configs/skills/`` natively, and the default :class:`AgentskillsAdaptor` writes to both. """ - from plugins import load_plugins + from molecule_runtime.plugins import load_plugins workspace_plugins_dir = os.path.join(config.config_path, "plugins") plugins = load_plugins( workspace_plugins_dir=workspace_plugins_dir, diff --git a/claude_sdk_executor.py b/claude_sdk_executor.py index a05823c..b1147ff 100644 --- a/claude_sdk_executor.py +++ b/claude_sdk_executor.py @@ -41,7 +41,7 @@ from a2a.server.agent_execution import AgentExecutor, RequestContext from a2a.server.events import EventQueue from a2a.helpers import new_agent_text_message -from executor_helpers import ( +from molecule_runtime.executor_helpers import ( CONFIG_MOUNT, MEMORY_CONTENT_MAX_CHARS, WORKSPACE_MOUNT, @@ -62,7 +62,7 @@ from executor_helpers import ( ) if TYPE_CHECKING: - from heartbeat import HeartbeatLoop + from molecule_runtime.heartbeat import HeartbeatLoop logger = logging.getLogger(__name__) @@ -210,8 +210,8 @@ async def _report_tool_use(block: Any) -> None: # executor must still run when the workspace's network/auth # plumbing isn't fully set up (e.g. unit tests). import httpx - from a2a_client import PLATFORM_URL, WORKSPACE_ID - from platform_auth import auth_headers + from molecule_runtime.a2a_client import PLATFORM_URL, WORKSPACE_ID + from molecule_runtime.platform_auth import auth_headers except Exception: return try: