Skip to content

fix(sandbox): support borrowed Enroot sandboxes and image digests - #6105

Merged
yaoyu-33 merged 3 commits into
NVIDIA-NeMo:mainfrom
yaoyu-33:codex/enroot-borrowed-task-sandboxes
Nov 16, 2026
Merged

yaoyu-33 merged 3 commits into
NVIDIA-NeMo:mainfrom
yaoyu-33:codex/enroot-borrowed-task-sandboxes

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Harbor environments create a task sandbox and lend it to an agent session. Enroot previously failed that handoff with does not support serialize()/connect(). Digest-pinned OCI references also failed to import on Enroot before 4.0, whose URI parser reads the text before @ as a registry user.

This adds same-host, same-UID serialize/connect support with matching data/runtime directories and live-container checks. The descriptor leaves out the sandbox environment, which may hold task secrets: enroot exec builds each command's environment from the init's /proc/<pid>/environ, so the borrower still sees it. Borrower disconnect leaves the creator's sandbox running. A borrowed handle signals the creator's process group only while its leader still carries the container marker, so a process-group ID reused after the creator stopped is never signalled. Image references ending in @sha256:<digest> are translated to repository:sha256:<digest>, which Enroot 3.1 and later accept; the original reference remains the squashfs cache key, and Enroot's own USER@ prefix is left alone. The descriptor is trusted control-plane state; it does not grant a portable lease or cross-host access. environment_servers/harbor/README.md no longer says Enroot cannot serialize.

This is a focused prerequisite found while exercising #5697 / #5794; a separate issue is unnecessary. The PR targets main and contains none of that stack's commits. #5792 also adds Enroot serialize/connect with the same env exclusion; whichever lands second drops its copy.

Validation (head 26e3956446, main 39d2bde61e merged in):

  • Linux, Python 3.13.14: pytest tests/unit_tests/sandbox/test_enroot_provider.py — 82 passed; pytest tests/unit_tests/sandbox/test_sandbox_connect.py — 7 passed. On macOS the Linux-only /proc test skips and the existing test_create_start_timeout_cleans_up fails for lack of /proc, as on main.
  • pre-commit run --files on the four changed files — passed.
  • Real Enroot 3.4.1, owner and borrower in separate processes, for alpine:3.20@sha256:d9e853e8… and docker.io/library/alpine@sha256:d9e853e8…: import → owner exec → serialize (no env key) → borrower connect → exec sees the env given at enroot start → upload inside and outside the mount → download → disconnect → owner exec reads the borrower's files → stop. enroot list is empty and the staging folder is gone afterwards; connecting after stop is refused as stale. These runs set bypass_entrypoint: false, because the existing --rc /dev/null default fails on Enroot 3.4.1 (fixed separately in fix(sandbox): support LAB harness sessions across sandbox providers #5792).
  • Real Enroot 3.4.1: the enroot start process-group leader's cmdline carries the container marker; a borrowed close after the owner's stop sends no signal; a borrower stop() on a live sandbox still tears it down and the owner's later stop succeeds.
  • A/B on Enroot 3.4.1: main's untranslated docker://alpine:3.20@sha256:… fails with "Authenticating with user: alpine:3.20 … 401 Unauthorized".
  • Earlier, at 0127f1c9f8 (descriptor still carried env), with Enroot 4.2.1: imported four original TB4 agent/verifier images pinned by digest; on Harbor stack 55f9d566b with the same provider patch, Claude Code 2.1.108 and OpenCode each completed bun-sourcemap-leak and wal-recovery-ordering with a real Qwen3-VL-8B-Instruct vLLM endpoint, separate verifier artifacts, no missing/masked/failed rollouts, and no remaining task rootfs. Rewards were zero; this validates the harness/provider path, not benchmark accuracy. Claude Code reached its turn limit on WAL and its output limit on Bun; OpenCode returned completed responses. Model-call capture was disabled.

Compatibility: reconnect requires the same host, PID namespace, OS user, data/runtime paths and staging directory. The owner remains responsible for stopping the sandbox; a borrower's stop() also tears it down, as with the other same-host providers. The smoke evidence covers functional handoff and cleanup; it is not full-benchmark qualification.

@yaoyu-33 yaoyu-33 added bug Something isn't working area:sandbox Sandbox providers, isolation, and sandbox runtime contracts needs-review PR is ready for code review and waiting on a reviewer complexity:medium Single-domain change with interacting parts or a moderate review surface labels Nov 13, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 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.

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 0127f1c

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 13, 2026 16:44

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM — no concerns found. I reviewed all three changed files and traced descriptor reconstruction, borrowed-sandbox cleanup, file transfers, and digest translation through their affected callers and tests.

The handoff implementation preserves the state needed by the borrower, and disconnect leaves teardown with the creator. Digest translation retains the original image reference as the cache key.

This was a static review; I didn't execute tests or independently reproduce the reported Enroot smoke runs. Two delegated review payloads were unavailable, so I independently inspected their descriptor and digest-translation topics.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@yaoyu-33 yaoyu-33 reopened this Nov 15, 2026
@yaoyu-33 yaoyu-33 reopened this Nov 15, 2026
yaoyu-33 and others added 2 commits November 15, 2026 10:48
The Enroot descriptor carried the sandbox env, which can hold task
secrets and travels to the agent server. `enroot exec` builds each
command's environment from the init's /proc/<pid>/environ, so the
borrower does not need it; drop it, as AsyncSandbox.serialize() does
for sidecar env.

A borrowed handle has no start process to reap, so close() could
signal a process-group ID the creator already reaped and the kernel
reused. Signal it only while the group leader still carries the
container marker.

Translate only a sha256 digest after the last '@', so Enroot's own
USER@REGISTRY prefix is left as before. Say that the '@' spelling
fails only on Enroot before 4.0. Reject a non-Gym sandbox_id as a
malformed descriptor rather than a stale PID.

Move the README text under its own headings after the config example,
and update the Harbor README line that said Enroot cannot serialize.
Cover the new rejection rows, registry ports, the cache key, the
process-group guard, a disconnect that leaves the creator's group and
staging alone, and the real /proc marker check on Linux.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 26e3956

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 15, 2026 19:18
@yaoyu-33
yaoyu-33 requested a review from agronskiy November 15, 2026 19:34
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 16, 2026

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

SHIP. Thanks, this is careful, and the real Enroot 3.4.1 owner/borrower runs plus the digest A/B are exactly the evidence I'd want.

I checked:

  • Descriptor and connect(): connect() validates host, UID, data and runtime paths, container name, init PID marker, staging dir and mount point before rebuilding the handle. The task env is left out, which is safe because enroot exec reads /proc/<pid>/environ.
  • Borrower disconnect(): it can't affect the creator. AsyncSandbox.disconnect() only calls provider.aclose(), and Enroot's aclose() is a no-op.
  • Borrowed stop() after the owner stopped: the new _kill_start_group guard means it only signals a process group whose leader still carries the container marker. That closes the reused-PGID hole.
  • Digest translation: it only fires on a trailing @sha256:, strips a tag only when the last : is after the last / (so host:5000/repo@sha256:… keeps its port), and leaves Enroot's USER@ prefix alone.

CI is green, and test_enroot_provider.py passes locally apart from the macOS-only /proc case you called out.

One NOTE on the #5792 overlap you mention: #5792 is approved and adds a near-identical serialize_handle/connect, but without the stopped-sandbox check in serialize_handle, the stricter start_pgid validation, or the _kill_start_group guard for borrowed handles. If #5792 lands first, please keep those three pieces (and the digest translation) when you rebase, rather than dropping this copy wholesale.

@yaoyu-33
yaoyu-33 added this pull request to the merge queue Nov 16, 2026
@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/43979064925

Merged via the queue into NVIDIA-NeMo:main with commit bdbcad1 Nov 16, 2026
77 checks passed
@yaoyu-33
yaoyu-33 deleted the codex/enroot-borrowed-task-sandboxes branch November 16, 2026 23:38
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 bug Something isn't working complexity:medium Single-domain change with interacting parts or a moderate review surface needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants