Skip to content

fix(vibench): remove a released session's scratch files shielded - #6413

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/sandbox-stop-retried-owners
Nov 19, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/sandbox-stop-retried-owners

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

vibench's release stops the session's build sandbox and then removes its scratch files. The stop is shielded and bounded by AsyncSandbox.stop (#6410), but a client that disconnects still cancelled the removal after it, so the close returned before it dropped the session's record and fenced it.

The removal is now shielded like the stop, so a close cut short by a disconnect still removes the scratch files and then, with no await left, drops the record and fences the session. A thread running rmtree cannot be cancelled anyway, so the removal has no time limit of its own.

The harbor, partner_if and scale_swe stops this PR used to move need no change now that stop() itself is shielded and bounded.

How it works

flowchart LR
  subgraph before["Before"]
    direction TB
    a1["close, client disconnects"] --> a2["stop the build sandbox, shielded"]
    a2 --> a3["remove scratch files: cancelled"]
    a3 --> a4["close ends before it drops the record<br/>and fences the session"]
  end
  subgraph after["After"]
    direction TB
    b1["close, client disconnects"] --> b2["stop the build sandbox, shielded"]
    b2 --> b3["remove scratch files, shielded"]
    b3 --> b4["drop the record and fence the session,<br/>with no await left to cancel"]
  end
  before ~~~ after
Loading

Where this sits in the stack

This is one PR in a stack of PRs that implement Milestone 1 of the sandbox ownership design: every sandbox has one owner, the server that starts it, which stops it on every path, and every other user borrows it. Each PR is one commit, so each diff shows only that PR's change.

The highlighted box is this PR.

flowchart LR
  M["PR 5266<br/>sandbox checkpointer"]
  U1["PR 6410, merged<br/>shielded, bounded<br/>AsyncSandbox.stop"]
  U2["PR 6411, merged<br/>gdpval failed-seed<br/>sandbox"]
  U3["PR 6412<br/>browser record kept<br/>until it closes"]
  U4["PR 6413<br/>vibench shielded<br/>scratch removal"]
  U5["PR 6414<br/>public<br/>OwnedSandboxes"]
  U6["PR 6415<br/>lifecycle<br/>under load"]
  U7["PR 6416<br/>typed<br/>network rule"]
  U8["PR 6417<br/>borrow and<br/>AgentSandboxConfig"]
  U1 --> U2
  U2 --> U3
  U2 --> U4
  U1 --> U5 --> U6 --> U7 --> U8
  M -.->|"PR 6414 rebases onto it"| U5
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef merged fill:#d1fae5,stroke:#047857,color:#1f2937
  class U1,U2 merged
  class U4 this
Loading
  1. fix(sandbox): shield and bound AsyncSandbox.stop and the other releases #6410 (merged): fix(sandbox): shield and bound AsyncSandbox.stop and the other releases
  2. fix(gdpval): keep a failed seed's sandbox until a stop succeeds #6411 (merged): fix(gdpval): keep a failed seed's sandbox until a stop succeeds
  3. fix(interactive_browser): drop a browser's record only after it closes #6412 (ananthsub/sandbox-stop-keep-record): fix(interactive_browser): drop a browser's record only after it closes
  4. fix(vibench): remove a released session's scratch files shielded #6413 (ananthsub/sandbox-stop-retried-owners): fix(vibench): remove a released session's scratch files shielded (this PR)
  5. feat(sandbox): expose the shared OwnedSandboxes owner #6414 (ananthsub/owned-sandboxes): feat(sandbox): make the sandbox checkpointer the public OwnedSandboxes
  6. feat(sandbox): stop, start and export owned sandboxes safely under load #6415 (ananthsub/owned-sandboxes-lifecycle): feat(sandbox): stop, start and export owned sandboxes safely under load
  7. feat(sandbox): apply typed network rules through owner capabilities #6416 (ananthsub/owned-sandboxes-network): feat(sandbox): typed network rule and provider capabilities for owners
  8. feat(sandbox): borrow lent sandboxes and share harness configuration #6417 (ananthsub/sandbox-borrow): feat(agents): borrow lent sandboxes and type the agent's own sandbox

Validation

  • pre-commit run --files <changed files> on the unit's diff (ruff, ruff-format, import-linter, guardwords).
  • pytest -n 16 tests/unit_tests, in a venv with CI's extras, with the same failures as on main.
  • Server tests: vibench, and harbor, partner_if and scale_swe, which this PR no longer changes.
  • A new test cuts a close short with a disconnect while the build sandbox stops, and checks that the record is dropped, the scratch files are gone and the session is fenced, so a re-seed is refused. It failed 5 of 5 runs with the shield removed.

Rollouts

N/A: a normal close is the same; only cancellation behavior changes.

Compatibility and benchmark impact

None.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally.
  • Documentation added or updated, or N/A with justification. N/A: no user-facing behavior to document.
  • Pre-commit checks pass locally, run on this unit's changed files.
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s).

@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:mid Autobot PR risk: mid label Nov 18, 2026
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from 0e18a88 to 7c30750 Compare November 18, 2026 23:19
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from 584f72b to 1b16f8f Compare November 18, 2026 23:19
@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:sandbox Sandbox providers, isolation, and sandbox runtime contracts labels Nov 18, 2026
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from 1b16f8f to 26a3dca Compare November 19, 2026 05:51
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from 7c30750 to 0d0324f Compare November 19, 2026 05:51
@ananthsub ananthsub changed the title fix(sandbox): shield the stops left in harbor, partner_if, scale_swe and vibench fix(vibench): remove a released session's scratch files shielded Nov 19, 2026
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from 26a3dca to 9814f47 Compare November 19, 2026 15:03
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from 0d0324f to 0aa8151 Compare November 19, 2026 15:03
@ananthsub
ananthsub marked this pull request as ready for review November 19, 2026 15:04
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 19, 2026 15:04
@yaoyu-33
yaoyu-33 requested a review from init-nikhil November 19, 2026 15:08

@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

LGTM. No concerns found in the shielded cleanup or the disconnect regression test. I traced the release callers and shared cancellation contract. Failed stops still keep ownership for retry, while successful close drops the record and fences the session without another await.

Source inspection only. I did not execute tests.

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.

@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from 9814f47 to a86139a Compare November 19, 2026 15:31
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from 0aa8151 to 1de460e Compare November 19, 2026 15:31

@hemildesai hemildesai 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

LGTM, no concerns. The stop already gets #6410's shield and bound, and this shields only the rmtree that follows, so the record is removed and the session fenced with no unshielded await left. It's the same pattern as #6411, with no double shielding. The new disconnect test drives a real anyio cancel scope against the fake provider.

The only red check is test_docker_compose.py::test_log_paths_exist_before_the_command_hooks_and_healthcheck_and_a_foreign_target_is_linked in Sandbox tests. This PR touches only vibench and that test passes on #6410–#6412, so I've re-run it. I'll approve once it's green.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 19, 2026
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from 1de460e to c8b292c Compare November 19, 2026 15:54
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from a86139a to 6905e65 Compare November 19, 2026 15:55
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from c8b292c to 5131416 Compare November 19, 2026 15:56
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from 6905e65 to 25ad956 Compare November 19, 2026 15:56
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from 25ad956 to b4240bb Compare November 19, 2026 16:31
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from 5131416 to 3c6f2b6 Compare November 19, 2026 16:32
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from b4240bb to b1cd701 Compare November 19, 2026 16:43
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from 3c6f2b6 to bb422bb Compare November 19, 2026 16:43
hemildesai
hemildesai previously approved these changes Nov 19, 2026

@hemildesai hemildesai 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.

Approving at b1cd701. The patch is unchanged from the version I reviewed, now rebased, and CI is green.

vibench's release stops the session's build sandbox and then removes its
scratch files. The stop is shielded and bounded by AsyncSandbox.stop, but a
client that disconnects still cancelled the removal after it, so the close
returned before it dropped the session's record and fenced it.

The removal is now shielded like the stop, so a close cut short by a
disconnect still removes the scratch files and then, with no await left,
drops the record and fences the session.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-keep-record branch from bb422bb to 1e19e37 Compare November 19, 2026 17:48
@ananthsub
ananthsub changed the base branch from ananthsub/sandbox-stop-keep-record to main November 19, 2026 17:49
@ananthsub
ananthsub dismissed hemildesai’s stale review November 19, 2026 17:49

The base branch was changed.

@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-retried-owners branch from b1cd701 to bb5d8f3 Compare November 19, 2026 17:49
@ananthsub
ananthsub merged commit 372383d into main Nov 19, 2026
69 checks passed
@ananthsub
ananthsub deleted the ananthsub/sandbox-stop-retried-owners branch November 19, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:sandbox Sandbox providers, isolation, and sandbox runtime contracts bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer risk:mid Autobot PR risk: mid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants