Skip to content

Commit 1711241

Browse files
committed
fix(onboard): honor explicit sandbox recreation
1 parent 8cdc3c4 commit 1711241

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/lib/onboard/machine/handlers/sandbox-checkpoint-crash-recovery.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,28 @@ describe("sandbox crash-recovery replay (#5961, #6228)", () => {
924924
expect(calls.error.mock.calls.flat().join("\n")).toContain("--recreate-sandbox");
925925
});
926926

927+
it("recreates after build or policy drift when explicitly requested (#9297)", async () => {
928+
const session = sessionWithCheckpoint(
929+
crashedCheckpoint({
930+
effectGroups: {
931+
sandbox_create: { completedAt: "2026-01-01T00:00:00.000Z", fingerprint: "stale-build" },
932+
},
933+
}),
934+
);
935+
session.machine.state = "openclaw";
936+
const { deps, calls } = createDeps({ getSandboxReuseState: () => "ready" }, session);
937+
938+
await handleSandboxState({
939+
...baseOptions(deps, session),
940+
resume: true,
941+
sandboxName: "my-assistant",
942+
recreateSandbox: () => true,
943+
});
944+
945+
expect(calls.createSandbox).toHaveBeenCalledOnce();
946+
expect(calls.error).not.toHaveBeenCalled();
947+
});
948+
927949
it("rejects reuse when a resolved policy or package input drifted despite an unchanged build version and policy tier (#7022)", async () => {
928950
const { deps, calls } = createDeps({ getSandboxReuseState: () => "ready" });
929951
const session = sessionWithCheckpoint(crashedCheckpoint());

src/lib/onboard/machine/handlers/sandbox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ class SandboxStateFlow<
851851
sandboxName: string,
852852
createIntent: ResolvedSandboxCreateIntent,
853853
): void {
854+
if (this.options.recreateSandbox(false)) return;
854855
const recordedFingerprint = state.session?.checkpoint?.effectGroups.sandbox_create?.fingerprint;
855856
if (!recordedFingerprint) return;
856857
// Older and reuse-backfilled receipts contain the stable create-input prefix.

0 commit comments

Comments
 (0)