Skip to content

feat(harbor): overlay image mode, Dockerfiles with FROM plus RUN run at seed without a build (M16) - #4256

Merged
adil-a merged 1 commit into
adasif/harbor-m15-config-homesfrom
adasif/harbor-m16-overlay
Oct 21, 2026
Merged

adil-a merged 1 commit into
adasif/harbor-m15-config-homesfrom
adasif/harbor-m16-overlay

Conversation

@adil-a

@adil-a adil-a commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

RFC M16, overlay image mode. A Harbor task whose environment/Dockerfile is a pullable FROM plus RUN, WORKDIR, ENV, USER and an empty ENTRYPOINT runs without a build and without a registry: the server pulls the base image and runs the RUN lines inside the sandbox at seed, before the healthcheck and the agent. This is the slice of Dockerfile support that SWE-bench Verified and SWE-bench Pro need; COPY, ADD, multi-stage and heredoc Dockerfiles are still rejected with the instruction named and wait for M20.

  • nemo_gym/tasks/harbor/dockerfile.py: parse_dockerfile and resolve_dockerfile. ENV, WORKDIR and USER are resolved at prepare exactly as docker build resolves them, starting from the base image's recorded OCI config (Env, WorkingDir, User). Every pair of an ENV line expands against the environment before the line; double-quoted and unquoted values expand, single-quoted stay literal, \$ is a literal dollar, ${X:-${Y}} nests. The task's env, workdir and user are literal before any sandbox exists.
  • nemo_gym/tasks/harbor/image_configs.py: records Env and the base image of every Dockerfile task at prepare, only for the tasks the run selects and whose effective docker_image (after the dataset.toml override) is unset. A base image whose config cannot be fetched fails prepare naming the image; no default PATH is guessed.
  • resources_servers/harbor/app.py: _apply_overlay runs each RUN with its resolved env (exported with shlex.quote), workdir (created as root once per directory and chowned to the step's user) and user (numeric USER resolved with getent). Root steps use the base image's User as the sandbox default (HarborTask.sandbox_user). A RUN that exits non-zero or exhausts build_timeout_sec is a terminal 422 with the command and output tail; a provider failure is a 503; an overlay failure while preparing a separate verifier masks the sample instead of discarding the rollout. Sandbox TTLs include build_timeout_sec.
  • Continuation lines are joined as Docker joins them (backslash and newline removed, nothing inserted). Heredoc detection only rejects real heredocs.

Known gap, for M20: SandboxSpec has no user field, so a Dockerfile's final USER applies to the overlay RUN lines but not to later execs that pass no user.

Testing

261 tests pass across tests/unit_tests/test_harbor_tasks.py, tests/unit_tests/test_harbor_image_configs.py and resources_servers/harbor/tests/test_app.py: classifier and resolver cases (SWE-bench Verified and TB2.1 Debian shapes, chained PATH, quoting, modifiers, 17 rejections each naming the instruction), loader cases, and server cases with a container-like fake sandbox that applies the spec env and per-exec user (Docker-order env per step, WORKDIR after USER, numeric USER, root steps on a jovyan image, 422 versus 503, masked verifier overlay, TTLs, output tail). Two review rounds with refutation and reproduction, 49 findings, all fixed. No model rollout yet; the first real run is the SWE-bench Pro reference run (M23).

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 8, 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 M16 at 4e9672df against its M15 stack base (#3807, bf7c74f2). The overlay approach is useful, but I’m requesting changes for six correctness issues around runtime-image metadata, WORKDIR creation, legacy records, shell behavior, and user/group identity. The inline comments include concrete triggers and suggested corrections; four smaller comments are nonblocking suggestions.

The focused tests pass, but targeted fixtures and shell reproductions expose the cases described below. No live provider/model rollout was run, so integration validation remains outstanding. Inherited final-USER and separate-verifier working-directory limitations are not counted as new M16 findings, and this review does not assume the ongoing M1–M3 fixes are present.

Comment thread nemo_gym/tasks/harbor/task.py Resolved
Comment thread environment_servers/harbor/app.py Resolved
Comment thread nemo_gym/tasks/harbor/image_configs.py Resolved
Comment thread nemo_gym/tasks/harbor/task.py Resolved
Comment thread nemo_gym/tasks/harbor/image_configs.py Resolved
Comment thread environment_servers/harbor/app.py Resolved
Comment thread nemo_gym/tasks/harbor/task.py Resolved
Comment thread nemo_gym/tasks/harbor/task.py Resolved
Comment thread environment_servers/harbor/README.md Resolved
Comment thread tests/unit_tests/test_harbor_tasks.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-m16-overlay branch from 4e9672d to 7917f36 Compare October 14, 2026 01:07
@adil-a
adil-a force-pushed the adasif/harbor-m16-overlay branch from 7917f36 to e1ee143 Compare October 14, 2026 01:33
@adil-a
adil-a force-pushed the adasif/harbor-m16-overlay branch from 235fe44 to 5ebea82 Compare October 14, 2026 15:02
@adil-a
adil-a force-pushed the adasif/harbor-m16-overlay branch from 5ebea82 to 157022e 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-m16-overlay branch from 157022e to 3dd2f3f Compare October 14, 2026 17:00
@adil-a

adil-a commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 3dd2f3f

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 14, 2026 17:02
@github-actions github-actions Bot added the sla:author-overdue Author response is over the one-business-day SLA label Oct 14, 2026
@adil-a
adil-a force-pushed the adasif/harbor-m16-overlay branch from 9ddb5a0 to 1fa41c6 Compare October 20, 2026 00:20
@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1fa41c6

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ebab4b8

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4befbfe

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b7ede71

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Status at the new head b7ede71. The six threads from your 19 Oct list and the three added that day are all answered inline: sandbox defaults come from the image that runs (a declared image takes the Dockerfile's final USER), WORKDIR instructions are created in order with the user in effect and the sandbox is created without the final workdir, pull and overlay tasks start the pinned reference the record was resolved at (the multi-arch index for a tag), the recorded Shell runs shell-form lines and exec form bypasses it, uid 0 with a group keeps the group on its workdir and runs as plain root since only Docker's --user takes user:group, and the README names harbor:overlay_failed against provider_unavailable. Legacy records re-resolve at their pinned digest (RECORD_VERSION), the prebuilt fallback is consistent across resolution errors, and shared image metadata is read once per discovery.

Of the three later ones, FROM flags and an escape directive now need a build, the literal Dockerfile ENV reaches the sandbox spec, and the [agent].user carry is in #4566 with the seed change in #4663, as the replies say.

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks, I verified the three additional findings across the stack, including the fixes in #4566 and #4663. Those are addressed.

Four earlier concerns still reproduce: declared-image workdir defaults, default-shell selection, the explicit group during overlay RUN, and verifier directory ownership when separate_verifier_for_artifacts is enabled. The last case is narrower now—the original separate-verifier path is gone, but the optional forced-separate path recreates the permission failure.

These four threads still need follow-up. The verified fixes in later PRs don’t need backports just to close the earlier findings.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dcd0045

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b5dea2f

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 07ff952

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

The four threads are addressed at head 07ff952 and each one carries the detail. A declared image takes its default user from the Dockerfile's final USER, with the FROM record supplying the user only when the Dockerfile has no USER line, overlay RUN lines run under the shell the image records and exec form lines run with no shell, a RUN line under a USER that names a group runs as that pair as written with the root exec path kept only for plain root, and the verifier directory ownership follows Harbor 0.22.0's verifier exactly as the transfer.py thread on #3754 explains, with no chown of the uploaded tree.

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks for the updates. Of the four findings we reopened, one is now fixed and three need further work. I verified the explicit-group fix in #4566 and left that thread resolved. I replied in and reopened the three remaining threads: working-directory defaults, default-shell selection, and forced-separate-verifier directory ownership.

The replies include the specific cases that still reproduce on the combined stack. Counting the later-stack fixes, that leaves 10 of our 13 findings addressed, with 3 remaining.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 6afdf58

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

Checked this PR's own head 6afdf58a. All three of Yu's open threads still apply here, not only on the #4664 tip:

  • nemo_gym/tasks/harbor/task.py:264 still has workdir = workdir or resolved.workdir, so the FROM image's / wins over the declared image's WORKDIR.
  • environment_servers/harbor/overlay.py overlay_shell_command still leaves default-shell lines for the provider's shell (Bash on Docker), not /bin/sh -c.
  • _create_verifier_sandbox still precreates the final workdir before the overlay replays.

Holding approval until those land. The rest of M16 can wait for that pass.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 97efdc1

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 513a3c8

…at seed without a build (M16)

The loader recognises a Dockerfile made of a pullable `FROM` plus `RUN`, `WORKDIR`, `ENV`, `USER`,
`LABEL` and an empty `ENTRYPOINT`/`CMD`. `ENV`, `WORKDIR` and `USER` resolve at prepare the way
`docker build` resolves them: the base image's OCI config (recorded into `compose-images.json` by
`record_base_images` before the tasks load) is the starting state, `$NAME` expands against the
accumulated environment, a relative `WORKDIR` joins the previous one, and each `RUN` line
snapshots the state in effect at its point. Nothing reaches the sandbox with a live `$`. A base
image the registry cannot resolve stops the preparation naming the image and the tasks.

The environment server runs the recorded lines right after the sandbox starts, before the
workdir, the healthcheck and the harness: as root unless a Dockerfile `USER` precedes the line
(root images keep the plain exec path; a numeric user is mapped to its name in the image), with
`ENV` exported and `WORKDIR` created and entered, all within `[environment].build_timeout_sec`.
A failing line stops the sandbox and fails the seed as a terminal failure carrying the command
and the tail of its output; a provider that cannot run a line is retryable. A separate verifier
that runs in the task's own image gets the same overlay, and an overlay failure there masks the
sample with `harbor:overlay_failed` instead of discarding the rollout. Agent user overrides
(`[agent].user`, Dockerfile `USER`) are no longer rejected.

Test hygiene: the prepare tests run under a fake registry (recording base images otherwise
fetches from Docker Hub), and the validation CLI fixture clears and restores the root logging
handlers.

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 e9cf170

@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 e9cf1703. All three of Yu's findings are addressed at this head:

  • Default-shell overlay lines now run through exec /bin/sh -c, so a line written for dash behaves as it did in the build. The dash test checks this.
  • A separate verifier for an overlay task starts without the workdir, so the overlay's WORKDIR step creates it for the user in effect (end-to-end test with USER node).
  • The FROM record's workdir stands in only when the task has no declared docker_image or the Dockerfile sets a WORKDIR.

@yuhezhang-ai, could you re-review to clear your change request?

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

Rechecked the three remaining findings at e9cf1703, including the M24 changes and their inclusion in the combined stack at 4d4bf21e. All are addressed: the declared image keeps its own working directory, the overlay verifier defers directory creation, and default-shell RUN steps explicitly invoke /bin/sh -c.

The 65 focused tests pass, and the previous failure reproductions now behave correctly. Validation used local provider fixtures and host-shell checks, not live containers. No remaining blocker from my review. Thanks for the fixes.

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

This branch was previously deployed

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

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work QA_verified waiting-on-customer Waiting on the original author to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants