From ddafdd4de88da77db32f9434fe3210259f2e96d9 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 11:32:15 -0700 Subject: [PATCH 01/10] test(vllm): validate Docker storage socket alias Signed-off-by: Apurv Kumaria --- test/vllm-docker-storage.test.ts | 122 +++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 test/vllm-docker-storage.test.ts diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts new file mode 100644 index 00000000000..c15213c21b5 --- /dev/null +++ b/test/vllm-docker-storage.test.ts @@ -0,0 +1,122 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +// @module-tag e2e/credential-free + +import { spawnSync } from "node:child_process"; +import fs from "node:fs"; +import path from "node:path"; + +import { expect, test } from "vitest"; + +import { probeDockerStorage } from "../src/lib/inference/vllm-storage"; + +const TARGET_ID = "vllm-docker-storage"; +const DOCKER_HOST = "unix:///run/docker.sock"; +const RUN_REAL_DOCKER = + process.env.E2E_TARGET_ID === TARGET_ID || + process.env.NEMOCLAW_RUN_VLLM_STORAGE_DOCKER_E2E === "1"; +const realDockerTest = RUN_REAL_DOCKER ? test : test.skip; + +interface DockerInfo { + DockerRootDir?: unknown; + OSType?: unknown; + ServerVersion?: unknown; +} + +function dockerEnvironment(): NodeJS.ProcessEnv { + const env: NodeJS.ProcessEnv = { ...process.env, DOCKER_HOST }; + delete env.DOCKER_CONTEXT; + return env; +} + +function writeEvidence(evidence: Record): void { + const artifactDir = process.env.E2E_ARTIFACT_DIR; + if (!artifactDir) return; + fs.mkdirSync(artifactDir, { recursive: true }); + fs.writeFileSync( + path.join(artifactDir, `${TARGET_ID}.json`), + `${JSON.stringify(evidence, null, 2)}\n`, + ); +} + +realDockerTest( + "measures real Docker storage through the /run/docker.sock alias (#7039)", + () => { + expect(process.platform, "this release acceptance requires a native Linux host").toBe("linux"); + expect( + fs.statSync("/run/docker.sock").isSocket(), + "/run/docker.sock must be a Unix socket", + ).toBe(true); + + const env = dockerEnvironment(); + const infoResult = spawnSync("docker", ["info", "--format", "{{json .}}"], { + encoding: "utf8", + env, + timeout: 15_000, + }); + expect( + infoResult.status, + `docker info through ${DOCKER_HOST} failed:\n${ + infoResult.error?.message || infoResult.stderr || infoResult.stdout + }`, + ).toBe(0); + + const info = JSON.parse(infoResult.stdout) as DockerInfo; + expect(info.OSType).toBe("linux"); + expect(typeof info.DockerRootDir).toBe("string"); + const dockerRootDir = String(info.DockerRootDir); + expect(path.isAbsolute(dockerRootDir)).toBe(true); + const dockerRootStats = fs.statfsSync(dockerRootDir, { bigint: true }); + const dockerRootAvailableBytes = dockerRootStats.bavail * dockerRootStats.bsize; + expect(dockerRootAvailableBytes).toBeGreaterThan(0n); + + const previousDockerHost = process.env.DOCKER_HOST; + const previousDockerContext = process.env.DOCKER_CONTEXT; + process.env.DOCKER_HOST = DOCKER_HOST; + delete process.env.DOCKER_CONTEXT; + try { + const probe = probeDockerStorage(); + expect(probe.ok, probe.ok ? undefined : probe.reason).toBe(true); + if (!probe.ok) return; + + const capacityStats = fs.statfsSync(probe.capacity.path, { bigint: true }); + const measuredAvailableBytes = capacityStats.bavail * capacityStats.bsize; + expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); + expect(probe.capacity.availableBytes).toBeGreaterThan(0n); + + const checkoutResult = spawnSync("git", ["rev-parse", "HEAD"], { + encoding: "utf8", + timeout: 5_000, + }); + expect( + checkoutResult.status, + `could not record the validated checkout: ${ + checkoutResult.error?.message || checkoutResult.stderr || checkoutResult.stdout + }`, + ).toBe(0); + const checkoutSha = checkoutResult.stdout.trim(); + expect(checkoutSha).toMatch(/^[0-9a-f]{40}$/u); + const evidence = { + schemaVersion: 1, + checkoutSha, + platform: process.platform, + architecture: process.arch, + dockerHost: DOCKER_HOST, + dockerServerVersion: info.ServerVersion, + dockerRootDir, + dockerRootAvailableBytes: String(dockerRootAvailableBytes), + measuredPath: probe.capacity.path, + measuredSource: probe.capacity.source, + measuredAvailableBytes: String(probe.capacity.availableBytes), + }; + writeEvidence(evidence); + console.info(`[${TARGET_ID}] ${JSON.stringify(evidence)}`); + } finally { + if (previousDockerHost === undefined) delete process.env.DOCKER_HOST; + else process.env.DOCKER_HOST = previousDockerHost; + if (previousDockerContext === undefined) delete process.env.DOCKER_CONTEXT; + else process.env.DOCKER_CONTEXT = previousDockerContext; + } + }, + 30_000, +); From ad2cc34d4e3cfce47d5bd344defa07ec740d5e92 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 11:38:31 -0700 Subject: [PATCH 02/10] test(vllm): keep Docker storage gate linear Signed-off-by: Apurv Kumaria --- test/vllm-docker-storage.test.ts | 103 +++++++++++++++---------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index c15213c21b5..42f4684b39b 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -2,11 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // @module-tag e2e/credential-free +import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; -import { expect, test } from "vitest"; +import { afterEach, expect, test, vi } from "vitest"; import { probeDockerStorage } from "../src/lib/inference/vllm-storage"; @@ -31,14 +32,21 @@ function dockerEnvironment(): NodeJS.ProcessEnv { function writeEvidence(evidence: Record): void { const artifactDir = process.env.E2E_ARTIFACT_DIR; - if (!artifactDir) return; - fs.mkdirSync(artifactDir, { recursive: true }); - fs.writeFileSync( - path.join(artifactDir, `${TARGET_ID}.json`), - `${JSON.stringify(evidence, null, 2)}\n`, - ); + const persist = + artifactDir === undefined + ? () => undefined + : () => { + fs.mkdirSync(artifactDir, { recursive: true }); + fs.writeFileSync( + path.join(artifactDir, `${TARGET_ID}.json`), + `${JSON.stringify(evidence, null, 2)}\n`, + ); + }; + persist(); } +afterEach(() => vi.unstubAllEnvs()); + realDockerTest( "measures real Docker storage through the /run/docker.sock alias (#7039)", () => { @@ -70,53 +78,44 @@ realDockerTest( const dockerRootAvailableBytes = dockerRootStats.bavail * dockerRootStats.bsize; expect(dockerRootAvailableBytes).toBeGreaterThan(0n); - const previousDockerHost = process.env.DOCKER_HOST; - const previousDockerContext = process.env.DOCKER_CONTEXT; - process.env.DOCKER_HOST = DOCKER_HOST; - delete process.env.DOCKER_CONTEXT; - try { - const probe = probeDockerStorage(); - expect(probe.ok, probe.ok ? undefined : probe.reason).toBe(true); - if (!probe.ok) return; + vi.stubEnv("DOCKER_HOST", DOCKER_HOST); + vi.stubEnv("DOCKER_CONTEXT", undefined); + const probe = probeDockerStorage(); + expect(probe.ok, probe.ok ? undefined : probe.reason).toBe(true); + assert(probe.ok); - const capacityStats = fs.statfsSync(probe.capacity.path, { bigint: true }); - const measuredAvailableBytes = capacityStats.bavail * capacityStats.bsize; - expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); - expect(probe.capacity.availableBytes).toBeGreaterThan(0n); + const capacityStats = fs.statfsSync(probe.capacity.path, { bigint: true }); + const measuredAvailableBytes = capacityStats.bavail * capacityStats.bsize; + expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); + expect(probe.capacity.availableBytes).toBeGreaterThan(0n); - const checkoutResult = spawnSync("git", ["rev-parse", "HEAD"], { - encoding: "utf8", - timeout: 5_000, - }); - expect( - checkoutResult.status, - `could not record the validated checkout: ${ - checkoutResult.error?.message || checkoutResult.stderr || checkoutResult.stdout - }`, - ).toBe(0); - const checkoutSha = checkoutResult.stdout.trim(); - expect(checkoutSha).toMatch(/^[0-9a-f]{40}$/u); - const evidence = { - schemaVersion: 1, - checkoutSha, - platform: process.platform, - architecture: process.arch, - dockerHost: DOCKER_HOST, - dockerServerVersion: info.ServerVersion, - dockerRootDir, - dockerRootAvailableBytes: String(dockerRootAvailableBytes), - measuredPath: probe.capacity.path, - measuredSource: probe.capacity.source, - measuredAvailableBytes: String(probe.capacity.availableBytes), - }; - writeEvidence(evidence); - console.info(`[${TARGET_ID}] ${JSON.stringify(evidence)}`); - } finally { - if (previousDockerHost === undefined) delete process.env.DOCKER_HOST; - else process.env.DOCKER_HOST = previousDockerHost; - if (previousDockerContext === undefined) delete process.env.DOCKER_CONTEXT; - else process.env.DOCKER_CONTEXT = previousDockerContext; - } + const checkoutResult = spawnSync("git", ["rev-parse", "HEAD"], { + encoding: "utf8", + timeout: 5_000, + }); + expect( + checkoutResult.status, + `could not record the validated checkout: ${ + checkoutResult.error?.message || checkoutResult.stderr || checkoutResult.stdout + }`, + ).toBe(0); + const checkoutSha = checkoutResult.stdout.trim(); + expect(checkoutSha).toMatch(/^[0-9a-f]{40}$/u); + const evidence = { + schemaVersion: 1, + checkoutSha, + platform: process.platform, + architecture: process.arch, + dockerHost: DOCKER_HOST, + dockerServerVersion: info.ServerVersion, + dockerRootDir, + dockerRootAvailableBytes: String(dockerRootAvailableBytes), + measuredPath: probe.capacity.path, + measuredSource: probe.capacity.source, + measuredAvailableBytes: String(probe.capacity.availableBytes), + }; + writeEvidence(evidence); + console.info(`[${TARGET_ID}] ${JSON.stringify(evidence)}`); }, 30_000, ); From 3f6480674f0dcba29b8fe0e9f08cbf8f1f87a4e2 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 11:47:02 -0700 Subject: [PATCH 03/10] test(vllm): reuse probe storage sample Signed-off-by: Apurv Kumaria --- test/vllm-docker-storage.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index 42f4684b39b..b36489a3549 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -80,11 +80,19 @@ realDockerTest( vi.stubEnv("DOCKER_HOST", DOCKER_HOST); vi.stubEnv("DOCKER_CONTEXT", undefined); - const probe = probeDockerStorage(); + const capacitySamples = new Map(); + const probe = probeDockerStorage({ + statfs: (target) => { + const sample = fs.statfsSync(target, { bigint: true }); + capacitySamples.set(target, sample); + return sample; + }, + }); expect(probe.ok, probe.ok ? undefined : probe.reason).toBe(true); assert(probe.ok); - const capacityStats = fs.statfsSync(probe.capacity.path, { bigint: true }); + const capacityStats = capacitySamples.get(probe.capacity.path); + assert(capacityStats, `the probe did not sample ${probe.capacity.path}`); const measuredAvailableBytes = capacityStats.bavail * capacityStats.bsize; expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); expect(probe.capacity.availableBytes).toBeGreaterThan(0n); From 92da766607d0009646a89ef05fa67b09b6ff866a Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 11:52:58 -0700 Subject: [PATCH 04/10] test(vllm): exercise install storage gate Signed-off-by: Apurv Kumaria --- test/vllm-docker-storage.test.ts | 56 +++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index b36489a3549..6a29f51e881 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -5,11 +5,16 @@ import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import fs from "node:fs"; +import os from "node:os"; import path from "node:path"; import { afterEach, expect, test, vi } from "vitest"; -import { probeDockerStorage } from "../src/lib/inference/vllm-storage"; +import { detectVllmProfile, installVllm } from "../src/lib/inference/vllm"; +import { + imageStorageRequirementBytes, + probeDockerStorage, +} from "../src/lib/inference/vllm-storage"; const TARGET_ID = "vllm-docker-storage"; const DOCKER_HOST = "unix:///run/docker.sock"; @@ -45,11 +50,14 @@ function writeEvidence(evidence: Record): void { persist(); } -afterEach(() => vi.unstubAllEnvs()); +afterEach(() => { + vi.restoreAllMocks(); + vi.unstubAllEnvs(); +}); realDockerTest( - "measures real Docker storage through the /run/docker.sock alias (#7039)", - () => { + "allows non-interactive managed vLLM past the real /run/docker.sock storage gate (#7039)", + async () => { expect(process.platform, "this release acceptance requires a native Linux host").toBe("linux"); expect( fs.statSync("/run/docker.sock").isSocket(), @@ -97,6 +105,45 @@ realDockerTest( expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); expect(probe.capacity.availableBytes).toBeGreaterThan(0n); + const profile = detectVllmProfile({ platform: "linux", type: "nvidia" }); + assert(profile); + const acceptanceProfile = { + ...profile, + image: `example.invalid/nemoclaw/vllm@sha256:${"0".repeat(64)}`, + imageDownloadSizeBytes: 1, + containerName: `nemoclaw-vllm-storage-e2e-${String(process.pid)}`, + pullTimeoutSec: 1, + }; + expect(probe.capacity.availableBytes).toBeGreaterThanOrEqual( + imageStorageRequirementBytes(acceptanceProfile.imageDownloadSizeBytes), + ); + + const fakeBinDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-vllm-storage-")); + const blockedHome = path.join("/proc", `nemoclaw-vllm-storage-e2e-${String(process.pid)}`); + const errorSpy = vi.spyOn(console, "error").mockImplementation(() => undefined); + try { + fs.writeFileSync(path.join(fakeBinDir, "nvidia-smi"), "#!/bin/sh\nexit 0\n", { + mode: 0o755, + }); + vi.stubEnv("PATH", `${fakeBinDir}${path.delimiter}${process.env.PATH ?? ""}`); + vi.stubEnv("HOME", blockedHome); + vi.stubEnv("NEMOCLAW_VLLM_MODEL", profile.defaultModel.envValue); + vi.stubEnv("NEMOCLAW_VLLM_EXTRA_ARGS_JSON", undefined); + expect(os.homedir()).toBe(blockedHome); + + const result = await installVllm(acceptanceProfile, { + hasImage: false, + nonInteractive: true, + promptFn: async () => "", + }); + expect(result).toEqual({ ok: false }); + const installErrors = errorSpy.mock.calls.flat().map(String).join("\n"); + expect(installErrors).toContain("could not create Hugging Face cache directory"); + expect(installErrors).not.toContain("Docker storage for the managed vLLM image"); + } finally { + fs.rmSync(fakeBinDir, { force: true, recursive: true }); + } + const checkoutResult = spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf8", timeout: 5_000, @@ -121,6 +168,7 @@ realDockerTest( measuredPath: probe.capacity.path, measuredSource: probe.capacity.source, measuredAvailableBytes: String(probe.capacity.availableBytes), + managedInstallCrossedImageStorageGate: true, }; writeEvidence(evidence); console.info(`[${TARGET_ID}] ${JSON.stringify(evidence)}`); From 7275631fb4bcc668088b279a763ac424d84f8416 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 12:35:20 -0700 Subject: [PATCH 05/10] test(vllm): record release candidate identity Signed-off-by: Apurv Kumaria --- test/vllm-docker-storage.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index 6a29f51e881..3b4d574cecb 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -125,6 +125,7 @@ realDockerTest( fs.writeFileSync(path.join(fakeBinDir, "nvidia-smi"), "#!/bin/sh\nexit 0\n", { mode: 0o755, }); + fs.writeFileSync(path.join(fakeBinDir, "curl"), "#!/bin/sh\nexit 0\n", { mode: 0o755 }); vi.stubEnv("PATH", `${fakeBinDir}${path.delimiter}${process.env.PATH ?? ""}`); vi.stubEnv("HOME", blockedHome); vi.stubEnv("NEMOCLAW_VLLM_MODEL", profile.defaultModel.envValue); @@ -156,9 +157,30 @@ realDockerTest( ).toBe(0); const checkoutSha = checkoutResult.stdout.trim(); expect(checkoutSha).toMatch(/^[0-9a-f]{40}$/u); + const sourceVersionResult = spawnSync("git", ["describe", "--tags", "--always", "--dirty"], { + encoding: "utf8", + timeout: 5_000, + }); + expect( + sourceVersionResult.status, + `could not record the validated source version: ${ + sourceVersionResult.error?.message || + sourceVersionResult.stderr || + sourceVersionResult.stdout + }`, + ).toBe(0); + const releaseCandidateSourceVersion = sourceVersionResult.stdout.trim(); + expect(releaseCandidateSourceVersion).not.toBe(""); + const packageMetadata = JSON.parse( + fs.readFileSync(path.join(process.cwd(), "package.json"), "utf8"), + ) as { version?: unknown }; + expect(typeof packageMetadata.version).toBe("string"); + const packageVersion = String(packageMetadata.version); const evidence = { schemaVersion: 1, checkoutSha, + releaseCandidateSourceVersion, + packageVersion, platform: process.platform, architecture: process.arch, dockerHost: DOCKER_HOST, From d0dbf61825f872402f16bab7ba32528872b11973 Mon Sep 17 00:00:00 2001 From: Charan Jagwani Date: Thu, 16 Jul 2026 12:36:13 -0700 Subject: [PATCH 06/10] test(vllm): exercise Docker storage acceptance Signed-off-by: Charan Jagwani --- .github/workflows/e2e.yaml | 6 ++ src/lib/inference/vllm.ts | 5 +- .../shared-e2e-workflow-boundary.test.ts | 24 ++++++- test/vllm-docker-storage.test.ts | 69 +++++++++++++++++-- tools/e2e/workflow-boundary.mts | 14 ++++ 5 files changed, 111 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 110992ecd2c..366e4dfc049 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -19,6 +19,11 @@ on: required: false default: "" type: string + candidate_version: + description: "Optional exact NemoClaw release-candidate version for vllm-docker-storage evidence. Release acceptance for #7039 requires v0.0.85; empty records only the exact checkout SHA." + required: false + default: "" + type: string inference_mode: description: "Inference adapter mode for compatible Vitest E2E jobs: mock, internal-nvidia, or public-nvidia." required: false @@ -506,6 +511,7 @@ jobs: - name: Run tagged credential-free test env: + NEMOCLAW_CANDIDATE_VERSION: ${{ matrix.id == 'vllm-docker-storage' && inputs.candidate_version || '' }} TEST_FILE: ${{ matrix.file }} TEST_PROJECT: ${{ matrix.project }} run: | diff --git a/src/lib/inference/vllm.ts b/src/lib/inference/vllm.ts index 36a1dde93db..e945b36f100 100644 --- a/src/lib/inference/vllm.ts +++ b/src/lib/inference/vllm.ts @@ -847,8 +847,9 @@ function printModelStorageWarning( async function imageStorageAccepted( profile: VllmProfile, opts: InstallVllmOptions, + probeResult: StorageProbeResult = probeDockerStorage(), ): Promise { - const probe = probeDockerStorage(); + const probe = probeResult; const requiredBytes = imageStorageRequirementBytes(profile.imageDownloadSizeBytes); if (probe.ok && probe.capacity.availableBytes >= requiredBytes) { return true; @@ -867,6 +868,8 @@ async function imageStorageAccepted( return isAffirmativeAnswer(await opts.promptFn(" Continue with the pull anyway? [y/N]: ")); } +export const __test = { imageStorageAccepted }; + async function modelStorageAccepted( profile: VllmProfile, model: VllmModelDef, diff --git a/test/e2e/support/shared-e2e-workflow-boundary.test.ts b/test/e2e/support/shared-e2e-workflow-boundary.test.ts index 8851f86d623..5879af50e22 100644 --- a/test/e2e/support/shared-e2e-workflow-boundary.test.ts +++ b/test/e2e/support/shared-e2e-workflow-boundary.test.ts @@ -16,12 +16,17 @@ import { validateE2eWorkflowBoundary } from "../../../tools/e2e/workflow-boundar import { readWorkflow } from "../../helpers/e2e-workflow-contract"; type Workflow = { + on: { + workflow_dispatch: { + inputs: Record; + }; + }; jobs: Record< string, { env?: Record; needs?: string[]; - steps?: Array<{ name?: string; run?: string }>; + steps?: Array<{ env?: Record; name?: string; run?: string }>; } >; }; @@ -87,4 +92,21 @@ describe("shared E2E workflow boundary", () => { expect(errors).toContain("workflow missing shared E2E job"); }); + + it("keeps release-candidate evidence optional and scoped to the vLLM storage test", () => { + const errors = validateMutatedWorkflow((workflow) => { + workflow.on.workflow_dispatch.inputs.candidate_version.default = "v0.0.85"; + const runStep = workflow.jobs["shared-e2e"].steps!.find( + (step) => step.name === "Run tagged credential-free test", + ); + runStep!.env!.NEMOCLAW_CANDIDATE_VERSION = "${{ inputs.candidate_version }}"; + }); + + expect(errors).toEqual( + expect.arrayContaining([ + "workflow_dispatch candidate_version must be an optional empty string by default", + "shared E2E test step must scope candidate_version to vllm-docker-storage only", + ]), + ); + }); }); diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index b36489a3549..b0132c9d110 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -9,10 +9,15 @@ import path from "node:path"; import { afterEach, expect, test, vi } from "vitest"; -import { probeDockerStorage } from "../src/lib/inference/vllm-storage"; +import { __test, detectVllmProfile } from "../src/lib/inference/vllm"; +import { + imageStorageRequirementBytes, + probeDockerStorage, +} from "../src/lib/inference/vllm-storage"; const TARGET_ID = "vllm-docker-storage"; const DOCKER_HOST = "unix:///run/docker.sock"; +const RELEASE_CANDIDATE_VERSION = "v0.0.85"; const RUN_REAL_DOCKER = process.env.E2E_TARGET_ID === TARGET_ID || process.env.NEMOCLAW_RUN_VLLM_STORAGE_DOCKER_E2E === "1"; @@ -45,11 +50,45 @@ function writeEvidence(evidence: Record): void { persist(); } -afterEach(() => vi.unstubAllEnvs()); +function validationSubject( + checkoutSha: string, + candidateVersion = process.env.NEMOCLAW_CANDIDATE_VERSION, +): + | { kind: "checkout"; checkoutSha: string } + | { kind: "release-candidate"; version: string; checkoutSha: string } { + if (!candidateVersion) return { kind: "checkout", checkoutSha }; + if (candidateVersion !== RELEASE_CANDIDATE_VERSION) { + throw new Error( + `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}; received ${JSON.stringify(candidateVersion)}`, + ); + } + return { kind: "release-candidate", version: candidateVersion, checkoutSha }; +} + +afterEach(() => { + vi.restoreAllMocks(); + vi.unstubAllEnvs(); +}); + +test("distinguishes checkout evidence from exact v0.0.85 release acceptance (#7039)", () => { + const checkoutSha = "a".repeat(40); + expect(validationSubject(checkoutSha, undefined)).toEqual({ kind: "checkout", checkoutSha }); + expect(validationSubject(checkoutSha, RELEASE_CANDIDATE_VERSION)).toEqual({ + kind: "release-candidate", + version: RELEASE_CANDIDATE_VERSION, + checkoutSha, + }); + expect(() => validationSubject(checkoutSha, "0.0.85")).toThrow( + `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}`, + ); + expect(() => validationSubject(checkoutSha, "v0.0.84")).toThrow( + `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}`, + ); +}); realDockerTest( - "measures real Docker storage through the /run/docker.sock alias (#7039)", - () => { + "accepts a real Linux profile from the measured /run/docker.sock capacity (#7039)", + async () => { expect(process.platform, "this release acceptance requires a native Linux host").toBe("linux"); expect( fs.statSync("/run/docker.sock").isSocket(), @@ -95,7 +134,24 @@ realDockerTest( assert(capacityStats, `the probe did not sample ${probe.capacity.path}`); const measuredAvailableBytes = capacityStats.bavail * capacityStats.bsize; expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); - expect(probe.capacity.availableBytes).toBeGreaterThan(0n); + + const profile = detectVllmProfile({ platform: "linux", type: "nvidia" }); + assert(profile, "the release acceptance host must support the real Linux vLLM profile"); + const requiredBytes = imageStorageRequirementBytes(profile.imageDownloadSizeBytes); + expect(probe.capacity.availableBytes).toBeGreaterThanOrEqual(requiredBytes); + + const promptFn = vi.fn(async () => { + throw new Error("the sufficient-capacity path must not prompt"); + }); + const warning = vi.spyOn(console, "error").mockImplementation(() => undefined); + const accepted = await __test.imageStorageAccepted( + profile, + { hasImage: false, nonInteractive: true, promptFn }, + probe, + ); + expect(accepted).toBe(true); + expect(promptFn).not.toHaveBeenCalled(); + expect(warning).not.toHaveBeenCalled(); const checkoutResult = spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf8", @@ -112,6 +168,7 @@ realDockerTest( const evidence = { schemaVersion: 1, checkoutSha, + validationSubject: validationSubject(checkoutSha), platform: process.platform, architecture: process.arch, dockerHost: DOCKER_HOST, @@ -121,6 +178,8 @@ realDockerTest( measuredPath: probe.capacity.path, measuredSource: probe.capacity.source, measuredAvailableBytes: String(probe.capacity.availableBytes), + requiredAvailableBytes: String(requiredBytes), + imageStorageAccepted: accepted, }; writeEvidence(evidence); console.info(`[${TARGET_ID}] ${JSON.stringify(evidence)}`); diff --git a/tools/e2e/workflow-boundary.mts b/tools/e2e/workflow-boundary.mts index 92d1b6875a9..700353cf876 100644 --- a/tools/e2e/workflow-boundary.mts +++ b/tools/e2e/workflow-boundary.mts @@ -872,6 +872,12 @@ function validateSharedE2eJob(errors: string[], jobs: WorkflowRecord): void { if (runEnv.TEST_PROJECT !== "${{ matrix.project }}") { errors.push("shared E2E test step must pass matrix.project through TEST_PROJECT"); } + if ( + runEnv.NEMOCLAW_CANDIDATE_VERSION !== + "${{ matrix.id == 'vllm-docker-storage' && inputs.candidate_version || '' }}" + ) { + errors.push("shared E2E test step must scope candidate_version to vllm-docker-storage only"); + } requireRunContains( errors, runVitest, @@ -3767,6 +3773,14 @@ export function validateE2eWorkflow(workflowValue: unknown): string[] { if (Object.hasOwn(dispatchInputs, "test_filter")) { errors.push("workflow_dispatch must not expose legacy test_filter input"); } + const candidateVersionInput = requireInput(errors, dispatchInputs, "candidate_version"); + if ( + candidateVersionInput.type !== "string" || + candidateVersionInput.required !== false || + candidateVersionInput.default !== "" + ) { + errors.push("workflow_dispatch candidate_version must be an optional empty string by default"); + } const permissions = asRecord(workflow.permissions); if (permissions.contents !== "read") errors.push("workflow permissions.contents must be read"); From 0b9bdb86281a55ae37508bd975cdc07649ed1670 Mon Sep 17 00:00:00 2001 From: Charan Jagwani Date: Thu, 16 Jul 2026 12:47:53 -0700 Subject: [PATCH 07/10] test(vllm): keep candidate evidence branch-free Signed-off-by: Charan Jagwani --- test/vllm-docker-storage.test.ts | 46 +++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index b0132c9d110..196fc3a75ec 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -29,6 +29,30 @@ interface DockerInfo { ServerVersion?: unknown; } +type ValidationSubject = + | { kind: "checkout"; checkoutSha: string } + | { kind: "release-candidate"; version: string; checkoutSha: string }; + +type ValidationSubjectFactory = (checkoutSha: string) => ValidationSubject; + +const checkoutValidationSubject: ValidationSubjectFactory = (checkoutSha) => ({ + kind: "checkout", + checkoutSha, +}); + +const validationSubjectFactories = new Map([ + [undefined, checkoutValidationSubject], + ["", checkoutValidationSubject], + [ + RELEASE_CANDIDATE_VERSION, + (checkoutSha) => ({ + kind: "release-candidate", + version: RELEASE_CANDIDATE_VERSION, + checkoutSha, + }), + ], +]); + function dockerEnvironment(): NodeJS.ProcessEnv { const env: NodeJS.ProcessEnv = { ...process.env, DOCKER_HOST }; delete env.DOCKER_CONTEXT; @@ -52,17 +76,14 @@ function writeEvidence(evidence: Record): void { function validationSubject( checkoutSha: string, - candidateVersion = process.env.NEMOCLAW_CANDIDATE_VERSION, -): - | { kind: "checkout"; checkoutSha: string } - | { kind: "release-candidate"; version: string; checkoutSha: string } { - if (!candidateVersion) return { kind: "checkout", checkoutSha }; - if (candidateVersion !== RELEASE_CANDIDATE_VERSION) { - throw new Error( - `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}; received ${JSON.stringify(candidateVersion)}`, - ); - } - return { kind: "release-candidate", version: candidateVersion, checkoutSha }; + candidateVersion: string | undefined, +): ValidationSubject { + const factory = validationSubjectFactories.get(candidateVersion); + assert( + factory, + `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}; received ${JSON.stringify(candidateVersion)}`, + ); + return factory(checkoutSha); } afterEach(() => { @@ -73,6 +94,7 @@ afterEach(() => { test("distinguishes checkout evidence from exact v0.0.85 release acceptance (#7039)", () => { const checkoutSha = "a".repeat(40); expect(validationSubject(checkoutSha, undefined)).toEqual({ kind: "checkout", checkoutSha }); + expect(validationSubject(checkoutSha, "")).toEqual({ kind: "checkout", checkoutSha }); expect(validationSubject(checkoutSha, RELEASE_CANDIDATE_VERSION)).toEqual({ kind: "release-candidate", version: RELEASE_CANDIDATE_VERSION, @@ -168,7 +190,7 @@ realDockerTest( const evidence = { schemaVersion: 1, checkoutSha, - validationSubject: validationSubject(checkoutSha), + validationSubject: validationSubject(checkoutSha, process.env.NEMOCLAW_CANDIDATE_VERSION), platform: process.platform, architecture: process.arch, dockerHost: DOCKER_HOST, From 750928d3e562a317cdf7619f9f9b1114c52263c5 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 12:54:02 -0700 Subject: [PATCH 08/10] test(vllm): bound Docker storage acceptance Signed-off-by: Apurv Kumaria --- .github/workflows/e2e.yaml | 6 - src/lib/inference/vllm.ts | 5 +- .../shared-e2e-workflow-boundary.test.ts | 24 +- test/vllm-docker-storage.test.ts | 223 ++++++++++++------ tools/e2e/workflow-boundary.mts | 15 -- 5 files changed, 153 insertions(+), 120 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 366e4dfc049..110992ecd2c 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -19,11 +19,6 @@ on: required: false default: "" type: string - candidate_version: - description: "Optional exact NemoClaw release-candidate version for vllm-docker-storage evidence. Release acceptance for #7039 requires v0.0.85; empty records only the exact checkout SHA." - required: false - default: "" - type: string inference_mode: description: "Inference adapter mode for compatible Vitest E2E jobs: mock, internal-nvidia, or public-nvidia." required: false @@ -511,7 +506,6 @@ jobs: - name: Run tagged credential-free test env: - NEMOCLAW_CANDIDATE_VERSION: ${{ matrix.id == 'vllm-docker-storage' && inputs.candidate_version || '' }} TEST_FILE: ${{ matrix.file }} TEST_PROJECT: ${{ matrix.project }} run: | diff --git a/src/lib/inference/vllm.ts b/src/lib/inference/vllm.ts index e945b36f100..36a1dde93db 100644 --- a/src/lib/inference/vllm.ts +++ b/src/lib/inference/vllm.ts @@ -847,9 +847,8 @@ function printModelStorageWarning( async function imageStorageAccepted( profile: VllmProfile, opts: InstallVllmOptions, - probeResult: StorageProbeResult = probeDockerStorage(), ): Promise { - const probe = probeResult; + const probe = probeDockerStorage(); const requiredBytes = imageStorageRequirementBytes(profile.imageDownloadSizeBytes); if (probe.ok && probe.capacity.availableBytes >= requiredBytes) { return true; @@ -868,8 +867,6 @@ async function imageStorageAccepted( return isAffirmativeAnswer(await opts.promptFn(" Continue with the pull anyway? [y/N]: ")); } -export const __test = { imageStorageAccepted }; - async function modelStorageAccepted( profile: VllmProfile, model: VllmModelDef, diff --git a/test/e2e/support/shared-e2e-workflow-boundary.test.ts b/test/e2e/support/shared-e2e-workflow-boundary.test.ts index 5879af50e22..8851f86d623 100644 --- a/test/e2e/support/shared-e2e-workflow-boundary.test.ts +++ b/test/e2e/support/shared-e2e-workflow-boundary.test.ts @@ -16,17 +16,12 @@ import { validateE2eWorkflowBoundary } from "../../../tools/e2e/workflow-boundar import { readWorkflow } from "../../helpers/e2e-workflow-contract"; type Workflow = { - on: { - workflow_dispatch: { - inputs: Record; - }; - }; jobs: Record< string, { env?: Record; needs?: string[]; - steps?: Array<{ env?: Record; name?: string; run?: string }>; + steps?: Array<{ name?: string; run?: string }>; } >; }; @@ -92,21 +87,4 @@ describe("shared E2E workflow boundary", () => { expect(errors).toContain("workflow missing shared E2E job"); }); - - it("keeps release-candidate evidence optional and scoped to the vLLM storage test", () => { - const errors = validateMutatedWorkflow((workflow) => { - workflow.on.workflow_dispatch.inputs.candidate_version.default = "v0.0.85"; - const runStep = workflow.jobs["shared-e2e"].steps!.find( - (step) => step.name === "Run tagged credential-free test", - ); - runStep!.env!.NEMOCLAW_CANDIDATE_VERSION = "${{ inputs.candidate_version }}"; - }); - - expect(errors).toEqual( - expect.arrayContaining([ - "workflow_dispatch candidate_version must be an optional empty string by default", - "shared E2E test step must scope candidate_version to vllm-docker-storage only", - ]), - ); - }); }); diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index 196fc3a75ec..c80433de148 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -5,11 +5,12 @@ import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import fs from "node:fs"; +import os from "node:os"; import path from "node:path"; +import { pathToFileURL } from "node:url"; import { afterEach, expect, test, vi } from "vitest"; -import { __test, detectVllmProfile } from "../src/lib/inference/vllm"; import { imageStorageRequirementBytes, probeDockerStorage, @@ -17,7 +18,7 @@ import { const TARGET_ID = "vllm-docker-storage"; const DOCKER_HOST = "unix:///run/docker.sock"; -const RELEASE_CANDIDATE_VERSION = "v0.0.85"; +const INSTALL_SUBPROCESS_TIMEOUT_MS = 15_000; const RUN_REAL_DOCKER = process.env.E2E_TARGET_ID === TARGET_ID || process.env.NEMOCLAW_RUN_VLLM_STORAGE_DOCKER_E2E === "1"; @@ -29,29 +30,56 @@ interface DockerInfo { ServerVersion?: unknown; } -type ValidationSubject = - | { kind: "checkout"; checkoutSha: string } - | { kind: "release-candidate"; version: string; checkoutSha: string }; - -type ValidationSubjectFactory = (checkoutSha: string) => ValidationSubject; - -const checkoutValidationSubject: ValidationSubjectFactory = (checkoutSha) => ({ - kind: "checkout", - checkoutSha, +function dockerProxySource(realDockerPath: string, commandLogPath: string): string { + return `#!/usr/bin/env node +const { appendFileSync } = require("node:fs"); +const { spawnSync } = require("node:child_process"); +const args = process.argv.slice(2); +appendFileSync(${JSON.stringify(commandLogPath)}, JSON.stringify(args) + "\\n"); +const command = ["container", "image"].includes(args[0]) + ? args.slice(0, 2).join(" ") + : args[0]; +const allowed = new Set(["container ls", "image inspect", "info"]); +if (!allowed.has(command)) { + process.stderr.write("blocked mutating Docker command: " + args.join(" ") + "\\n"); + process.exit(97); +} +const result = spawnSync(${JSON.stringify(realDockerPath)}, args, { + env: process.env, + stdio: "inherit", + timeout: 10000, + killSignal: "SIGKILL", }); +if (result.error) { + process.stderr.write(result.error.message + "\\n"); + process.exit(98); +} +process.exit(result.status ?? 99); +`; +} -const validationSubjectFactories = new Map([ - [undefined, checkoutValidationSubject], - ["", checkoutValidationSubject], - [ - RELEASE_CANDIDATE_VERSION, - (checkoutSha) => ({ - kind: "release-candidate", - version: RELEASE_CANDIDATE_VERSION, - checkoutSha, - }), - ], -]); +function installChildSource(vllmModuleUrl: string): string { + return ` +import vllmModule from ${JSON.stringify(vllmModuleUrl)}; +const { detectVllmProfile, installVllm } = vllmModule; +const profile = detectVllmProfile({ platform: "linux", type: "nvidia" }); +if (!profile) throw new Error("managed vLLM has no generic Linux profile"); +process.env.NEMOCLAW_VLLM_MODEL = profile.defaultModel.envValue; +delete process.env.NEMOCLAW_VLLM_EXTRA_ARGS_JSON; +const result = await installVllm({ + ...profile, + image: "example.invalid/nemoclaw/vllm@sha256:${"0".repeat(64)}", + imageDownloadSizeBytes: 1, + containerName: "nemoclaw-vllm-storage-e2e-" + String(process.pid), + pullTimeoutSec: 1, +}, { + hasImage: false, + nonInteractive: true, + promptFn: async () => "", +}); +process.stdout.write("\\nNEMOCLAW_INSTALL_RESULT=" + JSON.stringify(result) + "\\n"); +`; +} function dockerEnvironment(): NodeJS.ProcessEnv { const env: NodeJS.ProcessEnv = { ...process.env, DOCKER_HOST }; @@ -74,43 +102,14 @@ function writeEvidence(evidence: Record): void { persist(); } -function validationSubject( - checkoutSha: string, - candidateVersion: string | undefined, -): ValidationSubject { - const factory = validationSubjectFactories.get(candidateVersion); - assert( - factory, - `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}; received ${JSON.stringify(candidateVersion)}`, - ); - return factory(checkoutSha); -} - afterEach(() => { vi.restoreAllMocks(); vi.unstubAllEnvs(); }); -test("distinguishes checkout evidence from exact v0.0.85 release acceptance (#7039)", () => { - const checkoutSha = "a".repeat(40); - expect(validationSubject(checkoutSha, undefined)).toEqual({ kind: "checkout", checkoutSha }); - expect(validationSubject(checkoutSha, "")).toEqual({ kind: "checkout", checkoutSha }); - expect(validationSubject(checkoutSha, RELEASE_CANDIDATE_VERSION)).toEqual({ - kind: "release-candidate", - version: RELEASE_CANDIDATE_VERSION, - checkoutSha, - }); - expect(() => validationSubject(checkoutSha, "0.0.85")).toThrow( - `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}`, - ); - expect(() => validationSubject(checkoutSha, "v0.0.84")).toThrow( - `NEMOCLAW_CANDIDATE_VERSION must be exactly ${RELEASE_CANDIDATE_VERSION}`, - ); -}); - realDockerTest( - "accepts a real Linux profile from the measured /run/docker.sock capacity (#7039)", - async () => { + "allows non-interactive managed vLLM past the real /run/docker.sock storage gate (#7039)", + () => { expect(process.platform, "this release acceptance requires a native Linux host").toBe("linux"); expect( fs.statSync("/run/docker.sock").isSocket(), @@ -156,24 +155,83 @@ realDockerTest( assert(capacityStats, `the probe did not sample ${probe.capacity.path}`); const measuredAvailableBytes = capacityStats.bavail * capacityStats.bsize; expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); + expect(probe.capacity.availableBytes).toBeGreaterThan(0n); - const profile = detectVllmProfile({ platform: "linux", type: "nvidia" }); - assert(profile, "the release acceptance host must support the real Linux vLLM profile"); - const requiredBytes = imageStorageRequirementBytes(profile.imageDownloadSizeBytes); - expect(probe.capacity.availableBytes).toBeGreaterThanOrEqual(requiredBytes); + expect(probe.capacity.availableBytes).toBeGreaterThanOrEqual(imageStorageRequirementBytes(1)); - const promptFn = vi.fn(async () => { - throw new Error("the sufficient-capacity path must not prompt"); + const fakeBinDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-vllm-storage-")); + const blockedHome = path.join(fakeBinDir, "blocked-home"); + const commandLogPath = path.join(fakeBinDir, "docker-commands.jsonl"); + const dockerPathResult = spawnSync("sh", ["-c", "command -v docker"], { + encoding: "utf8", + env, + timeout: 5_000, }); - const warning = vi.spyOn(console, "error").mockImplementation(() => undefined); - const accepted = await __test.imageStorageAccepted( - profile, - { hasImage: false, nonInteractive: true, promptFn }, - probe, - ); - expect(accepted).toBe(true); - expect(promptFn).not.toHaveBeenCalled(); - expect(warning).not.toHaveBeenCalled(); + expect( + dockerPathResult.status, + `could not resolve the Docker CLI: ${ + dockerPathResult.error?.message || dockerPathResult.stderr || dockerPathResult.stdout + }`, + ).toBe(0); + const realDockerPath = dockerPathResult.stdout.trim(); + expect(path.isAbsolute(realDockerPath)).toBe(true); + let installDockerCommands: string[] = []; + try { + fs.writeFileSync(blockedHome, "not a directory\n"); + fs.writeFileSync(path.join(fakeBinDir, "nvidia-smi"), "#!/bin/sh\nexit 0\n", { + mode: 0o755, + }); + fs.writeFileSync(path.join(fakeBinDir, "curl"), "#!/bin/sh\nexit 0\n", { mode: 0o755 }); + fs.writeFileSync( + path.join(fakeBinDir, "docker"), + dockerProxySource(realDockerPath, commandLogPath), + { mode: 0o755 }, + ); + const childEnv = dockerEnvironment(); + childEnv.HOME = blockedHome; + childEnv.PATH = `${fakeBinDir}${path.delimiter}${process.env.PATH ?? ""}`; + const installResult = spawnSync( + process.execPath, + [ + "--import", + "tsx", + "--input-type=module", + "--eval", + installChildSource(pathToFileURL(path.resolve("src/lib/inference/vllm.ts")).href), + ], + { + cwd: process.cwd(), + encoding: "utf8", + env: childEnv, + timeout: INSTALL_SUBPROCESS_TIMEOUT_MS, + killSignal: "SIGKILL", + }, + ); + expect( + installResult.error, + `managed-vLLM install subprocess failed to complete: ${installResult.error?.message}`, + ).toBeUndefined(); + expect( + installResult.status, + `managed-vLLM install subprocess failed:\n${installResult.stderr}\n${installResult.stdout}`, + ).toBe(0); + expect(installResult.stdout).toContain('NEMOCLAW_INSTALL_RESULT={"ok":false}'); + expect(installResult.stderr).toContain("could not create Hugging Face cache directory"); + expect(installResult.stderr).not.toContain("Docker storage for the managed vLLM image"); + const dockerCommands = fs + .readFileSync(commandLogPath, "utf8") + .trim() + .split(/\r?\n/u) + .map((line) => JSON.parse(line) as string[]); + expect(dockerCommands.map((args) => args.slice(0, 2))).toEqual([ + ["container", "ls"], + ["image", "inspect"], + ["info", "--format"], + ]); + installDockerCommands = dockerCommands.map((args) => args.slice(0, 2).join(" ")); + } finally { + fs.rmSync(fakeBinDir, { force: true, recursive: true }); + } const checkoutResult = spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf8", @@ -187,10 +245,30 @@ realDockerTest( ).toBe(0); const checkoutSha = checkoutResult.stdout.trim(); expect(checkoutSha).toMatch(/^[0-9a-f]{40}$/u); + const sourceVersionResult = spawnSync("git", ["describe", "--tags", "--always", "--dirty"], { + encoding: "utf8", + timeout: 5_000, + }); + expect( + sourceVersionResult.status, + `could not record the validated source version: ${ + sourceVersionResult.error?.message || + sourceVersionResult.stderr || + sourceVersionResult.stdout + }`, + ).toBe(0); + const releaseCandidateSourceVersion = sourceVersionResult.stdout.trim(); + expect(releaseCandidateSourceVersion).not.toBe(""); + const packageMetadata = JSON.parse( + fs.readFileSync(path.join(process.cwd(), "package.json"), "utf8"), + ) as { version?: unknown }; + expect(typeof packageMetadata.version).toBe("string"); + const packageVersion = String(packageMetadata.version); const evidence = { schemaVersion: 1, checkoutSha, - validationSubject: validationSubject(checkoutSha, process.env.NEMOCLAW_CANDIDATE_VERSION), + releaseCandidateSourceVersion, + packageVersion, platform: process.platform, architecture: process.arch, dockerHost: DOCKER_HOST, @@ -200,8 +278,9 @@ realDockerTest( measuredPath: probe.capacity.path, measuredSource: probe.capacity.source, measuredAvailableBytes: String(probe.capacity.availableBytes), - requiredAvailableBytes: String(requiredBytes), - imageStorageAccepted: accepted, + managedInstallCrossedImageStorageGate: true, + installSubprocessTimeoutMs: INSTALL_SUBPROCESS_TIMEOUT_MS, + installDockerCommands, }; writeEvidence(evidence); console.info(`[${TARGET_ID}] ${JSON.stringify(evidence)}`); diff --git a/tools/e2e/workflow-boundary.mts b/tools/e2e/workflow-boundary.mts index 700353cf876..0a01f80a748 100644 --- a/tools/e2e/workflow-boundary.mts +++ b/tools/e2e/workflow-boundary.mts @@ -872,12 +872,6 @@ function validateSharedE2eJob(errors: string[], jobs: WorkflowRecord): void { if (runEnv.TEST_PROJECT !== "${{ matrix.project }}") { errors.push("shared E2E test step must pass matrix.project through TEST_PROJECT"); } - if ( - runEnv.NEMOCLAW_CANDIDATE_VERSION !== - "${{ matrix.id == 'vllm-docker-storage' && inputs.candidate_version || '' }}" - ) { - errors.push("shared E2E test step must scope candidate_version to vllm-docker-storage only"); - } requireRunContains( errors, runVitest, @@ -3773,15 +3767,6 @@ export function validateE2eWorkflow(workflowValue: unknown): string[] { if (Object.hasOwn(dispatchInputs, "test_filter")) { errors.push("workflow_dispatch must not expose legacy test_filter input"); } - const candidateVersionInput = requireInput(errors, dispatchInputs, "candidate_version"); - if ( - candidateVersionInput.type !== "string" || - candidateVersionInput.required !== false || - candidateVersionInput.default !== "" - ) { - errors.push("workflow_dispatch candidate_version must be an optional empty string by default"); - } - const permissions = asRecord(workflow.permissions); if (permissions.contents !== "read") errors.push("workflow permissions.contents must be read"); From ef666be45d57c05102c0ee9f725a3864b0db6432 Mon Sep 17 00:00:00 2001 From: Apurv Kumaria Date: Thu, 16 Jul 2026 13:08:36 -0700 Subject: [PATCH 09/10] test(vllm): retain managed image storage size Signed-off-by: Apurv Kumaria --- test/vllm-docker-storage.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index c80433de148..8fe6992d14d 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -11,6 +11,7 @@ import { pathToFileURL } from "node:url"; import { afterEach, expect, test, vi } from "vitest"; +import { detectVllmProfile } from "../src/lib/inference/vllm"; import { imageStorageRequirementBytes, probeDockerStorage, @@ -69,7 +70,6 @@ delete process.env.NEMOCLAW_VLLM_EXTRA_ARGS_JSON; const result = await installVllm({ ...profile, image: "example.invalid/nemoclaw/vllm@sha256:${"0".repeat(64)}", - imageDownloadSizeBytes: 1, containerName: "nemoclaw-vllm-storage-e2e-" + String(process.pid), pullTimeoutSec: 1, }, { @@ -157,7 +157,10 @@ realDockerTest( expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); expect(probe.capacity.availableBytes).toBeGreaterThan(0n); - expect(probe.capacity.availableBytes).toBeGreaterThanOrEqual(imageStorageRequirementBytes(1)); + const profile = detectVllmProfile({ platform: "linux", type: "nvidia" }); + assert(profile, "managed vLLM has no generic Linux profile"); + const requiredAvailableBytes = imageStorageRequirementBytes(profile.imageDownloadSizeBytes); + expect(probe.capacity.availableBytes).toBeGreaterThanOrEqual(requiredAvailableBytes); const fakeBinDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-vllm-storage-")); const blockedHome = path.join(fakeBinDir, "blocked-home"); @@ -278,6 +281,8 @@ realDockerTest( measuredPath: probe.capacity.path, measuredSource: probe.capacity.source, measuredAvailableBytes: String(probe.capacity.availableBytes), + imageDownloadSizeBytes: String(profile.imageDownloadSizeBytes), + requiredAvailableBytes: String(requiredAvailableBytes), managedInstallCrossedImageStorageGate: true, installSubprocessTimeoutMs: INSTALL_SUBPROCESS_TIMEOUT_MS, installDockerCommands, From cfef6bb9fe869bde909f4ee16588aeee13c192a5 Mon Sep 17 00:00:00 2001 From: Charan Jagwani Date: Thu, 16 Jul 2026 13:41:28 -0700 Subject: [PATCH 10/10] test(vllm): exercise express storage acceptance Signed-off-by: Charan Jagwani --- test/vllm-docker-storage.test.ts | 149 +++++++++++++++++-------------- tools/e2e/workflow-boundary.mts | 1 + 2 files changed, 85 insertions(+), 65 deletions(-) diff --git a/test/vllm-docker-storage.test.ts b/test/vllm-docker-storage.test.ts index 8fe6992d14d..b4359014f46 100644 --- a/test/vllm-docker-storage.test.ts +++ b/test/vllm-docker-storage.test.ts @@ -9,13 +9,10 @@ import os from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; -import { afterEach, expect, test, vi } from "vitest"; +import { expect, test } from "vitest"; import { detectVllmProfile } from "../src/lib/inference/vllm"; -import { - imageStorageRequirementBytes, - probeDockerStorage, -} from "../src/lib/inference/vllm-storage"; +import { imageStorageRequirementBytes } from "../src/lib/inference/vllm-storage"; const TARGET_ID = "vllm-docker-storage"; const DOCKER_HOST = "unix:///run/docker.sock"; @@ -31,6 +28,12 @@ interface DockerInfo { ServerVersion?: unknown; } +interface StatfsSample { + path: string; + bavail: string; + bsize: string; +} + function dockerProxySource(realDockerPath: string, commandLogPath: string): string { return `#!/usr/bin/env node const { appendFileSync } = require("node:fs"); @@ -59,25 +62,30 @@ process.exit(result.status ?? 99); `; } -function installChildSource(vllmModuleUrl: string): string { +function installChildSource( + onboardModuleUrl: string, + statfsLogPath: string, + model: string, +): string { return ` -import vllmModule from ${JSON.stringify(vllmModuleUrl)}; -const { detectVllmProfile, installVllm } = vllmModule; -const profile = detectVllmProfile({ platform: "linux", type: "nvidia" }); -if (!profile) throw new Error("managed vLLM has no generic Linux profile"); -process.env.NEMOCLAW_VLLM_MODEL = profile.defaultModel.envValue; +const fs = (await import("node:fs")).default; +const originalStatfsSync = fs.statfsSync.bind(fs); +fs.statfsSync = (...args) => { + const sample = originalStatfsSync(...args); + fs.appendFileSync(${JSON.stringify(statfsLogPath)}, JSON.stringify({ + path: String(args[0]), + bavail: String(sample.bavail), + bsize: String(sample.bsize), + }) + "\\n"); + return sample; +}; +process.env.NEMOCLAW_NON_INTERACTIVE = "1"; +process.env.NEMOCLAW_PROVIDER = "install-vllm"; +process.env.NEMOCLAW_VLLM_MODEL = ${JSON.stringify(model)}; delete process.env.NEMOCLAW_VLLM_EXTRA_ARGS_JSON; -const result = await installVllm({ - ...profile, - image: "example.invalid/nemoclaw/vllm@sha256:${"0".repeat(64)}", - containerName: "nemoclaw-vllm-storage-e2e-" + String(process.pid), - pullTimeoutSec: 1, -}, { - hasImage: false, - nonInteractive: true, - promptFn: async () => "", -}); -process.stdout.write("\\nNEMOCLAW_INSTALL_RESULT=" + JSON.stringify(result) + "\\n"); +const onboardModule = await import(${JSON.stringify(onboardModuleUrl)}); +const { setupNim } = onboardModule.default ?? onboardModule; +await setupNim({ platform: "linux", type: "nvidia" }, null, null, false); `; } @@ -102,13 +110,8 @@ function writeEvidence(evidence: Record): void { persist(); } -afterEach(() => { - vi.restoreAllMocks(); - vi.unstubAllEnvs(); -}); - realDockerTest( - "allows non-interactive managed vLLM past the real /run/docker.sock storage gate (#7039)", + "allows non-interactive express managed vLLM past the real /run/docker.sock storage gate (#7039)", () => { expect(process.platform, "this release acceptance requires a native Linux host").toBe("linux"); expect( @@ -134,37 +137,15 @@ realDockerTest( expect(typeof info.DockerRootDir).toBe("string"); const dockerRootDir = String(info.DockerRootDir); expect(path.isAbsolute(dockerRootDir)).toBe(true); - const dockerRootStats = fs.statfsSync(dockerRootDir, { bigint: true }); - const dockerRootAvailableBytes = dockerRootStats.bavail * dockerRootStats.bsize; - expect(dockerRootAvailableBytes).toBeGreaterThan(0n); - - vi.stubEnv("DOCKER_HOST", DOCKER_HOST); - vi.stubEnv("DOCKER_CONTEXT", undefined); - const capacitySamples = new Map(); - const probe = probeDockerStorage({ - statfs: (target) => { - const sample = fs.statfsSync(target, { bigint: true }); - capacitySamples.set(target, sample); - return sample; - }, - }); - expect(probe.ok, probe.ok ? undefined : probe.reason).toBe(true); - assert(probe.ok); - - const capacityStats = capacitySamples.get(probe.capacity.path); - assert(capacityStats, `the probe did not sample ${probe.capacity.path}`); - const measuredAvailableBytes = capacityStats.bavail * capacityStats.bsize; - expect(probe.capacity.availableBytes).toBe(measuredAvailableBytes); - expect(probe.capacity.availableBytes).toBeGreaterThan(0n); const profile = detectVllmProfile({ platform: "linux", type: "nvidia" }); assert(profile, "managed vLLM has no generic Linux profile"); const requiredAvailableBytes = imageStorageRequirementBytes(profile.imageDownloadSizeBytes); - expect(probe.capacity.availableBytes).toBeGreaterThanOrEqual(requiredAvailableBytes); const fakeBinDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-vllm-storage-")); const blockedHome = path.join(fakeBinDir, "blocked-home"); const commandLogPath = path.join(fakeBinDir, "docker-commands.jsonl"); + const statfsLogPath = path.join(fakeBinDir, "statfs-samples.jsonl"); const dockerPathResult = spawnSync("sh", ["-c", "command -v docker"], { encoding: "utf8", env, @@ -178,9 +159,27 @@ realDockerTest( ).toBe(0); const realDockerPath = dockerPathResult.stdout.trim(); expect(path.isAbsolute(realDockerPath)).toBe(true); + const cachedImageResult = spawnSync( + realDockerPath, + ["image", "inspect", "--format", "{{.Id}}", profile.image], + { encoding: "utf8", env, timeout: 10_000 }, + ); + expect( + cachedImageResult.error, + `could not check the managed vLLM image cache: ${cachedImageResult.error?.message}`, + ).toBeUndefined(); + expect( + cachedImageResult.status, + "the managed vLLM image must be absent so production cannot skip its storage guard", + ).not.toBe(0); let installDockerCommands: string[] = []; + let productionStatfsSamples: StatfsSample[] = []; + let measuredPath = ""; + let measuredAvailableBytes = 0n; try { - fs.writeFileSync(blockedHome, "not a directory\n"); + fs.mkdirSync(blockedHome); + fs.writeFileSync(path.join(blockedHome, ".cache"), "not a directory\n"); + fs.writeFileSync(statfsLogPath, ""); fs.writeFileSync(path.join(fakeBinDir, "nvidia-smi"), "#!/bin/sh\nexit 0\n", { mode: 0o755, }); @@ -200,7 +199,11 @@ realDockerTest( "tsx", "--input-type=module", "--eval", - installChildSource(pathToFileURL(path.resolve("src/lib/inference/vllm.ts")).href), + installChildSource( + pathToFileURL(path.resolve("src/lib/onboard.ts")).href, + statfsLogPath, + profile.defaultModel.envValue, + ), ], { cwd: process.cwd(), @@ -216,22 +219,37 @@ realDockerTest( ).toBeUndefined(); expect( installResult.status, - `managed-vLLM install subprocess failed:\n${installResult.stderr}\n${installResult.stdout}`, - ).toBe(0); - expect(installResult.stdout).toContain('NEMOCLAW_INSTALL_RESULT={"ok":false}'); + `managed-vLLM express subprocess did not reach the intentional post-guard abort:\n${installResult.stderr}\n${installResult.stdout}`, + ).toBe(1); expect(installResult.stderr).toContain("could not create Hugging Face cache directory"); + expect(installResult.stderr).toContain( + "[non-interactive] Aborting: vLLM install failed. See errors above.", + ); expect(installResult.stderr).not.toContain("Docker storage for the managed vLLM image"); + expect(`${installResult.stdout}\n${installResult.stderr}`).not.toContain("Continue anyway"); const dockerCommands = fs .readFileSync(commandLogPath, "utf8") .trim() .split(/\r?\n/u) .map((line) => JSON.parse(line) as string[]); - expect(dockerCommands.map((args) => args.slice(0, 2))).toEqual([ - ["container", "ls"], - ["image", "inspect"], - ["info", "--format"], - ]); installDockerCommands = dockerCommands.map((args) => args.slice(0, 2).join(" ")); + expect(new Set(installDockerCommands)).toEqual( + new Set(["container ls", "image inspect", "info --format"]), + ); + + const statfsLog = fs.readFileSync(statfsLogPath, "utf8").trim(); + expect(statfsLog, "production did not consume a filesystem capacity sample").not.toBe(""); + productionStatfsSamples = statfsLog + .split(/\r?\n/u) + .map((line) => JSON.parse(line) as StatfsSample); + const dockerRootSample = [...productionStatfsSamples] + .reverse() + .find((sample) => path.resolve(sample.path) === path.resolve(dockerRootDir)); + assert(dockerRootSample, `production did not sample Docker root ${dockerRootDir}`); + measuredPath = dockerRootSample.path; + measuredAvailableBytes = BigInt(dockerRootSample.bavail) * BigInt(dockerRootSample.bsize); + expect(measuredAvailableBytes).toBeGreaterThan(0n); + expect(measuredAvailableBytes).toBeGreaterThanOrEqual(requiredAvailableBytes); } finally { fs.rmSync(fakeBinDir, { force: true, recursive: true }); } @@ -277,10 +295,11 @@ realDockerTest( dockerHost: DOCKER_HOST, dockerServerVersion: info.ServerVersion, dockerRootDir, - dockerRootAvailableBytes: String(dockerRootAvailableBytes), - measuredPath: probe.capacity.path, - measuredSource: probe.capacity.source, - measuredAvailableBytes: String(probe.capacity.availableBytes), + dockerRootAvailableBytes: String(measuredAvailableBytes), + measuredPath, + measuredSource: "Docker root directory", + measuredAvailableBytes: String(measuredAvailableBytes), + productionStatfsSamples, imageDownloadSizeBytes: String(profile.imageDownloadSizeBytes), requiredAvailableBytes: String(requiredAvailableBytes), managedInstallCrossedImageStorageGate: true, diff --git a/tools/e2e/workflow-boundary.mts b/tools/e2e/workflow-boundary.mts index 0a01f80a748..92d1b6875a9 100644 --- a/tools/e2e/workflow-boundary.mts +++ b/tools/e2e/workflow-boundary.mts @@ -3767,6 +3767,7 @@ export function validateE2eWorkflow(workflowValue: unknown): string[] { if (Object.hasOwn(dispatchInputs, "test_filter")) { errors.push("workflow_dispatch must not expose legacy test_filter input"); } + const permissions = asRecord(workflow.permissions); if (permissions.contents !== "read") errors.push("workflow permissions.contents must be read");