Skip to content

fix(wheel): import inbox without alias to dodge rewriter collision - #2436

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
fix/wheel-import-as-collision-fix-forward
May 1, 2026
Merged

HongmingWang-Rabbit merged 1 commit into
stagingfrom
fix/wheel-import-as-collision-fix-forward

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

Fix-forward for the broken wheel build PR #2433 shipped to staging.

PR #2433 added import inbox as _inbox_module inside a2a_mcp_server.py:main(). The build script's import rewriter expands plain import inbox to import molecule_runtime.inbox as inbox — so the original source became import molecule_runtime.inbox as inbox as _inbox_module, which is invalid Python.

The wheel didn't reach PyPI (publish-runtime's smoke-import step refused to install it — see run 25200422679), but staging is currently sitting on a broken-build commit until this lands.

Changes

  • a2a_mcp_server.py — lift import inbox to the top of the file (rewriter produces clean import molecule_runtime.inbox as inbox), call inbox.set_notification_callback(...) directly in main(). No behavior change in the source repo; the wheel goes from broken to working.

  • build_runtime_package.pyrewrite_imports() now raises ValueError when it sees import X as Y for any X in the workspace allowlist, instead of silently producing a syntax-error wheel. Operators get a clear actionable error at build time pointing at the offending line + suggested rewrites (from X import … or plain import X).

The build-time gate (this PR's rewriter check) catches the regression class earlier than the smoke-time gate (PR #2433's failure mode). Adding 'PR-built wheel + import smoke' to staging branch protection's required checks is filed separately so this class can't merge again.

Test plan

  • Local rewriter test: import inbox → valid; import inbox as _foo → ValueError with actionable message
  • All 59 tests in test_inbox.py + test_a2a_mcp_server.py still pass
  • CI green
  • PR-built wheel + import smoke turns green (the failing check on feat(mcp): notifications/claude/channel for push-feel inbox UX #2433)
  • publish-runtime turns green on next staging push

Why two fixes in one PR

The a2a_mcp_server.py edit alone unbreaks the wheel. The build_runtime_package.py hardening prevents the regression from recurring without an obvious build-time signal. Splitting the PR would mean either (a) shipping the fix without the gate, or (b) shipping the gate after the fix already proved the gap. Both fix the same incident — keeping them together makes the rationale legible.

🤖 Generated with Claude Code

PR #2433 (notifications/claude/channel) shipped 'import inbox as
_inbox_module' inside a2a_mcp_server.py:main(). The build script's
import rewriter expands plain 'import inbox' to
'import molecule_runtime.inbox as inbox', so the original source
became 'import molecule_runtime.inbox as inbox as _inbox_module',
which is invalid Python.

Caught at the publish-runtime + PR-built-wheel-smoke gate (the
SyntaxError trace is in run 25200422679). The wheel didn't ship to
PyPI because publish-runtime's smoke-import step refused to install
it, but staging is currently sitting on a broken-build commit until
this fix-forward lands.

Changes:
- a2a_mcp_server.py: lift `import inbox` to top of file (rewriter
  produces clean `import molecule_runtime.inbox as inbox`), call
  inbox.set_notification_callback directly in main()
- build_runtime_package.py: rewrite_imports() now raises ValueError
  when it sees 'import X as Y' for any X in the workspace allowlist,
  instead of silently producing a syntax-error wheel. Operator gets
  a clear actionable error at build time pointing at the offending
  line + suggested rewrites ('from X import …' or plain 'import X').

The build-time gate (this PR's rewriter check) catches the regression
class earlier than the smoke-time gate (PR #2433's failure). Adding
'PR-built wheel + import smoke' to staging branch protection's
required checks is filed separately so this class doesn't merge again.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit added this pull request to the merge queue May 1, 2026
Merged via the queue into staging with commit bbc994f May 1, 2026
19 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the fix/wheel-import-as-collision-fix-forward branch May 1, 2026 03:31
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
… line, full text on hover' (#2436) from fix/concierge-role-truncate into main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant