From f234cae92159d0195358f102f5280ab1368f89ba Mon Sep 17 00:00:00 2001 From: Tinson Lai Date: Tue, 4 Aug 2026 08:33:07 +0000 Subject: [PATCH 1/3] fix(sandbox): remove the incomplete snapshot when creation fails Writing the manifest publishes a snapshot, and it ran before the failed directories and state files were weighed, so a failed create left a listable and restorable capture behind. Pass --keep-failed or set NEMOCLAW_KEEP_FAILED_SNAPSHOT=1 to keep it for diagnosis. Rebuild and backup-all keep their partial-manifest salvage. Signed-off-by: Tinson Lai --- docs/manage-sandboxes/backup-restore.mdx | 6 + docs/reference/commands.mdx | 12 ++ src/commands/sandbox/snapshot.test.ts | 11 + src/commands/sandbox/snapshot/create.ts | 14 +- .../snapshot-failed-create-cleanup.test.ts | 195 ++++++++++++++++++ src/lib/actions/sandbox/snapshot.test.ts | 21 -- src/lib/actions/sandbox/snapshot.ts | 39 +++- src/lib/cli/public-display-defaults.ts | 2 +- ...andbox-incomplete-snapshot-removal.test.ts | 68 ++++++ src/lib/state/sandbox.ts | 21 ++ test/snapshot.test.ts | 33 +++ 11 files changed, 397 insertions(+), 25 deletions(-) create mode 100644 src/lib/actions/sandbox/snapshot-failed-create-cleanup.test.ts create mode 100644 src/lib/state/sandbox-incomplete-snapshot-removal.test.ts diff --git a/docs/manage-sandboxes/backup-restore.mdx b/docs/manage-sandboxes/backup-restore.mdx index 10f2d02d2d4..af02cd75eb0 100644 --- a/docs/manage-sandboxes/backup-restore.mdx +++ b/docs/manage-sandboxes/backup-restore.mdx @@ -100,6 +100,12 @@ Tag a snapshot with a human-readable label: $$nemoclaw my-assistant snapshot create --name before-upgrade ``` +When a directory or state file cannot be captured, `snapshot create` reports the failed items, removes the incomplete snapshot, and exits nonzero. +`snapshot list` shows no new entry, so a later restore cannot select a capture that never completed. + +To keep the incomplete snapshot for diagnosis, pass `--keep-failed` or set `NEMOCLAW_KEEP_FAILED_SNAPSHOT=1`. +A kept snapshot is listed and restorable like any other, so remove it once you no longer need it. + ## Restore a Snapshot Restore the latest snapshot: diff --git a/docs/reference/commands.mdx b/docs/reference/commands.mdx index 4d71c30eac9..e3222108b1c 100644 --- a/docs/reference/commands.mdx +++ b/docs/reference/commands.mdx @@ -2967,6 +2967,7 @@ $$nemoclaw my-assistant snapshot create | Flag | Description | |------|-------------| | `--name