Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/lib/agent/runtime-recovery-preload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ function makeHarness() {
hostileMarker: path.join(root, "hostile-proxy-env-sourced"),
};

fs.writeFileSync(paths.sourceSafetyNet, "module.exports = 'trusted safety net';\n");
fs.writeFileSync(paths.sourceCiao, "module.exports = 'trusted ciao guard';\n");
fs.writeFileSync(paths.sourceSafetyNet, "module.exports = 'trusted safety net';\n", {
mode: 0o644,
});
fs.writeFileSync(paths.sourceCiao, "module.exports = 'trusted ciao guard';\n", {
mode: 0o644,
});

return paths;
}
Expand Down
4 changes: 2 additions & 2 deletions test/cli/sandbox-status-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ describe("CLI sandbox status JSON output", () => {
const localBin = path.join(home, "bin");
fs.mkdirSync(localBin, { recursive: true });
writeSandboxRegistry(home, "alpha", {
provider: "openai-api",
provider: "compatible-endpoint",
model: "gpt-4o-mini",
openshellDriver: "vm",
});
Expand All @@ -481,7 +481,7 @@ describe("CLI sandbox status JSON output", () => {
"#!/usr/bin/env bash",
'if [ "$1" = "inference" ] && [ "$2" = "get" ]; then',
" echo 'Gateway inference:'",
" echo ' Provider: openai-api'",
" echo ' Provider: compatible-endpoint'",
" echo ' Model: gpt-4o-mini'",
" exit 0",
"fi",
Expand Down
8 changes: 6 additions & 2 deletions test/helpers/runtime-recovery-preload-test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export function createRecoveryPreloadHarnessPaths(root: string): RecoveryPreload
preloadTmpSafetyNet: path.join(root, "preload-tmp-safety-net.js"),
preloadTmpCiao: path.join(root, "preload-tmp-ciao.js"),
};
fs.writeFileSync(paths.preloadSourceSafetyNet, "module.exports = 'trusted safety net';\n");
fs.writeFileSync(paths.preloadSourceCiao, "module.exports = 'trusted ciao guard';\n");
fs.writeFileSync(paths.preloadSourceSafetyNet, "module.exports = 'trusted safety net';\n", {
mode: 0o644,
});
fs.writeFileSync(paths.preloadSourceCiao, "module.exports = 'trusted ciao guard';\n", {
mode: 0o644,
});
return paths;
}

Expand Down
49 changes: 45 additions & 4 deletions tools/e2e-scenarios/workflow-boundary.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { readFileSync } from "node:fs";
import { readFileSync, statSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import YAML from "yaml";
Expand Down Expand Up @@ -30,6 +30,12 @@ export interface FreeStandingJobsInventory {
scenarioToJob: Map<string, string>;
}

type CachedFreeStandingJobsInventory = {
mtimeMs: number;
size: number;
inventory: FreeStandingJobsInventory;
};

const SELECTOR_PATTERN = /^[A-Za-z0-9_-]+(,[A-Za-z0-9_-]+)*$/;
const SELECTOR_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
const FREE_STANDING_JOB_MARKER = "FREE_STANDING_VITEST_JOB";
Expand Down Expand Up @@ -123,10 +129,22 @@ function deriveFreeStandingJobsInventoryFromJobs(jobs: WorkflowRecord): {
};
}

const freeStandingJobsInventoryCache = new Map<string, CachedFreeStandingJobsInventory>();

function readWorkflowRecord(workflowPath: string): WorkflowRecord {
return asRecord(YAML.parse(readFileSync(workflowPath, "utf-8")));
}

function cloneFreeStandingJobsInventory(
inventory: FreeStandingJobsInventory,
): FreeStandingJobsInventory {
return {
allowedJobs: [...inventory.allowedJobs],
freeStandingScenarios: [...inventory.freeStandingScenarios],
scenarioToJob: new Map(inventory.scenarioToJob),
};
}

export function validateFreeStandingWorkflowInventory(
workflowPath = DEFAULT_VITEST_WORKFLOW_PATH,
): string[] {
Expand All @@ -137,11 +155,22 @@ export function validateFreeStandingWorkflowInventory(
export function readFreeStandingJobsInventory(
workflowPath = DEFAULT_VITEST_WORKFLOW_PATH,
): FreeStandingJobsInventory {
const stats = statSync(workflowPath);
const cached = freeStandingJobsInventoryCache.get(workflowPath);
if (cached && cached.mtimeMs === stats.mtimeMs && cached.size === stats.size) {
return cloneFreeStandingJobsInventory(cached.inventory);
}

const workflow = readWorkflowRecord(workflowPath);
const { errors, inventory } = deriveFreeStandingJobsInventoryFromJobs(asRecord(workflow.jobs));
if (errors.length > 0) {
throw new Error(`Invalid free-standing workflow inventory:\n${errors.join("\n")}`);
}
freeStandingJobsInventoryCache.set(workflowPath, {
mtimeMs: stats.mtimeMs,
size: stats.size,
inventory: cloneFreeStandingJobsInventory(inventory),
});
return inventory;
}

Expand Down Expand Up @@ -2479,7 +2508,9 @@ function validateDiagnosticsVitestJob(errors: string[], jobs: WorkflowRecord): v
errors.push("diagnostics-vitest job must not expose Docker auth to branch-controlled steps");
}
if (jobEnv.E2E_ARTIFACT_DIR !== "${{ github.workspace }}/e2e-artifacts/vitest/diagnostics") {
errors.push("diagnostics-vitest job must write artifacts under e2e-artifacts/vitest/diagnostics");
errors.push(
"diagnostics-vitest job must write artifacts under e2e-artifacts/vitest/diagnostics",
);
}
if (jobEnv.NEMOCLAW_CLI_BIN !== "${{ github.workspace }}/bin/nemoclaw.js") {
errors.push("diagnostics-vitest job must point NEMOCLAW_CLI_BIN at the repo CLI");
Expand All @@ -2499,7 +2530,12 @@ function validateDiagnosticsVitestJob(errors: string[], jobs: WorkflowRecord): v
if (jobEnv.OPENSHELL_GATEWAY !== "nemoclaw") {
errors.push("diagnostics-vitest job must force OPENSHELL_GATEWAY=nemoclaw");
}
for (const secret of ["NVIDIA_API_KEY", "DOCKERHUB_USERNAME", "DOCKERHUB_TOKEN", "GITHUB_TOKEN"]) {
for (const secret of [
"NVIDIA_API_KEY",
"DOCKERHUB_USERNAME",
"DOCKERHUB_TOKEN",
"GITHUB_TOKEN",
]) {
requireEnvDoesNotExposeSecret(errors, "diagnostics-vitest job", jobEnv, secret);
}

Expand Down Expand Up @@ -2534,7 +2570,12 @@ function validateDiagnosticsVitestJob(errors: string[], jobs: WorkflowRecord): v
if (!setupNode) errors.push("diagnostics-vitest job missing step: Set up Node");
requireFullShaAction(errors, setupNode, "diagnostics-vitest setup-node");

const installRootDependencies = requireJobStep(errors, jobName, steps, "Install root dependencies");
const installRootDependencies = requireJobStep(
errors,
jobName,
steps,
"Install root dependencies",
);
requireRunContains(errors, installRootDependencies, "npm ci --ignore-scripts");

const buildCli = requireJobStep(errors, jobName, steps, "Build CLI");
Expand Down
Loading