fix(adapter): skip gateway spawn under MOLECULE_SMOKE_MODE

The boot-smoke gate (molecule-core#2275) invokes adapters with stub
creds and no network so it can exercise executor.execute() lazy
imports. OpenClaw's setup() spawns a real `openclaw gateway --dev`
subprocess that needs valid creds + network — under smoke env it
exits immediately, raising RuntimeError("OpenClaw gateway process
exited") and failing the publish-image workflow.

Add a 1-line opt-out at the top of setup() so the runtime can reach
its smoke short-circuit. Real production boots are unaffected.

Closes the openclaw failure surfaced when running publish-image
across all 8 workspace templates with the new boot-smoke step.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hongming Wang 2026-04-30 22:46:51 -07:00
parent 62eeb4cddd
commit ad2aba5770

View File

@ -56,6 +56,16 @@ class OpenClawAdapter(BaseAdapter):
async def setup(self, config: AdapterConfig) -> None: # pragma: no cover async def setup(self, config: AdapterConfig) -> None: # pragma: no cover
"""Install OpenClaw, run onboard, copy workspace files, start gateway.""" """Install OpenClaw, run onboard, copy workspace files, start gateway."""
# Boot-smoke contract (molecule-core#2275): the publish-image gate
# invokes us with stub creds + no network so it can exercise lazy
# imports inside execute(). Real gateway spawn would fail here
# (no valid api_key, no `openclaw` binary on PATH yet), so skip
# the heavy setup path entirely. The runtime's smoke_mode short-
# circuit fires immediately after create_executor() returns.
if os.environ.get("MOLECULE_SMOKE_MODE") == "1":
logger.info("MOLECULE_SMOKE_MODE=1 — skipping OpenClaw gateway spawn")
return
npm_prefix = os.path.expanduser("~/.local") npm_prefix = os.path.expanduser("~/.local")
os.environ["PATH"] = f"{npm_prefix}/bin:{os.environ.get('PATH', '')}" os.environ["PATH"] = f"{npm_prefix}/bin:{os.environ.get('PATH', '')}"