Skip to content

feat: forward selected host environment variables to managed workers - #1584

Merged
willkill07 merged 2 commits into
NVIDIA:release/0.11from
willkill07:feat/relay-1177-worker-forward-env
Oct 30, 2026
Merged

willkill07 merged 2 commits into
NVIDIA:release/0.11from
willkill07:feat/relay-1177-worker-forward-env

Conversation

@willkill07

@willkill07 willkill07 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Overview

Let plugin authors select which host environment variables reach managed workers through load.forward_env in relay-plugin.toml. This allows worker-side environment references to resolve without adding end-user forwarding settings.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Support exact names and a single trailing wildcard, such as EXAMPLE_CONTEXT_ID and EXAMPLE_CONFIG_*. Reject malformed patterns and this option on native plugins.
  • Preserve the existing environment allowlist. Missing selected variables are ignored. Relay's token, endpoints, and resolved message limits take precedence over forwarded values.
  • Keep forwarding under plugin-author control, with no general variable denylist. Document the trusted-plugin model, name matching, and startup behavior using fictional examples.
  • Preserve patterns through manifest serialization and stored worker records. Add coverage for parsing, matching, defaults, and process launch.

Plugin authors can select exact names and prefixes in relay-plugin.toml:

[load]
runtime = "python"
entrypoint = "example_worker:main"
forward_env = [
  "EXAMPLE_CONTEXT_ID", # Exact variable name
  "EXAMPLE_CONFIG_*",   # All names starting with EXAMPLE_CONFIG_
]

Rust API compatibility: callers that construct DynamicPluginManifestWorkerLoad or DynamicPluginWorkerLoadContract directly must provide the new forward_env field. Use an empty vector to keep the existing behavior. No worker protocol change is required.

Validation:

  • just test-rust: 6,629 passed, 4 skipped.
  • Focused manifest and worker environment tests passed. The manifest tests were rerun after replacing example names.
  • Staged repository hooks passed, including formatting, Clippy, Cargo checks, and dependency audits.
  • just docs-linkcheck passed. The published-redirect comparison was skipped because the docs service returned HTTP 403.
  • Reviewed the added documentation against the repository's NVIDIA style guidance.

Binding suites were not run because no binding code or worker protocol changed; forwarding is implemented and tested in the shared Rust host.

Where should the reviewer start?

Start with minimize_worker_environment and spawn_worker_process in crates/core/src/plugin/dynamic/worker.rs, then the manifest validation in crates/core/src/plugin/dynamic/manifest.rs. Launch coverage is in crates/core/tests/unit/dynamic_worker_tests.rs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • New Features
    • Worker plugins can receive selected host environment variables at launch. Configure exact variable names or trailing-wildcard prefix patterns; unselected variables remain excluded, and Relay-provided settings cannot be overridden. Omitting the setting or using an empty list forwards no additional host variables.
  • Documentation
    • Plugin documentation explains the configuration syntax, platform-specific matching behavior, Relay version requirement, and security considerations for forwarding variables, including credentials. It also clarifies that forwarded values are available to worker plugins but aren’t shown in inspection output.

@willkill07
willkill07 requested review from a team as code owners October 29, 2026 23:22
@github-actions github-actions Bot added size:M PR is medium Feature a new feature lang:rust PR changes/introduces Rust code labels Oct 29, 2026
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Worker load manifests now accept validated environment names and trailing-wildcard prefixes. Worker launches retain matching host variables while preserving baseline variables and Relay-supplied settings. Tests and documentation cover configuration, validation, and launch behavior.

Changes

Worker environment forwarding

Layer / File(s) Summary
Manifest contract and validation
crates/core/src/plugin/dynamic.rs, crates/core/src/plugin/dynamic/manifest.rs, crates/core/tests/unit/plugin_dynamic_tests.rs, docs/build-plugins/package-discoverable-plugins.mdx, docs/build-plugins/_code/*
Worker load contracts and manifests include forward_env, which defaults to an empty list and is omitted from serialization when empty. Validation accepts ASCII environment names and trailing-* prefixes. Tests cover valid and invalid patterns, native manifest rejection, serialization, and conversion. The documentation and worker examples describe the setting and its matching rules.
Worker launch environment selection
crates/core/src/plugin/dynamic/worker.rs, crates/core/tests/unit/dynamic_worker_tests.rs, docs/build-plugins/workers/grpc-v1-protocol.mdx
Worker launches pass validated patterns to environment minimization. The launcher retains matching host variables, uses case-insensitive matching on Windows, and removes an inherited endpoint-file variable before applying the configured value. Tests cover matching, baseline variables, and endpoint behavior. The protocol documentation describes forwarding and Relay-supplied settings.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PluginManifest
  participant DynamicPluginManifestWorkerLoad
  participant WorkerProcessLaunch
  participant WorkerProcess
  PluginManifest->>DynamicPluginManifestWorkerLoad: Deserialize and validate forward_env patterns
  DynamicPluginManifestWorkerLoad->>WorkerProcessLaunch: Pass validated patterns
  WorkerProcessLaunch->>WorkerProcess: Launch with retained host variables and Relay settings
Loading

Possibly related PRs

  • NVIDIA/NeMo-Relay#1499: Both changes affect the worker launch environment and preservation of Relay-supplied settings.
Merge Risk: Minimal · up to 156fe

No actionable merge-blocking risk remains in the reviewed change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title follows Conventional Commits with the allowed type 'feat', lowercase, imperative summary, 68 characters, and no trailing period. It clearly matches the main change: forwarding selected host …
Description check Passed The description follows the repository template. It includes the Overview with both checklist items marked, Details with the implementation and validation notes, a 'Where should the reviewer start?' s…
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.
Full details: Title check

Explanation

The title follows Conventional Commits with the allowed type 'feat', lowercase, imperative summary, 68 characters, and no trailing period. It clearly matches the main change: forwarding selected host environment variables to managed workers via load.forward_env.

Full details: Description check

Explanation

The description follows the repository template. It includes the Overview with both checklist items marked, Details with the implementation and validation notes, a 'Where should the reviewer start?' section pointing to worker.rs, manifest.rs, and dynamic_worker_tests.rs, and a Related Issues section using 'Resolves' with RELAY-1177. It explains the purpose, the exact and trailing-wildcard matching, the validation rules, and the Rust API compatibility impact.

Full details: Docstring Coverage

Explanation

Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 15 functions across 5 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@willkill07 willkill07 self-assigned this Oct 29, 2026
@willkill07 willkill07 added this to the 0.11 milestone Oct 29, 2026
@github-actions

Copy link
Copy Markdown

@bbednarski9

bbednarski9 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

nit, but could be nice to include an example for plugin authors in the description - something like:

[load]
runtime = "python"
entrypoint = "tokenomics_meter_worker:main"
forward_env = [
  "CODEX_HOME",       # Exact variable name
  "TOKENOMICS_*",     # All names beginning with TOKENOMICS_
]

@bbednarski9 bbednarski9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ty, looks good

@willkill07
willkill07 enabled auto-merge (squash) October 30, 2026 00:06
@willkill07
willkill07 merged commit 923b973 into NVIDIA:release/0.11 Oct 30, 2026
97 checks passed
@willkill07
willkill07 deleted the feat/relay-1177-worker-forward-env branch October 30, 2026 14:46

This branch was previously deployed

1 inactive deployment
fern — 156fe474 Deployed Oct 30, 2026 by willkill07 via Clean up docs preview #6823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature a new feature lang:rust PR changes/introduces Rust code size:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants