Skip to content

feat(router): add --enable-wasm flag to Python CLI and Helm chart - #1729

Merged
slin1237 merged 2 commits into
smg-project:mainfrom
neverCase:enable-wasm-args
Jun 15, 2026
Merged

slin1237 merged 2 commits into
smg-project:mainfrom
neverCase:enable-wasm-args

Conversation

@neverCase

@neverCase neverCase commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

Problem

The --enable-wasm CLI flag was previously only available in the Rust binary entrypoint but missing from the Python launcher (launch_router.py) and Helm chart, causing the WASM module manager to never support posting wasm plugins and the post request always return 500.

Solution

Adds enable_wasm field to RouterArgs dataclass + argparse, to the
PyO3 Router struct + RouterConfigBuilder chain, and a new
router.wasm.enabled value in the Helm chart.

Changes

Test Plan

Checklist
  • cargo +nightly fmt passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • (Optional) Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

Summary by CodeRabbit

  • New Features
    • Added Router WebAssembly (WASM) enablement support via a new enable_wasm option (default: disabled).
    • Expanded the Router configuration API to accept enable_wasm.
    • Introduced a router CLI flag --<prefix>enable-wasm to turn WASM support on when set.
    • Updated Helm chart configuration with a WASM toggle (router.wasm.enabled), defaulting to disabled for backward compatibility.

@github-actions github-actions Bot added the python-bindings Python bindings changes label Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an enable_wasm boolean flag (default disabled) to the Router configuration, threading it through the PyO3 Rust binding struct and config builder, the Python RouterArgs dataclass and CLI argument parser, and the Helm chart helper template with a corresponding values.yaml default.

Changes

WASM enable flag end-to-end

Layer / File(s) Summary
PyO3 Router struct field, config wiring, and constructor
bindings/python/src/lib.rs
Router struct gains enable_wasm: bool; to_router_config() forwards it via .enable_wasm(self.enable_wasm); the PyO3 #[new] signature and fn new(...) argument list both append the new keyword parameter with default false.
Python CLI flag and Helm chart wiring
bindings/python/src/smg/router_args.py, deploy/helm/smg/templates/_helpers.tpl, deploy/helm/smg/values.yaml
RouterArgs adds enable_wasm: bool = False and a --<prefix>enable-wasm (store_true) CLI flag. The Helm smg.routerArgs helper conditionally emits --enable-wasm when .Values.router.wasm.enabled is set, and values.yaml adds enabled: false as the default.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • lightseekorg/smg#775: Both PRs extend the same Python Router configuration surface (bindings/python/src/lib.rs and bindings/python/src/smg/router_args.py) by adding new feature flags/fields and wiring them into the router config/constructor flow—enable_wasm vs enable_mesh.

Suggested reviewers

  • CatherineSue
  • key4ng
  • gongwei-130

Poem

🐇 A flag was planted, small but bright,
enable_wasm = false by default at night.
Rust struct, PyO3, the CLI too,
Helm chart whispering, "WASM? Up to you!"
Flip it to true, the modules take flight —
The rabbit hops on, everything's right. 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(router): add --enable-wasm flag to Python CLI and Helm chart' directly and accurately summarizes the main objective: adding the --enable-wasm flag support to Python CLI and Helm chart components.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mergify

mergify Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Hi @neverCase, the DCO sign-off check has failed. All commits must include a Signed-off-by line.

To fix existing commits:

# Sign off the last N commits (replace N with the number of unsigned commits)
git rebase HEAD~N --signoff
git push --force-with-lease

To sign off future commits automatically:

  • Use git commit -s every time, or
  • VSCode: enable Git: Always Sign Off in Settings
  • PyCharm: enable Sign-off commit in the Commit tool window

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an enable_wasm configuration option to enable WebAssembly module support across the Python bindings and Helm charts. However, a compilation error was identified in bindings/python/src/lib.rs because the enable_wasm parameter is missing from the Router::new function signature, despite being used in the struct initialization.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

mesh_port,
mesh_peer_urls,
drain_settle_secs,
enable_wasm,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The parameter enable_wasm: bool is missing from the function signature of Router::new (around line 1000). This will cause a compilation error because enable_wasm is not in scope when initializing the Router struct at line 1125, and the PyO3 signature macro will also fail to match the function arguments.

Please update the new function signature in bindings/python/src/lib.rs to include enable_wasm: bool:

    fn new(
        // ...
        drain_settle_secs: u64,
        enable_wasm: bool,
    ) -> PyResult<Self> {

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee67350510

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

mesh_port,
mesh_peer_urls,
drain_settle_secs,
enable_wasm,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add enable_wasm to the Rust constructor parameters

When building the Python bindings, this initializer now uses enable_wasm, but fn new still has no enable_wasm argument—the parameter list above still ends at drain_settle_secs. In any build of the Python extension with this commit, the Rust compiler has no local named enable_wasm here, so the bindings fail to compile instead of exposing the new CLI flag.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bindings/python/src/lib.rs`:
- Around line 884-885: The pyo3 signature declares `enable_wasm = false` as a
constructor parameter on line 884, but the corresponding `fn new(...)` function
(around lines 891-1000) does not include `enable_wasm` as a parameter in its
function signature, causing it to be undefined when referenced in the
initializer code at lines 1124-1126. Add `enable_wasm` as a parameter to the `fn
new(...)` function signature to match the pyo3 signature declaration, ensuring
the parameter is properly received and available for use in the initialization
logic that references it.

In `@bindings/python/src/smg/router_args.py`:
- Around line 897-901: The `--{prefix}enable-wasm` argument uses `default=False`
which makes the prefixed key always present/non-None, causing the
`from_cli_args()` method to treat it as explicitly set and bypass the fallback
logic for backend args in prefixed mode. Change the `default=False` parameter to
`default=None` in the add_argument call for the enable-wasm flag so that
fallback semantics work correctly when the flag is not explicitly provided by
the user.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e0a72645-8c9a-4e1d-9750-e965c3eb9fd7

📥 Commits

Reviewing files that changed from the base of the PR and between d8d3594 and ee67350.

📒 Files selected for processing (4)
  • bindings/python/src/lib.rs
  • bindings/python/src/smg/router_args.py
  • deploy/helm/smg/templates/_helpers.tpl
  • deploy/helm/smg/values.yaml

Comment thread bindings/python/src/lib.rs
Comment thread bindings/python/src/smg/router_args.py
Signed-off-by: zhujing <1024769485@qq.com>
Signed-off-by: zhujing <1024769485@qq.com>
@slin1237
slin1237 merged commit d302b1f into smg-project:main Jun 15, 2026
23 of 36 checks passed
@neverCase
neverCase deleted the enable-wasm-args branch June 15, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python-bindings Python bindings changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants