Skip to content

feat(evaluator-sdk): add Docker Compose sandbox provider (AALGO-330)#777

Open
ngoncharenko wants to merge 3 commits into
mainfrom
ngoncharenko/aalgo-330-bugnemo-containerized
Open

feat(evaluator-sdk): add Docker Compose sandbox provider (AALGO-330)#777
ngoncharenko wants to merge 3 commits into
mainfrom
ngoncharenko/aalgo-330-bugnemo-containerized

Conversation

@ngoncharenko

@ngoncharenko ngoncharenko commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a reusable Docker Compose sandbox provider to the evaluator SDK and its generated nemo-platform mirror. The provider owns one caller-described Compose project and exposes the existing sandbox protocol without moving other app-specific policy into the SDK.

What changed

  • Added DockerComposeSandboxProvider with ordered Compose files, profiles, explicit project names/directories, exact long-running and one-shot service topology, and image-first startup (build=False by default).
  • Added rendered-configuration and topology validation, occupied host-port preflight, nonblocking POSIX project locking, compose up --wait readiness, lifecycle status, diagnostics, teardown hooks, retrying compose down, optional volume removal, and residual Docker-resource verification.
  • Added command execution and file transfers through Compose. Uploads prepare targets as root, preserve directory-content copy semantics, discover the runtime UID:GID, and repair ownership so non-root services can modify transferred files.
  • Hardened subprocess timeout/cancellation and output redaction, including shielded startup-failure cleanup.
  • Froze project scope, target service, and topology per active session so runtime configuration changes cannot redirect teardown; public changes apply to the next lifecycle.
  • Normalized relative container paths against /, validated every scaled service replica, and wrapped lock filesystem failures in SandboxCreateError.
  • Added hermetic and live Docker Compose coverage and regenerated the SDK mirror with serial make vendor.
  • Documented the provider in the sandbox README.

Why

Other app need a containerized local topology, while the evaluator SDK should own only reusable sandbox mechanics. This keeps the ownership boundary explicit: callers supply Compose topology, build policy, port hints, and optional teardown policy; the SDK supplies lifecycle, transfer, isolation and ownership, diagnostics, and cleanup mechanics.

Root causes addressed

  • Startup diagnostics ran before shielded cleanup, so cancellation could leak the stack and project lock.
  • Compose commands re-read mutable provider fields during an active lifecycle, allowing teardown to target a different project.
  • Docker copy resolves relative container paths from /, while in-container mkdir and chown resolve from the image WORKDIR.
  • Readiness collapsed replica rows by service name and could hide an unhealthy replica.
  • Non-contention lock filesystem errors escaped the provider's documented SandboxCreateError boundary.

Impact

  • Evaluator consumers can run multi-service Compose sandboxes through the same provider-neutral API used by other runtimes.
  • Existing images remain the SDK default; source builds are opt-in.
  • Non-root target services can modify uploaded files.
  • Failed or cancelled startup reliably tears down owned resources.
  • No existing public sandbox-provider method signatures changed.

Validation

  • 54 passed — focused Compose provider tests
  • 3 passed — live Docker Compose tests
  • 266 passed, 2 skipped — full packages/nemo_evaluator_sdk/tests/agent_eval suite
  • Scoped Ruff check and format check
  • Scoped ty check
  • Serial make vendor
  • Source/generated mirror parity check
  • Provider callable docstring check
  • git diff --check 8f7743d4bba4e3e065bf18ebad7609e42d64ac98

Tracking

AALGO-330

Summary by CodeRabbit

  • New Features

    • Added a Docker Compose–based sandbox provider with per-project exclusivity via OS-level locking, ordered compose files, profiles, explicit service topology validation, and readiness enforcement.
    • Supports exec, file upload/download, status inspection, optional teardown hook, improved cleanup/teardown verification, port probing, and secret redaction.
    • Uses build=False by default (requires explicit source-build intent) and fails early on unsupported/platform-mismatch scenarios.
  • Tests

    • Added hermetic and live Compose provider coverage, including lifecycle, cancellation/timeout behavior, redaction checks, locking, and optional skips when no Compose daemon is available.
  • Documentation

    • Updated the sandbox README with Compose provider contract, behavior, and testing guidance.

@github-actions github-actions Bot added the feat label Jul 20, 2026
Signed-off-by: Nick Goncharenko <ngoncharenko@nvidia.com>
Signed-off-by: Nick Goncharenko <ngoncharenko@nvidia.com>
@ngoncharenko
ngoncharenko force-pushed the ngoncharenko/aalgo-330-bugnemo-containerized branch from 21b3909 to 9f0a288 Compare July 20, 2026 05:06
@ngoncharenko
ngoncharenko marked this pull request as ready for review July 20, 2026 05:07
@ngoncharenko
ngoncharenko requested review from a team as code owners July 20, 2026 05:07
@ngoncharenko ngoncharenko self-assigned this Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4f7b8b75-7344-4b80-90a9-6e2c27d85cd0

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0a288 and dd8f7af.

⛔ Files ignored due to path filters (1)
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/agent_eval/runtimes/sandbox/providers/compose.py is excluded by !sdk/**
📒 Files selected for processing (2)
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py
  • packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py
  • packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py

📝 Walkthrough

Walkthrough

Adds a Docker Compose-backed sandbox provider with exclusive project locking, topology and readiness validation, command and file-transfer APIs, status inspection, cancellation-safe cleanup, secret redaction, and hermetic/live integration tests.

Changes

Compose sandbox runtime

Layer / File(s) Summary
Provider contracts and project ownership
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py, packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/README.md
Defines Compose topology and public provider types, validates configuration, manages exclusive POSIX project locks, and documents the provider and test suites.
Compose startup and readiness
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider_live.py
Creates Compose projects, validates rendered services and published ports, applies build/pull/profile options, starts services, and verifies long-running and one-shot readiness.
Sandbox commands and file transfers
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider_live.py
Adds service-targeted execution, status inspection, file and directory transfers, path normalization, ownership repair, and session validation.
Cleanup and cancellation handling
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py
Adds diagnostics, teardown hooks, shutdown retries, resource verification, optional volume removal, lock retirement, and cancellation-safe cleanup.
Subprocess control and output redaction
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py
Adds streaming subprocess execution with timeouts and process-group termination while redacting secrets from progress output and diagnostics.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant DockerComposeSandboxProvider
  participant DockerCompose
  participant SandboxServices
  Client->>DockerComposeSandboxProvider: create(spec)
  DockerComposeSandboxProvider->>DockerCompose: config and preflight
  DockerCompose->>SandboxServices: inspect topology and ports
  DockerComposeSandboxProvider->>DockerCompose: compose up --wait
  DockerCompose->>SandboxServices: start project
  SandboxServices-->>DockerComposeSandboxProvider: readiness state
  DockerComposeSandboxProvider-->>Client: SandboxHandle
  Client->>DockerComposeSandboxProvider: exec or transfer
  DockerComposeSandboxProvider->>DockerCompose: service command or cp
  DockerCompose->>SandboxServices: execute operation
  SandboxServices-->>Client: result
  Client->>DockerComposeSandboxProvider: close(handle)
  DockerComposeSandboxProvider->>DockerCompose: compose down
  DockerCompose->>SandboxServices: remove project resources
Loading

Suggested labels: test

Suggested reviewers: maxdubrinsky, svvarom

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a Docker Compose sandbox provider to evaluator-sdk.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ngoncharenko/aalgo-330-bugnemo-containerized

Comment @coderabbitai help to get the list of available commands.

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

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
`@packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py`:
- Around line 1755-1771: Update _published_port_available to set SO_REUSEADDR on
the probe socket when using SOCK_STREAM, before bind; leave UDP probing
unchanged and preserve detection of ports held by active listeners.
🪄 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: 06fa71a1-6077-4f52-ba0e-43d6b53e4514

📥 Commits

Reviewing files that changed from the base of the PR and between 611dc85 and 9f0a288.

⛔ Files ignored due to path filters (1)
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/agent_eval/runtimes/sandbox/providers/compose.py is excluded by !sdk/**
📒 Files selected for processing (4)
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/README.md
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/sandbox/providers/compose.py
  • packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider.py
  • packages/nemo_evaluator_sdk/tests/agent_eval/test_sandbox_compose_provider_live.py

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 26411/34155 77.3% 61.7%
Integration Tests 15094/32804 46.0% 18.4%

Signed-off-by: Nick Goncharenko <ngoncharenko@nvidia.com>

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.

This file is a bit large. It might be helpful if decomposed into smaller modules for clarity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants