From bebde179d5d9f6a55c9969b1fc68298cd018ee8b Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 11:12:29 -0700 Subject: [PATCH 1/6] test(e2e): validate native GPU sandbox topology Co-authored-by: hulynn Signed-off-by: Apurv Kumaria --- test/e2e/live/gpu-e2e.test.ts | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/e2e/live/gpu-e2e.test.ts b/test/e2e/live/gpu-e2e.test.ts index f6e0f548b5a..3c5beb80b4d 100644 --- a/test/e2e/live/gpu-e2e.test.ts +++ b/test/e2e/live/gpu-e2e.test.ts @@ -184,7 +184,43 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { expect(resultText(status)).toMatch(/CUDA verified|CUDA unverified|last CUDA proof failed/i); expect(resultText(status)).not.toMatch(/last CUDA proof failed|CUDA unverified/i); - assertGpuInstallProofs(resultText(install)); + const installLog = resultText(install); + assertGpuInstallProofs(installLog); + expect(installLog).toContain( + "Direct sandbox GPU enabled; allowing OpenShell GPU policy enrichment.", + ); + expect(installLog).not.toContain( + "Recreating OpenShell Docker sandbox container with NVIDIA GPU access", + ); + expect(installLog).not.toContain("Docker GPU mode selected:"); + + const sandboxContainers = await host.command( + "docker", + [ + "ps", + "-a", + "--filter", + `label=openshell.ai/sandbox-name=${SANDBOX_NAME}`, + "--format", + "{{.Names}}", + ], + { + artifactName: "gpu-native-route-sandbox-containers", + env: buildAvailabilityProbeEnv(), + timeoutMs: 30_000, + }, + ); + expect(sandboxContainers.exitCode, resultText(sandboxContainers)).toBe(0); + const sandboxContainerNames = sandboxContainers.stdout + .split(/\r?\n/) + .map((line) => line.trim()) + .filter(Boolean); + expect( + sandboxContainerNames, + `native GPU route must retain exactly one sandbox container; got ${sandboxContainers.stdout}`, + ).toHaveLength(1); + expect(sandboxContainerNames[0]).not.toContain("-nemoclaw-gpu-backup-"); + const route = await sandbox.openshell(["inference", "get"], { artifactName: "openshell-inference-route", env: env(), From 6cdf24ff3307f335af6a9bee3d00274fc7737c57 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 11:32:30 -0700 Subject: [PATCH 2/6] test(e2e): require healthy native GPU sandbox Co-authored-by: hulynn Signed-off-by: Apurv Kumaria --- test/e2e/live/gpu-e2e.test.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test/e2e/live/gpu-e2e.test.ts b/test/e2e/live/gpu-e2e.test.ts index 3c5beb80b4d..4c8b8f6d626 100644 --- a/test/e2e/live/gpu-e2e.test.ts +++ b/test/e2e/live/gpu-e2e.test.ts @@ -192,7 +192,7 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { expect(installLog).not.toContain( "Recreating OpenShell Docker sandbox container with NVIDIA GPU access", ); - expect(installLog).not.toContain("Docker GPU mode selected:"); + expect(installLog).not.toContain("Docker GPU mode selected"); const sandboxContainers = await host.command( "docker", @@ -202,7 +202,7 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { "--filter", `label=openshell.ai/sandbox-name=${SANDBOX_NAME}`, "--format", - "{{.Names}}", + "{{json .}}", ], { artifactName: "gpu-native-route-sandbox-containers", @@ -211,15 +211,26 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { }, ); expect(sandboxContainers.exitCode, resultText(sandboxContainers)).toBe(0); - const sandboxContainerNames = sandboxContainers.stdout + const sandboxContainerInventory = sandboxContainers.stdout .split(/\r?\n/) .map((line) => line.trim()) - .filter(Boolean); + .filter(Boolean) + .map( + (line) => + JSON.parse(line) as { + Names?: string; + State?: string; + Status?: string; + }, + ); expect( - sandboxContainerNames, + sandboxContainerInventory, `native GPU route must retain exactly one sandbox container; got ${sandboxContainers.stdout}`, ).toHaveLength(1); - expect(sandboxContainerNames[0]).not.toContain("-nemoclaw-gpu-backup-"); + const retainedSandboxContainer = sandboxContainerInventory[0]; + expect(retainedSandboxContainer.Names).not.toContain("-nemoclaw-gpu-backup-"); + expect(retainedSandboxContainer.State).toBe("running"); + expect(retainedSandboxContainer.Status).toMatch(/\(healthy\)/i); const route = await sandbox.openshell(["inference", "get"], { artifactName: "openshell-inference-route", From dc94801fbf526dc0f2d70fa90b7a942ba448a650 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 12:32:48 -0700 Subject: [PATCH 3/6] test(gpu): require Ready OpenShell phase Co-authored-by: hulynn Signed-off-by: Apurv Kumaria --- test/e2e/live/gpu-e2e.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/e2e/live/gpu-e2e.test.ts b/test/e2e/live/gpu-e2e.test.ts index 4c8b8f6d626..75fb6d5fd58 100644 --- a/test/e2e/live/gpu-e2e.test.ts +++ b/test/e2e/live/gpu-e2e.test.ts @@ -240,6 +240,17 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { expect(route.exitCode, resultText(route)).toBe(0); expect(resultText(route)).toMatch(/ollama/i); + const readySandbox = await sandbox.openshell(["sandbox", "get", SANDBOX_NAME], { + artifactName: "openshell-sandbox-ready-after-inference", + env: buildAvailabilityProbeEnv(), + timeoutMs: 30_000, + }); + expect(readySandbox.exitCode, resultText(readySandbox)).toBe(0); + expect( + readySandbox.stdout.split(/\r?\n/).some((line) => line.trim() === "Phase: Ready"), + `OpenShell sandbox must be exactly Ready after routed inference; got ${resultText(readySandbox)}`, + ).toBe(true); + const tokenRecord = readTokenFileChecked(ollamaProxyTokenFile()); expect(tokenRecord.mode).toBe("600"); const token = tokenRecord.token; From 3e1c4d3767be3111555585264c042d31bee54eee Mon Sep 17 00:00:00 2001 From: Charan Jagwani Date: Thu, 16 Jul 2026 13:03:15 -0700 Subject: [PATCH 4/6] test(e2e): check Ready after routed inference Signed-off-by: Charan Jagwani --- test/e2e/live/gpu-e2e.test.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/e2e/live/gpu-e2e.test.ts b/test/e2e/live/gpu-e2e.test.ts index 44992437734..cb02cd38189 100644 --- a/test/e2e/live/gpu-e2e.test.ts +++ b/test/e2e/live/gpu-e2e.test.ts @@ -240,17 +240,6 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { expect(route.exitCode, resultText(route)).toBe(0); expect(resultText(route)).toMatch(/ollama/i); - const readySandbox = await sandbox.openshell(["sandbox", "get", SANDBOX_NAME], { - artifactName: "openshell-sandbox-ready-after-inference", - env: buildAvailabilityProbeEnv(), - timeoutMs: 30_000, - }); - expect(readySandbox.exitCode, resultText(readySandbox)).toBe(0); - expect( - readySandbox.stdout.split(/\r?\n/).some((line) => line.trim() === "Phase: Ready"), - `OpenShell sandbox must be exactly Ready after routed inference; got ${resultText(readySandbox)}`, - ).toBe(true); - const tokenRecord = readTokenFileChecked(ollamaProxyTokenFile()); expect(tokenRecord.mode).toBe("600"); const token = tokenRecord.token; @@ -313,6 +302,17 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { expect(chat.exitCode, resultText(chat)).toBe(0); expect(chatContent(chat.stdout)).toMatch(/pong/i); + const readySandbox = await sandbox.openshell(["sandbox", "get", SANDBOX_NAME], { + artifactName: "openshell-sandbox-ready-after-inference", + env: buildAvailabilityProbeEnv(), + timeoutMs: 30_000, + }); + expect(readySandbox.exitCode, resultText(readySandbox)).toBe(0); + expect( + readySandbox.stdout.split(/\r?\n/).some((line) => line.trim() === "Phase: Ready"), + `OpenShell sandbox must be exactly Ready after routed inference; got ${resultText(readySandbox)}`, + ).toBe(true); + const restart = await host.command( "bash", [ From 2bd90d62ecff2b49183b8573b7d2e5b32b2f82c4 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 13:34:16 -0700 Subject: [PATCH 5/6] test(e2e): tolerate ANSI in Ready phase Co-authored-by: Charan Jagwani Signed-off-by: Apurv Kumaria --- test/e2e/live/gpu-e2e-helpers.ts | 7 +++++++ test/e2e/live/gpu-e2e.test.ts | 3 ++- test/e2e/support/gpu-e2e-helpers.test.ts | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/e2e/live/gpu-e2e-helpers.ts b/test/e2e/live/gpu-e2e-helpers.ts index 3a2a24d3c57..ff8236d0762 100644 --- a/test/e2e/live/gpu-e2e-helpers.ts +++ b/test/e2e/live/gpu-e2e-helpers.ts @@ -11,6 +11,7 @@ import { type SandboxClient, validateSandboxName } from "../fixtures/clients/san import { expect } from "../fixtures/e2e-test.ts"; import { CLI_ENTRYPOINT, REPO_ROOT } from "../fixtures/paths.ts"; import type { ShellProbeResult } from "../fixtures/shell-probe.ts"; +import { stripAnsi } from "./json-envelope.ts"; export { REPO_ROOT }; @@ -117,6 +118,12 @@ export function chatContent(raw: string): string { ); } +export function hasExactReadyPhase(output: string): boolean { + return stripAnsi(output) + .split(/\r?\n/) + .some((line) => line.trim() === "Phase: Ready"); +} + function asRecord(value: unknown): Record | undefined { return value && typeof value === "object" && !Array.isArray(value) ? (value as Record) diff --git a/test/e2e/live/gpu-e2e.test.ts b/test/e2e/live/gpu-e2e.test.ts index cb02cd38189..c48c12f8ee5 100644 --- a/test/e2e/live/gpu-e2e.test.ts +++ b/test/e2e/live/gpu-e2e.test.ts @@ -16,6 +16,7 @@ import { detectOllamaModel, ensureOllama, env, + hasExactReadyPhase, ollamaProxyTokenFile, openClawModelConfigProjectionScript, PROXY_PORT, @@ -309,7 +310,7 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", { }); expect(readySandbox.exitCode, resultText(readySandbox)).toBe(0); expect( - readySandbox.stdout.split(/\r?\n/).some((line) => line.trim() === "Phase: Ready"), + hasExactReadyPhase(readySandbox.stdout), `OpenShell sandbox must be exactly Ready after routed inference; got ${resultText(readySandbox)}`, ).toBe(true); diff --git a/test/e2e/support/gpu-e2e-helpers.test.ts b/test/e2e/support/gpu-e2e-helpers.test.ts index 81ae262eaed..6ceb16f15e7 100644 --- a/test/e2e/support/gpu-e2e-helpers.test.ts +++ b/test/e2e/support/gpu-e2e-helpers.test.ts @@ -11,6 +11,7 @@ import { describe, expect, it } from "vitest"; import { assertAgentExecutionSucceeded, env, + hasExactReadyPhase, openClawModelConfigProjectionScript, } from "../live/gpu-e2e-helpers.ts"; @@ -139,6 +140,14 @@ describe("GPU E2E helpers", () => { ); }); + it("accepts an ANSI-colored exact Ready sandbox phase", () => { + expect(hasExactReadyPhase("Sandbox:\n \u001b[2mPhase:\u001b[0m Ready\n")).toBe(true); + }); + + it("rejects an ANSI-colored non-Ready sandbox phase", () => { + expect(hasExactReadyPhase("Sandbox:\n \u001b[2mPhase:\u001b[0m Error\n")).toBe(false); + }); + it("accepts successful execution proof when the model suppresses visible text", () => { expect(() => assertAgentExecutionSucceeded(agentOutput(), "inference", GPU_MODEL), From 6b69f86ad994121423de4d01a12f19769c7f45c5 Mon Sep 17 00:00:00 2001 From: Charan Jagwani Date: Thu, 16 Jul 2026 14:29:24 -0700 Subject: [PATCH 6/6] test(e2e): reject contradictory Ready phases Signed-off-by: Charan Jagwani --- test/e2e/live/gpu-e2e-helpers.ts | 6 ++++-- test/e2e/support/gpu-e2e-helpers.test.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/e2e/live/gpu-e2e-helpers.ts b/test/e2e/live/gpu-e2e-helpers.ts index ff8236d0762..026d2be622d 100644 --- a/test/e2e/live/gpu-e2e-helpers.ts +++ b/test/e2e/live/gpu-e2e-helpers.ts @@ -119,9 +119,11 @@ export function chatContent(raw: string): string { } export function hasExactReadyPhase(output: string): boolean { - return stripAnsi(output) + const phaseLines = stripAnsi(output) .split(/\r?\n/) - .some((line) => line.trim() === "Phase: Ready"); + .map((line) => line.trim()) + .filter((line) => line.startsWith("Phase:")); + return phaseLines.length === 1 && phaseLines[0] === "Phase: Ready"; } function asRecord(value: unknown): Record | undefined { diff --git a/test/e2e/support/gpu-e2e-helpers.test.ts b/test/e2e/support/gpu-e2e-helpers.test.ts index 6ceb16f15e7..5a0ae23e122 100644 --- a/test/e2e/support/gpu-e2e-helpers.test.ts +++ b/test/e2e/support/gpu-e2e-helpers.test.ts @@ -148,6 +148,15 @@ describe("GPU E2E helpers", () => { expect(hasExactReadyPhase("Sandbox:\n \u001b[2mPhase:\u001b[0m Error\n")).toBe(false); }); + it.each([ + ["Error before Ready", "Phase: Error\nPhase: Ready\n"], + ["Ready before Error", "Phase: Ready\nPhase: Error\n"], + ["prefixed Ready", "Current Phase: Ready\n"], + ["suffixed Ready", "Phase: Ready (stale)\n"], + ])("rejects %s output", (_case, output) => { + expect(hasExactReadyPhase(output)).toBe(false); + }); + it("accepts successful execution proof when the model suppresses visible text", () => { expect(() => assertAgentExecutionSucceeded(agentOutput(), "inference", GPU_MODEL),