Skip to content

Fix native runtime startup initialization - #869

Merged
i386 merged 1 commit into
Mesh-LLM:mainfrom
i386:codex/fix-runtime-command-initialization
Jun 18, 2026
Merged

Fix native runtime startup initialization#869
i386 merged 1 commit into
Mesh-LLM:mainfrom
i386:codex/fix-runtime-command-initialization

Conversation

@i386

@i386 i386 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

MeshLLM can now install or load the dynamic native runtime from inside the existing async process runtime without panicking, and CLI-only commands no longer preload host runtime state before dispatch.

This fixes the root cause behind the release smoke panic:

Cannot start a runtime from within a runtime

Details

  • Makes host runtime initialization async so native-runtime startup install awaits the existing Tokio runtime instead of creating a nested runtime and calling block_on.
  • Dispatches mesh-llm CLI subcommands before startup native-runtime initialization, so commands like mesh-llm runtime install do not first trigger implicit startup install/load behavior.
  • Updates the dynamic native-runtime unit tests to cover async cache-hit, cache-miss install, and install-failure startup paths.

Why CI missed this

The failing path was a cache-miss startup/install path under the dynamic-native-runtime release feature. The problematic code only panicked when it needed to run the async installer from inside the already-running mesh-llm Tokio runtime. A compatible cache hit skips that installer and would not expose the bug.

The release smoke hit this exact shape by staging a release binary and invoking native runtime installation in an isolated release workflow environment. Existing PR checks compile the dynamic runtime feature, but they did not assert the shipped binary can run runtime install or perform startup native-runtime install from an empty cache under the release smoke layout.

A follow-up CI hardening would be an isolated-cache smoke step that runs mesh-llm runtime install --bundle-dir ... --cache-dir $(mktemp -d) and a startup load/install check with MESH_LLM_NATIVE_RUNTIME_CACHE_DIR pointed at an empty directory.

Validation

  • cargo test -p mesh-llm-host-runtime --features dynamic-native-runtime --lib native_runtime
  • cargo check -p mesh-llm --bin mesh-llm --features dynamic-native-runtime
  • cargo clippy -p mesh-llm --bin mesh-llm --features dynamic-native-runtime --all-targets -- -D warnings
  • cargo check -p mesh-llm --bin mesh-llm
  • rustfmt --edition 2024 --check crates/mesh-llm/src/lib.rs crates/mesh-llm-host-runtime/src/lib.rs crates/mesh-llm-host-runtime/src/system/native_runtime.rs
  • git diff --check

Summary by CodeRabbit

  • Refactor
    • Host runtime initialization now operates asynchronously, enabling smoother startup and better system resource utilization
    • Native runtime loading refactored to use async operations for more efficient handling of initialization tasks
    • System bootstrap sequence improved through elimination of blocking operations during runtime setup

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ef01a7a-b2e8-4d74-99c9-70758bf8fe3e

📥 Commits

Reviewing files that changed from the base of the PR and between 9de1fc6 and e7101d4.

📒 Files selected for processing (3)
  • crates/mesh-llm-host-runtime/src/lib.rs
  • crates/mesh-llm-host-runtime/src/system/native_runtime.rs
  • crates/mesh-llm/src/lib.rs

📝 Walkthrough

Walkthrough

Converts the dynamic native runtime loader from synchronous execution (with manual Tokio current-thread runtime construction) to async/await. try_load_installed_native_runtime, its generic helpers, and default_install_executor become async fns. The initialize_host_runtime public API follows suit, and both run() call sites and the CLI entrypoint are updated to await it.

Changes

Async Native Runtime Loading Path

Layer / File(s) Summary
Core async loader and executor conversion
crates/mesh-llm-host-runtime/src/system/native_runtime.rs
Adds std::future::Future import; converts try_load_installed_native_runtime, try_load_installed_native_runtime_with, resolve_startup_native_runtime_plan_with, and default_install_executor to async fn; introduces InstallFuture generic bound on InstallExecutorFn; removes manual Tokio runtime construction in default_install_executor; updates all internal .await call sites.
Public API and run entry points
crates/mesh-llm-host-runtime/src/lib.rs
initialize_host_runtime is promoted to pub async fn; run() and run_runtime() add .await to the initialization call; the dynamic-native-runtime feature-gate path awaits try_load_installed_native_runtime().
CLI entrypoint reordering and async init
crates/mesh-llm/src/lib.rs
run_cli_entrypoint moves commands::dispatch before host runtime initialization and adds an early-return when dispatch handles the command; initialize_host_runtime() is now awaited.
Test suite async conversion
crates/mesh-llm-host-runtime/src/system/native_runtime.rs
Three feature-gated tests switch from #[test] to #[tokio::test] and become async fn; install-executor closures become async move blocks; all try_load_installed_native_runtime_with calls gain .await.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • ndizazzo
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix native runtime startup initialization' directly addresses the main issue being fixed: a runtime initialization panic during native runtime startup. It clearly summarizes the primary purpose of the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

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

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

@i386
i386 marked this pull request as ready for review June 18, 2026 03:04
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.

2 participants