Skip to content

tracking: migrate in-scope resources servers to the Sandbox API #3216

Open

Description

@ananthsub

Why this work is needed

Several resources servers execute model-controlled Python, shell commands, SQL, compilers, or document parsers directly on the resources-server or Ray-worker host. Process timeouts, Ray placement, language-level deny lists, and restricted builtins limit failures, but they do not provide an operating-system isolation boundary.

Other resources servers already use Docker, Singularity, or a separate NeMo Skills sandbox service. Those paths are isolated, but they duplicate lifecycle, configuration, file transfer, timeout, and cleanup behavior that the provider-neutral nemo_gym.sandbox API is intended to standardize.

This issue tracks the resources servers that should migrate. It complements #2763, which defines canonical sandbox architecture and reusable patterns. This issue owns the environment-by-environment adoption work identified by the repository audit.

Scope criteria

A resources server is in scope when either condition applies:

  • model-controlled content reaches a host or Ray-worker code runtime, shell, compiler, writable database, or unsafe document parser during rollout or verification; or
  • runtime execution is already isolated through benchmark-specific infrastructure that should converge on nemo_gym.sandbox.

Setup scripts, data-preparation commands, test-only subprocesses, trusted parser workers, and benchmark-native simulators are not migration work unless their runtime capabilities change.

Wave 1: remove direct host execution

  • math_with_code — move persistent model Python into per-session sandboxes; preserve scientific libraries and interpreter state.
  • browsecomp_advanced_harness — move bash_command into a per-session sandbox while keeping search and judge calls server-side.
  • code_gen — replace Ray-worker execution of LiveCodeBench solutions with stateless sandbox verification.
  • bigcodebench — replace the mutable host Python 3.10 virtual environment and runner subprocess with a versioned sandbox image.
  • code_fim — run reconstructed HumanEval-Infilling programs in stateless sandboxes.
  • evalplus — run HumanEval+ and MBPP+ solutions in stateless sandboxes with the dataset cache baked into the image.
  • scicode — move scientific code execution into sandboxes without uploading the large HDF5 corpus for every verification.
  • newton_bench — replace the regex deny list and persistent host child with per-session sandboxes.
  • nvarc — run inductive transform() implementations in a stateless Python/NumPy sandbox.
  • bird_sql — execute generated SQL against a sandbox-local database copy and prevent timed-out work from continuing on the host.

Wave 2: consolidate benchmark-specific isolation

  • gdpval — move ZIP extraction and LibreOffice parsing of model deliverables into a prebuilt sandbox image.
  • competitive_coding_challenges — replace the custom NeMo Skills LocalSandbox client after grader metadata and cache staging are redesigned.
  • swerl_gen — migrate the outer Singularity execution boundary to the common Apptainer provider; keep nested evaluator commands inside that boundary.
  • math_formal_lean — replace the bespoke NeMo Skills HTTP client with direct Lean execution through AsyncSandbox.
  • ns_tools — replace the NeMo Skills Python sidecar/client lifecycle with the common sandbox facade while preserving request-scoped state and cleanup.

Wave 3: add the required adapter

  • aviary — add an Aviary environment adapter before migrating the Docker/Enroot-backed BixBench notebook variants.

Audited and excluded from this migration

These servers contained execution-like code and were reviewed explicitly, but they are not deferred migration tasks:

  • toolsandbox executes an allowlisted tool-call representation inside a benchmark-native state machine. It does not accept arbitrary Python or expose host-capable tools today.
  • spider2_lite executes SQL against an in-memory copy of the benchmark database. It may later use sandboxes for resource fairness, but it does not have the writable host-database exposure present in bird_sql.
  • math_with_judge and math_with_autograder run trusted SymPy/math-verification parsing in killable child processes. They do not execute model-provided code.
  • vlm_eval_kit runs a fixed trusted setup script at server startup. This should move to a prebuilt resources-server image rather than a per-rollout sandbox.

cvdp, litmus_agent, and swebench already use nemo_gym.sandbox and are not migration targets. The remaining audited resources servers do not execute model-controlled content through a host runtime during rollout or verification.

Common migration requirements

  • Use a prebuilt, versioned image. Do not install benchmark dependencies when each sandbox starts.
  • Disable runtime network access unless the benchmark explicitly requires it. Keep search, judge, and credential-bearing API calls in trusted server code where possible.
  • Apply enforceable CPU, memory, wall-time, output-size, and lifecycle limits appropriate to the selected provider.
  • Treat provider selection as part of the threat model. The common API does not make every provider an equivalent hostile-code boundary.
  • Use one of the established lifecycle shapes: stateless verification, Litmus-style per-session state, or SWE-bench-style separate agent and verification sandboxes.
  • Avoid per-rollout transfer of large immutable assets such as SciCode's HDF5 corpus and competitive-coding grader caches. Bake, mount, or fetch them through a trusted artifact path.
  • Add fake-provider contract tests and at least one opt-in real-provider test for each new image/runtime family.
  • Preserve benchmark result details, timeout classification, session cleanup, and verifier behavior.

Provider and API gaps that may block individual migrations

  • The neutral API has single-file transfer but no directory/archive primitive.
  • Endpoint support is limited to Docker and OpenSandbox; PTY and reconnection support are narrower still.
  • Neutral TTL and resource fields are not enforced uniformly by every provider.
  • The API does not declare an isolation-strength contract. Container providers normally share the host kernel.
  • SWE-bench currently catches TimeoutError, while providers commonly return SandboxExecResult.error_type == "timeout"; timeout handling should be made consistent as related cleanup.

Acceptance criteria

  • Each in-scope resources server has a linked implementation issue or pull request and an identified owner.
  • Every Wave 1 server no longer executes model-controlled code, shell, SQL, or compiler input directly on a resources-server or Ray-worker host.
  • Every Wave 2 server uses the common facade or has a documented unresolved platform blocker with an owner.
  • Aviary's adapter decision and ownership are recorded.
  • Migration tests cover execution results, timeout classification, cancellation, state where applicable, and cleanup.
  • At least one real rollout is inspected for each migrated benchmark, as required by the repository quality bar.
  • Sandbox images and large immutable assets have reproducible build or publication paths.
  • The resources-server inventory in this issue remains current as child work lands.

Activity

  1. added
    tracking
    area:environment
    area:sandbox
    on Sep 10, 2026
  2. jimmy-holdout commented on Oct 27, 2026

    @jimmy-holdout

    Some measurements for the bird_sql item: besides host isolation, the writable database also affects rewards.

    At 85b42ba, execute_sqlite opens the per-db_id file read/write inside with sqlite3.connect(...), which commits on exit (eval_utils.py#L29-L41). Gold and model SQL run against that same file (app.py#L127-L128, eval_utils.py#L84-L98), so a write in model SQL carries over to later rollouts on that db_id. All 11 BIRD dev databases go through this path. Measured through verify() on a copy of california_schools:

    • Task 0's answer DELETE FROM frpm WHERE CDSCode = (<top Alameda row>) RETURNING <its rate> returns the gold value, scores 1.0, and deletes the row. Task 0's gold result then changes from 1.0 to 0.9833….
    • One rollout answering DELETE FROM frpm scores 0 but empties the table. After it, the constant answer SELECT 1 WHERE 0 scores 1.0 on 33 of the 89 california_schools tasks (0 before).

    The changes stay on disk across restarts, since ensure_bird_sql reuses the extracted files (setup_bird_sql.py#L29-L31).

    Reproduction (save as repro.py in the repo root after BIRD dev has been extracted to the default resources_servers/bird_sql/.bird_sql/ directory)
    import asyncio, json, shutil, tempfile
    from pathlib import Path
    from resources_servers.bird_sql.eval_utils import execute_and_compare
    
    src = Path("resources_servers/bird_sql/.bird_sql/dev_20240627")
    db = Path(tempfile.mkdtemp()) / "california_schools.sqlite"  # work on a copy
    shutil.copyfile(src / "dev_databases/california_schools/california_schools.sqlite", db)
    tasks = [t for t in json.loads((src / "dev.json").read_text()) if t["db_id"] == "california_schools"]
    sem = asyncio.Semaphore(8)
    
    async def n_pass(pred):
        return sum([(await execute_and_compare(db, t["SQL"], pred, sem))[0] for t in tasks])
    
    async def main():
        print("SELECT 1 WHERE 0 passes", await n_pass("SELECT 1 WHERE 0"), "/", len(tasks))  # 0 / 89
        print(await execute_and_compare(db, tasks[0]["SQL"], "DELETE FROM frpm", sem))  # (False, [(1.0,)], [], None)
        print("SELECT 1 WHERE 0 passes", await n_pass("SELECT 1 WHERE 0"), "/", len(tasks))  # 33 / 89
    
    asyncio.run(main())

    #4898 also reworks execute_sqlite. Its version closes the connection without committing, which rolls back a plain DELETE/UPDATE/INSERT. A DELETE … RETURNING still returns the gold rows, though, so it still scores 1.0, and DDL such as DROP TABLE still persists under Python's default transaction handling.

    Until the sandbox migration lands, opening the file read-only closes this with one line. sec_local_index already opens its index read-only (local_edgar_search.py#L382-L384), and spider2_lite runs queries on an in-memory copy instead (eval_utils.py#L46-L65):

    -        with sqlite3.connect(str(db_path)) as conn:
    +        with sqlite3.connect(f"{db_path.resolve().as_uri()}?mode=ro", uri=True) as conn:

    With it, a write fails as a query error (reward 0) and the file is unchanged. Scoring all 1534 BIRD dev tasks with their reference SQL as the answer gave identical per-task results with and without the change, and the WAL-mode card_games.sqlite still reads fine. The same change fits the connect call in #4898's version. I'm happy to send it as a small PR with tests if that's useful, or to leave it to #4898 or the sandbox work.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Environment & Benchmarksarea:environmentarea:sandboxsandboxtracking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions