feat: support dynamic plugin discovery via plugins.toml#290
Conversation
Signed-off-by: Alex Fournier <afournier@nvidia.com>
WalkthroughAdds first-class dynamic plugin support to ChangesDynamic Plugin Loading and Reporting
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@crates/cli/src/config.rs`:
- Around line 1022-1032: The unconditional assignment on line 1031 of
plugin_toml.value to resolved.gateway.plugin_config causes a plugins.toml file
with only dynamic plugins (where plugin_toml.value is None) to erase any plugin
config previously loaded from config.toml. Guard the assignment so that
resolved.gateway.plugin_config is only updated when plugin_toml.value is Some,
preventing None values from overwriting existing configuration. The conflict
check already ensures both sources don't define config simultaneously, so this
guard will preserve config from config.toml when plugins.toml contains only
dynamic plugins.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 5663ca62-17de-47b7-abfe-4da8a74d1364
📒 Files selected for processing (6)
crates/cli/src/config.rscrates/cli/src/doctor.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/tests/coverage/launcher_tests.rscrates/core/src/plugin.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (15)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Use
snake_casenaming convention for Rust identifiers (e.g.,nemo_relay_tool_call)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node work
**/*.rs: Runcargo fmt --allto format all Rust code
Runcargo clippy --workspace --all-targets -- -D warningsto enforce all clippy lints as errors
**/*.rs: Runcargo fmt --allwhen Rust files changed as part of WebAssembly work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files changed as part of WebAssembly work
**/*.rs: If any Rust code changed, always runjust test-rust
If any Rust code changed, also runcargo fmt --all
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting withcargo fmt --all
Run Rust linting withcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Usecargo fmtfor Rust code formatting
Runcargo clippy -- -D warningsto lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code withuv run pre-commit run --all-filesto enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Maintain documented and tested validation and report behavior for adaptive surfaces
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rs
**/{Cargo.toml,**/*.rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Maintain consistency between Rust package names in
Cargo.tomland their actual usage across the codebase
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
**/*.{h,hpp,c,cpp,rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Ensure FFI header and library naming follows consistent conventions across platform-specific builds
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update Rust crate names and module prefixes during coordinated rename operations
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
**/*.{rs,py,go,js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions: Rust and Python use
snake_case, C FFI exports prefixednemo_relay_, Go usesPascalCasefor public APIs, Node.js usescamelCase.
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
crates/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
UseJson = serde_json::Valuein Rust-facing runtime APIs for JSON payload handling.
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
**
⚙️ CodeRabbit configuration file
**:AGENTS.md
This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.
Project Overview
NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.
The shared runtime model is:
- Scope stacks decide where work belongs and which scope-local behavior is visible.
- Middleware registries decide what guardrails and intercepts run around managed calls.
- Plugins install reusable runtime behavior from configuration.
- Events record runtime behavior in ATOF form.
- Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.
Repository Structure
The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.crates/ core/ # Rust core runtime crate, published as nemo-relay adaptive/ # Adaptive runtime primitives and plugin components python/ # PyO3 native extension for the Python package ffi/ # Raw C ABI layer used by downstream bindings such as Go node/ # NAPI Node.js binding and JavaScript/TypeScript entry points wasm/ # wasm-bindgen WebAssembly binding and JS wrappers python/ nemo_relay/ # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers tests/ # Python tests go/ nemo_relay/ # Experimental Go CGo binding and tests fern/ # Fern documentation site scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile third_party/ # P...
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rscrates/cli/src/doctor.rscrates/core/src/plugin.rscrates/cli/src/config.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/cli/tests/coverage/launcher_tests.rscrates/cli/tests/coverage/config_tests.rscrates/cli/tests/coverage/doctor_tests.rs
**/*config*.{rs,ts,py,go,js,json,yaml,yml}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Ensure dynamic config shape still matches the documented canonical model
Files:
crates/cli/tests/coverage/config_tests.rscrates/cli/src/config.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/src/plugin.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
crates/core/**/*.rs: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.
Files:
crates/core/src/plugin.rs
crates/{core,adaptive}/**
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly
Files:
crates/core/src/plugin.rs
crates/{core,adaptive}/**/*.rs
⚙️ CodeRabbit configuration file
crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.
Files:
crates/core/src/plugin.rs
🔇 Additional comments (7)
crates/cli/tests/coverage/config_tests.rs (1)
25-56: LGTM!Also applies to: 409-442, 486-506, 557-576, 577-691
crates/cli/src/doctor.rs (2)
30-32: 📐 Maintainability & Code QualityConfirm required Rust validation commands were run for this change.
Please provide confirmation/output for:
just test-rustcargo fmt --allcargo clippy --workspace --all-targets -- -D warningsAs per coding guidelines: “Any Rust change must run
just test-rust”, “Any Rust change must runcargo fmt --all”, and “Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings”.Source: Coding guidelines
89-98: LGTM!Also applies to: 159-159, 195-195, 217-260, 1407-1435
crates/cli/tests/coverage/doctor_tests.rs (1)
123-123: LGTM!Also applies to: 305-330, 405-405, 590-590, 606-634
crates/cli/tests/coverage/launcher_tests.rs (1)
248-248: LGTM!Also applies to: 325-325, 472-472, 498-498, 544-544, 577-577, 626-626, 702-702, 729-729, 772-772, 815-815, 851-851, 1046-1046, 1165-1165
crates/core/src/plugin.rs (1)
1124-1156: LGTM!crates/cli/src/config.rs (1)
486-518: LGTM!
| if let Some(config_source) = config_toml_plugin_source | ||
| && plugin_toml.value.is_some() | ||
| { | ||
| return Err(CliError::Config(format!( | ||
| "plugin config is defined in both {} and {}; choose one source", | ||
| config_source.display(), | ||
| format_paths(&plugin_toml.sources) | ||
| ))); | ||
| } | ||
| gateway.plugin_config = Some(plugin_toml.value); | ||
| resolved.gateway.plugin_config = plugin_toml.value; | ||
| resolved.dynamic_plugins = plugin_toml.dynamic_plugins; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -nP --type=rust -C4 'fn apply_file_config' crates/cli/src/config.rs
rg -nP --type=rust -C2 'plugin_config\s*=' crates/cli/src/config.rs
rg -nP --type=rust -C3 'fn has_config_toml_plugin_config' crates/cli/src/config.rsRepository: NVIDIA/NeMo-Relay
Length of output: 2007
🏁 Script executed:
sed -n '1015,1040p' crates/cli/src/config.rs | cat -nRepository: NVIDIA/NeMo-Relay
Length of output: 1209
🏁 Script executed:
rg -nP --type=rust 'apply_file_config|apply_plugin_toml' crates/cli/src/config.rs | head -20Repository: NVIDIA/NeMo-Relay
Length of output: 376
🏁 Script executed:
rg -nP --type=rust 'struct PluginTomlConfig' crates/cli/src/config.rs -A 5Repository: NVIDIA/NeMo-Relay
Length of output: 316
Guard assignment so plugins.toml with only dynamic plugins doesn't erase plugin config from config.toml.
Line 1031 unconditionally assigns plugin_toml.value (which is Option<Value>) to resolved.gateway.plugin_config, but the conflict check at line 1021 only triggers when both config_toml_plugin_source and plugin_toml.value are Some. This means a plugins.toml containing only [[plugins.dynamic]] will silently overwrite any plugin config already set by config.toml with None.
Proposed fix
- resolved.gateway.plugin_config = plugin_toml.value;
+ if plugin_toml.value.is_some() {
+ resolved.gateway.plugin_config = plugin_toml.value;
+ }
resolved.dynamic_plugins = plugin_toml.dynamic_plugins;🤖 Prompt for 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.
In `@crates/cli/src/config.rs` around lines 1022 - 1032, The unconditional
assignment on line 1031 of plugin_toml.value to resolved.gateway.plugin_config
causes a plugins.toml file with only dynamic plugins (where plugin_toml.value is
None) to erase any plugin config previously loaded from config.toml. Guard the
assignment so that resolved.gateway.plugin_config is only updated when
plugin_toml.value is Some, preventing None values from overwriting existing
configuration. The conflict check already ensures both sources don't define
config simultaneously, so this guard will preserve config from config.toml when
plugins.toml contains only dynamic plugins.
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub(crate) enum DynamicPluginReferenceResolutionStatus { | ||
| Resolved, | ||
| } |
There was a problem hiding this comment.
Is there any way this would be unresolved? Do we need this and
pub(crate) fn reference_status(&self) -> DynamicPluginReferenceResolutionStatusbelow?
Overview
Support manifest-backed dynamic plugin discovery through
plugins.tomlwithout turningplugins.tomlinto a second plugin contract.Details
[[plugins.dynamic]]parsing to the CLI config loadermanifestand derive canonicalplugin.idfromrelay-plugin.toml[plugins.dynamic.config]while rejecting plugin-owned and lifecycle fields inplugins.tomlplugins.tomlsourcesPluginConfigpath so existingcomponentsbehavior is preservedResolvedConfigandnemo-relay doctorhuman/JSON reportingplugins.tomlmerge semantics in core so the CLI does not duplicate merge logicValidation run:
just test-rustcargo clippy --workspace --all-targets -- -D warningscargo test -p nemo-relay-cli config::tests -- --nocapturecargo test -p nemo-relay-cli doctor::tests::format_human_reports_discovered_dynamic_plugins_in_configuration -- --nocapturecargo test -p nemo-relay-cli doctor::tests::format_json_is_stable_and_versioned -- --nocapturecargo test -p nemo-relay-cli doctor::tests::format_json_reports_discovered_dynamic_plugin_fields -- --nocaptureuv run pre-commit run --files crates/cli/src/config.rs crates/cli/src/doctor.rs crates/cli/tests/coverage/config_tests.rs crates/cli/tests/coverage/doctor_tests.rs crates/cli/tests/coverage/launcher_tests.rs crates/core/src/plugin.rsWhere should the reviewer start?
Start in
crates/cli/src/config.rs, then reviewcrates/cli/src/doctor.rsfor the reporting surface andcrates/cli/tests/coverage/config_tests.rsfor the newplugins.dynamiccontract coverage.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
New Features
plugins.tomlwith manifest references, including resolution and configuration tracking.Chores