Repository navigation
[3/4] feat(environments): add profile-aware scaffolding - #2442
Merged
Merged
Conversation
Contributor
|
🌿 Preview your docs: https://nvidia-preview-mbien-environment-onboarding-scaffold.docs.buildwithfern.com/nemo/gym Here are the markdown pages you've updated: |
This was referenced Aug 10, 2026
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
from
August 10, 2026 12:31
9656332 to
c9c744d
Compare
Glorf
marked this pull request as ready for review
August 10, 2026 12:38
Glorf
force-pushed
the
mbien/environment-onboarding-validation
branch
from
August 10, 2026 16:29
1b807f2 to
2aa19ba
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
2 times, most recently
from
August 10, 2026 18:03
46ac8c3 to
b7e2b26
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-validation
branch
2 times, most recently
from
August 11, 2026 11:49
ae953b8 to
c67e180
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
from
August 11, 2026 11:49
b7e2b26 to
9addc03
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-validation
branch
from
August 11, 2026 12:04
c67e180 to
92d757b
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
2 times, most recently
from
August 11, 2026 12:51
1b3f459 to
ca7522f
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-validation
branch
from
August 11, 2026 12:51
92d757b to
c45df25
Compare
ritaneves
force-pushed
the
mbien/environment-onboarding-validation
branch
from
August 11, 2026 15:58
c45df25 to
2103fb7
Compare
ritaneves
force-pushed
the
mbien/environment-onboarding-scaffold
branch
from
August 11, 2026 15:58
ca7522f to
5804e32
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-validation
branch
from
August 11, 2026 18:29
2103fb7 to
5b94cc3
Compare
Glorf
added a commit
that referenced
this pull request
Aug 11, 2026
## Summary Defines an opt-in `manifest.yaml` contract for Gym environments and benchmarks without changing how workloads run. ## Stack - **1/4 — Manifest contract** (this PR) - 2/4 — [Static manifest validation](#2441) - 3/4 — [Profile-aware scaffolding](#2442) - 4/4 — [Onboarding catalog and commands](#2443) Each PR contains one commit and is based on the preceding branch. ## What this PR delivers - A strict manifest model for identity, catalog metadata, reward semantics, determinism, integration shape, and config-owned composition mirrors. - Four integration profiles matching Gym's existing extension points: `custom-gym-verifier`, `custom-gym-agent-loop`, `external-agent-loop`, and `external-rollout-driver`. - A Pydantic contract that can emit Draft 2020-12 JSON Schema on demand. - SPDX expression validation through `packaging`, including `LicenseRef` values and Gym's private-license labels. - A neutral example, focused contract tests, and contributor documentation. The manifest is the single place to read a workload declaration. Gym configuration remains the authoritative place to write runtime composition. Names and versions must be non-empty; Semantic Versioning is documented guidance, while immutable-version enforcement is staged work. ## Compatibility and scope - Existing environments and benchmarks continue to run without a manifest. - No runtime dispatch, wire protocol, server route, or existing workload changes. - The manifest remains opt-in until later stack layers consume it. - Capabilities, concrete version resolution, pinning, swap enforcement, and certificate-backed validation remain follow-ups. ## Validation - Manifest parsing, invariants, SPDX expressions, serialization, and schema tests. - Independent Draft 2020-12 validation of the generated representation. - Ruff and whitespace checks. Signed-off-by: Michal Bien <[email protected]>
Glorf
force-pushed
the
mbien/environment-onboarding-validation
branch
from
August 11, 2026 19:36
5b94cc3 to
03e2231
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
2 times, most recently
from
August 11, 2026 19:38
8ab999e to
6a5e7e7
Compare
bxyu-nvidia
previously approved these changes
Aug 12, 2026
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
from
August 12, 2026 07:30
6a5e7e7 to
61ec62c
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-validation
branch
from
August 12, 2026 08:02
03e2231 to
ab88cfd
Compare
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
from
August 12, 2026 08:02
61ec62c to
65cb4e0
Compare
Glorf
added a commit
that referenced
this pull request
Aug 12, 2026
## Summary Adds service-free validation for manifest-backed environments and benchmarks. It checks the declaration against resolved Gym configuration before any service starts. ## Stack - 1/4 — [Manifest contract](#2417) - **2/4 — Static manifest validation** (this PR) - 3/4 — [Profile-aware scaffolding](#2442) - 4/4 — [Onboarding catalog and commands](#2443) This PR contains one commit and is based on the 1/4 branch. ## What this PR delivers - Offline resolution of Gym configuration and inheritance without endpoint probes, service startup, or model calls. - Manifest identity and catalog-path checks. - Config-authoritative component and dataset selection, including an actionable error when composition has more than one dataset-bearing agent. - Read-only comparison of manifest composition mirrors with resolved config, plus explicit atomic synchronization. - Advisory integration-profile inference with evidence, warnings for mismatches, and `unknown` when static source inspection is inconclusive. - Static parsing of preparation and rollout-driver hooks, plus streamed JSONL and prompt-contract validation. ## Compatibility and scope - Gym config remains the runtime source of truth; manifest mirrors never select runtime composition. - Validation does not import workload components, execute preparation code, start services, provision compute, call a model, probe endpoints, or inspect output-directory writability. - Profile inference reports evidence and never dispatches or gates runtime behavior. - Existing manifest-free workloads continue to run unchanged. ## Validation - Representative built-in and custom profile-inference cases. - Mirror repair, multi-agent ambiguity, hook parsing, prompt application, and malformed-data regressions. - Ruff and whitespace checks. ## Next layer The next PR adds non-destructive profile-aware scaffolding and reusable verifier fixtures. Signed-off-by: Michal Bien <[email protected]>
Base automatically changed from
mbien/environment-onboarding-validation
to
main
August 12, 2026 08:21
Signed-off-by: Michal Bien <[email protected]>
Glorf
force-pushed
the
mbien/environment-onboarding-scaffold
branch
from
August 12, 2026 08:27
65cb4e0 to
e3d71b8
Compare
Glorf
added a commit
that referenced
this pull request
Aug 12, 2026
## Summary Completes the user-facing onboarding MVP with a local registry and four commands: ```bash gym env init --environment my_eval --profile custom-gym-verifier gym env validate my_eval gym env test my_eval gym env publish my_eval ``` ## Stack - 1/4 — [Manifest contract](#2417) - 2/4 — [Static manifest validation](#2441) - 3/4 — [Profile-aware scaffolding](#2442) - **4/4 — Onboarding catalog and commands** (this PR) This PR contains one commit and is based on the 3/4 branch. ## What this PR delivers - A unified local workload registry for manifest-backed and legacy environments and benchmarks. - Transition visibility for runnable compositions still colocated under `resources_servers/`; reusable scorer, tool, and state components without agent datasets remain component entries. - Kind-filtered list, search, inspect, status, profile, domain, and JSON views. - Environment and benchmark targets for `gym env init`. - Static checks, advisory profile evidence, warnings, and mirror synchronization through `gym env validate`. - Verifier execution in the resources server's managed dependency environment through `gym env test`. - A local structural `gym env publish` check that reruns validation and fixtures, rejects manifest metadata placeholders, and confirms exact catalog discovery as `experimental`. - Public documentation for terminology, ownership, profiles, migration behavior, and all four commands. `publish` does not assess implementation quality, run a full evaluation, deploy, commit, push, or claim certificate-backed validation. ## Compatibility - Existing runtime configuration and execution remain unchanged. - Existing init, config validation, resources-server test, list, and search forms remain available. - Manifest-free runnable workloads remain visible with `no-manifest` status and continue to run as before. - Malformed manifests are isolated during global discovery and remain directly diagnosable with `gym env validate --manifest ...`. ## Validation - 510 sandbox-safe onboarding and affected CLI tests pass; the socket-binding case also passes outside the sandbox. - CI-version Ruff and whitespace checks pass. ## Staged follow-ups - Capability declarations, concrete component-version resolution, pinning, and swap refusal. - Runtime readiness probes as a separate pre-run validation layer. - In-place manifest backfill and phased CI enforcement for legacy runnable compositions. - Repository publication automation, ownership updates, and immutable version enforcement. - Certificate-backed `validated` status and a hosted catalog index. - A session-stateful onboarding sentinel and stored-trajectory replay coverage. These follow-ups strengthen runtime readiness, governance, and migration. They do not change the manifest contract, guided authoring path, local checks, or transition registry delivered here. Signed-off-by: Michal Bien <[email protected]>
kajalj22
pushed a commit
to kajalj22/Gym
that referenced
this pull request
Oct 8, 2026
…nt (NVIDIA-NeMo#4085) ## What does this PR do? `gym env init --reuse-verifier <scorer>` now produces a workload that validates and runs when the scorer's config bundles an agent behind an environment server. Every shipped scorer that exports `VERIFIER_FIXTURE` does since NVIDIA-NeMo#3724, so the documented reuse command in the [New Environment guide](https://docs.nvidia.com/nemo/gym/latest/contribute/environments/new-environment#onboarding-commands) failed for all of them: ```bash gym env init --benchmark my_benchmark --profile custom-gym-verifier \ --reuse-verifier example_single_tool_call --reward-range 0 1 --higher-is-better gym env validate my_benchmark # Error: In server instance 'example_single_tool_call_environment_server', field 'agent_server' references # responses_api_agents/'example_single_tool_call_simple_agent', which is not defined in the merged config. ``` ### Cause The scaffold derives the workload's agent with `_inherit_from: <scorer>_simple_agent`, which moves that agent to the new name. NVIDIA-NeMo#3724 added `<scorer>_environment_server` to every shipped scorer config, naming the original agent, and made the scaffold write a fresh `<name>_environment_server`. After the move, the scorer's server named an agent that no longer existed. Running the same repro against Gym before and after NVIDIA-NeMo#3724 confirms the window: `65943edd` (its parent) validates, and `016bb6b8` (NVIDIA-NeMo#3724) fails. Every later commit through `325fb49d` fails too. `test_reuse_supports_a_bundled_default_agent` did not catch it because its synthetic scorer has no environment server. ### Fix When the reused config has an environment server in front of its bundled agent, the scaffold moves that server with the agent. It inherits the server under the workload's name and points it at the renamed agent: ```yaml my_benchmark_agent: _inherit_from: example_single_tool_call_simple_agent ... my_benchmark_environment_server: _inherit_from: example_single_tool_call_environment_server environment_servers: legacy_agent: agent_server: name: my_benchmark_agent ``` This is the shape the shipped benchmarks that reuse a scorer already use (for example `benchmarks/aegis_v4_safety/config.yaml`), and the `INHERITED` block in `scripts/add_legacy_agent_environment_servers.py`. Each agent ends up behind exactly one environment server, which rollout collection requires (`AmbiguousEnvironmentServerError` otherwise). Two alternatives were tried and rejected: - **Keep the fresh server and repoint the scorer's server as well.** Static validation passes, but two servers then front one agent, so every agent-routed row fails at rollout time. - **Repoint the scorer's server in place.** Two workloads that reuse the same scorer in one run both edit that one server, and the second wins. The first agent is left without a server, so Gym generates a deprecated relay for it, or fails with `error_on_agent_without_environment_server`. Inheriting gives each workload its own server. This also applies to a workload named after its scorer: it now inherits under `<name>_catalog_environment_server`, mirroring the existing `<name>_catalog_agent` fallback. The scaffold now rejects three reused configs it cannot inherit safely, each with an error that says to compose the config by hand: - the bundled agent is fronted by more than one environment server; - that environment server is itself derived with `_inherit_from` or `_copy` (inheriting it again leaves its own source unresolved); - `environment_server_routes` in the reused config names that server (inheriting retires the name). No config in the repository hits any of these. Reused configs without a bundled environment server keep the previous behavior, a fresh `legacy_agent` server. ### Related work - NVIDIA-NeMo#4053 (open) changes the migration script to repoint declared servers in place, to keep names that `environment_server_routes` uses. This PR does not touch the files NVIDIA-NeMo#4053 changes. The scaffold inherits instead because of the multi-workload case above, and it refuses the routed case rather than renaming a routed server. `_agent_reference_fields` uses the same reference rule that NVIDIA-NeMo#4053 introduces as `environment_server_agent_refs`: `agent_server` may omit its type, and any other field must be typed `responses_api_agents`. - `r0.7.0` contains both NVIDIA-NeMo#2442 and NVIDIA-NeMo#3724, so the release branch has the same defect. This fix is a cherry-pick candidate. ### Known limitation, unchanged With `--profile custom-gym-agent-loop` or `external-agent-loop`, reusing a scorer that bundles an agent still fails validation (`AlmostServerError`). The generated agent adds a second implementation key to the inherited `simple_agent`. This fails on `main` too, is independent of this change, and is left for a separate fix. No GitHub issue exists. NeMo Gym QA found this while adding coverage for the onboarding commands from NVIDIA-NeMo#1029; an NVBug is being filed with the same repro. ## Validation - `tests/unit_tests/test_environment_scaffold.py`: 14 new or extended reuse tests. Each one resolves the generated config as a run does, with `error_on_agent_without_environment_server: true`, and checks `rollout_collection._environment_servers_by_agent`. They cover the following: - typed and untyped `agent_server` references; - a workload named after its scorer; - three workloads reusing one scorer composed in one run; - instance-name collisions, with a fallback and a rejection; - the three rejections above; - both shipped fixture scorers, pinned to the inherit path. 13 of the new tests fail against `main`'s `scaffold.py`. 9 fail against a first draft of this fix that repointed in place for a workload named after its scorer. - `pytest tests/unit_tests/test_environment_scaffold.py tests/unit_tests/test_global_config.py tests/unit_tests/test_cli_main.py tests/unit_tests/test_cli.py tests/unit_tests/test_environment_validation.py tests/unit_tests/test_environment_onboarding.py tests/unit_tests/test_environment_publication.py tests/unit_tests/test_add_legacy_agent_environment_servers.py`: 657 passed. - `pre-commit run --all-files`: all hooks pass. - Standalone repro, run on `main` and on this branch: - It scaffolds the documented command for `example_single_tool_call` and `equivalence_llm_judge`. - Before this change: 2 of 2 fail `gym env validate`. - After: 0 of 2 fail. ## Rollout evidence The live smoke test ran against this branch, using the `inference_provider` model type with `nvidia/nvidia/Nemotron-3-Nano-30B-A3B`: 1. `gym env init --environment qa_reuse_smoke --reuse-verifier example_single_tool_call --reward-range 0 1 --higher-is-better`, with the sample row replaced by one row from the scorer's own `data/example.jsonl`. 2. `gym env validate qa_reuse_smoke`. 3. `gym env start --environment qa_reuse_smoke --search-dir <workspace>`. 4. `gym eval run --no-serve --agent qa_reuse_smoke_agent --limit 1`. Results: - Four servers started: `example_single_tool_call`, `qa_reuse_smoke_agent`, `qa_reuse_smoke_environment_server`, and `policy_model`. - The rollout went through the inherited environment server, and the model called `get_weather`. - The reused verifier scored it 1.0, and the failures file was empty. The QA suite case that runs the documented reuse command for both shipped fixture scorers fails on `main` and passes on this branch. ## Compatibility and docs - For a scorer that bundles an environment server, `gym env init --reuse-verifier` now generates a config with an inherited environment server. Workloads previously generated this way did not validate, so nothing that worked before changes. No runtime, config-engine, or benchmark-result change. - Docs: N/A. The guide already documents this command. This change makes it behave as documented, and the guide's description of the scaffold's environment server stays accurate for every shipped scorer. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: qiaochuz <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds non-destructive scaffolding for all four integration profiles and a reusable, in-process verifier-fixture contract.
Stack
This PR contains one commit and is based on the 2/4 branch.
What this PR delivers
custom-gym-verifier,custom-gym-agent-loop,external-agent-loop, andexternal-rollout-driver.unknownuntil their authored behavior is implemented.prepare()hook.--reuse-verifiersupport across all profiles for compatible existing scorers with an explicit reward contract.gym env init --resources-serverpath; the legacy command keeps its combined runnable config.Compatibility and scope
Validation
Next layer
The final PR exposes the stack through discovery and the four-command onboarding journey.