Repository navigation
fix(sandbox): observe host gateway on probe-only and wait for readiness before probing #7192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
22f846a
fix(sandbox): observe host gateway on probe-only and wait for readine…
laitingsheng 5142c39
test(cli): update sandbox fixtures for probe-only readiness wait
laitingsheng 813f348
docs(sandbox): scope host-gateway recovery guidance to openclaw/hermes
laitingsheng 7b81e32
fix(sandbox): recheck probe target after readiness
apurvvkumaria 5fd4f79
docs(sandbox): document probe readiness boundary
apurvvkumaria 67ebc87
fix(sandbox): pin readiness polls to owning gateway
apurvvkumaria 9e4bf99
docs(sandbox): clarify host gateway recovery boundary
apurvvkumaria 9b47d01
test(sandbox): assert timeout avoids recovery
apurvvkumaria 74700b2
test(sandbox): cover gateway-scoped readiness polls
apurvvkumaria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { afterEach, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest"; | ||
|
|
||
| import { | ||
| connectModulePath, | ||
| createConnectHarness, | ||
| requireDist, | ||
| } from "../../../../test/support/connect-flow-test-harness"; | ||
|
|
||
| describe("connectSandbox probe-only observe mode", () => { | ||
| let exitSpy: MockInstance; | ||
|
|
||
| beforeEach(() => { | ||
| process.env.NEMOCLAW_TEST_NO_SLEEP = "1"; | ||
| exitSpy = vi.spyOn(process, "exit").mockImplementation(((code?: number | string | null) => { | ||
| throw new Error(`process.exit(${code ?? 0})`); | ||
| }) as never); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| vi.unstubAllEnvs(); | ||
| delete process.env.NEMOCLAW_TEST_NO_SLEEP; | ||
| delete process.env.NEMOCLAW_CONNECT_TIMEOUT; | ||
| delete require.cache[requireDist.resolve(connectModulePath)]; | ||
| }); | ||
|
|
||
| it("passes gatewayRecovery=observe to ensureLiveSandboxOrExit on probeOnly", async () => { | ||
| const harness = createConnectHarness(); | ||
|
|
||
| await expect(harness.connectSandbox("alpha", { probeOnly: true })).resolves.toBeUndefined(); | ||
|
|
||
| expect(harness.ensureLiveSandboxSpy).toHaveBeenCalledWith( | ||
| "alpha", | ||
| expect.objectContaining({ allowNonReadyPhase: true, gatewayRecovery: "observe" }), | ||
| ); | ||
| expect(exitSpy).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("uses gatewayRecovery=recover on the full connect path", async () => { | ||
| const harness = createConnectHarness(); | ||
|
|
||
| await expect(harness.connectSandbox("alpha")).rejects.toThrow("process.exit(0)"); | ||
|
|
||
| expect(harness.ensureLiveSandboxSpy).toHaveBeenCalledWith( | ||
| "alpha", | ||
| expect.objectContaining({ allowNonReadyPhase: true, gatewayRecovery: "recover" }), | ||
| ); | ||
| }); | ||
|
|
||
| it("re-observes the live sandbox after delayed readiness before process or forward recovery (#7173)", async () => { | ||
| const harness = createConnectHarness({ | ||
| registryEntry: { gatewayPort: 8091 }, | ||
| listOutputs: ["alpha Starting", "alpha Ready"], | ||
| processCheck: { | ||
| checked: true, | ||
| wasRunning: true, | ||
| recovered: false, | ||
| forwardRecovered: true, | ||
| }, | ||
| }); | ||
|
|
||
| await expect(harness.connectSandbox("alpha", { probeOnly: true })).resolves.toBeUndefined(); | ||
|
|
||
| const listInvocations = harness.captureOpenshellSpy.mock.invocationCallOrder.filter( | ||
| (_, index) => { | ||
| const call = harness.captureOpenshellSpy.mock.calls[index]; | ||
| return ( | ||
| Array.isArray(call?.[0]) && | ||
| (call[0] as string[])[0] === "sandbox" && | ||
| (call[0] as string[])[1] === "list" | ||
| ); | ||
| }, | ||
| ); | ||
| expect(listInvocations).toHaveLength(2); | ||
| const listArgs = harness.captureOpenshellSpy.mock.calls | ||
| .map((call) => call[0]) | ||
| .filter( | ||
| (args): args is string[] => | ||
| Array.isArray(args) && args[0] === "sandbox" && args[1] === "list", | ||
| ); | ||
| expect(listArgs).toEqual([ | ||
| ["sandbox", "list", "-g", "nemoclaw-8091"], | ||
| ["sandbox", "list", "-g", "nemoclaw-8091"], | ||
| ]); | ||
| const liveLookupOrder = harness.ensureLiveSandboxSpy.mock.invocationCallOrder; | ||
| expect(liveLookupOrder).toHaveLength(2); | ||
| const recoveryOrder = harness.checkAndRecoverSpy.mock.invocationCallOrder; | ||
| expect(recoveryOrder).toHaveLength(1); | ||
| expect(listInvocations[1]).toBeLessThan(liveLookupOrder[1]); | ||
| expect(liveLookupOrder[1]).toBeLessThan(recoveryOrder[0]); | ||
| expect(harness.logSpy).toHaveBeenCalledWith( | ||
| expect.stringContaining("restored dashboard port forward"), | ||
| ); | ||
| }); | ||
|
|
||
| it("does not run process or forward recovery for a terminal sandbox phase (#7173)", async () => { | ||
| const harness = createConnectHarness({ listOutput: "alpha Error" }); | ||
|
|
||
| await expect(harness.connectSandbox("alpha", { probeOnly: true })).rejects.toThrow( | ||
| "process.exit(1)", | ||
| ); | ||
|
|
||
| expect(harness.ensureLiveSandboxSpy).toHaveBeenCalledOnce(); | ||
| expect(harness.checkAndRecoverSpy).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("suggests a longer equivalent retry when probe-only readiness times out", async () => { | ||
| vi.spyOn(Date, "now").mockReturnValueOnce(0).mockReturnValue(300_001); | ||
| const harness = createConnectHarness({ listOutput: "alpha Starting" }); | ||
|
|
||
| await expect(harness.connectSandbox("alpha", { probeOnly: true })).rejects.toThrow( | ||
| "process.exit(1)", | ||
| ); | ||
|
|
||
| const errors = harness.errorSpy.mock.calls.map((call) => String(call[0])).join("\n"); | ||
| expect(errors).toContain("Timed out after 300s waiting for sandbox 'alpha'"); | ||
| expect(errors).toContain("NEMOCLAW_CONNECT_TIMEOUT=600 nemoclaw alpha connect --probe-only"); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| expect(harness.checkAndRecoverSpy).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.