Skip to content

feat(harbor): configuration homes, dataset.toml [gym] table and gym dataset init (M15) - #3807

Merged
adil-a merged 1 commit into
adasif/harbor-m13-compose-gpufrom
adasif/harbor-m15-config-homes
Oct 21, 2026
Merged

adil-a merged 1 commit into
adasif/harbor-m13-compose-gpufrom
adasif/harbor-m15-config-homes

Conversation

@adil-a

@adil-a adil-a commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Milestone M15 of the Harbor tasks RFC: configuration homes. The harbor resources server runs every Harbor-shaped dataset, so its config is the one place a dataset-specific setting must never land. By M13 it held eight such fields. This PR removes them and fixes where each kind of setting lives. Stacked on the M13 PR (#3754). Rebased onto main 128eab4 (2026-10-04).

  • Dataset settings in dataset.toml. A [gym] table beside the task folders: [gym.defaults] with timeout_multiplier and resource_multiplier, and [gym.tasks."<id>".environment] overrides written with Harbor's own [environment] fields (env merges, other fields replace). An override key that [environment] does not have is rejected by name, even though task.toml itself ignores unknown keys. The loader applies them, so servers, agents and rows see the effective task.toml. The task digest still pins the folder alone. nemo_gym/tasks/harbor/dataset_config.py.
  • Deployment settings on the sandbox provider. The OpenSandbox provider gains images.rewrites (ordered {from, to} prefix rules), images.auth (credentials by image prefix, longest wins, a spec's own image_auth still wins), setup.commands (run as root after readiness, within setup.timeout_s each) and setup.env (set in every sandbox under the spec's own variables, for platform knobs such as the exec daemon's grace period). A failed setup command raises OpenSandboxSetupError, which is never treated as a retryable create error, whatever its stderr says. A create cancelled during the probe or the setup commands still cleans up the new sandbox instead of leaving it to its TTL. Every sandbox consumer gets these blocks.
  • Server config pinned. Removed: sandbox_env, sandbox_env_by_task, sandbox_setup_commands, sandbox_setup_timeout_s, derive_cpu_env, image_rewrites, image_rewrite_auth, compose_image_configs (fetch writes compose-images.json next to the task folders and the server reads it there). test_server_config_holds_only_deployment_settings asserts the remaining field set and rejects dataset names in the class source.
  • Verifier mode as Harbor infers it. A [verifier.environment] block alone selects separate verification, as in Harbor 0.22. environment_mode = "shared" keeps the shared mode, and a shared verifier cannot declare its own [verifier.environment]. A separate-mode task that declares no artifacts loads with a warning, since the verifier still receives /logs/artifacts.
  • Run overlays merge last. gym eval run <taskset> ... +config_paths=[overlay.yaml] emitted the component config paths after the caller's tokens, so provider defaults such as setup.commands: [] and images.rewrites: [] erased the overlay's values. The component token now comes first, and a regression test checks that the caller's overlay is the last config_paths entry. Found by the TB2.1 parity run, where the run overlay's Debian 11 archive repair never reached the sandbox and two verifiers could not install curl.
  • gym dataset init <name> (--root, --image) scaffolds a dataset in this shape: dataset.toml with its [gym] table and one task with task.toml, instruction.md, tests/test.sh and solution/solve.sh. A test reads the scaffold back through the loader and the row writer. gym env init prints a deprecation notice for new datasets and stays for custom resources servers until M23.
  • Terminus 2 tests expect terminus2_outcome in the response metadata. The agent change that writes it lives earlier in the stack, so this branch only updates the test expectations.
  • Docs: harbor README table of the four homes, OpenSandbox page section on image policy and setup commands, shipped provider config, TB4 README parity settings.

Review fixes (2026-10-04)

  • c676da96b infers the verifier mode as Harbor does, rejects unknown keys in [gym.tasks."<id>".environment] by name, never retries OpenSandboxSetupError, and cleans up the sandbox when a create is cancelled. It supersedes 18fa2f296 (2026-09-30), which had selected separate mode only from environment_mode and rejected separate mode without artifacts.
  • 90bfc9358 updates the Terminus 2 test expectation for terminus2_outcome.

Earlier fix commits on the branch: 94d494ed0 (config_paths ordering, 2026-09-29) and a947c4dbf (Terminus 2 outcome metadata test, 2026-09-29).

No issue: tracked in the RFC (M15) and its MR 400.

Validation

pytest tests/unit_tests/test_harbor_tasks.py tests/unit_tests/test_harbor_image_configs.py \
  tests/unit_tests/test_opensandbox_provider.py tests/unit_tests/test_sandbox.py \
  tests/unit_tests/test_tb4_harbor_sandbox_overlay.py tests/unit_tests/test_compose_config.py \
  resources_servers/harbor/tests responses_api_agents/harbor_oracle_agent/tests   # 380 passed, 2 skipped (2026-10-05, rebased branch)
ruff check <changed .py> && ruff format --check <changed .py>              # clean (2026-10-05)
pre-commit run --from-ref <M13 tip> --to-ref HEAD                          # clean before the rebase
gym dataset init demo-ds                                                   # scaffold written and loaded

New tests: per-task override merging and unknown-key rejection, defaults scaling timeouts and resources, the scaffold round trip, config_paths ordering, verifier mode inference and the separate-mode warning, provider image policy (prefix rewrites and longest-prefix auth), setup commands run as root with a failure failing the create and never retried, and a cancelled create cleaning up its sandbox.

Rollouts

N/A for model compute: the sandbox spec a task produces is unchanged when no [gym] table and no provider image policy are configured, which the server tests assert. The TB4 parity rerun with this branch applied (2026-10-01, before the 2026-10-04 rebase) is reported in #3754: 66 tasks on both paths, 55 identical, 10 flips traced to sampling, one infrastructure row. The parity audits (TB4 and TB2.1) found the config_paths ordering and Terminus 2 outcome defects fixed here.

TB4 does not run overlay-free on this branch. The TB4 README documents what a run still supplies: the poll-cadence overlay from #3754, Compose networking and the shared-memory label in the sandbox and sandbox_gpu provider blocks, images.rewrites pointing the three non-root images at derived images for gym dataset validate only, and, for a like-for-like comparison with the old server, a hand-written dataset.toml override setting CIRCLE_NODE_TOTAL=3 for nextjs-performance. Model runs use the upstream images.

Compatibility and benchmark impact

Configuration: the eight removed harbor server fields are rejected at config load (the config forbids extra fields). Their replacements are dataset.toml [gym] for per-task environment and multipliers, and the provider's images and setup blocks for mirrors, credentials, setup commands and deployment-wide environment. derive_cpu_env has no replacement: like Docker and Harbor, the sandbox gets exactly the task's [environment].env. Verifier mode selection is unchanged against M13. A separate-mode task without artifacts now logs a warning. Benchmark results: none when the same values are supplied through the new homes.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ffrujeri

ffrujeri commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Could you help me understand how changes to dataset.toml participate in task identity? _ng_digest appears to cover the task folder, while this PR applies the adjacent [gym] configuration in load_task(), including resource and timeout changes. If dataset.toml changes after materialization, could the resources server load different effective task settings while the row digest still matches?

Is that intentional, or should the effective [gym] configuration also be pinned or included in the digest so that such a change requires rematerialization?

Comment thread nemo_gym/tasks/harbor/task.py Resolved
Comment thread nemo_gym/tasks/harbor/dataset_config.py Resolved
Comment thread nemo_gym/cli/main.py Resolved
Comment thread nemo_gym/tasks/harbor/models.py Resolved
Comment thread environment_servers/harbor/app.py Resolved
@adil-a
adil-a force-pushed the adasif/harbor-m15-config-homes branch from e7b56d3 to 2d6537b Compare October 9, 2026 20:08
@adil-a
adil-a force-pushed the adasif/harbor-m15-config-homes branch from 2d6537b to bf7c74f Compare October 9, 2026 20:20

@yuhezhang-ai yuhezhang-ai 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.

Could we address the setup-error classification and the accepted override aliases? I also left two nonblocking suggestions for malformed override diagnostics and the deployment-wide setup example. The correctness findings were reproduced on this head with controlled local tests; no live sandbox or model rollout was run.

Comment thread nemo_gym/tasks/harbor/dataset_config.py Resolved
Comment thread nemo_gym/tasks/harbor/dataset_config.py Resolved
@adil-a
adil-a force-pushed the adasif/harbor-m15-config-homes branch from 8e9a871 to 2f413e5 Compare October 19, 2026 21:27
@adil-a

adil-a commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 2f413e5

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0eb423a

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 8dc08eb

Comment thread nemo_gym/cli/main.py Resolved
@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 6d6aaa3

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 145e126

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Status at the new head 145e126.

Felipe, on dataset.toml and identity, from the code at this head: a row's _ng_digest is task_digest(folder_digest, dataset, task_id) in nemo_gym/tasks/harbor/task.py. The folder digest is content_hash over the task folder, and whenever dataset.toml has any [gym] content the digest also folds in the applied slice, [gym.defaults] and the task's own [gym.tasks] entry, serialised as JSON. A dataset without a [gym] table keeps the plain folder hash, which is what the package store publishes and checks. So a [gym] edit after materialization does change identity: a resumed gym eval run or gym dataset validate compares the cached rows' digests with the freshly prepared ones before dispatch and refuses with "changed digest" (test_eval_run_resume_refuses_a_changed_selection_or_digest), the server refuses a row whose digest is not the one in its taskset mapping with a 422, and at seed it copies dataset.toml beside the task snapshot, reloads the task and refuses a digest that no longer matches with a 409 (test_dataset_toml_edit_after_materialization_is_refused). Since #4664 the manifest records the plain folder digests separately (HarborTask.folder_digest), so a settings edit changes the dataset digest once through dataset_toml_digest instead of reading as a task file edit, and every row also carries _ng_dataset_digest.

Yu He, the 9 Oct and 15 Oct items are answered inline: OpenSandboxSetupError subclasses OpenSandboxCreateError, the deprecated memory, storage and allow_internet spellings are normalised before the merge (there is no legacy image key to map), malformed env overrides are HarborTaskErrors naming the file and table, the setup example no-ops without apt-get, the scaffold writes names Harbor 0.22.0 accepts with the harbor add, remove and sync caveat documented, the duplicate test definitions are gone, and the next-step commands are shell-quoted.

@yuhezhang-ai

yuhezhang-ai commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Thanks, Adil—I rechecked the latest M15 against its immediate parent, and the earlier findings are addressed. One small nonblocking follow-up: could the compatibility test guard harbor.models.dataset.manifest directly? When collected alongside Gym’s Harbor server tests, importorskip("harbor") finds Gym’s own package, then the external-library import fails.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 18b3498

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7123266

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test d4791ca

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. The importorskip("harbor") guards live in responses_api_agents/harbor_agent/tests/test_app.py on main, which this stack does not touch, so guarding harbor.models.dataset.manifest directly is a small separate fix to that suite rather than a change in M15. I will take it after the stack lands so that it does not get mixed into these diffs.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f327379

yuhezhang-ai
yuhezhang-ai previously approved these changes Oct 21, 2026

@yuhezhang-ai yuhezhang-ai 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.

Thanks for addressing the review findings. Approved; the remaining optional-library test guard can be handled as a nonblocking follow-up.

To clarify the location: my comment concerns tests/unit_tests/test_harbor_scaffold.py:110–112, which M15 adds. I should have named the file originally. The responses_api_agents/harbor_agent/tests/test_app.py mentioned in your reply is a different suite.

Collecting this scaffold test alongside environment_servers/harbor/tests/test_app.py makes pytest.importorskip("harbor") find Gym’s local package, then the external-model import fails with No module named 'harbor.models'. Guarding harbor.models.dataset.manifest and harbor.models.task.config directly would preserve the intended skip. This remains nonblocking and can be handled after the stack lands; my approval stands.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the pointer, and sorry for sending you to the wrong suite. The guard you mean is the one M15 adds in tests/unit_tests/test_harbor_scaffold.py, where importorskip("harbor") resolves to Gym's own harbor package when the scaffold test is collected next to the environment server tests, so the external import then fails instead of skipping. I will guard harbor.models.dataset.manifest and harbor.models.task.config directly in the next fixup round of M15, together with Yu's reopened threads, so the test skips cleanly without the external library and still checks Harbor's serializer when it is installed.

ffrujeri
ffrujeri previously approved these changes Oct 21, 2026

@ffrujeri ffrujeri 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.

Approving f3273796. Dataset settings moving into dataset.toml [gym] and deployment settings onto the sandbox provider looks right, and so does the config_paths ordering fix. images.auth only reaches the SDK image spec, and no log line prints it. Harbor, scaffold, OpenSandbox provider, sandbox, Compose and transfer suites pass locally (526 passed, 14 skipped). The 5 local failures are the 127.0.1.1 hostname tests flagged on #3746 and the optional-harbor scaffold guard Yu already noted. CI unit and server suites are green. One question inline.

Comment thread environment_servers/harbor/sandboxes.py Resolved
@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test befad33

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0871bfa

…ataset init (M15)

The harbor environment server runs every Harbor-shaped dataset, so its config is the one place a
dataset-specific setting must never land. The per-task and operator environment, setup commands,
thread-count derivation, image rewrites with their credentials and the Compose metadata path are
gone from it; a test pins the config to its deployment fields and rejects dataset names in it.

What a dataset needs on top of its tasks now lives beside them, as data, in the `[gym]` table of
Harbor's `dataset.toml`: `[gym.defaults]` with `timeout_multiplier` and `resource_multiplier`, and
`[gym.tasks."<id>"]` overrides written with Harbor's own `[environment]` fields (env merges, other
fields replace). The loader applies them, so servers, agents and rows see the effective task.toml
and the task digest still pins the folder alone. The server's task snapshot carries `dataset.toml`
beside the task, so the sandboxes it creates see the same effective task as the rows and the
oracle. Image mirrors, registry credentials and root setup commands move to the OpenSandbox
provider block (`images`, `setup`), where they describe a deployment. `compose-images.json` is
read where `gym dataset fetch` writes it.

`gym dataset init <name>` scaffolds a dataset in this shape, and the harbor README documents the
four configuration homes. `benchmarks/harbor/terminal_bench_4/README.md` shows the per-task
`CIRCLE_NODE_TOTAL` override as a dataset.toml entry.

Squashed from the previous branch and re-applied onto the environment server.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0020c35

@ffrujeri ffrujeri 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.

Approving 0020c35a. This answers my cpu_cap_env question: the CPU-count hints are back for the agent sandbox, the Compose main service and the separate verifier (sized by its own cpus), and the task's own env wins on a clash. The setup.commands fallback to the image's user on a no-root cell mirrors exec_as_root, and a command that still fails continues to fail the create.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/39686559302

This branch was previously deployed

1 inactive deployment
public — 0020c35a Deployed Oct 21, 2026 by copy-pr-bot[bot] via release / finalize / notify #6426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:config Hydra configuration, schemas, composition, and compatibility complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer QA_verified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants