Repository navigation
test(agent): stabilize supervision and exec-transport tests and fence lost launches - #5933
Conversation
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE — one RISK.
I inspected all five changed files and traced the launch, stop, cleanup and directory-retirement paths. The new assertions distinguish a fenced launch from a supervisor that starts but immediately stops. However, the new adapter imports introduce a failure in the existing public-API enforcement test, detailed inline.
This was a static review. I didn't execute tests or independently verify the reported mutation results.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| import pytest | ||
|
|
||
| from nemo_gym.agents import HARNESS_RUNNER_FILE, HARNESS_RUNNER_SCRIPT, SandboxSession | ||
| from nemo_gym.agents.utils.supervisor_client import LAUNCH_CLAIM_FILE, SUPERVISOR_FILE, SUPERVISOR_PID_FILE |
There was a problem hiding this comment.
RISK — Route the new imports through the public API
Could you update this import and its equivalents in Codex, OpenCode, and OpenClaw?
Failure: test_code_outside_the_library_imports_exported_names_from_the_public_api scans tracked adapter tests and rejects deep imports of exported names. SUPERVISOR_FILE is already exported, so these four new imports produce offending entries and fail the assertion. The check and export also exist in the base; this is an introduced core-suite failure, not just an import-style preference.
Correction: Replace the two agent imports in each adapter test file with:
from nemo_gym.agents import (
HARNESS_RUNNER_FILE,
HARNESS_RUNNER_SCRIPT,
LAUNCH_CLAIM_FILE,
SUPERVISOR_FILE,
SUPERVISOR_PID_FILE,
SandboxSession,
)To make that replacement resolve, add LAUNCH_CLAIM_FILE and SUPERVISOR_PID_FILE to the supervisor-client imports in the TYPE_CHECKING block of the agents package, and add these entries to its _PUBLIC_API:
"LAUNCH_CLAIM_FILE": "utils.supervisor_client",
"SUPERVISOR_PID_FILE": "utils.supervisor_client",This restores the external-consumer import contract without weakening its enforcement. Keep the shared core test's defining-module imports unchanged. The facade forwards the same constants, so retain both retirement parameters and all script-existence, absent-PID, stop-claim and absent-directory assertions.
Acceptance — proposed, not executed: Run pytest tests/unit_tests/test_public_api_facades.py; expect no offending imports, matching type-checking exports, and identical facade/defining-module objects. Run the five changed test files; expect both replay parameters in every adapter and the shared claim-window test to pass. Verify the suggested changes before adopting them.
Several core, model, agent and terminal_bench_4 tests gave real work a deadline of tens of milliseconds, or bounded how long it took, and failed whenever a busy CI runner was slower. Give deadlines that must not fire room for a slow runner, hold the first model attempt on an event so only it times out, replace the elapsed bound on concurrent stale-copy deletion with a gate that every deletion must reach, and apply the 25 ms verifier budget only to the terminal_bench_4 cases meant to run out of it. The exec-transport and supervision changes moved to #5933 and the terminus changes to #5943. Signed-off-by: Ananth Subramaniam <[email protected]>
3ed9c88 to
76f8d4c
Compare
Several core, model, agent and terminal_bench_4 tests gave real work a deadline of tens of milliseconds, or bounded how long it took, and failed whenever a busy CI runner was slower. Give deadlines that must not fire room for a slow runner, replace the elapsed bound on concurrent stale-copy deletion with a gate that every deletion must reach, and apply the 25 ms verifier budget only to the terminal_bench_4 cases meant to run out of it. The exec-transport and supervision changes moved to #5933 and the terminus changes to #5943. Signed-off-by: Ananth Subramaniam <[email protected]>
The lost-launch tests replayed the delayed launch only after the session directory was retired, so the missing supervisor script stopped it and a broken launch claim went unnoticed. Replay the delayed launch before retirement too, with the supervisor still in place, and add a supervisor client test that takes the stop claim between the guard and `ln -s` so that `ln -s` alone has to fence the launch. Signed-off-by: Ananth Subramaniam <[email protected]>
Take SUPERVISOR_FILE from the public nemo_gym.agents facade, give the new closes a 10 s deadline that a loaded runner will not hit, and fail fast if the launch finishes before its bash -n check. Signed-off-by: Ananth Subramaniam <[email protected]>
Give the process-supervision and exec-transport tests deadlines that a loaded runner cannot hit, and fire the supervisor deadline on purpose once the harness is ready instead of racing harness start-up. Align the Kilo Code, OpenClaw and OpenCode exec-transport copies with the Codex copy from #5926: a 60 s activation deadline, an explicit expiry after the harness is ready, a ready wait that fails at once if the harness exits early, uploads that do not wait behind the supervised exec, and a delayed-startup case. All four copies close and expire with a 10 s CLOSE_TIMEOUT. Give the Codex, OpenCode and Pi sandbox-runner tests a 60 s supervisor deadline with a 5 s cleanup budget, drive timeouts through the expire file, and stop a supervisor that a failing test leaves running. The Pool lifecycle timeout cases expire after the fake Pool is ready, and the OpenClaw MCP probe timeout is 8 s. Refs #5672 Signed-off-by: Ananth Subramaniam <[email protected]>
…ests Match the other exec-transport copies: the provider deadline is the activation deadline plus CLOSE_TIMEOUT and the provider margin, not just more than the old 3 s close. Signed-off-by: Ananth Subramaniam <[email protected]>
85aea61 to
b9170d8
Compare
Several core, model, agent and terminal_bench_4 tests gave real work a deadline of tens of milliseconds, or bounded how long it took, and failed whenever a busy CI runner was slower. Give deadlines that must not fire room for a slow runner, replace the elapsed bound on concurrent stale-copy deletion with a gate that every deletion must reach, and apply the 25 ms verifier budget only to the terminal_bench_4 cases meant to run out of it. The exec-transport and supervision changes moved to #5933 and the terminus changes to #5943. Signed-off-by: Ananth Subramaniam <[email protected]>
What and why
This PR changes only tests, in two parts:
The agent test changes in the first part moved here from #5901, which now covers only the non-agent test files.
Stabilizing supervision and exec-transport tests
These tests run real shells and supervisors and scan
/proc. CI runs them underpytest -n 16on shared runners. Several of them gave that work a deadline of half a second to a few seconds that had to not fire, or relied on the supervisor deadline firing at a moment the test did not control. So they failed intermittently on unrelated pull requests.#5926 fixed this pattern in the Codex exec-transport copy:
expire()once the harness is ready;uploads_independent_of_execson the local provider;This PR builds on that and aligns the other copies with it:
CLOSE_TIMEOUTfor closes and expiry. test(agents): AUT-2815 stabilize supervision and diagnostic deadlines #5926 left Codex at 3 seconds, which still flaked under load. feat(copilot): add a sandboxed Copilot CLI agent server #5082 had already widened Kilo Code's close timeout to 10 seconds. This PR keeps that, and checks the exact provider deadline as the other copies do.uploads_independent_of_execs.Fencing lost launches
The supervisor launch command in
nemo_gym/agents/utils/supervisor_client.pyis fenced twice. A guard ([ -d dir ] && [ ! -L claim ] || exit 0) skips the launch early, andln -s launch claim || exit 0makes the claim. A stop that has already claimed the launch should keep a delayed launch from ever starting the supervisor.The lost-launch tests in the four exec-transport copies replayed the delayed launch only after
closehad retired the session directory. At that point the supervisor script is gone, so the replay fails for that reason alone. Removing the guard and makingln -snon-fatal left those tests passing.stop.bash -ncheck, which runs after the guard and beforeln -s. It does this with abashshim onPATHthat waits for a release file, and fails at once if the launch finishes before reaching that check. While the launch is held, a stop claims it, and then the launch is released. The guard has already passed, so the test coversln -srefusing a claim that the stop already holds. It cannot prove that the claim is atomic: a check followed by a separate write would also pass.All new waiting is poll- or event-based, with 30- to 60-second deadlines that fire only when something is broken.
Issues
Refs #5672: this covers the exec-transport and process-supervision tests. The transfer tests that the issue also lists are not fixed here.
Validation
All runs were in a worktree venv on current
upstream/main.tests/unit_tests/test_public_api_facades.py) pass underpytest -n 16, with nothing skipped.pytest -n 16while 60 busy-loop processes loaded a 24-core host. There were no failures, and no supervisor or sleep processes were left afterwards.ln -smade non-fatal: the before-retirement replay fails for all four transports, and the shared claim-window test fails. In each case the failing check is the one that says no supervisor started. The after-retirement replay still passes, which was the original gap.ln -smade non-fatal, guard kept: the shared claim-window test fails. The transport replays pass, because the guard still sees the existing claim.ln -skept: the new tests pass. This is expected, becauseln -salone still fences the launch, so this change is not a correctness bug.pre-commit run --filespasses on the changed files, and the commits are DCO signed off.Commands:
pytest -n 16 tests/unit_tests/test_public_api_facades.py \ tests/unit_tests/agents/test_sandbox_supervisor_client.py \ responses_api_agents/{codex,kilocode,openclaw,opencode}_agent/tests/test_exec_transport.py \ responses_api_agents/{codex,opencode,pi}_agent/tests/test_sandbox_runner.py \ responses_api_agents/pool_agent/tests/test_lifecycle.py \ responses_api_agents/openclaw_agent/tests/test_mcp_probe_supervision.pyRollout evidence
N/A: this is a test-only change, with no change to agent, verifier or library behavior.