Repository navigation
Conversation
…onfig.spec SandboxConfig gains derive_cpu_env (default false), and CpuCappedSandboxConfig defaults it to true for the task sandboxes that cap tool parallelism today. spec() takes the server's own env, layered under the CPU caps and the config env, and a network_policy that it places in provider_options, refusing one that provider_options already sets. SandboxNetwork in nemo_gym.server_runtime is the LentSandboxes egress builder made public and typed, with a new no_network access that denies all egress. LentSandboxes now builds its rule through it; its behavior is unchanged. Signed-off-by: Ananth Subramaniam <[email protected]>
denovo_swe, r2e_gym, swe_internal_v1, swemer_ultra and swe_gym now type sandbox_config as CpuCappedSandboxConfig and build their task sandbox through spec() instead of a hand-built SandboxSpec. swemer_ultra passes its Gradle env and swe_gym its conda env as the server env. The checked-in recipes build the same spec as before; a sandbox_config key these servers never read now fails at startup instead of being dropped. SandboxSessionResourcesServer reads ttl_s from a typed config or a mapping while the other subclasses still use mappings. Signed-off-by: Ananth Subramaniam <[email protected]>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
…rk loans swe_internal_v1 goes back to its mapping sandbox_config: PRs #5656 and #6173 read new keys from it with .get(), so it moves to the stage after they merge. LentSandboxes now refuses network_access no_network, since the harness in a lent sandbox calls the model server, and SandboxNetwork's validator returns Self. Signed-off-by: Ananth Subramaniam <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found. The four SWE migrations preserve the existing sandbox specs and environment precedence. The shared network-policy extraction and typed/mapping session-TTL handling fit the affected callers.
I reviewed all 24 changed files and their directly affected paths. This was a static review; I couldn't run tests in the read-only environment.
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.
What changed
This PR is the first stage of moving resources servers off hand-built sandbox specs and onto the typed
SandboxConfig.spec(). It changes the shared code and migrates four servers.Shared code
SandboxConfiggainsderive_cpu_env(defaultfalse). When it is on,spec()adds the CPU-cap environment(
cpu_cap_env(resources.cpu)) under the config's ownenv.CpuCappedSandboxConfigis aSandboxConfigwhosederive_cpu_envdefaults totrue. The SWE servers use itbecause they derive the caps by default today. Servers already on
SandboxConfigkeep thefalsedefault, sotheir specs do not change.
spec()takes two new keyword arguments:env: the server's own fixed environment. The CPU caps, thensandbox_config.env, override it. That is theorder these servers apply today.
network_policy: the sandbox's egress rule, placed inprovider_options["network_policy"].spec()refuses itwhen
provider_optionsalready sets one.SandboxNetwork(new, innemo_gym.server_runtime) is the single builder of egress rules for sandboxes that aresources server starts. It is the private
LentSandboxespolicy code, made public and typed, with accessinherit,no_network,model_onlyormodel_and_tools.no_network(deny all egress) is new;deepsweneeds it, because its agent sandbox denies all egress when no model server is set. A provider without network policies, or an allowed server on a loopback host, is refused as
ResourcesSeedRejectedError(HTTP 422), asLentSandboxesdoes today.LentSandboxesbuilds its egress rule withSandboxNetworkand passes it tospec(). Its constructor andbehavior are unchanged, and it refuses
no_network, because the harness in a lent sandbox calls the modelserver.
SandboxSessionResourcesServerreadsttl_sfrom either a typedSandboxConfigor a mapping, so it serves bothmigrated and unmigrated servers.
Servers migrated
denovo_swe,r2e_gym,swemer_ultraandswe_gymnow declaresandbox_config: CpuCappedSandboxConfigandbuild their task sandbox with
spec().swemer_ultrapasses its Gradle environment andswe_gymits condaenvironment as the server
env.#5676 also edits these four
app.pyfiles, but only their request classes, so the overlap is textual. No open PRreads a new
sandbox_configkey in them.swe_internal_v1stays on its mapping in this PR, because #5656(
sandbox_config.files) and #6173 (sandbox_config.legacy_container_setup) read new keys from it with.get().It moves in a later stage, after those PRs merge.
#6177 shares no files with this PR, and none of the four migrated servers is among the seven it changes
(
swe_rebench,swe_internal_v1,swemer_v1,swemer_v2,swemer_oml,scale_swe,swe_next). ItsAgentNetworkConfigmixin typessandbox_configas a mapping and reads it with.get(), so this PR leaves thoseseven servers alone. Expected order: #6177 lands first, either before or after this PR, then the stage that migrates
its servers.
Why
About 23 resources servers take
sandbox_configas an untyped mapping and buildSandboxSpecby hand. Most ofthese copies are the same 25 lines. Two problems follow:
enforce_agent_no_networkon servers that never read it, so those runs had open egress.After this change, a sandbox setting is one
spec()argument, and egress rules have one builder.No issue is linked: this is the structural follow-up to the review of PR #6177.
Later stages
Each later stage is its own PR, with the same spec-equality tests:
swemer_v1,swemer_v2,swemer_oml,scale_sweandswe_next. Theirenforce_agent_no_networkandsandbox_model_serverkeys map ontoSandboxNetwork(access="model_only"). Arecipe that sets the flag without a model server stays refused at load, as feat(swe): block egress from the agent's sandbox in the SWE servers #6177 does. The policy is passed to
spec(network_policy=...)for the agent's sandbox only, andfeat(swe): block egress from the agent's sandbox in the SWE servers #6177's
AgentNetworkConfigmixin is retired.swe_internal_v1andswe_rebench(also moving theirfeat(swe): block egress from the agent's sandbox in the SWE servers #6177 network keys onto
SandboxNetwork), each with aSandboxConfigsubclass for the keys those PRs add (files,legacy_container_setup, and the existinguse_maven_mirror), plusswebench,terminal_bench_2_1andopencode_search.deepswe,deepswe_external1andswebench_pro, whose network settings map ontoSandboxNetwork.deepswethen fails closed on providers without network policies; today it runs those sandboxes with open egress.
job_bench,workspace_bench,misalignment_monitor,officeqaandbrowsecomp_advanced_harness, which readthe image from the config or pass it straight to
SandboxSpec.spec()will gain a per-taskresourcesargument in thedeepswestage, the first stage that needs it.Compatibility
sandbox_configkey that recipes set keeps its meaning:ttl_s,ready_timeout_s,resources,env,metadata,provider_optionsandderive_cpu_env. The checked-in recipesbuild the same spec as before.
metadataandenvvalues must be strings, as they already are for servers onSandboxConfig.SandboxConfig.derive_cpu_envis a new field with afalsedefault, so existingSandboxConfigusers areunchanged.
Tests
_create_sandbox, using thesandbox_configblock of its checked-in recipe, and compares the result with the full expected spec: image,workdir, TTLs, environment (CPU caps plus the server's own variables), files, metadata, resources and provider
options. The same test also checks that the config's
envstill overrides the caps, thatderive_cpu_env: falsestill turns them off, and that an unknown key is refused. I wrote these tests before migrating, and the spec tests
passed against the old code too. The unknown-key test is the only one that fails on the old code, by design.
SandboxNetworktests cover the server checks for each access level, the deny-all and model-plus-tools rules,refusal (HTTP 422) of a provider without network policies or a loopback server, and refusal of a restriction that
provider_optionsalready sets.SandboxConfigtests cover the environment layering,derive_cpu_envon and off, and hownetwork_policycombines with the other provider options.
LentSandboxesnetwork tests are unchanged apart from the module they patch. A new test checks thatno_networkis refused.r2e_gymandswe_gymeach had a test that searchedapp.pysource text forcpu_cap_env(...). The newspec-equality test replaces it.
Commands run:
The unit-suite failures in my local environment are the same set on unmodified
upstream/main: they come fromoptional packages missing in the local venv, not from this change.
gym env testis left to CI.Rollout evidence
N/A: this changes how specs are built, not the specs themselves. For each migrated server, the tests show that its
checked-in recipe builds the same
SandboxSpecas before.