From 3df5867b56d2bc6956ea052319e51e3c4f54de88 Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Mon, 27 Apr 2026 03:35:49 -0700 Subject: [PATCH] fix: restore main_sync entry point in workspace/main.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wheel's pyproject.toml has declared `molecule-runtime = "molecule_runtime.main:main_sync"` since the publish pipeline was created on 2026-04-26, but the function itself was never present in workspace/main.py — it lived in the pre-monorepo molecule-ai-workspace-runtime repo and was lost during the consolidation that made workspace/ the source of truth. The 0.1.15 wheel still had main_sync from a leftover snapshot, so the regression went unnoticed until 0.1.16 (the first wheel built from the new source-of-truth) shipped. Symptom: every workspace container restart loops with ImportError: cannot import name 'main_sync' from 'molecule_runtime.main' — the molecule-runtime CLI script's first line tries to import the missing symbol. Workspaces stay in `provisioning` until the 10-min sweep marks them failed. Caught by .github/workflows/runtime-pin-compat.yml, which already imports the symbol by name as its smoke test. (That check kept failing red on every recent merge_group run; this PR fixes the underlying symbol-not-found instead of the smoke step.) Also strengthens publish-runtime.yml's wheel smoke from `import molecule_runtime.main` (loads the module — passes even when entry-point target is missing) to `from molecule_runtime.main import main_sync` (the actual contract the CLI script needs). Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/publish-runtime.yml | 9 ++++++++- workspace/main.py | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-runtime.yml b/.github/workflows/publish-runtime.yml index c22fbcc7..b7c77f82 100644 --- a/.github/workflows/publish-runtime.yml +++ b/.github/workflows/publish-runtime.yml @@ -142,7 +142,14 @@ jobs: # of \`from molecule_runtime.transcript_auth import ...\` — the # 0.1.16 incident), this fails with ModuleNotFoundError instead # of shipping to PyPI and breaking every workspace startup. - import molecule_runtime.main # noqa: F401 + # Import the entry-point target by NAME — not just the module. + # The wheel's pyproject.toml declares + # `molecule-runtime = molecule_runtime.main:main_sync` so if + # main_sync goes missing (it did in 0.1.16-0.1.18), every + # workspace startup fails with `ImportError: cannot import name + # 'main_sync'`. Plain `import molecule_runtime.main` doesn't + # catch that because the module loads fine. + from molecule_runtime.main import main_sync # noqa: F401 from molecule_runtime import a2a_client, a2a_tools from molecule_runtime.builtin_tools import memory from molecule_runtime.adapters import get_adapter, BaseAdapter, AdapterConfig diff --git a/workspace/main.py b/workspace/main.py index 2dd9d4e4..a947123c 100644 --- a/workspace/main.py +++ b/workspace/main.py @@ -613,5 +613,18 @@ async def main(): # pragma: no cover await temporal_wrapper.stop() -if __name__ == "__main__": # pragma: no cover +def main_sync(): # pragma: no cover + """Synchronous entry point for the `molecule-runtime` console script. + + Declared in scripts/build_runtime_package.py as the wheel's entry-point + target (`molecule-runtime = "molecule_runtime.main:main_sync"`). Removed + silently during the pre-monorepo consolidation, which broke every + workspace startup against 0.1.16/0.1.17/0.1.18 with `ImportError: + cannot import name 'main_sync'`. The .github/workflows/runtime-pin-compat.yml + smoke step is the regression gate. + """ asyncio.run(main()) + + +if __name__ == "__main__": # pragma: no cover + main_sync()