From 35a162985ff218285c66fea775e933e3f85ecb02 Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Mon, 3 Aug 2026 21:13:53 -0400 Subject: [PATCH 1/8] fix(onboard): add capability-gated gateway removal hint renderer (#8139) --- ci/source-architecture-budget.json | 2 +- src/lib/onboard/gateway-removal-hint.test.ts | 34 ++++++++++++++++++++ src/lib/onboard/gateway-removal-hint.ts | 28 ++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/lib/onboard/gateway-removal-hint.test.ts create mode 100644 src/lib/onboard/gateway-removal-hint.ts diff --git a/ci/source-architecture-budget.json b/ci/source-architecture-budget.json index c7b2239d0cf..33f679dac41 100644 --- a/ci/source-architecture-budget.json +++ b/ci/source-architecture-budget.json @@ -55,7 +55,7 @@ }, "allowedCycles": [], "maxRootFiles": { - "src/lib/onboard": 310, + "src/lib/onboard": 311, "src/lib/actions": 19, "src/lib/actions/sandbox": 183, "src/lib/state": 37, diff --git a/src/lib/onboard/gateway-removal-hint.test.ts b/src/lib/onboard/gateway-removal-hint.test.ts new file mode 100644 index 00000000000..a6839a2ed8a --- /dev/null +++ b/src/lib/onboard/gateway-removal-hint.test.ts @@ -0,0 +1,34 @@ +import { describe, expect, it } from "vitest"; + +import { gatewayRemovalHintLines } from "./gateway-removal-hint"; + +describe("gatewayRemovalHintLines", () => { + it("prints only the modern remove verb when the installed OpenShell has no lifecycle commands (#8139)", () => { + const lines = gatewayRemovalHintLines("nemoclaw", false); + + expect(lines).toEqual([" openshell gateway remove nemoclaw"]); + expect(lines.join("\n")).not.toContain("gateway destroy"); + }); + + it("omits the legacy destroy verb when support is unknown", () => { + expect(gatewayRemovalHintLines("nemoclaw").join("\n")).not.toContain("gateway destroy"); + }); + + it("appends the legacy destroy verb only when the installed OpenShell advertises it", () => { + const lines = gatewayRemovalHintLines("nemoclaw", true); + + expect(lines).toEqual([ + " openshell gateway remove nemoclaw", + " # For OpenShell releases that still expose lifecycle commands:", + " openshell gateway destroy -g nemoclaw", + ]); + }); + + it("renders the caller's gateway name in every emitted command", () => { + const lines = gatewayRemovalHintLines("nemoclaw-8081", true); + + expect(lines).toContain(" openshell gateway remove nemoclaw-8081"); + expect(lines).toContain(" openshell gateway destroy -g nemoclaw-8081"); + expect(lines.join("\n")).not.toMatch(/\bnemoclaw\b(?!-8081)/); + }); +}); diff --git a/src/lib/onboard/gateway-removal-hint.ts b/src/lib/onboard/gateway-removal-hint.ts new file mode 100644 index 00000000000..9ff3edde458 --- /dev/null +++ b/src/lib/onboard/gateway-removal-hint.ts @@ -0,0 +1,28 @@ +/** + * Renders the manual gateway-removal command block shared by every onboard + * failure hint. + * + * OpenShell dropped the `gateway destroy` lifecycle verb in 0.0.44; current + * builds answer it with `error: unrecognized subcommand 'destroy'` (#8139). + * #6570 fixed the destroy-path hint but left the onboard hints printing the + * legacy verb behind a prose caveat the reader cannot evaluate, so gate it on + * the same capability probe the execution paths already use + * (`gatewayCliSupportsLifecycleCommands`). + * + * `supportsLifecycleCommands` defaults to false so an un-probed caller prints + * only the verb that current OpenShell accepts. + * + * Current consumers: gateway-start-failure.ts, gpu-recovery.ts, + * gateway-gpu-passthrough.ts. + */ +export function gatewayRemovalHintLines( + gatewayName: string, + supportsLifecycleCommands = false, +): string[] { + const lines = [` openshell gateway remove ${gatewayName}`]; + if (supportsLifecycleCommands) { + lines.push(" # For OpenShell releases that still expose lifecycle commands:"); + lines.push(` openshell gateway destroy -g ${gatewayName}`); + } + return lines; +} From d483e3e202638f59530cd6e83bd16760b44095b0 Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Mon, 3 Aug 2026 21:19:16 -0400 Subject: [PATCH 2/8] fix(onboard): add missing SPDX headers to gateway-removal-hint files --- src/lib/onboard/gateway-removal-hint.test.ts | 3 +++ src/lib/onboard/gateway-removal-hint.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/lib/onboard/gateway-removal-hint.test.ts b/src/lib/onboard/gateway-removal-hint.test.ts index a6839a2ed8a..0b78b1f2214 100644 --- a/src/lib/onboard/gateway-removal-hint.test.ts +++ b/src/lib/onboard/gateway-removal-hint.test.ts @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + import { describe, expect, it } from "vitest"; import { gatewayRemovalHintLines } from "./gateway-removal-hint"; diff --git a/src/lib/onboard/gateway-removal-hint.ts b/src/lib/onboard/gateway-removal-hint.ts index 9ff3edde458..2dbef688256 100644 --- a/src/lib/onboard/gateway-removal-hint.ts +++ b/src/lib/onboard/gateway-removal-hint.ts @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + /** * Renders the manual gateway-removal command block shared by every onboard * failure hint. From 88180d7e2b80cc8cf6743baed514b67d36b5af33 Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Mon, 3 Aug 2026 21:27:35 -0400 Subject: [PATCH 3/8] fix(onboard): gate the gateway start-failure legacy verb on CLI support (#8139) --- src/lib/onboard.ts | 1 + src/lib/onboard/gateway-start-failure.ts | 10 +++++-- test/gateway-final-failure-cleanup.test.ts | 32 +++++++++++++++++++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/lib/onboard.ts b/src/lib/onboard.ts index c2d87df914b..888caa33f66 100644 --- a/src/lib/onboard.ts +++ b/src/lib/onboard.ts @@ -1332,6 +1332,7 @@ const handleFinalGatewayStartFailure = createFinalGatewayStartFailureHandler({ timeout: 10_000, }), cleanupGateway: destroyGateway, + supportsLifecycleCommands: () => gatewayCliSupportsLifecycleCommands(runCaptureOpenshell), }); function getGatewayClusterContainerState(): string { diff --git a/src/lib/onboard/gateway-start-failure.ts b/src/lib/onboard/gateway-start-failure.ts index a2aa51c4741..2615e12285f 100644 --- a/src/lib/onboard/gateway-start-failure.ts +++ b/src/lib/onboard/gateway-start-failure.ts @@ -4,6 +4,7 @@ import { compactText } from "../core/url-utils"; import { redact } from "../security/redact"; import { classifyGatewayStartFailure } from "../validation"; +import { gatewayRemovalHintLines } from "./gateway-removal-hint"; const ANSI_RE = /\x1B(?:\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\)|[@-_])/g; @@ -14,12 +15,14 @@ export type FinalGatewayStartFailureOptions = { cleanupGateway?: () => void; exitProcess?: (code: number) => never; printError?: (message?: string) => void; + supportsLifecycleCommands?: () => boolean; }; export type FinalGatewayStartFailureDeps = { getGatewayName(): string; collectDiagnostics(): string | null | undefined; cleanupGateway(): void; + supportsLifecycleCommands?(): boolean; }; export function normalizeGatewayStartError(error: unknown): Error { @@ -66,6 +69,7 @@ export function createFinalGatewayStartFailureHandler(deps: FinalGatewayStartFai cleanupGateway = deps.cleanupGateway, exitProcess = (code) => process.exit(code), printError = (message = "") => console.error(message), + supportsLifecycleCommands = deps.supportsLifecycleCommands ?? (() => false), }: FinalGatewayStartFailureOptions): never { if (dockerUnreachable) { printDockerDaemonRecovery(printError); @@ -107,9 +111,9 @@ export function createFinalGatewayStartFailureHandler(deps: FinalGatewayStartFai printError(" openshell doctor check"); printError(""); printError(" If gateway cleanup did not complete, run:"); - printError(` openshell gateway remove ${gatewayName}`); - printError(" # For OpenShell releases that still expose lifecycle commands:"); - printError(` openshell gateway destroy -g ${gatewayName}`); + for (const line of gatewayRemovalHintLines(gatewayName, supportsLifecycleCommands())) { + printError(line); + } if (process.platform === "linux") { printError( " sudo pkill -f openshell-gateway # if a privileged host gateway process remains", diff --git a/test/gateway-final-failure-cleanup.test.ts b/test/gateway-final-failure-cleanup.test.ts index c3dd1e6bebd..ae8bcff379c 100644 --- a/test/gateway-final-failure-cleanup.test.ts +++ b/test/gateway-final-failure-cleanup.test.ts @@ -9,6 +9,7 @@ type FinalGatewayStartFailureOptions = { cleanupGateway?: () => void; exitProcess?: (code: number) => never; printError?: (message?: string) => void; + supportsLifecycleCommands?: () => boolean; }; type OnboardGatewayFailureInternals = { @@ -64,7 +65,7 @@ describe("final gateway startup failure cleanup", () => { expect(errors).toContain(" gateway log line"); expect(errors).toContain(" Cleanup attempted."); expect(errors).toContain(" openshell gateway remove nemoclaw"); - expect(errors).toContain(" openshell gateway destroy -g nemoclaw"); + expect(errors).not.toContain(" openshell gateway destroy -g nemoclaw"); if (process.platform === "linux") { expect(errors).toContain( " sudo pkill -f openshell-gateway # if a privileged host gateway process remains", @@ -110,4 +111,33 @@ describe("final gateway startup failure cleanup", () => { expect(errors).toContain(" openshell doctor logs --name nemoclaw"); expect(errors).toContain(" If gateway cleanup did not complete, run:"); }); + + it("prints the legacy gateway destroy verb only when the installed OpenShell advertises it (#8139)", () => { + const collect = (supportsLifecycleCommands: boolean): string[] => { + const errors: string[] = []; + expect(() => + handleFinalGatewayStartFailure({ + retries: 0, + collectDiagnostics: () => "", + cleanupGateway: () => {}, + exitProcess: (code: number): never => { + throw new Error(`exit ${code}`); + }, + printError: (message = "") => { + errors.push(message); + }, + supportsLifecycleCommands: () => supportsLifecycleCommands, + }), + ).toThrow("exit 1"); + return errors; + }; + + const modern = collect(false); + expect(modern).toContain(" openshell gateway remove nemoclaw"); + expect(modern.join("\n")).not.toContain("gateway destroy"); + + const legacy = collect(true); + expect(legacy).toContain(" openshell gateway remove nemoclaw"); + expect(legacy).toContain(" openshell gateway destroy -g nemoclaw"); + }); }); From f225349c011e6bf549936b19c18b47c93c8cbeee Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Mon, 3 Aug 2026 21:39:09 -0400 Subject: [PATCH 4/8] test(onboard): pin the gateway destroy-verb capability seams (#8139) Pass an explicit supportsLifecycleCommands: () => false override in the pre-existing production-wired test so it no longer falls through to the real openshell binary probe, which can process.exit(1) the vitest worker when no openshell binary is resolvable. Add a deps-level test in gateway-start-failure.test.ts that constructs the handler with supportsLifecycleCommands in deps and no per-call override, covering the deps ?? (() => false) fallthrough that was previously only reached incidentally. --- src/lib/onboard/gateway-start-failure.test.ts | 22 +++++++++++++++++++ test/gateway-final-failure-cleanup.test.ts | 1 + 2 files changed, 23 insertions(+) diff --git a/src/lib/onboard/gateway-start-failure.test.ts b/src/lib/onboard/gateway-start-failure.test.ts index da5a991efb7..1c23e338bf9 100644 --- a/src/lib/onboard/gateway-start-failure.test.ts +++ b/src/lib/onboard/gateway-start-failure.test.ts @@ -125,4 +125,26 @@ describe("createFinalGatewayStartFailureHandler", () => { expect(output).not.toContain("fghijklmno"); expect(output).toMatch(/NVIDIA_API_KEY=ghp_\*+/); }); + + it("prints the legacy destroy verb from the deps-level supportsLifecycleCommands when no per-call override is given (#8139)", () => { + const printed: string[] = []; + const handleFailure = createFinalGatewayStartFailureHandler({ + getGatewayName: () => "nemoclaw-test", + collectDiagnostics: () => "", + cleanupGateway: vi.fn(), + supportsLifecycleCommands: () => true, + }); + + expect(() => + handleFailure({ + retries: 0, + printError: (message = "") => printed.push(message), + exitProcess: (code): never => { + throw new Error(`exit ${code}`); + }, + }), + ).toThrow("exit 1"); + + expect(printed).toContain(" openshell gateway destroy -g nemoclaw-test"); + }); }); diff --git a/test/gateway-final-failure-cleanup.test.ts b/test/gateway-final-failure-cleanup.test.ts index ae8bcff379c..473dbe0f376 100644 --- a/test/gateway-final-failure-cleanup.test.ts +++ b/test/gateway-final-failure-cleanup.test.ts @@ -56,6 +56,7 @@ describe("final gateway startup failure cleanup", () => { printError: (message = "") => { errors.push(message); }, + supportsLifecycleCommands: () => false, }), ).toThrow("exit 1"); From c7f447f8c7f6588b60b1bd2500f5c3ac1e7f9e9f Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Mon, 3 Aug 2026 21:56:48 -0400 Subject: [PATCH 5/8] fix(onboard): gate the GPU recovery legacy verb on CLI support (#8139) Co-Authored-By: Claude Opus 5 --- src/lib/onboard/gpu-recovery.test.ts | 25 ++++++++++++++++++++++--- src/lib/onboard/gpu-recovery.ts | 6 +++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lib/onboard/gpu-recovery.test.ts b/src/lib/onboard/gpu-recovery.test.ts index 0b64953ac99..ca989008f1a 100644 --- a/src/lib/onboard/gpu-recovery.test.ts +++ b/src/lib/onboard/gpu-recovery.test.ts @@ -27,13 +27,13 @@ describe("gpuPassthroughRecoveryLines", () => { expect(joined).toContain("Existing gateway was started without GPU passthrough"); expect(joined).toContain("attempted safe gateway replacement automatically"); expect(joined).toContain("openshell gateway remove nemoclaw"); - expect(joined).toContain("openshell gateway destroy -g nemoclaw"); + expect(joined).not.toContain("openshell gateway destroy -g nemoclaw"); expect(joined).toContain("sudo pkill -f openshell-gateway"); expect(joined).toContain("nemoclaw onboard --gpu"); expect(joined).not.toContain("nemoclaw uninstall"); // Must NOT suggest the per-sandbox `nemoclaw destroy` form — there - // is nothing to destroy. (`openshell gateway destroy -g` is fine; it's - // the legacy gateway-lifecycle verb, not a sandbox destroy.) + // is nothing to destroy. The legacy `openshell gateway destroy -g` verb is + // also absent: current OpenShell rejects it (#8139). expect(joined).not.toMatch(/nemoclaw [a-z-]+ destroy/); }); @@ -90,6 +90,25 @@ describe("gpuPassthroughRecoveryLines", () => { expect(joined).not.toContain("destroy --yes"); expect(joined).not.toContain("nemoclaw onboard --gpu"); }); + + it("emits the legacy gateway destroy verb only when the installed OpenShell advertises it (#8139)", () => { + const modern = gpuPassthroughRecoveryLines([], { supportsLifecycleCommands: false }).join("\n"); + expect(modern).toContain("openshell gateway remove nemoclaw"); + expect(modern).not.toContain("gateway destroy"); + + const legacy = gpuPassthroughRecoveryLines([], { supportsLifecycleCommands: true }).join("\n"); + expect(legacy).toContain("openshell gateway remove nemoclaw"); + expect(legacy).toContain("openshell gateway destroy -g nemoclaw"); + }); + + it("keeps the legacy verb out of the sandbox-destroy branches regardless of CLI support", () => { + for (const names of [["alpha"], ["alpha", "beta"]]) { + const joined = gpuPassthroughRecoveryLines(names, { + supportsLifecycleCommands: true, + }).join("\n"); + expect(joined).not.toContain("gateway destroy"); + } + }); }); describe("reportGpuPassthroughRecovery", () => { diff --git a/src/lib/onboard/gpu-recovery.ts b/src/lib/onboard/gpu-recovery.ts index 97146ace69b..07cc33067b1 100644 --- a/src/lib/onboard/gpu-recovery.ts +++ b/src/lib/onboard/gpu-recovery.ts @@ -14,9 +14,11 @@ */ import * as registry from "../state/registry"; +import { gatewayRemovalHintLines } from "./gateway-removal-hint"; export type GpuPassthroughRecoveryOptions = { missingRuntimePlatform?: "jetson" | null; + supportsLifecycleCommands?: boolean; }; /** @@ -53,9 +55,7 @@ export function gpuPassthroughRecoveryLines( " Existing gateway was started without GPU passthrough.", " No sandboxes are registered, so onboard attempted safe gateway replacement automatically.", " If the retry still fails, clear the stale gateway state and re-onboard with GPU enabled:", - " openshell gateway remove nemoclaw", - " # For OpenShell releases that still expose lifecycle commands:", - " openshell gateway destroy -g nemoclaw", + ...gatewayRemovalHintLines("nemoclaw", options.supportsLifecycleCommands ?? false), " sudo pkill -f openshell-gateway # if a privileged host gateway process remains", " nemoclaw onboard --gpu", ]; From 154636bee629f1b12e9d323700e18968f15b6268 Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Mon, 3 Aug 2026 22:15:16 -0400 Subject: [PATCH 6/8] fix(onboard): gate the GPU passthrough legacy verb on CLI support (#8139) --- .../onboard/gateway-gpu-passthrough.test.ts | 60 +++++++++++++++++++ src/lib/onboard/gateway-gpu-passthrough.ts | 25 ++++++-- src/lib/onboard/machine/handlers/gateway.ts | 2 + 3 files changed, 81 insertions(+), 6 deletions(-) diff --git a/src/lib/onboard/gateway-gpu-passthrough.test.ts b/src/lib/onboard/gateway-gpu-passthrough.test.ts index 1505b201d55..17e1e754097 100644 --- a/src/lib/onboard/gateway-gpu-passthrough.test.ts +++ b/src/lib/onboard/gateway-gpu-passthrough.test.ts @@ -7,8 +7,13 @@ vi.mock("../adapters/docker", () => ({ dockerInspect: vi.fn(), })); +vi.mock("../state/registry", () => ({ + listSandboxes: vi.fn(() => ({ sandboxes: [], defaultSandbox: null })), +})); + import * as docker from "../adapters/docker"; import type { GatewayReuseState } from "../state/gateway"; +import * as registry from "../state/registry"; import { canRestartCpuOnlyGatewayForGpuIntent, decideGatewayGpuReuseForGpuIntent, @@ -162,4 +167,59 @@ describe("gateway GPU passthrough inspection", () => { expect(retireLegacyGatewayForDockerDriverUpgrade).not.toHaveBeenCalled(); expect(destroyGatewayRuntimeForGpuReuse).not.toHaveBeenCalled(); }); + + it("omits the legacy gateway destroy verb from the unreadable-registry hint (#8139)", () => { + const runReconcile = (supportsLifecycleCommands: boolean): string[] => { + const errors: string[] = []; + vi.mocked(docker.dockerInspect).mockReturnValue({ + pid: 0, + output: [null, "[]", ""], + stdout: "[]", + stderr: "", + status: 0, + signal: null, + }); + vi.mocked(registry.listSandboxes).mockImplementation(() => { + throw new Error("registry unreadable"); + }); + const errorSpy = vi.spyOn(console, "error").mockImplementation((message?: unknown) => { + errors.push(String(message)); + }); + const exitSpy = vi.spyOn(process, "exit").mockImplementation(((code?: number) => { + throw new Error(`exit ${code}`); + }) as never); + + try { + expect(() => + reconcileGatewayGpuReuseForGpuIntent({ + gatewayReuseState: healthy, + gpuPassthrough: true, + gatewayName: "nemoclaw", + currentSandboxName: null, + recreateSandbox: false, + confirmedDockerDriverGateway: false, + stopDashboardForwards: vi.fn(), + retireLegacyGatewayForDockerDriverUpgrade: vi.fn(), + destroyGatewayRuntimeForGpuReuse: vi.fn(), + supportsLifecycleCommands, + }), + ).toThrow(/exit 1/); + } finally { + errorSpy.mockRestore(); + exitSpy.mockRestore(); + // Explicitly restore the shared module mocks for later tests in this file. + vi.mocked(registry.listSandboxes).mockReturnValue({ sandboxes: [], defaultSandbox: null }); + vi.mocked(docker.dockerInspect).mockReset(); + } + return errors; + }; + + const modern = runReconcile(false).join("\n"); + expect(modern).toContain("openshell gateway remove nemoclaw"); + expect(modern).not.toContain("gateway destroy"); + + const legacy = runReconcile(true).join("\n"); + expect(legacy).toContain("openshell gateway remove nemoclaw"); + expect(legacy).toContain("openshell gateway destroy -g nemoclaw"); + }); }); diff --git a/src/lib/onboard/gateway-gpu-passthrough.ts b/src/lib/onboard/gateway-gpu-passthrough.ts index 15508e502ab..864e539e56f 100644 --- a/src/lib/onboard/gateway-gpu-passthrough.ts +++ b/src/lib/onboard/gateway-gpu-passthrough.ts @@ -7,6 +7,7 @@ import type { GatewayReuseState } from "../state/gateway"; import * as registry from "../state/registry"; import { isLinuxDockerDriverGatewayEnabled } from "./docker-driver-platform"; import { destroyGatewayForReuse } from "./gateway-cleanup"; +import { gatewayRemovalHintLines } from "./gateway-removal-hint"; import { reportGpuPassthroughRecovery } from "./gpu-recovery"; export type LegacyGatewayGpuInspection = "gpu-enabled" | "cpu-only" | "not-found" | "unknown"; @@ -30,6 +31,7 @@ export type GatewayGpuReuseReconcileOptions = { stopDashboardForwards: () => void; retireLegacyGatewayForDockerDriverUpgrade: () => void; destroyGatewayRuntimeForGpuReuse: () => boolean; + supportsLifecycleCommands?: boolean; }; // Docker-driver/package-managed gateways do not expose reusable GPU state @@ -109,6 +111,7 @@ function reportUnreadableSandboxRegistryForGpuGatewayReuse( error: (line: string) => void, exit: (code: number) => never, gatewayName: string, + supportsLifecycleCommands: boolean, ): never { error(" Existing gateway was started without GPU passthrough."); error( @@ -117,9 +120,9 @@ function reportUnreadableSandboxRegistryForGpuGatewayReuse( error( " Fix the registry read error and rerun, or manually verify no sandboxes depend on the gateway before running:", ); - error(` openshell gateway remove ${gatewayName}`); - error(" # For OpenShell releases that still expose lifecycle commands:"); - error(` openshell gateway destroy -g ${gatewayName}`); + for (const line of gatewayRemovalHintLines(gatewayName, supportsLifecycleCommands)) { + error(line); + } error(" sudo pkill -f openshell-gateway # if a privileged host gateway process remains"); error(" nemoclaw onboard --gpu"); exit(1); @@ -144,6 +147,7 @@ export function reconcileGatewayGpuReuseForGpuIntent({ stopDashboardForwards, retireLegacyGatewayForDockerDriverUpgrade, destroyGatewayRuntimeForGpuReuse, + supportsLifecycleCommands = false, }: GatewayGpuReuseReconcileOptions): GatewayReuseState { if ( !shouldInspectLegacyGatewayGpuPassthrough( @@ -174,7 +178,12 @@ export function reconcileGatewayGpuReuseForGpuIntent({ const registeredSandboxNames = legacyGatewayGpuInspection === "cpu-only" ? readRegisteredSandboxNamesForGatewayGpuReuse() : []; if (registeredSandboxNames === null) { - reportUnreadableSandboxRegistryForGpuGatewayReuse(console.error, process.exit, gatewayName); + reportUnreadableSandboxRegistryForGpuGatewayReuse( + console.error, + process.exit, + gatewayName, + supportsLifecycleCommands, + ); } const gatewayGpuReuseDecision = decideGatewayGpuReuseForGpuIntent({ @@ -206,11 +215,15 @@ export function reconcileGatewayGpuReuseForGpuIntent({ ); } if (gatewayReuseState !== "missing") { - reportGpuPassthroughRecovery(console.error, () => registeredSandboxNames); + reportGpuPassthroughRecovery(console.error, () => registeredSandboxNames, { + supportsLifecycleCommands, + }); process.exit(1); } } else if (gatewayGpuReuseDecision === "abort-with-recovery") { - reportGpuPassthroughRecovery(console.error, () => registeredSandboxNames); + reportGpuPassthroughRecovery(console.error, () => registeredSandboxNames, { + supportsLifecycleCommands, + }); process.exit(1); } return gatewayReuseState; diff --git a/src/lib/onboard/machine/handlers/gateway.ts b/src/lib/onboard/machine/handlers/gateway.ts index 9b98e17abbe..9319543feab 100644 --- a/src/lib/onboard/machine/handlers/gateway.ts +++ b/src/lib/onboard/machine/handlers/gateway.ts @@ -61,6 +61,7 @@ export interface GatewayStateOptions { hostGpuPlatform: NvidiaPlatform | null; recreateSandbox: boolean; confirmedDockerDriverGateway: boolean; + supportsLifecycleCommands: boolean; stopDashboardForwards: () => void; retireLegacyGatewayForDockerDriverUpgrade: () => void; destroyGatewayRuntimeForGpuReuse: () => boolean; @@ -211,6 +212,7 @@ async function handleGatewayStatePhase({ deps.isLinuxDockerDriverGatewayEnabled() && gatewayReuseState === "healthy" && !supportsLifecycleCommands, + supportsLifecycleCommands, stopDashboardForwards: deps.stopAllDashboardForwards, retireLegacyGatewayForDockerDriverUpgrade: deps.retireLegacyGatewayForDockerDriverUpgrade, destroyGatewayRuntimeForGpuReuse: deps.destroyGatewayRuntimeForGpuReuse, From 0b6f3424cd421441068b0ffcd9c15f06a269f0d7 Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Mon, 3 Aug 2026 23:07:16 -0400 Subject: [PATCH 7/8] test(onboard): close a live-probe CI hazard and cover the lifecycle flag forward (#8139) Add the missing supportsLifecycleCommands override to the second handleFinalGatewayStartFailure test in test/gateway-final-failure-cleanup.test.ts: without it, the call falls through to the live gatewayCliSupportsLifecycleCommands probe, which calls process.exit(1) inside the vitest worker on a runner without an openshell binary (killing the rest of that worker's tests). Add a test asserting handleGatewayState forwards gatewayCliSupportsLifecycleCommands()'s result unchanged to reconcileGatewayGpuReuseForGpuIntent, guarding against a wrong (inverted or hardcoded) value compiling clean. Document why the abort-with-recovery supportsLifecycleCommands argument in gateway-gpu-passthrough.ts is dead but intentionally kept for uniformity with its sibling call. --- src/lib/onboard/gateway-gpu-passthrough.ts | 6 +++++ .../onboard/machine/handlers/gateway.test.ts | 22 +++++++++++++++++++ test/gateway-final-failure-cleanup.test.ts | 1 + 3 files changed, 29 insertions(+) diff --git a/src/lib/onboard/gateway-gpu-passthrough.ts b/src/lib/onboard/gateway-gpu-passthrough.ts index 864e539e56f..a4e97af95d2 100644 --- a/src/lib/onboard/gateway-gpu-passthrough.ts +++ b/src/lib/onboard/gateway-gpu-passthrough.ts @@ -221,6 +221,12 @@ export function reconcileGatewayGpuReuseForGpuIntent({ process.exit(1); } } else if (gatewayGpuReuseDecision === "abort-with-recovery") { + // Defensive uniformity with the sibling call above: this branch is only + // reached with a non-empty registeredSandboxNames (abort-with-recovery + // implies !cpuOnlyGatewayRestartSafe, which implies names.length > 0), so + // gpuPassthroughRecoveryLines always takes its one-sandbox/multi-sandbox + // branch here and supportsLifecycleCommands cannot reach the gated + // gatewayRemovalHintLines output. reportGpuPassthroughRecovery(console.error, () => registeredSandboxNames, { supportsLifecycleCommands, }); diff --git a/src/lib/onboard/machine/handlers/gateway.test.ts b/src/lib/onboard/machine/handlers/gateway.test.ts index 0089a8d253a..2f1f497e595 100644 --- a/src/lib/onboard/machine/handlers/gateway.test.ts +++ b/src/lib/onboard/machine/handlers/gateway.test.ts @@ -530,6 +530,28 @@ describe("handleGatewayState", () => { expect(calls.startGateway).toHaveBeenCalledOnce(); expect(result.gatewayReuseState).toBe("missing"); }); + + it("forwards the CLI lifecycle-support probe result to the GPU reuse reconciler (#8139)", async () => { + const { deps: supportedDeps, calls: supportedCalls } = createDeps({ + gatewayCliSupportsLifecycleCommands: vi.fn(() => true), + }); + + await handleGatewayState(baseOptions(supportedDeps, "missing")); + + expect(supportedCalls.reconcileGpu).toHaveBeenCalledWith( + expect.objectContaining({ supportsLifecycleCommands: true }), + ); + + const { deps: unsupportedDeps, calls: unsupportedCalls } = createDeps({ + gatewayCliSupportsLifecycleCommands: vi.fn(() => false), + }); + + await handleGatewayState(baseOptions(unsupportedDeps, "missing")); + + expect(unsupportedCalls.reconcileGpu).toHaveBeenCalledWith( + expect.objectContaining({ supportsLifecycleCommands: false }), + ); + }); }); describe("externally supervised gateway lifecycle authority", () => { diff --git a/test/gateway-final-failure-cleanup.test.ts b/test/gateway-final-failure-cleanup.test.ts index 473dbe0f376..710e089995e 100644 --- a/test/gateway-final-failure-cleanup.test.ts +++ b/test/gateway-final-failure-cleanup.test.ts @@ -103,6 +103,7 @@ describe("final gateway startup failure cleanup", () => { printError: (message = "") => { errors.push(message); }, + supportsLifecycleCommands: () => false, }), ).toThrow("exit 1"); From f853cb0300178f595eccc459a3f9af5a96496455 Mon Sep 17 00:00:00 2001 From: Azeel Sajjad Date: Tue, 4 Aug 2026 19:27:29 -0400 Subject: [PATCH 8/8] fix(onboard): keep the onboard entrypoint net-neutral for the growth guardrail (#8139) --- src/lib/onboard.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/lib/onboard.ts b/src/lib/onboard.ts index 888caa33f66..f41c33cb539 100644 --- a/src/lib/onboard.ts +++ b/src/lib/onboard.ts @@ -1326,11 +1326,8 @@ function destroyGateway( const handleFinalGatewayStartFailure = createFinalGatewayStartFailureHandler({ getGatewayName: () => GATEWAY_NAME, - collectDiagnostics: () => - runCaptureOpenshell(["doctor", "logs", "--name", GATEWAY_NAME], { - ignoreError: true, - timeout: 10_000, - }), + // biome-ignore format: keep src/lib/onboard.ts net-neutral for growth guardrail. + collectDiagnostics: () => runCaptureOpenshell(["doctor", "logs", "--name", GATEWAY_NAME], { ignoreError: true, timeout: 10_000 }), cleanupGateway: destroyGateway, supportsLifecycleCommands: () => gatewayCliSupportsLifecycleCommands(runCaptureOpenshell), });