fix(dcode): use managed Python venv on PATH - #5816
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR moves Deep Agents Code to a managed Python virtualenv at ChangesDeep Agents Code venv PATH hardening
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in the Show a code coverage summary of the most covered files.
TypeScript / code-coverage/cliThe overall coverage in the Show a code coverage summary of the most covered files.
Updated |
|
🌿 Preview your docs: https://nvidia-preview-pr-5816.docs.buildwithfern.com/nemoclaw |
PR Review Advisor — No blocking findingsMerge posture: No blocking advisor findings This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision. |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
Vitest E2E Scenario RecommendationRequired Vitest E2E scenarios: None Full Vitest E2E advisor summaryVitest E2E Scenario AdvisorBase: Required Vitest E2E scenarios
Optional Vitest E2E scenarios
Relevant changed files
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.sh (1)
83-89: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the full canonical
PATH, not only the prefix.This probe still passes if an unexpected directory is inserted after
/opt/venv/bin, because it only checks^PATH=/usr/local/bin:/opt/venv/bin:plusUSRLOCAL_COUNT=1. That leaves room for a PATH-construction regression while the test stays green. Please compare against the full ordered PATH contract, or at least validate every expected segment and count, so any extra entry fails the check.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.sh` around lines 83 - 89, The PATH assertion in the e2e probe is too loose because it only checks the prefix and a single /usr/local/bin count, so unexpected entries can still slip through. Tighten the check in the sandbox_exec validation by comparing the full ordered PATH contract, or explicitly verifying every expected segment from the PATH/PYTHON/PIP probe output in 06-deepagents-code-python-egress.sh so any extra directory causes the test to fail.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@agents/langchain-deepagents-code/policy-additions.yaml`:
- Around line 93-97: The PyPI allowlist in the policy additions no longer covers
the supported `/sandbox` virtualenv path used by the documented quickstart flow.
Update the allowlist entries in the policy definition to include the
`/sandbox/.../bin/pip3` and `/sandbox/.../bin/python3*` executables, or
otherwise align the policy with the documented environment in the quickstart
docs and any related tests. Use the existing allowlist block in the policy file
as the reference point and keep the scope limited to the intended
package-install traffic.
---
Nitpick comments:
In `@test/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.sh`:
- Around line 83-89: The PATH assertion in the e2e probe is too loose because it
only checks the prefix and a single /usr/local/bin count, so unexpected entries
can still slip through. Tighten the check in the sandbox_exec validation by
comparing the full ordered PATH contract, or explicitly verifying every expected
segment from the PATH/PYTHON/PIP probe output in
06-deepagents-code-python-egress.sh so any extra directory causes the test to
fail.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: bd74ed99-864c-4731-9c34-60507c6be413
📒 Files selected for processing (11)
agents/langchain-deepagents-code/Dockerfileagents/langchain-deepagents-code/Dockerfile.baseagents/langchain-deepagents-code/dcode-wrapper.shagents/langchain-deepagents-code/manifest.yamlagents/langchain-deepagents-code/policy-additions.yamlagents/langchain-deepagents-code/start.shdocs/get-started/quickstart-langchain-deepagents-code.mdxdocs/security/best-practices.mdxtest/e2e/e2e-cloud-experimental/checks/05-deepagents-code-landlock-readonly.shtest/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.shtest/langchain-deepagents-code-image.test.ts
| expect(landlockCheck).toContain("/opt/venv is Landlock read-only for Deep Agents Code"); | ||
| expect(landlockCheck).toContain("/etc is Landlock read-only for Deep Agents Code"); | ||
| expect(pythonEgressCheck).toContain(`DCODE_CANONICAL_PATH="${DCODE_CANONICAL_PATH}"`); | ||
| expect(pythonEgressCheck).toContain('grep -Fxq "PATH=${DCODE_CANONICAL_PATH}"'); |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.sh`:
- Around line 54-79: The reachability checks in python_probe are misclassifying
urllib.request.urlopen HTTPError responses as blocked, which can let egress slip
through when an endpoint returns a non-2xx status. Update python_probe so it
treats HTTPError as a reached host outcome (or explicitly inspects the status
code) and only reports BLOCKED for true connection-level failures; keep
expect_allowed and expect_blocked aligned with the output format emitted by
python_probe.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 84e033b5-2be0-419e-978d-2a2a58171acb
📒 Files selected for processing (2)
test/e2e/e2e-cloud-experimental/checks/06-deepagents-code-python-egress.shtest/langchain-deepagents-code-image.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- test/langchain-deepagents-code-image.test.ts
<!-- markdownlint-disable MD041 --> ## Summary Installs Deep Agents Code into a managed `/opt/venv` Python environment and makes the sandbox PATH resolve `python3` and `pip3` there before system Python. This also protects the managed venv with policy/read-only coverage and documents the new user-visible Python environment contract. ## Related Issue Fixes NVIDIA#5782 ## Changes - Create `/opt/venv` with `python3 -m venv --copies` and install the hash-locked Deep Agents Code requirements through `/opt/venv/bin/pip3`. - Use one canonical Deep Agents Code PATH across the base image, final image, shell startup files, generated runtime env, and wrapper. - Remove upstream `dcode` and `deepagents-code` console scripts from both `/usr/local/bin` and `/opt/venv/bin` before installing the NemoClaw-managed wrapper. - Move package registry and network-policy Python/pip binaries to `/opt/venv`, make `/opt/venv` read-only, and extend live e2e probes for the PATH/readlink acceptance criteria. - Add docs for the managed Deep Agents Code Python environment and the agent-specific PATH hardening exception. ## Type of Change - [ ] Code change (feature, bug fix, or refactor) - [x] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [x] Docs updated for user-facing behavior changes - [ ] Docs not applicable — justification: - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: self-reviewed the sandbox image PATH, wrapper bypass boundary, package registry binary, Landlock read-only policy, and network policy binary changes; added focused unit/static/e2e acceptance coverage. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [ ] Git hooks passed during commit and push, or `npx prek run --from-ref main --to-ref HEAD` passes - [x] Targeted tests pass for changed behavior - [ ] Full `npm test` passes (broad runtime changes only) - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) Verification detail: - `npx vitest run test/langchain-deepagents-code-image.test.ts test/dcode-start-keepalive.test.ts test/policies.test.ts --project cli` passed (158 tests). - `npm run typecheck:cli` passed. - `SKIP=test-cli npx prek run --files ...` passed for the touched files, covering formatting, SPDX, YAML checks, shellcheck, hadolint, gitleaks, source-shape, and file-size hooks. - `npm run docs` passed with 0 errors and 2 pre-existing Fern warnings. - Full touched-file pre-commit without `SKIP=test-cli` hit unrelated local rlimit fork-resource failures in `test/sandbox-init.test.ts` and `test/sandbox-rlimit-hooks.test.ts`, matching the local environment issue already observed on this machine. - Commit `98abfba3a4c31c821018e0a73490eb602c7400ad` is GitHub Verified (`reason: valid`). --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Deep Agents Code now uses a managed virtual environment at `/opt/venv` and a consistent hardened `PATH` that prioritizes `/opt/venv/bin`. * Project-specific dependencies can still be isolated in a separate `/sandbox` virtual environment. * **Bug Fixes** * Sandbox policy and egress validation are now scoped to the `/opt/venv` Python/pip. * Read-only enforcement now covers `/opt/venv`. * **Documentation** * Updated quickstart and security guidance to describe the `/opt/venv` runtime and fixed `PATH` behavior. * **Tests** * Strengthened e2e and image checks for canonical `PATH`, tool availability, and `/opt/venv` behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Installs Deep Agents Code into a managed
/opt/venvPython environment and makes the sandbox PATH resolvepython3andpip3there before system Python.This also protects the managed venv with policy/read-only coverage and documents the new user-visible Python environment contract.
Related Issue
Fixes #5782
Changes
/opt/venvwithpython3 -m venv --copiesand install the hash-locked Deep Agents Code requirements through/opt/venv/bin/pip3.dcodeanddeepagents-codeconsole scripts from both/usr/local/binand/opt/venv/binbefore installing the NemoClaw-managed wrapper./opt/venv, make/opt/venvread-only, and extend live e2e probes for the PATH/readlink acceptance criteria.Type of Change
Quality Gates
Verification
Verifiedin GitHubnpx prek run --from-ref main --to-ref HEADpassesnpm testpasses (broad runtime changes only)npm run docsbuilds without warnings (doc changes only)Verification detail:
npx vitest run test/langchain-deepagents-code-image.test.ts test/dcode-start-keepalive.test.ts test/policies.test.ts --project clipassed (158 tests).npm run typecheck:clipassed.SKIP=test-cli npx prek run --files ...passed for the touched files, covering formatting, SPDX, YAML checks, shellcheck, hadolint, gitleaks, source-shape, and file-size hooks.npm run docspassed with 0 errors and 2 pre-existing Fern warnings.SKIP=test-clihit unrelated local rlimit fork-resource failures intest/sandbox-init.test.tsandtest/sandbox-rlimit-hooks.test.ts, matching the local environment issue already observed on this machine.98abfba3a4c31c821018e0a73490eb602c7400adis GitHub Verified (reason: valid).Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
New Features
/opt/venvand a consistent hardenedPATHthat prioritizes/opt/venv/bin./sandboxvirtual environment.Bug Fixes
/opt/venvPython/pip./opt/venv.Documentation
/opt/venvruntime and fixedPATHbehavior.Tests
PATH, tool availability, and/opt/venvbehavior.