Repository navigation
feat(harbor): environment server and loader generalization (M27) - #4663
Conversation
|
/ok to test 8426282 |
8426282 to
f0cb73a
Compare
|
/ok to test f0cb73a |
f0cb73a to
dba7440
Compare
|
/ok to test dba7440 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Reviewed dba74403 against the immediate stack parent #4689 (b8c94f17). The ownership split makes sense: Gym owns setup, grading and cleanup, and the agent borrows the sandbox. The inline comments cover five concrete issues affecting grading, task discovery or credential handling.
Representative end-to-end validation can proceed in parallel with these fixes; a P2 here is not a blanket reason to stop validation. Runs that exercise an affected path need its issue resolved before their results support an acceptance claim. Relevant tests and focused reproductions were run, but this review did not include a real-model, live-container rollout.
Nonblocking suggestions:
nemo_gym/tasks/harbor/task.py:383-397: Please pass the dataset root through the two build-required error helpers. Fords/group/task, they still nameds/group/built-images.json, although the new root-aware loader readsds/built-images.json.environment_servers/harbor/tests/test_app.py::test_seed_time_is_not_charged_against_the_task_deadline: Please avoid a 0.2-second real deadline around the full post-seed path, including filesystem work. The test failed under load and passed on focused idle reruns. A controlled clock or narrower fake verification step would preserve the invariant without depending on runner load.nemo_gym/rollout_collection.py::_episode_record: Please preservefailure.failure_kindalongside the newstep. Harbor now emitsharbor:task_deadline, but this conversion drops the kind before the failures sidecar and metrics consume it. Add an assertion through the response-to-record path.- Secret-template tests in
environment_servers/harbor/tests/test_app.py: Please cover a same-named value present in bothos.environand configuredsecrets, asserting the configured secret wins. The implementation is correct today, but reversing this precedence survived the focused mutation check.
dba7440 to
dda3d6d
Compare
|
/ok to test dda3d6d |
dda3d6d to
96cbc4a
Compare
c25e003 to
208b086
Compare
|
/ok to test 208b086 |
|
/ok to test 10c3ff7 |
|
/ok to test c4cc0a9 |
|
/ok to test e25da83 |
|
/ok to test 4a567f0 |
|
/ok to test 33f3c35 |
|
/ok to test 6010e95 |
|
/ok to test c912a37 |
|
/ok to test 041848a |
|
/ok to test 0fea08e |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — two BLOCKER grading defects, one RISK in override validation, and one NOTE about the generated image list.
Reviewed all 33 changed files and traced the affected sandbox, transfer, loader, and collector contracts. Current source addresses the earlier refusal-export, reserved-trajectory cleanup, collect-hook budget, and secret-map redaction failures; newly created fetch staging directories are hidden.
Validation was static source and regression-test inspection only. I could not execute tests or perform a live-model/container rollout. The inline findings include proposed acceptance checks; suggested code must be verified before adoption.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Inline comments (escaped v1):
-
environment_servers/harbor/sandboxes.pyline 432: BLOCKER — Restore the overlay workdir when running the forced-separate verifierFailure / blast radius: For a shared task forced into separate mode, use
FROM ubuntu:24.04\nWORKDIR /app\nRUN true, declareartifacts = ["/app/result.txt"], and have the package's test check relativeresult.txt. Creation correctly leaves the workdir unset so the overlay can create it, but applying the overlay never updates the sandbox spec. The separate verifier exec also supplies nocwd. Consequently, AsyncSandbox runs the test in the base image's directory (/here), not/app, silently scoring a correct artifact as missing.Correction: Keep this creation-time
None; setting it to/appwould reintroduce the root-owned WORKDIR bug. In_run_separate_verifier, add this argument to the finalverifier.exec:cwd=task.workdir if _verifier_gets_overlay(task, True) else None,
The invariant is that overlay creation remains deferred, while grading uses the task's resolved runtime workdir. Declared separate verifiers in their own images must continue using their own spec/image workdir, not the agent's.
Acceptance (proposed, not run): Extend the forced-overlay regression through verification: assert creation receives
workdir=None, a non-root overlay RUN still succeeds in its owned directory, andtest -f result.txtgrades the restored/app/result.txtas reward 1 without masking. Retain the non-overlay/home/node/appspec assertion and verify that an explicit verifier image with workdir/gradestill grades in/grade. -
environment_servers/harbor/verifier.pyline 893: BLOCKER — Make the generated sandbox trajectory readable by the verifier userFailure / blast radius: With server umask
077and a non-root[verifier].user,write_bytescreates the new trajectory as0600. upload_path preserves that mode and extracts as root. Thus/logs/agent/trajectory.jsonis root-owned0600, and a legitimate non-root grader cannot read the transcript this PR promises it. A test that catches the read failure and writes reward 0 silently misgrades the episode. This affects both verifier modes; current filesystem tests run their shell without enforcing the requested user.Correction: Preserve the host copy's umask and the package tests' original permissions, but explicitly make this generated sandbox file readable. After
await upload_path(sandbox, host, target), a narrowly scoped suggested addition is:readable = await exec_as_root( sandbox, f"chmod a+r -- {target}", timeout_s=60 ) if readable.return_code != 0: raise RuntimeError( f"Could not make {target} readable: {readable.stderr or readable.stdout}" )
targetis the fixed reserved path here. Do not widen the entire tests/log tree. Keep the existing unlink-before-upload ordering for planted links and directories.Acceptance (proposed, not run): Under umask
077, grade as a non-root user with a trusted test that reads and parses the trajectory; expect valid ATIF and reward 1, unmasked, in shared and separate modes. Assert the host copy remains0600while the sandbox copy is readable by that user. Retain the package-permission assertions, and retain the planted-entry cases' successful grading and preservation of other agent logs. -
nemo_gym/tasks/harbor/dataset_config.pyline 152: RISK — Validate verifier env overrides before callingdict()Failure / blast radius: A dataset containing
[gym.tasks."bad".verifier]\nenv = 1passes the outerdict[str, Any]override model, then raisesTypeErroratdict(value). The base-image scan catchesValueError, notTypeError, so one malformed override aborts preparation of every otherwise valid task instead of producing the normal named, per-task load error. The existing environment override helper already validates this contract before merging.Correction: Insert this guard before constructing
mergedin_override_verifier:if "env" in override: env = override["env"] if not isinstance(env, dict) or not all(isinstance(v, str) for v in env.values()): raise ValueError( f'[gym.tasks."{task_id}".verifier].env must be a table of strings' )
This keeps invalid dataset data in the loader's handled
ValueErrorpath while retaining key-wise merging for valid env tables.Acceptance (proposed, not run): Prepare a dataset with
goodandbadtasks and the override above. Expect onlygoodin the prepared tasks,badinskippedwithverifier].env must be a table of strings, and no uncaught exception. Directload_task(bad)should raiseHarborTaskError. Retain the existing merge regression:MODEbecomesstrict,KEEPstays1, and nested verifier-environment env tables retain bothAandB. -
nemo_gym/tasks/harbor/cli.pyline 216: NOTE — Use the dataset root for the generated pre-pull image list tooThe record is now correctly written at
dataset_root, but the later image-list calculation still readstasks[0].path.parent. If the first selected task is nested, it reads the group directory rather than the root record. run_images then emits a sidecar's mutable tag instead of the recorded digest actually used at runtime. Operators pre-pulling fromimages.jsoncache the wrong reference.Correction: Replace that calculation with:
distinct = run_images(tasks, read_image_configs(dataset_root))
This preserves existing flat-dataset and single-task behavior because
dataset_rootalready resolves to their record directory.Acceptance (proposed, not run): Extend the nested Compose preparation test so the fake registry records
redis:7-alpineas a distinctredis@sha256:<digest>reference. Assert bothprepared.imagesandimages.jsoncontain that digest, not the tag. Repeat with a flat task and a single-task target; both should retain the same pinned reference.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
|
/ok to test e7ef699 |
ffrujeri
left a comment
There was a problem hiding this comment.
Thanks for the thorough follow-through on yuhezhang-ai's findings; they look fixed at e7ef699, with tests. The latest push looks like a rebase onto the new M24 head, so the four findings from the codex review on 0fea08e still seem to apply: the forced-separate overlay cwd, trajectory readability under a strict umask, the unvalidated verifier.env override, and the images.json record folder. I left questions inline; could you take a look or say why they're fine? Required CI is green; only the non-blocking kilocode conformance probe fails.
nemo_gym/tasks/harbor/cli.py (around line 244): Could images.json list a sidecar's mutable tag instead of its pinned digest when the first selected task is nested (ds/group/task)? It looks like the images are now recorded at dataset_root, but this still reads read_image_configs(tasks[0].path.parent). Would read_image_configs(dataset_root) be the intended source, with the nested Compose prepare test asserting the digest in images.json?
|
/ok to test 6fc7bff |
|
/ok to test bd43b5f |
Generalizes the harbor environment server and the loader beyond the two
Terminal Bench datasets, per the M27 row of the gym-harbor-tasks RFC.
Shipped:
- Operator `secrets` on the server config reach the test.sh process only:
they fill `${NAME}` templates in `[verifier].env` and are exported into
that process; sandbox creation and the agent turn never see them.
- ATIF v1.7 `trajectory.json` written to /logs/agent before every verify
(shared and separate mode), exported from the Gym transcript by the new
`nemo_gym.atif_export.transcript_to_atif`; a failed export masks the
turn (`harbor:trajectory_export_failed`); Terminus user turns become the
previous step's observation (exporter extension).
- In-server image pull retries (`image_pull_retries`, jittered backoff,
per-server gate) before a retryable seed failure.
- Recursive dataset discovery: task folders may sit in subfolders;
dataset.toml and recorded image configs are read from the dataset root;
the taskset mapping records nested tasks under `paths`, which the server
and the oracle agent resolve.
- `gym dataset validate` reports verify time (`verify_s`) and the network
the verifier ran under (`network`) per task; results carry
`verifier_network`.
- `SandboxAccess.user` filled from the task's `[agent].user`.
- A slow agent-session close that fails only by timeout no longer
discards the finished turn; it is verified with observations unset.
- Per-task episode deadline enforced by default (`enforce_task_timeouts`,
`harness_setup_allowance_s`); the sandbox lifetime follows the task
budget; overruns fail with `harbor:task_deadline`.
- `EpisodeFailure.step`, forwarded by the collector as `_ng_failure_step`.
- `[gym.tasks."<id>"]` gains `verifier` overrides and `artifacts`
additions, applied by the loader like the `environment` overrides.
- `separate_verifier_for_artifacts` forces separate mode for tasks that
declare artifacts.
- The task's `[agent].timeout_sec` travels in the agent-session seed as
`agent_timeout_sec` (the row metadata stays until harnesses read it).
Already on the branch and left as is: taskset mapping with per-task
digests, strict rejection of Windows and TPU tasks, tool grants as the
`tool_accesses` list, the reward.txt fallback, mask_sample on Gym-side
failures and the reward.json rule.
Review fixes (Devil's Advocate on this commit): the ATIF live profile
exports model-caused shapes as partial trajectories instead of masking
them (a reasoning item no answer follows becomes an agent step with an
empty message and extra.nemo_gym.incomplete = max_output_tokens; several
reasoning segments join with newlines; empty or encrypted reasoning and
non-object tool arguments export with a note under extra.nemo_gym), and
still raises for what ATIF cannot represent; test.sh receives only the
`[verifier].env` the task resolves, never the whole secrets block; the
per-task deadline starts when the sandbox is ready, so image pull
retries are not charged against it (`_post_seed_budget_s`; the sandbox
TTL keeps the full budget); Compose groups and separate verifier
sandboxes get the same in-server pull retries (`_start_with_pull_retries`);
prepare records compose-images.json at the dataset root for nested
tasks; and duplicate task IDs are rejected by the folder walk itself,
before base-image recording and Dockerfile builds; the pull-failure check
walks exception groups (a Compose group whose cleanup failed too) and
the separate verifier's retry path has committed tests.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
|
/ok to test 78e630e |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Approving #4663 for the combined Harbor stack, including the working-directory fix in #4819.
Rechecked 78e630e1 against its current M24 parent (9fd2b1ae). The earlier runtime fixes remain intact. The transcript-permission and malformed verifier-env fixes check out. The original forced-separate working-directory case is fixed here; I also verified the additional directory-creation fix in #4819 at 7310fc25, so I count that as addressed for the combined stack.
One nonblocking follow-up remains: when the first selected task is nested, images.json still lists the sidecar's mutable tag instead of its recorded digest. I reproduced this here and at #4819, with flat-dataset and single-task controls passing. Please use read_image_configs(dataset_root) in the image-list calculation in nemo_gym/tasks/harbor/cli.py and cover the emitted list with a registry fixture that returns a distinct pinned digest.
Validation: 94 focused regression tests passed on this PR, with 12 optional checks skipped; six downstream checks passed. Separate preparation probes confirmed that malformed overrides skip only the bad task and that the image-list issue remains. Core/server CI, lint, docs and DCO pass; the nonblocking Kilocode conformance failure also occurs on the parent. This recheck did not include a live-model/container rollout.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40368871525 |
Generalizes the harbor environment server and the loader beyond the two
Terminal Bench datasets, per the M27 row of the gym-harbor-tasks RFC.
Shipped:
secretson the server config reach the test.sh process only:they fill
${NAME}templates in[verifier].envand are exported intothat process; sandbox creation and the agent turn never see them.
trajectory.jsonwritten to /logs/agent before every verify(shared and separate mode), exported from the Gym transcript by the new
nemo_gym.atif_export.transcript_to_atif; a failed export masks theturn (
harbor:trajectory_export_failed); Terminus user turns become theprevious step's observation (exporter extension).
image_pull_retries, jittered backoff,per-server gate) before a retryable seed failure.
dataset.toml and recorded image configs are read from the dataset root;
the taskset mapping records nested tasks under
paths, which the serverand the oracle agent resolve.
gym dataset validatereports verify time (verify_s) and the networkthe verifier ran under (
network) per task; results carryverifier_network.SandboxAccess.userfilled from the task's[agent].user.discards the finished turn; it is verified with observations unset.
enforce_task_timeouts,harness_setup_allowance_s); the sandbox lifetime follows the taskbudget; overruns fail with
harbor:task_deadline.EpisodeFailure.step, forwarded by the collector as_ng_failure_step.[gym.tasks."<id>"]gainsverifieroverrides andartifactsadditions, applied by the loader like the
environmentoverrides.separate_verifier_for_artifactsforces separate mode for tasks thatdeclare artifacts.
[agent].timeout_sectravels in the agent-session seed asagent_timeout_sec(the row metadata stays until harnesses read it).Already on the branch and left as is: taskset mapping with per-task
digests, strict rejection of Windows and TPU tasks, tool grants as the
tool_accesseslist, the reward.txt fallback, mask_sample on Gym-sidefailures and the reward.json rule.
Review fixes (Devil's Advocate on this commit): the ATIF live profile
exports model-caused shapes as partial trajectories instead of masking
them (a reasoning item no answer follows becomes an agent step with an
empty message and extra.nemo_gym.incomplete = max_output_tokens; several
reasoning segments join with newlines; empty or encrypted reasoning and
non-object tool arguments export with a note under extra.nemo_gym), and
still raises for what ATIF cannot represent; test.sh receives only the
[verifier].envthe task resolves, never the whole secrets block; theper-task deadline starts when the sandbox is ready, so image pull
retries are not charged against it (
_post_seed_budget_s; the sandboxTTL keeps the full budget); Compose groups and separate verifier
sandboxes get the same in-server pull retries (
_start_with_pull_retries);prepare records compose-images.json at the dataset root for nested
tasks; and duplicate task IDs are rejected by the folder walk itself,
before base-image recording and Dockerfile builds; the pull-failure check
walks exception groups (a Compose group whose cleanup failed too) and
the separate verifier's retry path has committed tests.
🤖 Generated with Claude Code