Skip to content

test(agent): stabilize supervision and exec-transport tests and fence lost launches - #5933

Merged
ananthsub merged 4 commits into
mainfrom
ananthsub/claim-fence-lost-launch-test
Nov 11, 2026
Merged

ananthsub merged 4 commits into
mainfrom
ananthsub/claim-fence-lost-launch-test

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What and why

This PR changes only tests, in two parts:

  1. It stabilizes the process-supervision and exec-transport tests for the Codex, Kilo Code, OpenClaw, OpenCode, Pi and Pool agents.
  2. It adds tests that catch a broken launch claim in the supervisor launch command.

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 under pytest -n 16 on 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:

  • a 60-second activation deadline;
  • an explicit expire() once the harness is ready;
  • a 30-second ready wait that fails right away if the harness exits early;
  • uploads_independent_of_execs on the local provider;
  • a delayed-startup case.

This PR builds on that and aligns the other copies with it:

  • Exec-transport tests (Kilo Code, OpenClaw, OpenCode): these now have test(agents): AUT-2815 stabilize supervision and diagnostic deadlines #5926's structure, including the delayed-startup case. All four copies, Codex included, use a 10-second CLOSE_TIMEOUT for 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.
  • Sandbox-runner tests (Codex, OpenCode, Pi):
    • The supervisor gets a 60-second deadline and a 5-second cleanup budget.
    • Timeout cases fire the deadline on purpose through the expire file once the harness is ready, instead of racing harness start-up against a 3-second deadline.
    • The path wait is poll-based with a 30-second deadline.
    • A test that fails early now stops its supervisor, so the supervisor cannot outlive the test.
  • Pool lifecycle test: the timeout cases wait for the fake Pool to be ready and then expire the activation, instead of relying on a 2-second deadline. The local sandbox declares uploads_independent_of_execs.
  • OpenClaw MCP probe supervision: the probe timeout is now 8 seconds instead of 2. This leaves time on a loaded runner for Node to start and for the healthy probe to finish before the blocked probe is stopped.

Fencing lost launches

The supervisor launch command in nemo_gym/agents/utils/supervisor_client.py is fenced twice. A guard ([ -d dir ] && [ ! -L claim ] || exit 0) skips the launch early, and ln -s launch claim || exit 0 makes 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 close had retired the session directory. At that point the supervisor script is gone, so the replay fails for that reason alone. Removing the guard and making ln -s non-fatal left those tests passing.

  • Each exec-transport copy now also replays the delayed launch before the directory is retired. The test first checks that the supervisor script is still in place, so only the stop's claim can fence the launch. It then checks that no supervisor started (no PID file) and that the claim still reads stop.
  • The shared supervisor client tests gain a test that holds the launch shell at its bash -n check, which runs after the guard and before ln -s. It does this with a bash shim on PATH that 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 covers ln -s refusing 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.

  • Every changed file and the public-import check (tests/unit_tests/test_public_api_facades.py) pass under pytest -n 16, with nothing skipped.
  • Under load: I ran the same set in repeated rounds of pytest -n 16 while 60 busy-loop processes loaded a 24-core host. There were no failures, and no supervisor or sleep processes were left afterwards.
  • Launch-claim mutations:
    • Guard removed and ln -s made 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 -s made non-fatal, guard kept: the shared claim-window test fails. The transport replays pass, because the guard still sees the existing claim.
    • Guard removed, ln -s kept: the new tests pass. This is expected, because ln -s alone still fences the launch, so this change is not a correctness bug.
  • pre-commit run --files passes 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.py

Rollout evidence

N/A: this is a test-only change, with no change to agent, verifier or library behavior.

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

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

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.

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.

ananthsub added a commit that referenced this pull request Nov 10, 2026
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]>
@ananthsub
ananthsub force-pushed the ananthsub/claim-fence-lost-launch-test branch from 3ed9c88 to 76f8d4c Compare November 10, 2026 17:04
@ananthsub ananthsub changed the title test(agent): fence lost launches with the claim before retirement test(agent): stabilize supervision and exec-transport tests and fence lost launches Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

ananthsub added a commit that referenced this pull request Nov 10, 2026
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]>
@ananthsub
ananthsub force-pushed the ananthsub/claim-fence-lost-launch-test branch from 85aea61 to b9170d8 Compare November 10, 2026 21:43
ananthsub added a commit that referenced this pull request Nov 11, 2026
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]>
@ananthsub
ananthsub merged commit 79e986f into main Nov 11, 2026
68 of 70 checks passed
@ananthsub
ananthsub deleted the ananthsub/claim-fence-lost-launch-test branch November 11, 2026 00:35

This branch had an error being deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants