Skip to content

feat(harbor): Compose template variables and env_file (RFC M19) - #4565

Merged
adil-a merged 1 commit into
adasif/harbor-m17-comparefrom
adasif/harbor-m19-compose-vars
Oct 21, 2026
Merged

adil-a merged 1 commit into
adasif/harbor-m17-comparefrom
adasif/harbor-m19-compose-vars

Conversation

@adil-a

@adil-a adil-a commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

RFC milestone M19. Prepare resolves Harbor's Compose interpolation from the task alone and the resources server reads the same resolved document at seed.

  • Variables: MAIN_IMAGE_NAME, CONTEXT_DIR, PREBUILT_IMAGE_NAME, CPUS, MEMORY, and the HOST_*_PATH / ENV_*_PATH log mounts as the /logs tree, with [environment].env as the task's own variables (their values interpolated first, as hil-bench relies on). The process environment is never consulted.
  • Every Compose interpolation form, nested defaults included. An unresolved variable or any residual $NAME fails prepare with its name.
  • env_file entries are read after interpolation, confined to the task's environment/ folder, inlined under environment with the service's own entries winning. Values are literal with Compose quoting and inline comments. Errors never echo file contents.
  • Every service's environment becomes a mapping of strings.

Checked against the hub task scale-ai/hil-bench-swe-ask-human (${CONTEXT_DIR}, ${MAIN_IMAGE_NAME}, defaulted task env values). Reviewed in two DA plus verify rounds, 5 findings fixed.

Test plan

  • tests/unit_tests/test_compose_config.py, tests/unit_tests/test_harbor_image_configs.py, resources_servers/harbor/tests/test_app.py (new cases for interpolation, env_file confinement, residual check, server seed path).
  • pre-commit run --files on the touched files.

Added 16 Oct 2026

Compose variables resolve in Harbor's order: Gym's infrastructure set (CONTEXT_DIR, TEST_DIR, COMPOSE_PROJECT_NAME), the task's [environment].env, the .env file, the process environment, the default in the expression, then an empty string with one warning. ${VAR:?msg} is a per-task refusal naming the task. 957 sampled hub tasks in 14 datasets were refused at prepare before this. The residual-interpolation check reports the key path, not the value, so a host secret is never echoed.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 13, 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.

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

Reviewed M19 at 07250b2f against its direct M17 base (ee485666, #4257).

Sharing one resolver between preparation and startup makes the behavior easier to reason about. I reproduced five issues in the new interpolation/env_file path and recommend addressing those before merging; the two P3 comments are nonblocking suggestions.

The existing short-form/remote-bind mount limitations and raw task-template propagation to the main container are inherited stack dependencies. I have kept them separate from the M19 findings; the new seed test mocks container creation and does not establish real startup compatibility. Integration should be rechecked after the lower-stack fixes land.

The focused Compose, image-config, and Harbor server tests passed, as did Ruff lint and formatting. The findings use focused CPU reproductions, including adapter preparation and M17 comparisons where applicable. No live sandbox or model rollout was run.

Comment thread nemo_gym/sandbox/compose_config.py Resolved
Comment thread nemo_gym/tasks/harbor/image_configs.py Resolved
Comment thread nemo_gym/sandbox/compose_config.py Resolved
Comment thread nemo_gym/sandbox/compose_config.py Resolved
Comment thread nemo_gym/sandbox/compose_config.py Resolved
Comment thread nemo_gym/sandbox/compose_config.py Resolved
Comment thread nemo_gym/sandbox/compose_config.py Resolved
@adil-a
adil-a removed this pull request from stack #3808 October 14, 2026 00:54
@adil-a
adil-a added this pull request to stack #4583 October 14, 2026 00:55
@adil-a
adil-a force-pushed the adasif/harbor-m19-compose-vars branch from 07250b2 to 0856425 Compare October 14, 2026 01:07
@adil-a
adil-a force-pushed the adasif/harbor-m19-compose-vars branch from 0856425 to ea9799b Compare October 14, 2026 01:33
@adil-a
adil-a force-pushed the adasif/harbor-m19-compose-vars branch 2 times, most recently from 479133f to f9cc51d Compare October 14, 2026 15:01
@adil-a
adil-a force-pushed the adasif/harbor-m19-compose-vars branch from f9cc51d to a181d10 Compare October 14, 2026 16:29
@adil-a
adil-a marked this pull request as ready for review October 14, 2026 16:49
@adil-a
adil-a force-pushed the adasif/harbor-m19-compose-vars branch from a181d10 to 3cef03d Compare October 14, 2026 17:00
@adil-a

adil-a commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 3cef03d

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 14, 2026 17:02
@yaoyu-33 yaoyu-33 added area:sandbox Sandbox providers, isolation, and sandbox runtime contracts complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 14, 2026
@adil-a

adil-a commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test bae9c23

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 56d1674

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 28e9cbb

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7c6ff07

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 2342cf6

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Status at the new head 2342cf6. All seven threads from the 13 Oct review are answered inline and you resolved them: healthcheck field types restored after interpolation, literal task environment values preserved (only a whole-value ${VAR} template resolves, as Harbor does), an unset service entry removes the env_file value, quoted env_file values keep escaped quotes, backslashes and newlines, an env_file the digest would skip is refused by name, parse errors name the service, file and line, and format: raw is refused. Nothing changed here in the rebase beyond what the parents moved.

yuhezhang-ai
yuhezhang-ai previously approved these changes Oct 20, 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.

All seven review findings are addressed. The README correction is included in #4566; the remaining PR-description wording is nonblocking.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4b0f8c4

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c66b753

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a757b19

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c0a7102

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 c0a7102e. The interpolation engine covers Compose's operators and nesting. env_file is confined to environment/ (no absolute paths, climbing out, or symlinks), and its errors name the line number without echoing content. Compose-variable, image-config, Compose and Harbor suites pass locally (271 passed), and CI is green apart from the non-blocking conformance probes. One non-blocking note inline.

Comment thread environment_servers/harbor/README.md Resolved
@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dd37ee6

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c093656

Compose files in Harbor tasks use `${MAIN_IMAGE_NAME}`, `${CONTEXT_DIR}` and `${VAR:-default}`
templates and `env_file` entries. Preparing the dataset and the environment server now read the
Compose file through one resolver: `env_file` is inlined into `environment`, and variables
resolve from the task alone (the main image recorded for the task, the task's `environment/`
folder, the task's own defaults), never from the server's process environment. The server
resolves against its task snapshot, so bind mounts point into that copy.

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 b783696

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

Re-approving b783696c after the restack. The patch only changed through import context. The README trust note about os.environ now lives in #4566.

@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/39688519209

This branch was previously deployed

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

Labels

area:sandbox Sandbox providers, isolation, and sandbox runtime contracts complexity:medium Single-domain change with interacting parts or a moderate 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.

5 participants