Skip to content

feat(sandbox): take a failed checkpoint snapshot again before failing the export - #4779

Draft
pthombre wants to merge 1 commit into
pthombre/partial-ckpt-sandbox-prepared-verifyfrom
pthombre/partial-ckpt-sandbox-snapshot-retry
Draft

pthombre wants to merge 1 commit into
pthombre/partial-ckpt-sandbox-prepared-verifyfrom
pthombre/partial-ckpt-sandbox-snapshot-retry

Conversation

@pthombre

@pthombre pthombre commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

One failed snapshot fails the whole checkpoint. At commit, the sandbox owner (#4220) snapshots every live session's sandbox, and one snapshot that fails fails the commit. OpenSandbox's commit job can fail (CommitJobFailed, after its own retries) while the sandbox keeps running. At a trainer checkpoint, that one failure ends a run: a 32-node SWE-bench run (job 8026244) died this way.

The owner now takes a failed snapshot again before it fails the export.

What this PR adds (nemo_gym/sandbox/checkpoint.py, nemo_gym/sandbox/owner.py):

  • sandbox_checkpoint.snapshot_attempts (default 3) bounds the snapshots taken of one sandbox per export. sandbox_checkpoint.snapshot_retry_delay_s (default 5 s) is the pause between them.
  • What is retried: a refused submit, and a snapshot that fails or does not become ready in time. Failing to index a snapshot is not retried.
  • Every attempt is indexed the moment the service returns its ID, so a later release deletes the failed snapshots too.
  • Each retry is logged as a WARNING with the attempt number, the session, the sandbox and the error.
  • SandboxSessionCheckpointer keeps working for direct callers: it takes snapshot_attempts (default 1, which keeps the previous behaviour) and snapshot_retry_delay_s. SandboxOwnerResourcesServer passes the configured values.

How it works

sequenceDiagram
  participant C as Controller
  participant R as Sandbox owner
  participant I as Snapshot index
  participant S as Sandbox service
  C->>R: commit c1
  R->>S: snapshot A (attempt 1)
  S-->>R: s1
  R->>I: write c1/s1
  S-->>R: s1 failed (CommitJobFailed)
  R->>R: wait snapshot_retry_delay_s
  R->>S: snapshot A (attempt 2)
  S-->>R: s2
  R->>I: write c1/s2
  S-->>R: s2 Ready
  R-->>C: the record names s2
  Note over R,S: a later release deletes s1 with the rest of c1's index
Loading

Where this sits in the stack

Stack #4578, on ananthsub/partial-ckpt-fault-tests: #4220 → #4221 → #4222 → #4576 → #4274 → #4451 → #4553 → #4778 → #4779 (this PR) → #4936.

The change is to #4220's SandboxSessionCheckpointer and the sandbox owner from #4576. It depends on none of #4274, #4451, #4553 or #4778; it sits at the top of the stack only so the PRs below did not need another rebase.

Issue

Part of #3284 (sandboxed blackbox agents). It was split out of #4274 because it applies to every sandbox owner, not only OpenCode's.

Validation

On this head (c670de9cc, the top of the stack), in the rl-gym.nightly container on Slurm (job 8087406):

  • Gym suites (SWE-bench, OpenCode, and the checkpoint, sandbox, OpenSandbox and token-capture unit tests): 2324 passed, 9 skipped, 0 failed.
  • ruff is clean, and the commit carries Signed-off-by.

New tests in tests/unit_tests/test_sandbox_checkpoint.py:

  • a snapshot that fails is taken again, and every attempt is indexed;
  • a refused snapshot submit is retried;
  • the export fails once every snapshot attempt has failed.

Rollout evidence

32-node SWE-bench run on this head (job 8093570): one snapshot failed once and its retry succeeded; 18 checkpoints committed with 0 failures; 5/5 steps, run_complete=True.

Earlier 32-node runs (jobs 8078235 and 8080199 → 8081456):

  • 2,125 snapshots became ready across the full run and the restore run (1,034 + 1,091).
  • In the restore run, one sandbox's snapshot failed on every attempt for about 30 minutes: 27 failed snapshots, each state=failed after about 80 s. One trainer checkpoint failed on it. The controller's own checkpoint retry then committed a later attempt, and the run completed 5/5 steps.

Retries cover transient failures, not persistent ones. This matches an earlier run (job 8028456), where the same sandboxes failed at consecutive checkpoints. A persistent per-sandbox failure needs a fix in OpenSandbox; its commit-job logs are not exposed to Gym.

Compatibility

  • Default behaviour changes for SandboxOwnerResourcesServer configs: up to 3 attempts per sandbox per export. Set sandbox_checkpoint.snapshot_attempts: 1 for the previous behaviour.
  • Deadline: a commit's deadline must allow snapshot_attempts × (snapshot wait + snapshot_retry_delay_s) for the slowest sandbox.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

… the export

OpenSandbox's commit job can fail (CommitJobFailed after its own retries) while the sandbox keeps running, and
one failed snapshot fails the whole checkpoint; at a trainer checkpoint that ends the run (job 8026244).
sandbox_checkpoint.snapshot_attempts (default 3) bounds the snapshots taken of one sandbox per export, with
snapshot_retry_delay_s between them. A refused submit or a snapshot that does not become ready is retried;
failing to index one is not. Every attempt is indexed, so a release deletes the failed ones too.

In job 8028456 the failures were persistent per sandbox (the same two sandboxes failed at two checkpoints
in a row), which a retry does not fix; this covers the transient case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>
@pthombre
pthombre force-pushed the pthombre/partial-ckpt-sandbox-snapshot-retry branch from d42ef58 to f8f0dc9 Compare October 25, 2026 16:57
pthombre added a commit that referenced this pull request Nov 7, 2026
…a renewable lease

Adds the optional provider capabilities partial-rollout checkpoints need on the
sandbox side, and implements them for OpenSandbox:

- SupportsSandboxSnapshot: snapshot(handle, name) starts a snapshot and returns
  its id at once; wait_snapshot_ready, delete_snapshot (404 is gone) and
  list_snapshots(prefix) go over the management API through Gym's shared
  aiohttp client. 429, 5xx and connection errors are retried; a 404 for a
  snapshot the API has only just created is waited out for
  snapshot_lookup_grace_s. The API's name filter matches whole names, so a
  prefix listing reads every page and filters client-side. A fork stays
  create(provider_options.snapshot_id), as on main.
- A renewable lease (create.renew_ttl_s): each sandbox is created with the
  lease, capped by the spec's ttl_s, and renewed every renew_interval_s
  (jittered) with renew_timeout_s per call, never past the spec's lifetime. A
  failed lease renewal is logged and retried; a renewal that finds the sandbox
  gone ends the loop quietly in both modes. Off by default: shipping it would
  break configs that set a longer renew_interval_s (swe_together, TB4).
- SupportsSandboxCheckpointPolling / SupportsSandboxParkedPolling and the
  AsyncSandbox.checkpoint_exec_polling() / parked_exec_polling() scopes: a
  harness stopped for a checkpoint is seen to end within
  checkpoint_background_poll_interval_s, and a sandbox paused for a snapshot is
  not polled until the park ends, forgiving one status request that failed
  meanwhile.
- AsyncSandbox.provider, owns_provider and handle properties.

Provenance: the provider half of #4220, #4553 and #4779 (legacy stack), rebuilt
on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
pthombre added a commit that referenced this pull request Nov 7, 2026
SandboxSessionCheckpointer (nemo_gym/_checkpoint/sandbox.py) checkpoints the
sandboxes a server owns, by an opaque key, for any owner: a resources server,
an agent or an environment server.

- export(keys, checkpoint_id) snapshots each live sandbox; a key without one
  exports None. Every snapshot is indexed under
  <state_dir>/<server>/snapshots/<checkpoint>/<snapshot> as soon as its id
  returns, before the readiness wait. A failed snapshot is taken again up to
  snapshot_attempts times; the backend semaphore covers the submit only, not
  the readiness wait.
- Snapshot names are ng-<run>-<server>-<checkpoint>-<key>-<attempt>, with
  short hashes and a run id written once into state_dir.
- restore(states) validates everything, forks all or nothing (rolling back
  its own forks), retries a fork the store cannot find yet, and stops the
  superseded sandboxes in the background.
- release(kept) deletes, under a file lock shared by every process of the
  server, the indexed snapshots of every checkpoint not kept, including a
  crashed process's and a failed commit's, then sweeps snapshots of dropped
  checkpoints the index never recorded by name. A failed delete keeps its
  marker for the next release.
- checkpoint_state_dir() requires checkpoint.state_dir (added to
  CheckpointSettings) once checkpointing is on.
- OpenSandbox's snapshots.py cleanup tool gains --name-prefix, so an operator deletes the
  snapshots a job left when it ended for good: --name-prefix ng-<run_id>- --reap.

Provenance: nemo_gym/sandbox/checkpoint.py of #4220 and #4779 (legacy stack),
moved out of nemo_gym.sandbox, without park/on_stop (stop-commit is deferred).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
pthombre added a commit that referenced this pull request Nov 13, 2026
…a renewable lease

Adds the optional provider capabilities partial-rollout checkpoints need on the
sandbox side, and implements them for OpenSandbox:

- SupportsSandboxSnapshot: snapshot(handle, name) starts a snapshot and returns
  its id at once; wait_snapshot_ready, delete_snapshot (404 is gone) and
  list_snapshots(prefix) go over the management API through Gym's shared
  aiohttp client. 429, 5xx and connection errors are retried; a 404 for a
  snapshot the API has only just created is waited out for
  snapshot_lookup_grace_s. The API's name filter matches whole names, so a
  prefix listing reads every page and filters client-side. A fork stays
  create(provider_options.snapshot_id), as on main.
- A renewable lease (create.renew_ttl_s): each sandbox is created with the
  lease, capped by the spec's ttl_s, and renewed every renew_interval_s
  (jittered) with renew_timeout_s per call, never past the spec's lifetime. A
  failed lease renewal is logged and retried; a renewal that finds the sandbox
  gone ends the loop quietly in both modes. Off by default: shipping it would
  break configs that set a longer renew_interval_s (swe_together, TB4).
- SupportsSandboxCheckpointPolling / SupportsSandboxParkedPolling and the
  AsyncSandbox.checkpoint_exec_polling() / parked_exec_polling() scopes: a
  harness stopped for a checkpoint is seen to end within
  checkpoint_background_poll_interval_s, and a sandbox paused for a snapshot is
  not polled until the park ends, forgiving one status request that failed
  meanwhile.
- AsyncSandbox.provider, owns_provider and handle properties.

Provenance: the provider half of #4220, #4553 and #4779 (legacy stack), rebuilt
on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
pthombre added a commit that referenced this pull request Nov 13, 2026
SandboxSessionCheckpointer (nemo_gym/_checkpoint/sandbox.py) checkpoints the
sandboxes a server owns, by an opaque key, for any owner: a resources server,
an agent or an environment server.

- export(keys, checkpoint_id) snapshots each live sandbox; a key without one
  exports None. Every snapshot is indexed under
  <state_dir>/<server>/snapshots/<checkpoint>/<snapshot> as soon as its id
  returns, before the readiness wait. A failed snapshot is taken again up to
  snapshot_attempts times; the backend semaphore covers the submit only, not
  the readiness wait.
- Snapshot names are ng-<run>-<server>-<checkpoint>-<key>-<attempt>, with
  short hashes and a run id written once into state_dir.
- restore(states) validates everything, forks all or nothing (rolling back
  its own forks), retries a fork the store cannot find yet, and stops the
  superseded sandboxes in the background.
- release(kept) deletes, under a file lock shared by every process of the
  server, the indexed snapshots of every checkpoint not kept, including a
  crashed process's and a failed commit's, then sweeps snapshots of dropped
  checkpoints the index never recorded by name. A failed delete keeps its
  marker for the next release.
- checkpoint_state_dir() requires checkpoint.state_dir (added to
  CheckpointSettings) once checkpointing is on.
- OpenSandbox's snapshots.py cleanup tool gains --name-prefix, so an operator deletes the
  snapshots a job left when it ended for good: --name-prefix ng-<run_id>- --reap.

Provenance: nemo_gym/sandbox/checkpoint.py of #4220 and #4779 (legacy stack),
moved out of nemo_gym.sandbox, without park/on_stop (stop-commit is deferred).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
pthombre added a commit that referenced this pull request Nov 14, 2026
…a renewable lease

Adds the optional provider capabilities partial-rollout checkpoints need on the
sandbox side, and implements them for OpenSandbox:

- SupportsSandboxSnapshot: snapshot(handle, name) starts a snapshot and returns
  its id at once; wait_snapshot_ready, delete_snapshot (404 is gone) and
  list_snapshots(prefix) go over the management API through Gym's shared
  aiohttp client. 429, 5xx and connection errors are retried; a 404 for a
  snapshot the API has only just created is waited out for
  snapshot_lookup_grace_s. The API's name filter matches whole names, so a
  prefix listing reads every page and filters client-side. A fork stays
  create(provider_options.snapshot_id), as on main.
- A renewable lease (create.renew_ttl_s): each sandbox is created with the
  lease, capped by the spec's ttl_s, and renewed every renew_interval_s
  (jittered) with renew_timeout_s per call, never past the spec's lifetime. A
  failed lease renewal is logged and retried; a renewal that finds the sandbox
  gone ends the loop quietly in both modes. Off by default: shipping it would
  break configs that set a longer renew_interval_s (swe_together, TB4).
- SupportsSandboxCheckpointPolling / SupportsSandboxParkedPolling and the
  AsyncSandbox.checkpoint_exec_polling() / parked_exec_polling() scopes: a
  harness stopped for a checkpoint is seen to end within
  checkpoint_background_poll_interval_s, and a sandbox paused for a snapshot is
  not polled until the park ends, forgiving one status request that failed
  meanwhile.
- AsyncSandbox.provider, owns_provider and handle properties.

Provenance: the provider half of #4220, #4553 and #4779 (legacy stack), rebuilt
on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
pthombre added a commit that referenced this pull request Nov 14, 2026
SandboxSessionCheckpointer (nemo_gym/_checkpoint/sandbox.py) checkpoints the
sandboxes a server owns, by an opaque key, for any owner: a resources server,
an agent or an environment server.

- export(keys, checkpoint_id) snapshots each live sandbox; a key without one
  exports None. Every snapshot is indexed under
  <state_dir>/<server>/snapshots/<checkpoint>/<snapshot> as soon as its id
  returns, before the readiness wait. A failed snapshot is taken again up to
  snapshot_attempts times; the backend semaphore covers the submit only, not
  the readiness wait.
- Snapshot names are ng-<run>-<server>-<checkpoint>-<key>-<attempt>, with
  short hashes and a run id written once into state_dir.
- restore(states) validates everything, forks all or nothing (rolling back
  its own forks), retries a fork the store cannot find yet, and stops the
  superseded sandboxes in the background.
- release(kept) deletes, under a file lock shared by every process of the
  server, the indexed snapshots of every checkpoint not kept, including a
  crashed process's and a failed commit's, then sweeps snapshots of dropped
  checkpoints the index never recorded by name. A failed delete keeps its
  marker for the next release.
- checkpoint_state_dir() requires checkpoint.state_dir (added to
  CheckpointSettings) once checkpointing is on.
- OpenSandbox's snapshots.py cleanup tool gains --name-prefix, so an operator deletes the
  snapshots a job left when it ended for good: --name-prefix ng-<run_id>- --reap.

Provenance: nemo_gym/sandbox/checkpoint.py of #4220 and #4779 (legacy stack),
moved out of nemo_gym.sandbox, without park/on_stop (stop-commit is deferred).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
gwarmstrong pushed a commit to gwarmstrong/Gym that referenced this pull request Nov 16, 2026
…kpointer (NVIDIA-NeMo#5265)

* feat(sandbox): snapshot, list and delete OpenSandbox snapshots, with a renewable lease

Adds the optional provider capabilities partial-rollout checkpoints need on the
sandbox side, and implements them for OpenSandbox:

- SupportsSandboxSnapshot: snapshot(handle, name) starts a snapshot and returns
  its id at once; wait_snapshot_ready, delete_snapshot (404 is gone) and
  list_snapshots(prefix) go over the management API through Gym's shared
  aiohttp client. 429, 5xx and connection errors are retried; a 404 for a
  snapshot the API has only just created is waited out for
  snapshot_lookup_grace_s. The API's name filter matches whole names, so a
  prefix listing reads every page and filters client-side. A fork stays
  create(provider_options.snapshot_id), as on main.
- A renewable lease (create.renew_ttl_s): each sandbox is created with the
  lease, capped by the spec's ttl_s, and renewed every renew_interval_s
  (jittered) with renew_timeout_s per call, never past the spec's lifetime. A
  failed lease renewal is logged and retried; a renewal that finds the sandbox
  gone ends the loop quietly in both modes. Off by default: shipping it would
  break configs that set a longer renew_interval_s (swe_together, TB4).
- SupportsSandboxCheckpointPolling / SupportsSandboxParkedPolling and the
  AsyncSandbox.checkpoint_exec_polling() / parked_exec_polling() scopes: a
  harness stopped for a checkpoint is seen to end within
  checkpoint_background_poll_interval_s, and a sandbox paused for a snapshot is
  not polled until the park ends, forgiving one status request that failed
  meanwhile.
- AsyncSandbox.provider, owns_provider and handle properties.

Provenance: the provider half of NVIDIA-NeMo#4220, NVIDIA-NeMo#4553 and NVIDIA-NeMo#4779 (legacy stack), rebuilt
on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* feat(checkpoint): sandbox checkpointer with a snapshot index and release

SandboxSessionCheckpointer (nemo_gym/_checkpoint/sandbox.py) checkpoints the
sandboxes a server owns, by an opaque key, for any owner: a resources server,
an agent or an environment server.

- export(keys, checkpoint_id) snapshots each live sandbox; a key without one
  exports None. Every snapshot is indexed under
  <state_dir>/<server>/snapshots/<checkpoint>/<snapshot> as soon as its id
  returns, before the readiness wait. A failed snapshot is taken again up to
  snapshot_attempts times; the backend semaphore covers the submit only, not
  the readiness wait.
- Snapshot names are ng-<run>-<server>-<checkpoint>-<key>-<attempt>, with
  short hashes and a run id written once into state_dir.
- restore(states) validates everything, forks all or nothing (rolling back
  its own forks), retries a fork the store cannot find yet, and stops the
  superseded sandboxes in the background.
- release(kept) deletes, under a file lock shared by every process of the
  server, the indexed snapshots of every checkpoint not kept, including a
  crashed process's and a failed commit's, then sweeps snapshots of dropped
  checkpoints the index never recorded by name. A failed delete keeps its
  marker for the next release.
- checkpoint_state_dir() requires checkpoint.state_dir (added to
  CheckpointSettings) once checkpointing is on.
- OpenSandbox's snapshots.py cleanup tool gains --name-prefix, so an operator deletes the
  snapshots a job left when it ended for good: --name-prefix ng-<run_id>- --reap.

Provenance: nemo_gym/sandbox/checkpoint.py of NVIDIA-NeMo#4220 and NVIDIA-NeMo#4779 (legacy stack),
moved out of nemo_gym.sandbox, without park/on_stop (stop-commit is deferred).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(sandbox): let each provider create a sandbox from its snapshots, with a typed not-found error

The snapshot protocol made `create` with `provider_options["snapshot_id"]` and no image the way to fork a
snapshot, which is OpenSandbox's API: a provider whose snapshots are created another way (an E2B template id, for
one) could not implement it. `SupportsSandboxSnapshot.create_from_snapshot` now owns that step;
`AsyncSandbox.start(snapshot_id=...)` calls it, and OpenSandbox implements it as the option it already took.

The checkpointer's fork retried on `"NOT_FOUND" in repr(error)`. Providers now raise
`SandboxSnapshotNotFoundError` for a snapshot they do not have, and the fork retries on that type only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(sandbox): await snapshot release, type the snapshot contract, and bound its requests

Addresses the review of the sandbox snapshot provider and checkpointer.

Checkpointer:
- release() deletes before it returns and takes the index lock without
  blocking, so the participant that awaits it admits no commit meanwhile
  and a cancelled wait cannot end up holding the lock. It raises
  SnapshotReleaseError when a delete failed, and says why when the index
  cannot be locked.
- restore() stops its completed forks when it is cancelled, logs a fork
  whose rollback stop failed and stops it again on the next restore, and
  refuses a state of a format version it does not know.
- A key is taken while its sandbox is created or restored, so two
  creates for one key start one sandbox.
- The sweep deletes only names the checkpointer gives; the index listing
  skips a folder that vanished; a spec that is not JSON fails the export
  before any snapshot; settle() only waits.
- The saved state carries a version and snapshot_ready_ts.

Provider contract and OpenSandbox:
- list_snapshots returns SandboxSnapshotInfo; failed, in-use and missing
  snapshots raise typed errors that carry the server's reason.
- create_from_snapshot recognizes SNAPSHOT::NOT_FOUND under the create
  wrapper, so the checkpointer's fork retry runs.
- Management requests are sent once within a short timeout and retried by
  their callers, connection errors and cut-off replies included; a 404 to
  a delete is confirmed with a lookup.
- Renewal jitter never exceeds the interval, the first renewal counts the
  time the create spent, and a vanished sandbox fails a sandbox without a
  lease as before.
- The final log read of a finished command waits out a park.

The lease stays off in the shipped config, with the reason in a comment.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>

* fix(sandbox): start the lease at the create request, track unstopped forks, and bound snapshot cleanup

Addresses the second review round of the sandbox snapshot provider and
checkpointer.

Checkpointer:
- release() is now delete_snapshots(kept) and SnapshotReleaseError is
  SnapshotDeleteIncompleteError: the lending code already uses "release"
  for stopping a session's sandbox.
- The state directory's ID is read from <state_dir>/state_dir_id, not
  run_id, which names a collection run elsewhere in Gym.
- A fork a restore will not install is tracked from before its stop
  until the stop succeeds, so a failed or cancelled stop cannot lose it.
  settle() stops such forks again, and the new aclose() stops every
  tracked sandbox and fork at shutdown.
- access() serializes with scope="operate": a borrower may run commands
  in the sandbox but not destroy it.
- export() warns once the index holds more than five checkpoints, and
  again when that doubles: nothing but a release deletes a snapshot.
- It snapshots through AsyncSandbox.snapshot() instead of the provider
  handle.

Sandbox API and provider contract:
- AsyncSandbox gains snapshot(name=...) and a started flag; the public
  handle accessor is removed.
- SandboxSnapshotNotFoundError derives from SandboxSnapshotError (and
  LookupError) and carries snapshot_id.
- SupportsSandboxSnapshot states that a provider must keep a snapshot's
  name and return it from list_snapshots.

OpenSandbox:
- The lease clock starts when the create request is sent, which is when
  the server starts the TTL, so the first renewal accounts for placement
  and the image pull as well as the setup.
- A parked command's poll is held only until the command's client wait
  runs out, not until the park ends.
- Management requests take the server and key from the SDK's connection
  config, so OPEN_SANDBOX_DOMAIN and OPEN_SANDBOX_API_KEY apply to them
  as they do to the SDK's own requests.
- One listing and one delete each have an overall budget
  (operations.snapshot_list_timeout_s, snapshot_delete_timeout_s); the
  listing asks for the server's largest page (200) and ends on an empty
  page.

Docs: a state_dir belongs to one job and its restarts; snapshots are
deleted only by a release and the service does not expire them; the
lease runs from the create request; the module docstring states the
provider-neutral contract and the OpenSandbox and Lustre specifics move
to the OpenSandbox page and the state_dir setting.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>

* fix(sandbox): treat a bare 404 on a create from a snapshot as snapshot not found

A live OpenSandbox service answers a create from a snapshot it has
deleted with HTTP 404 and no error code in the body, so the SDK's error
carried no SNAPSHOT::NOT_FOUND and create_from_snapshot raised a generic
create failure. The checkpointer's retry of a fork whose snapshot is not
found, and a caller that handles SandboxSnapshotNotFoundError, never saw
the typed error.

create_from_snapshot now raises SandboxSnapshotNotFoundError for that
404 as well. The create names nothing else that could be missing: the
snapshot stands in for the image.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>

* fix(sandbox): keep changed exec defaults across a restore and retry a failed lease renewal in time

- A checkpoint records the sandbox's current default user and working directory, so a fork runs commands as
  setup left them rather than as the sandbox was created.
- The spec's lifetime is counted from the create request, so renewals cannot extend a sandbox past its ttl_s
  by the time its startup took.
- A failed lease renewal is tried again within what is left of the lease, sooner as the expiry nears, instead
  of a full interval later.
- A snapshot listing page that has items must say whether another page follows; a missing or mistyped flag
  raises instead of returning a partial listing.
- A command poll waits for its wakeup under a timeout instead of racing two helper tasks.
- A release does not read the index folders of the checkpoints it keeps.

Signed-off-by: Pranav Prashant Thombre <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>

* fix(sandbox): close the checkpointer before a shutdown stops its sandboxes and jitter lease renewal retries

- aclose closes the checkpointer, so create, add and restore are refused, waits for the ones already
  running, and then stops the sandboxes; a restore that installs its forks during a shutdown has them stopped.
- Every sandbox stop has a time limit, so one that hangs does not hold up a shutdown.
- A create from a snapshot counts an HTTP 404 as a missing snapshot only when the SDK parsed no error code;
  a 404 with a code about the sandbox keeps its own type.
- A failed lease renewal's retry wait is jittered, so sandboxes created together do not retry in step.
- add's docstring says the default user and working directory of a fork come from the sandbox at export.
- Tests: a cancelled restore whose fork's stop fails keeps the fork tracked; the lookup-grace test no longer
  depends on an earlier test importing the SDK.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

---------

Signed-off-by: Pranav Thombre <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants