From b9d091001bf6c94f329a6cc37dadc2f3f4bafd07 Mon Sep 17 00:00:00 2001 From: Rebecca Sliter <571084+rsliter@users.noreply.github.com> Date: Thu, 15 Oct 2026 12:44:27 -0700 Subject: [PATCH 1/5] test(e2e): replace credentialed hosted smokes with contracts Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com> --- .github/workflows/e2e.yaml | 2 +- src/lib/inference/health.test.ts | 14 +- test/e2e/README.md | 57 ++-- test/e2e/live/inference-routing-helpers.ts | 18 +- .../inference-routing-provider-smoke.test.ts | 244 +++++++----------- test/e2e/mock-parity.json | 3 +- ...e2e-report-to-pr-workflow-boundary.test.ts | 4 +- .../hosted-provider-smoke-selection.test.ts | 84 ++++-- .../helpers/onboard-smoke-verifier-harness.ts | 12 +- .../onboarding/onboard-smoke-verifier.test.ts | 27 ++ tools/e2e/hosted-provider-smoke.mts | 46 ---- .../standard-profile-workflow-boundary.mts | 2 +- tools/e2e/target-catalogue.mts | 30 +-- 13 files changed, 258 insertions(+), 285 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index b593b7af8d2..afa77fbc3f7 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -3519,7 +3519,7 @@ jobs: secrets: DOCKERHUB_USERNAME: ${{ github.ref == 'refs/heads/main' && github.workflow_ref == 'NVIDIA/NemoClaw/.github/workflows/e2e.yaml@refs/heads/main' && github.repository == 'NVIDIA/NemoClaw' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && (inputs.checkout_sha == '' || needs.generate-matrix.outputs.e2e_credentials_allowed == 'true') && secrets.DOCKERHUB_USERNAME || '' }} DOCKERHUB_TOKEN: ${{ github.ref == 'refs/heads/main' && github.workflow_ref == 'NVIDIA/NemoClaw/.github/workflows/e2e.yaml@refs/heads/main' && github.repository == 'NVIDIA/NemoClaw' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && (inputs.checkout_sha == '' || needs.generate-matrix.outputs.e2e_credentials_allowed == 'true') && secrets.DOCKERHUB_TOKEN || '' }} - HOSTED_INFERENCE_API_KEY: ${{ github.ref == 'refs/heads/main' && github.workflow_ref == 'NVIDIA/NemoClaw/.github/workflows/e2e.yaml@refs/heads/main' && github.repository == 'NVIDIA/NemoClaw' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && (inputs.checkout_sha == '' || needs.generate-matrix.outputs.e2e_credentials_allowed == 'true') && (matrix.id == 'hosted-inference-openai' && secrets.OPENAI_API_KEY || matrix.id == 'hosted-inference-anthropic' && secrets.ANTHROPIC_API_KEY || matrix.id == 'hosted-inference-gemini' && secrets.GEMINI_API_KEY || matrix.id == 'hosted-inference-openrouter' && secrets.OPENROUTER_API_KEY || matrix.id == 'hosted-inference-hermes' && secrets.NOUS_API_KEY) || '' }} + HOSTED_INFERENCE_API_KEY: ${{ github.ref == 'refs/heads/main' && github.workflow_ref == 'NVIDIA/NemoClaw/.github/workflows/e2e.yaml@refs/heads/main' && github.repository == 'NVIDIA/NemoClaw' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && (inputs.checkout_sha == '' || needs.generate-matrix.outputs.e2e_credentials_allowed == 'true') && matrix.id == 'hosted-inference-openrouter' && secrets.OPENROUTER_API_KEY || '' }} catalogue-standard: name: ${{ matrix.display_name }} (${{ matrix.runtime_provider }}) diff --git a/src/lib/inference/health.test.ts b/src/lib/inference/health.test.ts index e98689d2c72..2c17471c446 100644 --- a/src/lib/inference/health.test.ts +++ b/src/lib/inference/health.test.ts @@ -149,16 +149,24 @@ describe("inference health", () => { it("invokes the Gemini OpenAI-compatible chat-completions shim, not the native v1/models surface", () => { let capturedArgv: string[] = []; + let authConfigContent = ""; + const credentialNames: string[] = []; const result = probeRemoteProviderHealth("gemini-api", { model: "gemini-2.5-flash", - getCredentialImpl: (envName) => (envName === "GEMINI_API_KEY" ? "gm-test-secret" : null), + getCredentialImpl: (envName) => { + credentialNames.push(envName); + return envName === "GEMINI_API_KEY" ? "gm-test-secret" : null; + }, runCurlProbeImpl: (argv) => { capturedArgv = argv; + authConfigContent = fs.readFileSync(curlArgValue(argv, "--config")!, "utf8"); return httpOk(); }, }); expect(result?.ok).toBe(true); + expect(result?.probed).toBe(true); + expect(credentialNames).toEqual(["GEMINI_API_KEY"]); expect(result?.endpoint).toBe( "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions", ); @@ -166,9 +174,11 @@ describe("inference health", () => { "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions", ); expect(capturedArgv.join(" ")).not.toContain("gm-test-secret"); + expect(authConfigContent).toContain("Authorization: Bearer gm-test-secret"); const payload = JSON.parse(capturedArgv[capturedArgv.indexOf("-d") + 1]); - expect(payload).toMatchObject({ + expect(payload).toEqual({ model: "gemini-2.5-flash", + messages: [{ role: "user", content: "Reply with exactly: OK" }], max_tokens: 256, }); }); diff --git a/test/e2e/README.md b/test/e2e/README.md index 9a07a75dd1c..109f5f319e0 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -2385,23 +2385,21 @@ The explicit `dgx-station-express` target runs the local Station Express install ## Fixed hosted provider qualification -`live/inference-routing-provider-smoke.test.ts` owns credential-backed native inference smoke tests. -Select `openai`, `anthropic`, `gemini`, `openrouter`, or `hermes` with -`NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE`. Selecting `openrouter` runs both -OpenRouter agent cases; `all` runs all six cases. -Use an approved disposable environment and credentials from its approved source. +`live/inference-routing-provider-smoke.test.ts` owns the credential-backed OpenRouter smoke. +Select `openrouter` with `NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE` to run both +OpenRouter agent cases. +Use an approved disposable environment and OpenRouter credential from its approved source. These tests are outside the credential-free `inference-routing` PR lane. -A skipped provider is missing qualification evidence. +A skipped OpenRouter case is missing qualification evidence. TC-INF-05 uses the same probe for NVIDIA credential isolation. Its separate environment, process, filesystem, and canary checks are replaced by the probe results; support tests cover leak detection and control cleanup. -OpenAI, Anthropic, Gemini, and OpenRouter onboard OpenClaw and start a fresh agent process. -Hermes Provider onboards Hermes and submits a fresh request to its managed API. +OpenRouter onboards OpenClaw and starts a fresh agent process. The `hosted-inference-openrouter` target also onboards Deep Agents Code with the same OpenRouter key and model. Its six-assertion case checks onboarding, credential isolation, the native TOML route, and one fresh `dcode -n --json` response. -The five OpenClaw and Hermes cases check the native endpoint, credential placeholder, +The OpenClaw case checks the native endpoint, credential placeholder, selected adapter, response model, and nonempty answer. The OpenRouter case switches the running sandbox to a second model and back. It requires a fresh agent response with that model after each switch and checks that the return route is readable. @@ -2410,7 +2408,7 @@ An unavailable or rate-limited intermediate model fails the first switch. The alternate route read and return-route model assertion were removed from this live case: agent responses prove the effective model after each restart, while the recorded-model behavior belongs to the `inference get` source tests. Both switch exit checks and the return route read remain. -After onboarding, each hosted-provider case runs one sandbox probe before its first native agent request. +After onboarding, the OpenRouter case runs one sandbox probe before its first native agent request. The OpenRouter model-switch requests and follow-up agent responses do not repeat that scan. The probe checks the raw environment and a bounded file sample for a salted fingerprint of the selected credential. The probe tries `ps aux`, then `ps -ef`, to check process arguments. @@ -2426,30 +2424,32 @@ rejection and credential binding. Deterministic tests own protocol/header construction, ownership collisions, sandbox isolation, restart, and failed-operation recovery. -Each selected case requires its matching approved model variable, listed below. The smoke does not select a default model. -The Hermes smoke uses `NOUS_API_KEY`. It does not prove interactive OAuth login or token refresh. +The smoke requires the approved `NEMOCLAW_OPENROUTER_MODEL`; it does not select a default model. Credentials remain in the test host environment and OpenShell provider store; artifacts redact them. The cleanup helper destroys each test sandbox. The Deep Agents Code case checks sandbox absence even if onboarding fails. -Other hosted cases check absence after successful onboarding; failed onboarding uses best-effort cleanup. +The OpenClaw case checks absence after successful onboarding; failed onboarding uses best-effort cleanup. Neither path proves removal of credentials from the OpenShell provider store. Discard the approved disposable gateway after each run, including failed onboarding. Use a fresh gateway for a retry. -Select one explicit target with `targets=hosted-inference-openai`, `hosted-inference-anthropic`, -`hosted-inference-gemini`, `hosted-inference-openrouter`, or `hosted-inference-hermes`. -These Docker targets reuse `inference-routing-provider-smoke.test.ts` and the trusted E2E controller. -These targets require explicit selection. Default suites and changed-file selection do not include them, -even when a workflow or provider source changes. The initial consumer is Slice 2 (#12589); its native -provider behavior must exist in the candidate before running these assertions. Advisor can recommend -an explicit hosted target. Selection does not grant dispatch or credential access. +Select `targets=hosted-inference-openrouter` explicitly. +This Docker target reuses `inference-routing-provider-smoke.test.ts` and the trusted E2E controller. +It requires explicit selection. Default suites and changed-file selection do not include it, +even when a workflow or provider source changes. Advisor can recommend the OpenRouter target. +Selection does not grant dispatch or credential access. The credential-free `inference-routing` target remains separate. -Before dispatch, obtain an approved disposable environment and credential source for the selected provider. +OpenAI, Anthropic, Gemini, and Hermes Provider use deterministic source contracts for fixed +endpoint and method selection, request headers and body, response parsing, native agent +configuration, provider-bound credentials, and rejection of crossed routes. Their four former +credentialed selectors are unavailable. These contracts do not demonstrate live upstream +authentication, model availability, or a fresh remote answer. That evidence is deferred for +issues #12589 and #12955; neither issue waits on those E2Es. + +Before dispatch, obtain an approved disposable environment and OpenRouter credential source. Credential-bearing hosted runs require the canonical `e2e.yaml` workflow from `main`. Branch-dispatched workflows receive no hosted-provider or registry credentials, even for an approved candidate. -The controller passes only that target's repository secret (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, -`GEMINI_API_KEY`, `OPENROUTER_API_KEY`, or `NOUS_API_KEY`) to the test step. -Set the corresponding repository variable `NEMOCLAW_OPENAI_MODEL`, `NEMOCLAW_ANTHROPIC_MODEL`, -`NEMOCLAW_GEMINI_MODEL`, `NEMOCLAW_OPENROUTER_MODEL`, or `NEMOCLAW_HERMES_MODEL` to an approved model. +The controller passes only `OPENROUTER_API_KEY` to the test step. +Set `NEMOCLAW_OPENROUTER_MODEL` to an approved model. Missing credentials or models fail before onboarding. A selected test that skips cannot produce passing evidence. The existing controller binds artifacts to the tested source revision and trusted workflow revision. For an authorized hosted-provider candidate run, the trusted reporter comments on the PR after the selected jobs finish. @@ -2463,9 +2463,4 @@ Candidate-controlled host processes can read or copy the selected provider key w The sandbox isolation check does not attest isolation from those host processes. Job cleanup and artifact redaction do not revoke the key or erase a copy made by candidate code. Rotate or revoke the key in its issuing provider to remove later access. -Hermes API-key evidence does not qualify interactive OAuth login. - -Hermes OAuth remains a separate live qualification for Slice 2 (#12589). An authorized account operator -must complete device authorization in an approved disposable interactive environment, verify a fresh -request through the returned native endpoint, restart, and verify another fresh request. Record the -tested commit and redacted results. This prerequisite adds no OAuth selector or automation. +Hermes interactive OAuth evidence is also deferred for Slice 2 (#12589). diff --git a/test/e2e/live/inference-routing-helpers.ts b/test/e2e/live/inference-routing-helpers.ts index 59b42308b89..b38be9987c2 100644 --- a/test/e2e/live/inference-routing-helpers.ts +++ b/test/e2e/live/inference-routing-helpers.ts @@ -43,15 +43,12 @@ const CREDENTIAL_CLASSIFICATION_PATTERN = const TRANSPORT_CLASSIFICATION_PATTERN = /unreachable|timeout|connect|ECONNREFUSED|ETIMEDOUT|ENETUNREACH|EHOSTUNREACH|ENOTFOUND|EAI_AGAIN|No route to host|transport|network|endpoint|dns/i; -function shouldRunProviderSmoke( - provider: "openai" | "anthropic" | "gemini" | "openrouter" | "hermes", -): boolean { +function shouldRunProviderSmoke(provider: "openrouter"): boolean { // The former shell script auto-ran these smokes when provider secrets were - // present. This live migration requires an explicit opt-in so PR-safe jobs - // cannot spend third-party quota accidentally; any future secret-backed lane - // must set NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE=all or a provider name. + // present. This live smoke requires explicit selection so PR-safe jobs do + // not spend third-party quota accidentally. const requested = process.env.NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE?.trim().toLowerCase(); - return requested === "1" || requested === "true" || requested === "all" || requested === provider; + return requested === provider; } type SkipFn = (note?: string) => void; @@ -440,15 +437,12 @@ async function expectAnthropicMessageThroughSandbox( ); } -export function requireProviderSmokeSelected( - provider: "openai" | "anthropic" | "gemini" | "openrouter" | "hermes", - skip: SkipFn, -): void { +export function requireProviderSmokeSelected(provider: "openrouter", skip: SkipFn): void { if (!shouldRunProviderSmoke(provider)) { const label = provider; skipLive( skip, - `set NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE=${provider} or all to run ${label} smoke`, + `set NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE=${provider} to run ${label} smoke`, ); } } diff --git a/test/e2e/live/inference-routing-provider-smoke.test.ts b/test/e2e/live/inference-routing-provider-smoke.test.ts index 9e604e3a169..279743d2b6a 100644 --- a/test/e2e/live/inference-routing-provider-smoke.test.ts +++ b/test/e2e/live/inference-routing-provider-smoke.test.ts @@ -4,8 +4,6 @@ import crypto from "node:crypto"; import { hostedCredentialScanCommand } from "./inference-routing-credential-scan.ts"; import { parse as parseToml } from "smol-toml"; -import YAML from "yaml"; -import { hermesApiCommand } from "../fixtures/hermes-api-command.ts"; import { HOSTED_PROVIDER_SMOKE_CASES as hostedCases, hostedProviderSmokeEnvironment, @@ -37,9 +35,7 @@ import { verifyCredentialPlaceholder, } from "./inference-routing-helpers.ts"; -// These credential-backed smokes are intentionally outside the PR-required -// inference-routing lane. Explicit hosted-inference catalogue targets supply -// only the selected credential through the trusted E2E controller. +// The OpenRouter smoke is explicitly selected through the trusted E2E controller. test( "TC-INF-05 real NVIDIA key is isolated from sandbox env, process list, and filesystem", @@ -239,8 +235,6 @@ test( }, ); -// Four cases use OpenClaw; the Nous API-key case uses Hermes. - test.for(hostedCases)( "$id $label answers through its native provider", { @@ -269,7 +263,6 @@ test.for(hostedCases)( const apiKey = environment[selected.credential]!; const model = environment[selected.modelEnv]!; await requireLivePrerequisites(host, runtimeProvider); - const hermes = selected.selector === "hermes"; const sandboxName = inferenceSandboxName(`e2e-${selected.selector}`); cleanup.add(`best-effort hosted inference cleanup for ${sandboxName}`, () => cleanupSandbox(host, sandbox, sandboxName), @@ -284,9 +277,7 @@ test.for(hostedCases)( "agent uses the native endpoint with a credential placeholder", "selected credential is absent from sandbox environment, process arguments, and sampled files", "fresh agent request answers with the selected model", - ...(selected.selector === "openrouter" - ? ["both OpenRouter model switches preserve a fresh agent response"] - : []), + "both OpenRouter model switches preserve a fresh agent response", ], }); progress.phase("onboard the hosted provider"); @@ -294,7 +285,7 @@ test.for(hostedCases)( artifacts, sandboxName, { - NEMOCLAW_AGENT: hermes ? "hermes" : "openclaw", + NEMOCLAW_AGENT: "openclaw", NEMOCLAW_MODEL: model, NEMOCLAW_PROVIDER: selected.provider, [selected.credential]: apiKey, @@ -310,12 +301,10 @@ test.for(hostedCases)( progress.phase("verify native agent configuration"); const config = await sandbox.exec( sandboxName, - hermes - ? ["cat", "/sandbox/.hermes/config.yaml"] - : [ - "node", - "-e", - String.raw` + [ + "node", + "-e", + String.raw` const fs = require("node:fs"); let config; try { @@ -336,10 +325,10 @@ console.log(JSON.stringify({ "openshell:resolve:env:" + process.argv[2], })); `, - selected.providerKey, - selected.placeholder, - selected.endpoint, - ], + selected.providerKey, + selected.placeholder, + selected.endpoint, + ], { artifactName: `${selected.id}-native-config`, env: buildAvailabilityProbeEnv(), @@ -348,12 +337,10 @@ console.log(JSON.stringify({ }, ); expect(config.exitCode, "native provider config read failed; inspect the artifact").toBe(0); - const providerConfig = hermes ? YAML.parse(config.stdout).model : JSON.parse(config.stdout); + const providerConfig = JSON.parse(config.stdout); expect(providerConfig).toMatchObject({ - [hermes ? "base_url" : "endpointMatches"]: hermes ? selected.endpoint : true, - [hermes ? "api_key" : "credentialHandleMatches"]: hermes - ? `\${${selected.placeholder}}` - : true, + endpointMatches: true, + credentialHandleMatches: true, }); progress.phase("verify hosted credential isolation"); const isolation = await sandbox.exec(sandboxName, hostedCredentialScanCommand(apiKey), { @@ -409,133 +396,94 @@ console.log(JSON.stringify({ .at(-1); return { response, document, text: parseOpenClawAgentText(response.stdout) }; }; - switch (selected.selector) { - case "openrouter": { - const alternateModel = - model === "nvidia/nemotron-3-super-120b-a12b" - ? "nvidia/nemotron-3-ultra-550b-a55b" - : "nvidia/nemotron-3-super-120b-a12b"; - const switchEnv = buildChildEnv( - { ...process.env, OPENROUTER_API_KEY: apiKey }, - { - additionalAllowedEnv: AVAILABILITY_PROBE_EXTRA_ENV_KEYS, - secretEnv: ["OPENROUTER_API_KEY"], - fixtureOverlay: {}, - }, - ); - progress.phase("switch OpenRouter models when selected"); - const toAlternate = await host.nemoclaw( - [ - "inference", - "set", - "--provider", - "openrouter-api", - "--model", - alternateModel, - "--sandbox", - sandboxName, - ], - { - artifactName: `${selected.id}-switch-to-alternate`, - env: switchEnv, - redactionValues: [apiKey], - timeoutMs: 180_000, - }, - ); - expect( - toAlternate.exitCode, - "OpenRouter alternate switch failed; inspect the redacted artifact", - ).toBe(0); - const { - response: alternateResponse, - document: alternateDocument, - text: alternateText, - } = await requestOpenClawAgent(`${selected.id}-alternate-native-agent`); - expect(alternateResponse.exitCode, resultText(alternateResponse)).toBe(0); - const alternateMeta = alternateDocument?.meta; - const alternateAgentMeta = isObjectRecord(alternateMeta) - ? alternateMeta.agentMeta - : undefined; - expect(isObjectRecord(alternateAgentMeta) ? alternateAgentMeta.model : undefined).toBe( - alternateModel, - ); - expect(alternateText.trim()).not.toBe(""); + const alternateModel = + model === "nvidia/nemotron-3-super-120b-a12b" + ? "nvidia/nemotron-3-ultra-550b-a55b" + : "nvidia/nemotron-3-super-120b-a12b"; + const switchEnv = buildChildEnv( + { ...process.env, OPENROUTER_API_KEY: apiKey }, + { + additionalAllowedEnv: AVAILABILITY_PROBE_EXTRA_ENV_KEYS, + secretEnv: ["OPENROUTER_API_KEY"], + fixtureOverlay: {}, + }, + ); + progress.phase("switch OpenRouter models when selected"); + const toAlternate = await host.nemoclaw( + [ + "inference", + "set", + "--provider", + "openrouter-api", + "--model", + alternateModel, + "--sandbox", + sandboxName, + ], + { + artifactName: `${selected.id}-switch-to-alternate`, + env: switchEnv, + redactionValues: [apiKey], + timeoutMs: 180_000, + }, + ); + expect( + toAlternate.exitCode, + "OpenRouter alternate switch failed; inspect the redacted artifact", + ).toBe(0); + const { + response: alternateResponse, + document: alternateDocument, + text: alternateText, + } = await requestOpenClawAgent(`${selected.id}-alternate-native-agent`); + expect(alternateResponse.exitCode, resultText(alternateResponse)).toBe(0); + const alternateMeta = alternateDocument?.meta; + const alternateAgentMeta = isObjectRecord(alternateMeta) ? alternateMeta.agentMeta : undefined; + expect(isObjectRecord(alternateAgentMeta) ? alternateAgentMeta.model : undefined).toBe( + alternateModel, + ); + expect(alternateText.trim()).not.toBe(""); - const backToSelected = await host.nemoclaw( - [ - "inference", - "set", - "--provider", - "openrouter-api", - "--model", - model, - "--sandbox", - sandboxName, - ], - { - artifactName: `${selected.id}-switch-back`, - env: switchEnv, - redactionValues: [apiKey], - timeoutMs: 180_000, - }, - ); - expect( - backToSelected.exitCode, - "OpenRouter return switch failed; inspect the redacted artifact", - ).toBe(0); - const selectedRoute = await host.nemoclaw([sandboxName, "inference", "get", "--json"], { - artifactName: `${selected.id}-selected-route`, - env: buildAvailabilityProbeEnv(), - timeoutMs: 30_000, - }); - expect( - selectedRoute.exitCode, - "OpenRouter selected route read failed; inspect the artifact", - ).toBe(0); - break; - } - default: - break; - } - progress.phase("request a fresh agent response"); - const responseOptions = { - artifactName: `${selected.id}-native-agent`, + const backToSelected = await host.nemoclaw( + [ + "inference", + "set", + "--provider", + "openrouter-api", + "--model", + model, + "--sandbox", + sandboxName, + ], + { + artifactName: `${selected.id}-switch-back`, + env: switchEnv, + redactionValues: [apiKey], + timeoutMs: 180_000, + }, + ); + expect( + backToSelected.exitCode, + "OpenRouter return switch failed; inspect the redacted artifact", + ).toBe(0); + const selectedRoute = await host.nemoclaw([sandboxName, "inference", "get", "--json"], { + artifactName: `${selected.id}-selected-route`, env: buildAvailabilityProbeEnv(), - redactionValues: [apiKey], - timeoutMs: 180_000, - }; - const openClawResult = hermes - ? null - : await requestOpenClawAgent(`${selected.id}-native-agent`); - const response = hermes - ? await sandbox.execShell( - sandboxName, - trustedSandboxShellScript( - hermesApiCommand( - JSON.stringify({ - model, - messages: [ - { role: "user", content: "Reply with one short greeting. Do not use tools." }, - ], - stream: false, - }), - ), - ), - responseOptions, - ) - : openClawResult!.response; + timeoutMs: 30_000, + }); + expect( + selectedRoute.exitCode, + "OpenRouter selected route read failed; inspect the artifact", + ).toBe(0); + progress.phase("request a fresh agent response"); + const { response, document, text } = await requestOpenClawAgent(`${selected.id}-native-agent`); expect(response.exitCode, resultText(response)).toBe(0); - const document = hermes ? JSON.parse(response.stdout) : openClawResult!.document; - // Hermes reports the response model through its API; its selected adapter is - // recorded in config. OpenClaw reports both in the agent response metadata. - const agentSelection = hermes - ? { provider: providerConfig.provider, model: document.model } - : document?.meta?.agentMeta; + const meta = document?.meta; + const agentSelection = isObjectRecord(meta) ? meta.agentMeta : undefined; expect(agentSelection).toMatchObject({ - provider: hermes ? "custom" : selected.providerKey, + provider: selected.providerKey, model, }); - const text = hermes ? (document.choices?.[0]?.message?.content ?? "") : openClawResult!.text; expect(text.trim()).not.toBe(""); }, ); diff --git a/test/e2e/mock-parity.json b/test/e2e/mock-parity.json index e531a933254..9347f606a1b 100644 --- a/test/e2e/mock-parity.json +++ b/test/e2e/mock-parity.json @@ -203,8 +203,7 @@ { "live": "test/e2e/live/inference-routing-provider-smoke.test.ts", "liveSources": [ - "test/e2e/live/inference-routing-credential-scan.ts", - "test/e2e/fixtures/hermes-api-command.ts" + "test/e2e/live/inference-routing-credential-scan.ts" ], "fast": [ "test/generation/generate-native-hosted-config.test.ts", diff --git a/test/e2e/support/e2e-report-to-pr-workflow-boundary.test.ts b/test/e2e/support/e2e-report-to-pr-workflow-boundary.test.ts index 4dede60cb7e..70f5755acc6 100644 --- a/test/e2e/support/e2e-report-to-pr-workflow-boundary.test.ts +++ b/test/e2e/support/e2e-report-to-pr-workflow-boundary.test.ts @@ -976,7 +976,7 @@ const HOSTED_CANDIDATE_ENV: ReportEnv = { WORKFLOW_SHA: "c".repeat(40), MATRIX_RESULT: "success", SELECTED_WORKFLOW_JOBS: '["catalogue-hosted-inference"]', - JOB_TARGETS: "hosted-inference-openai", + JOB_TARGETS: "hosted-inference-openrouter", }; function hostedCandidatePr() { @@ -1035,7 +1035,7 @@ it.each(["success", "failure", "skipped"])( }); expect(report.body).toContain(`**Candidate commit:** \`${"a".repeat(40)}\``); expect(report.body).toContain(`**Trusted workflow commit:** \`${"c".repeat(40)}\``); - expect(report.body).toContain("hosted-inference-openai"); + expect(report.body).toContain("hosted-inference-openrouter"); expect(report.body).toContain(` ${result} |`); expect(report.body).toContain("cleanup.json"); expect(report.body.includes("All selected tests passed")).toBe(result === "success"); diff --git a/test/e2e/support/hosted-provider-smoke-selection.test.ts b/test/e2e/support/hosted-provider-smoke-selection.test.ts index f38b1b25c4e..ff842caab30 100644 --- a/test/e2e/support/hosted-provider-smoke-selection.test.ts +++ b/test/e2e/support/hosted-provider-smoke-selection.test.ts @@ -29,13 +29,7 @@ describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label qualification selection", (se const id = `hosted-inference-${selected.selector}`; it("selects only the named provider in the existing smoke owner", () => { const target = catalogueTarget(id); - expect(target.agentRuntime).toBe( - selected.selector === "hermes" - ? "hermes" - : selected.selector === "openrouter" - ? "openclaw + langchain-deepagents-code" - : "openclaw", - ); + expect(target.agentRuntime).toBe("openclaw + langchain-deepagents-code"); expect(target.testFile).toBe("test/e2e/live/inference-routing-provider-smoke.test.ts"); expect( new RegExp(target.selector!).test( @@ -66,6 +60,20 @@ describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label qualification selection", (se }); }); +it.each(["openai", "anthropic", "gemini", "hermes"])( + "does not register or route the retired %s credentialed target", + (provider) => { + const id = `hosted-inference-${provider}`; + expect(E2E_TARGET_CATALOGUE.map((target) => target.id)).not.toContain(id); + expect(catalogueRecommendationSelectorIds()).not.toContain(id); + expect(() => catalogueTarget(id)).toThrow("Unknown catalogue E2E target"); + expect(() => buildE2eWorkflowPlan({ targets: id })).toThrow(); + expect(() => hostedProviderSmokeEnvironment(id, {})).toThrow( + "Unknown hosted inference qualification target", + ); + }, +); + it("runs both OpenRouter agents through the existing trusted target", () => { const target = catalogueTarget("hosted-inference-openrouter"); expect( @@ -161,6 +169,10 @@ describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label workflow credential boundary" const secrets = { DOCKERHUB_USERNAME: "registry-user", DOCKERHUB_TOKEN: "registry-canary", + OPENAI_API_KEY: "retired-openai-canary", + ANTHROPIC_API_KEY: "retired-anthropic-canary", + GEMINI_API_KEY: "retired-gemini-canary", + NOUS_API_KEY: "retired-hermes-canary", ...Object.fromEntries( HOSTED_PROVIDER_SMOKE_CASES.map((provider) => [provider.credential, provider.selector]), ), @@ -210,6 +222,45 @@ describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label workflow credential boundary" }); }); +it.each(["openai", "anthropic", "gemini", "hermes"])( + "does not forward the retired %s secret even in a trusted workflow", + (provider) => { + const expression = workflow.jobs["catalogue-hosted-inference"].secrets.HOSTED_INFERENCE_API_KEY; + const context = { + github: { + repository: "NVIDIA/NemoClaw", + ref: "refs/heads/main", + workflow_ref: "NVIDIA/NemoClaw/.github/workflows/e2e.yaml@refs/heads/main", + event_name: "workflow_dispatch", + }, + inputs: { checkout_sha: "" }, + needs: { "generate-matrix": { outputs: { e2e_credentials_allowed: "true" } } }, + matrix: { id: `hosted-inference-${provider}` }, + secrets: { + OPENROUTER_API_KEY: "selected-canary", + OPENAI_API_KEY: "retired-canary", + ANTHROPIC_API_KEY: "retired-canary", + GEMINI_API_KEY: "retired-canary", + NOUS_API_KEY: "retired-canary", + }, + }; + const observed = execFileSync( + process.execPath, + [ + "-e", + `const { readFileSync } = require("node:fs"); + const { runInNewContext } = require("node:vm"); + const { expression, context } = JSON.parse(readFileSync(0, "utf8")); + process.stdout.write(runInNewContext( + expression.slice(3, -2).replaceAll("needs.generate-matrix", 'needs["generate-matrix"]'), + context, { timeout: 1000 }));`, + ], + { input: JSON.stringify({ expression, context }), env: {}, encoding: "utf8", timeout: 5000 }, + ); + expect(observed).toBe(""); + }, +); + // Evaluate the reusable workflow expression with distinct models to detect provider crossover. it.each(HOSTED_PROVIDER_SMOKE_CASES)("routes only the approved $label model", (selected) => { const profile = YAML.parse(readFileSync(".github/workflows/e2e-standard-profile.yaml", "utf8")); @@ -262,14 +313,17 @@ it.each(HOSTED_PROVIDER_SMOKE_CASES)("routes only the approved $label model", (s describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label local smoke prerequisites", (selected) => { afterEach(() => vi.unstubAllEnvs()); - it.each([undefined, "unrelated-provider"])("skips without matching opt-in %s", (requested) => { - vi.stubEnv("NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE", requested); - const skip = vi.fn(); - expect(() => requireProviderSmokeSelected(selected.selector, skip)).toThrow( - `NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE=${selected.selector}`, - ); - expect(skip).toHaveBeenCalledOnce(); - }); + it.each([undefined, "unrelated-provider", "all", "openai", "anthropic", "gemini", "hermes"])( + "skips without matching opt-in %s", + (requested) => { + vi.stubEnv("NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE", requested); + const skip = vi.fn(); + expect(() => requireProviderSmokeSelected(selected.selector, skip)).toThrow( + `NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE=${selected.selector}`, + ); + expect(skip).toHaveBeenCalledOnce(); + }, + ); it("runs only after explicit selection and validates its named key and model", () => { vi.stubEnv("NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE", selected.selector); diff --git a/test/helpers/onboard-smoke-verifier-harness.ts b/test/helpers/onboard-smoke-verifier-harness.ts index 72383eb5bfd..e6fa3b2523c 100644 --- a/test/helpers/onboard-smoke-verifier-harness.ts +++ b/test/helpers/onboard-smoke-verifier-harness.ts @@ -7,6 +7,7 @@ import path from "node:path"; export type SmokeVerifierHarnessCall = [string, ...unknown[]]; type VerifyOnboardSmokeInvocation = { + capturePayload?: boolean; selectedChatCapability?: boolean; credentialEnv?: string; endpointUrl?: string; @@ -23,6 +24,7 @@ export async function runVerifyOnboardSmokeHarness( const Module = require("node:module"); const originalLoad = Module._load; const calls = []; +let capturePayload = false; process.env.VITEST = "false"; @@ -68,7 +70,12 @@ Module._load = function patchedLoad(request, _parent, _isMain) { const headerMatch = contents.match(/header = "([^"]+)"/); authConfigSummary = headerMatch ? headerMatch[1] : "config:" + contents.trim(); } - calls.push(["runCurlProbe", args[args.length - 1], authConfigSummary]); + calls.push([ + "runCurlProbe", + args[args.length - 1], + authConfigSummary, + ...(capturePayload ? [JSON.parse(args[args.indexOf("-d") + 1])] : []), + ]); return { ok: true, httpStatus: 200, @@ -96,7 +103,8 @@ console.log = (...args) => calls.push(["log", args.join(" ")]); (async () => { for (const invocation of invocations) { - const { selectedChatCapability, ...input } = invocation; + const { selectedChatCapability, capturePayload: requestedPayload, ...input } = invocation; + capturePayload = requestedPayload === true; const capabilityCache = selectedChatCapability ? new OnboardInferenceCapabilityCache() : undefined; const effectiveInvocation = { endpointUrl: "https://api.example.com/v1", diff --git a/test/onboarding/onboard-smoke-verifier.test.ts b/test/onboarding/onboard-smoke-verifier.test.ts index 01509a07e14..9d95e63262d 100644 --- a/test/onboarding/onboard-smoke-verifier.test.ts +++ b/test/onboarding/onboard-smoke-verifier.test.ts @@ -68,6 +68,33 @@ describe("Hermes onboard smoke verification", () => { ]); }); + it("uses the fixed Hermes endpoint, NOUS credential, and Chat Completions payload (#13280)", async () => { + const calls = await runVerifyOnboardSmokeHarness([ + { + provider: "hermes-provider", + credentialEnv: "NOUS_API_KEY", + endpointUrl: "https://inference-api.nousresearch.com/v1", + model: "nous/test-model", + capturePayload: true, + }, + ]); + expect(calls.filter((call) => call[0] === "resolveProviderCredential")).toEqual([ + ["resolveProviderCredential", "NOUS_API_KEY"], + ]); + expect(calls.filter((call) => call[0] === "runCurlProbe")).toEqual([ + [ + "runCurlProbe", + "https://inference-api.nousresearch.com/v1/chat/completions", + "Authorization: Bearer resolved-NOUS_API_KEY", + expect.objectContaining({ + model: "nous/test-model", + messages: [{ role: "user", content: expect.any(String) }], + }), + ], + ]); + expect(JSON.stringify(calls)).not.toContain("OPENAI_API_KEY"); + }); + it("does not send a duplicate smoke request for a matching selected Chat Completions capability", async () => { const calls = await runVerifyOnboardSmokeHarness([ { diff --git a/tools/e2e/hosted-provider-smoke.mts b/tools/e2e/hosted-provider-smoke.mts index 849271e37f8..3f31dae2ea3 100644 --- a/tools/e2e/hosted-provider-smoke.mts +++ b/tools/e2e/hosted-provider-smoke.mts @@ -2,41 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 export const HOSTED_PROVIDER_SMOKE_CASES = [ - { - id: "TC-INF-02", - selector: "openai", - provider: "openai", - label: "OpenAI", - credential: "OPENAI_API_KEY", - modelEnv: "NEMOCLAW_OPENAI_MODEL", - defaultModel: "gpt-4o-mini", - providerKey: "openai", - endpoint: "https://api.openai.com/v1", - placeholder: "OPENAI_API_KEY", - }, - { - id: "TC-INF-03", - selector: "anthropic", - provider: "anthropic", - label: "Anthropic", - credential: "ANTHROPIC_API_KEY", - modelEnv: "NEMOCLAW_ANTHROPIC_MODEL", - defaultModel: "claude-sonnet-4-6", - providerKey: "anthropic", - endpoint: "https://api.anthropic.com", - placeholder: "ANTHROPIC_API_KEY", - }, - { - id: "TC-INF-06", - selector: "gemini", - provider: "gemini", - label: "Gemini", - credential: "GEMINI_API_KEY", - modelEnv: "NEMOCLAW_GEMINI_MODEL", - providerKey: "inference", - endpoint: "https://generativelanguage.googleapis.com/v1beta/openai/", - placeholder: "GEMINI_API_KEY", - }, { id: "TC-INF-07", selector: "openrouter", @@ -48,17 +13,6 @@ export const HOSTED_PROVIDER_SMOKE_CASES = [ endpoint: "https://openrouter.ai/api/v1", placeholder: "OPENROUTER_API_KEY", }, - { - id: "TC-INF-08", - selector: "hermes", - provider: "hermes", - label: "Hermes Provider", - credential: "NOUS_API_KEY", - modelEnv: "NEMOCLAW_HERMES_MODEL", - providerKey: "inference", - endpoint: "https://inference-api.nousresearch.com/v1", - placeholder: "OPENAI_API_KEY", - }, ] as const; /** Only the selected provider credential reaches the existing smoke test process. */ diff --git a/tools/e2e/standard-profile-workflow-boundary.mts b/tools/e2e/standard-profile-workflow-boundary.mts index fa8436dc7f2..52507c58be9 100644 --- a/tools/e2e/standard-profile-workflow-boundary.mts +++ b/tools/e2e/standard-profile-workflow-boundary.mts @@ -36,7 +36,7 @@ const HOSTED_WORKFLOW_SOURCE_GUARD = "github.ref == 'refs/heads/main' && github.workflow_ref == 'NVIDIA/NemoClaw/.github/workflows/e2e.yaml@refs/heads/main' && "; const guardedCallerSecret = (name: string, hosted = false): string => name === "HOSTED_INFERENCE_API_KEY" - ? `\${{ ${HOSTED_WORKFLOW_SOURCE_GUARD}github.repository == 'NVIDIA/NemoClaw' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && (inputs.checkout_sha == '' || needs.generate-matrix.outputs.e2e_credentials_allowed == 'true') && (matrix.id == 'hosted-inference-openai' && secrets.OPENAI_API_KEY || matrix.id == 'hosted-inference-anthropic' && secrets.ANTHROPIC_API_KEY || matrix.id == 'hosted-inference-gemini' && secrets.GEMINI_API_KEY || matrix.id == 'hosted-inference-openrouter' && secrets.OPENROUTER_API_KEY || matrix.id == 'hosted-inference-hermes' && secrets.NOUS_API_KEY) || '' }}` + ? `\${{ ${HOSTED_WORKFLOW_SOURCE_GUARD}github.repository == 'NVIDIA/NemoClaw' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && (inputs.checkout_sha == '' || needs.generate-matrix.outputs.e2e_credentials_allowed == 'true') && matrix.id == 'hosted-inference-openrouter' && secrets.OPENROUTER_API_KEY || '' }}` : `\${{ ${hosted ? HOSTED_WORKFLOW_SOURCE_GUARD : ""}${TRUSTED_CALLER_CREDENTIAL_PREDICATE} && secrets.${name} || '' }}`; const SKILL_AGENT_UPLOAD_PATH = `${[ "e2e-artifacts/live/skill-agent/evidence-manifest.json", diff --git a/tools/e2e/target-catalogue.mts b/tools/e2e/target-catalogue.mts index 1bad5bdc3ac..799710aebe8 100644 --- a/tools/e2e/target-catalogue.mts +++ b/tools/e2e/target-catalogue.mts @@ -1006,38 +1006,22 @@ export const E2E_TARGET_CATALOGUE: readonly E2eCatalogueTarget[] = [ }), ...HOSTED_PROVIDER_SMOKE_CASES.map((selected) => dockerOnlyTarget(`hosted-inference-${selected.selector}`, { - displayName: - selected.selector === "openrouter" - ? "Inference: completes native OpenRouter agent requests" - : `Inference: completes a native ${selected.label} agent request`, - agentRuntime: - selected.selector === "hermes" - ? "hermes" - : selected.selector === "openrouter" - ? "openclaw + langchain-deepagents-code" - : "openclaw", + displayName: "Inference: completes native OpenRouter agent requests", + agentRuntime: "openclaw + langchain-deepagents-code", prAdvisorSelectable: true, owningPaths: [ "test/e2e/live/inference-routing-credential-scan.ts", `managed-inference/provider-profiles/nemoclaw-${selected.selector}-inference-v1.yaml`, - ...(["openai", "anthropic", "hermes"].includes(selected.selector) - ? ["src/lib/inference/native-provider/", "src/lib/onboard/setup-inference.ts"] - : []), - ...(selected.selector === "hermes" ? ["src/lib/hermes-provider-auth.ts"] : []), - ...(selected.selector === "openrouter" - ? [ - "agents/langchain-deepagents-code/managed-dcode-runtime.py", - "agents/langchain-deepagents-code/generate-config.ts", - "src/lib/inference/managed-dcode/", - ] - : []), + "agents/langchain-deepagents-code/managed-dcode-runtime.py", + "agents/langchain-deepagents-code/generate-config.ts", + "src/lib/inference/managed-dcode/", ], environmentOrInferenceEndpoint: `Ubuntu; ${selected.label} hosted inference`, profile: "hosted-inference", releaseRequired: false, testFile: "test/e2e/live/inference-routing-provider-smoke.test.ts", - selector: selected.selector === "openrouter" ? selected.id : `^${selected.id}`, - timeoutMinutes: selected.selector === "openrouter" ? 45 : 30, + selector: selected.id, + timeoutMinutes: 45, installMode: "none", restoreCli: true, exposeCliBin: true, From 541164f28a302846b850c57b4d18b7abe51cd657 Mon Sep 17 00:00:00 2001 From: Rebecca Sliter <571084+rsliter@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:04:10 -0700 Subject: [PATCH 2/5] test(e2e): keep provider smoke within assertion budget --- test/e2e/live/inference-routing-provider-smoke.test.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/e2e/live/inference-routing-provider-smoke.test.ts b/test/e2e/live/inference-routing-provider-smoke.test.ts index faa3b7a858a..642ed37bcd4 100644 --- a/test/e2e/live/inference-routing-provider-smoke.test.ts +++ b/test/e2e/live/inference-routing-provider-smoke.test.ts @@ -486,15 +486,6 @@ console.log(JSON.stringify({ backToSelected.exitCode, "OpenRouter return switch failed; inspect the redacted artifact", ).toBe(0); - const selectedRoute = await host.nemoclaw([sandboxName, "inference", "get", "--json"], { - artifactName: `${selected.id}-selected-route`, - env: buildAvailabilityProbeEnv(), - timeoutMs: 30_000, - }); - expect( - selectedRoute.exitCode, - "OpenRouter selected route read failed; inspect the artifact", - ).toBe(0); progress.phase("request a fresh agent response"); const { response, document, text } = await requestOpenClawAgent(`${selected.id}-native-agent`); expect(response.exitCode, resultText(response)).toBe(0); From 0682e7095cf10c9b5144e4c7b1742e7ab1448194 Mon Sep 17 00:00:00 2001 From: Rebecca Sliter <571084+rsliter@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:38:13 -0700 Subject: [PATCH 3/5] docs(e2e): state Hermes response parsing limit --- test/e2e/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index 109f5f319e0..46ff6281191 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -2439,11 +2439,12 @@ Selection does not grant dispatch or credential access. The credential-free `inference-routing` target remains separate. OpenAI, Anthropic, Gemini, and Hermes Provider use deterministic source contracts for fixed -endpoint and method selection, request headers and body, response parsing, native agent -configuration, provider-bound credentials, and rejection of crossed routes. Their four former -credentialed selectors are unavailable. These contracts do not demonstrate live upstream -authentication, model availability, or a fresh remote answer. That evidence is deferred for -issues #12589 and #12955; neither issue waits on those E2Es. +endpoint and method selection, request headers and body, native agent configuration, +provider-bound credentials, and rejection of crossed routes. OpenAI, Anthropic, and Gemini +also have response-parsing contracts. Hermes malformed HTTP 2xx body parsing is deferred +to #13290. Their four former credentialed selectors are unavailable. These contracts do not +demonstrate live upstream authentication, model availability, or a fresh remote answer. +That evidence is deferred for issues #12589 and #12955; neither issue waits on those E2Es. Before dispatch, obtain an approved disposable environment and OpenRouter credential source. Credential-bearing hosted runs require the canonical `e2e.yaml` workflow from `main`. From e6d423b697ca812c7705c14541ab9cfdba7e799b Mon Sep 17 00:00:00 2001 From: Rebecca Sliter <571084+rsliter@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:16:43 -0700 Subject: [PATCH 4/5] refactor(e2e): use direct OpenRouter smoke metadata --- .../inference-routing-provider-smoke.test.ts | 18 ++--- .../hosted-provider-smoke-selection.test.ts | 76 ++++++++----------- tools/e2e/hosted-provider-smoke.mts | 45 +++++------ tools/e2e/target-catalogue.mts | 59 +++++++------- tools/e2e/workflow-plan.mts | 6 +- 5 files changed, 84 insertions(+), 120 deletions(-) diff --git a/test/e2e/live/inference-routing-provider-smoke.test.ts b/test/e2e/live/inference-routing-provider-smoke.test.ts index 642ed37bcd4..cac7a29ad69 100644 --- a/test/e2e/live/inference-routing-provider-smoke.test.ts +++ b/test/e2e/live/inference-routing-provider-smoke.test.ts @@ -6,8 +6,8 @@ import { CLI_ENTRYPOINT } from "../fixtures/paths.ts"; import { hostedCredentialScanCommand } from "./inference-routing-credential-scan.ts"; import { parse as parseToml } from "smol-toml"; import { - HOSTED_PROVIDER_SMOKE_CASES as hostedCases, - hostedProviderSmokeEnvironment, + OPENROUTER_SMOKE, + openRouterSmokeEnvironment, } from "../../../tools/e2e/hosted-provider-smoke.mts"; import { parseOpenClawAgentText } from "../fixtures/openclaw-agent-output.ts"; import { isObjectRecord } from "../../../src/lib/core/json-types.ts"; @@ -147,7 +147,7 @@ test( async ({ artifacts, cleanup, host, progress, runtimeProvider, sandbox, secrets, skip }) => { progress.phase("confirm hosted OpenRouter prerequisites"); requireProviderSmokeSelected("openrouter", skip); - const environment = hostedProviderSmokeEnvironment("hosted-inference-openrouter", { + const environment = openRouterSmokeEnvironment({ OPENROUTER_API_KEY: secrets.optional("OPENROUTER_API_KEY"), NEMOCLAW_OPENROUTER_MODEL: process.env.NEMOCLAW_OPENROUTER_MODEL, }); @@ -236,8 +236,8 @@ test( }, ); -test.for(hostedCases)( - "$id $label answers through its native provider", +test( + "TC-INF-07 OpenRouter answers through its native provider", { timeout: 35 * 60_000, meta: { @@ -253,12 +253,10 @@ test.for(hostedCases)( ], }, }, - async ( - selected, - { artifacts, cleanup, host, progress, runtimeProvider, sandbox, secrets, skip }, - ) => { + async ({ artifacts, cleanup, host, progress, runtimeProvider, sandbox, secrets, skip }) => { + const selected = OPENROUTER_SMOKE; requireProviderSmokeSelected(selected.selector, skip); - const environment = hostedProviderSmokeEnvironment(`hosted-inference-${selected.selector}`, { + const environment = openRouterSmokeEnvironment({ [selected.credential]: secrets.optional(selected.credential), [selected.modelEnv]: process.env[selected.modelEnv], }); diff --git a/test/e2e/support/hosted-provider-smoke-selection.test.ts b/test/e2e/support/hosted-provider-smoke-selection.test.ts index 7e90ed3709f..77b2eb31089 100644 --- a/test/e2e/support/hosted-provider-smoke-selection.test.ts +++ b/test/e2e/support/hosted-provider-smoke-selection.test.ts @@ -6,8 +6,8 @@ import { execFileSync } from "node:child_process"; import YAML from "yaml"; import { afterEach, describe, expect, it, vi } from "vitest"; import { - HOSTED_PROVIDER_SMOKE_CASES, - hostedProviderSmokeEnvironment, + OPENROUTER_SMOKE, + openRouterSmokeEnvironment, } from "../../../tools/e2e/hosted-provider-smoke.mts"; import { catalogueTarget, @@ -24,14 +24,15 @@ import { validateStandardProfileWorkflowBoundary } from "../../../tools/e2e/stan import { requireProviderSmokeSelected } from "../live/inference-routing-helpers.ts"; const workflow = YAML.parse(readFileSync(".github/workflows/e2e.yaml", "utf8")); +const selected = OPENROUTER_SMOKE; -describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label qualification selection", (selected) => { - const id = `hosted-inference-${selected.selector}`; +describe("OpenRouter qualification selection", () => { + const id = "hosted-inference-openrouter"; it("selects only the named provider in the existing smoke owner", () => { const target = catalogueTarget(id); expect(target.agentRuntime).toBe("openclaw + langchain-deepagents-code"); expect(target.testFile).toBe("test/e2e/live/inference-routing-provider-smoke.test.ts"); - expect(target.timeoutMinutes).toBe(selected.selector === "openrouter" ? 90 : 30); + expect(target.timeoutMinutes).toBe(90); expect( new RegExp(target.selector!).test( `${selected.id} ${selected.label} answers through its native provider`, @@ -46,17 +47,17 @@ describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label qualification selection", (se }); it("passes only its approved key and model and refuses missing prerequisites", () => { expect( - hostedProviderSmokeEnvironment(id, { + openRouterSmokeEnvironment({ HOSTED_INFERENCE_API_KEY: "selected-canary", HOSTED_INFERENCE_MODEL: "approved-model", NVIDIA_API_KEY: "other-canary", }), ).toEqual({ [selected.credential]: "selected-canary", [selected.modelEnv]: "approved-model" }); + expect(() => openRouterSmokeEnvironment({ HOSTED_INFERENCE_MODEL: "approved-model" })).toThrow( + "requires", + ); expect(() => - hostedProviderSmokeEnvironment(id, { HOSTED_INFERENCE_MODEL: "approved-model" }), - ).toThrow("requires"); - expect(() => - hostedProviderSmokeEnvironment(id, { HOSTED_INFERENCE_API_KEY: "selected-canary" }), + openRouterSmokeEnvironment({ HOSTED_INFERENCE_API_KEY: "selected-canary" }), ).toThrow("requires"); }); }); @@ -69,9 +70,6 @@ it.each(["openai", "anthropic", "gemini", "hermes"])( expect(catalogueRecommendationSelectorIds()).not.toContain(id); expect(() => catalogueTarget(id)).toThrow("Unknown catalogue E2E target"); expect(() => buildE2eWorkflowPlan({ targets: id })).toThrow(); - expect(() => hostedProviderSmokeEnvironment(id, {})).toThrow( - "Unknown hosted inference qualification target", - ); }, ); @@ -121,26 +119,22 @@ it("keeps hosted targets available for explicit recommendations only", () => { ).catalogueMatrices["hosted-inference"].map((row) => row.id), ).toEqual([]); expect(catalogueRecommendationSelectorIds()).toEqual( - expect.arrayContaining( - HOSTED_PROVIDER_SMOKE_CASES.map((entry) => `hosted-inference-${entry.selector}`), - ), + expect.arrayContaining(["hosted-inference-openrouter"]), ); }); -it.each(HOSTED_PROVIDER_SMOKE_CASES)( - "does not automatically select $label for its profile change", - (selected) => { - expect( - catalogueTargetsForChangedFiles([ - `managed-inference/provider-profiles/nemoclaw-${selected.selector}-inference-v1.yaml`, - ]) - .filter((target) => target.profile === "hosted-inference") - .map((target) => target.id), - ).toEqual([]); - }, -); +it("does not automatically select OpenRouter for its profile change", () => { + expect( + catalogueTargetsForChangedFiles([ + "managed-inference/provider-profiles/nemoclaw-openrouter-inference-v1.yaml", + ]) + .filter((target) => target.profile === "hosted-inference") + .map((target) => target.id), + ).toEqual([]); +}); -describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label workflow credential boundary", (provider) => { +describe("OpenRouter workflow credential boundary", () => { + const provider = OPENROUTER_SMOKE; it.each([ { name: "main dispatch", allowed: true }, { name: "main push", event: "push", allowed: true }, @@ -180,9 +174,7 @@ describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label workflow credential boundary" ANTHROPIC_API_KEY: "retired-anthropic-canary", GEMINI_API_KEY: "retired-gemini-canary", NOUS_API_KEY: "retired-hermes-canary", - ...Object.fromEntries( - HOSTED_PROVIDER_SMOKE_CASES.map((provider) => [provider.credential, provider.selector]), - ), + OPENROUTER_API_KEY: "openrouter", }; const context = { github: { @@ -268,8 +260,8 @@ it.each(["openai", "anthropic", "gemini", "hermes"])( }, ); -// Evaluate the reusable workflow expression with distinct models to detect provider crossover. -it.each(HOSTED_PROVIDER_SMOKE_CASES)("routes only the approved $label model", (selected) => { +// Evaluate the reusable workflow expression with an unrelated model to detect model crossover. +it("routes only the approved OpenRouter model", () => { const profile = YAML.parse(readFileSync(".github/workflows/e2e-standard-profile.yaml", "utf8")); const step = profile.jobs.run.steps.find( (entry: { name?: string }) => entry.name === "Run catalogue E2E target", @@ -297,12 +289,7 @@ it.each(HOSTED_PROVIDER_SMOKE_CASES)("routes only the approved $label model", (s context: { matrix, inputs: { catalogue_id: `hosted-inference-${selected.selector}` }, - vars: Object.fromEntries( - HOSTED_PROVIDER_SMOKE_CASES.map((provider) => [ - provider.modelEnv, - `approved-${provider.selector}`, - ]), - ), + vars: { NEMOCLAW_OPENROUTER_MODEL: "approved-openrouter" }, }, }), env: {}, @@ -317,7 +304,7 @@ it.each(HOSTED_PROVIDER_SMOKE_CASES)("routes only the approved $label model", (s expect(() => validateE2eWorkflowPlan(plan)).toThrow("invalid output schema"); }); -describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label local smoke prerequisites", (selected) => { +describe("OpenRouter local smoke prerequisites", () => { afterEach(() => vi.unstubAllEnvs()); it.each([undefined, "unrelated-provider", "all", "openai", "anthropic", "gemini", "hermes"])( @@ -337,19 +324,18 @@ describe.each(HOSTED_PROVIDER_SMOKE_CASES)("$label local smoke prerequisites", ( const skip = vi.fn(); requireProviderSmokeSelected(selected.selector, skip); expect(skip).not.toHaveBeenCalled(); - const id = `hosted-inference-${selected.selector}`; expect(() => - hostedProviderSmokeEnvironment(id, { + openRouterSmokeEnvironment({ [selected.modelEnv]: "approved-model", }), ).toThrow("requires its approved credential and model"); expect(() => - hostedProviderSmokeEnvironment(id, { + openRouterSmokeEnvironment({ [selected.credential]: "synthetic-selected-key", }), ).toThrow("requires its approved credential and model"); expect( - hostedProviderSmokeEnvironment(id, { + openRouterSmokeEnvironment({ [selected.credential]: "synthetic-selected-key", [selected.modelEnv]: "approved-model", }), diff --git a/tools/e2e/hosted-provider-smoke.mts b/tools/e2e/hosted-provider-smoke.mts index 3f31dae2ea3..30b99d30995 100644 --- a/tools/e2e/hosted-provider-smoke.mts +++ b/tools/e2e/hosted-provider-smoke.mts @@ -1,34 +1,23 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -export const HOSTED_PROVIDER_SMOKE_CASES = [ - { - id: "TC-INF-07", - selector: "openrouter", - provider: "openrouter", - label: "OpenRouter", - credential: "OPENROUTER_API_KEY", - modelEnv: "NEMOCLAW_OPENROUTER_MODEL", - providerKey: "inference", - endpoint: "https://openrouter.ai/api/v1", - placeholder: "OPENROUTER_API_KEY", - }, -] as const; +export const OPENROUTER_SMOKE = { + id: "TC-INF-07", + selector: "openrouter", + provider: "openrouter", + label: "OpenRouter", + credential: "OPENROUTER_API_KEY", + modelEnv: "NEMOCLAW_OPENROUTER_MODEL", + providerKey: "inference", + endpoint: "https://openrouter.ai/api/v1", + placeholder: "OPENROUTER_API_KEY", +} as const; -/** Only the selected provider credential reaches the existing smoke test process. */ -export function hostedProviderSmokeEnvironment( - id: string, - environment: NodeJS.ProcessEnv, -): NodeJS.ProcessEnv { - const selected = HOSTED_PROVIDER_SMOKE_CASES.find( - (entry) => id === `hosted-inference-${entry.selector}`, - ); - if (!selected) throw new Error("Unknown hosted inference qualification target"); - const key = environment.HOSTED_INFERENCE_API_KEY || environment[selected.credential]; - const model = environment.HOSTED_INFERENCE_MODEL || environment[selected.modelEnv]; +/** Only the OpenRouter credential reaches the existing smoke test process. */ +export function openRouterSmokeEnvironment(environment: NodeJS.ProcessEnv): NodeJS.ProcessEnv { + const key = environment.HOSTED_INFERENCE_API_KEY || environment.OPENROUTER_API_KEY; + const model = environment.HOSTED_INFERENCE_MODEL || environment.NEMOCLAW_OPENROUTER_MODEL; if (!key || !model) - throw new Error( - "Selected hosted inference qualification requires its approved credential and model", - ); - return { [selected.credential]: key, [selected.modelEnv]: model }; + throw new Error("OpenRouter qualification requires its approved credential and model"); + return { OPENROUTER_API_KEY: key, NEMOCLAW_OPENROUTER_MODEL: model }; } diff --git a/tools/e2e/target-catalogue.mts b/tools/e2e/target-catalogue.mts index 5bdba9fae78..d91ca54bb6d 100644 --- a/tools/e2e/target-catalogue.mts +++ b/tools/e2e/target-catalogue.mts @@ -32,10 +32,7 @@ import { import { SANDBOX_SURVIVAL_TARGET_TIMEOUT_MINUTES } from "./sandbox-survival-timeout-contract.mts"; import { normalizeE2eSelectorId } from "./selector-aliases.mts"; -import { - HOSTED_PROVIDER_SMOKE_CASES, - hostedProviderSmokeEnvironment, -} from "./hosted-provider-smoke.mts"; +import { OPENROUTER_SMOKE, openRouterSmokeEnvironment } from "./hosted-provider-smoke.mts"; export const E2E_EXECUTION_PROFILES = [ "standard", @@ -1004,30 +1001,28 @@ export const E2E_TARGET_CATALOGUE: readonly E2eCatalogueTarget[] = [ NEMOCLAW_SANDBOX_NAME: "e2e-issue-4462", }, }), - ...HOSTED_PROVIDER_SMOKE_CASES.map((selected) => - dockerOnlyTarget(`hosted-inference-${selected.selector}`, { - displayName: "Inference: completes native OpenRouter agent requests", - agentRuntime: "openclaw + langchain-deepagents-code", - prAdvisorSelectable: true, - owningPaths: [ - "test/e2e/live/inference-routing-credential-scan.ts", - `managed-inference/provider-profiles/nemoclaw-${selected.selector}-inference-v1.yaml`, - "agents/langchain-deepagents-code/managed-dcode-runtime.py", - "agents/langchain-deepagents-code/generate-config.ts", - "src/lib/inference/managed-dcode/", - ], - environmentOrInferenceEndpoint: `Ubuntu; ${selected.label} hosted inference`, - profile: "hosted-inference", - releaseRequired: false, - testFile: "test/e2e/live/inference-routing-provider-smoke.test.ts", - selector: selected.id, - timeoutMinutes: 90, - installMode: "none", - restoreCli: true, - exposeCliBin: true, - environment: { NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE: selected.selector }, - }), - ), + dockerOnlyTarget("hosted-inference-openrouter", { + displayName: "Inference: completes native OpenRouter agent requests", + agentRuntime: "openclaw + langchain-deepagents-code", + prAdvisorSelectable: true, + owningPaths: [ + "test/e2e/live/inference-routing-credential-scan.ts", + "managed-inference/provider-profiles/nemoclaw-openrouter-inference-v1.yaml", + "agents/langchain-deepagents-code/managed-dcode-runtime.py", + "agents/langchain-deepagents-code/generate-config.ts", + "src/lib/inference/managed-dcode/", + ], + environmentOrInferenceEndpoint: "Ubuntu; OpenRouter hosted inference", + profile: "hosted-inference", + releaseRequired: false, + testFile: "test/e2e/live/inference-routing-provider-smoke.test.ts", + selector: OPENROUTER_SMOKE.id, + timeoutMinutes: 90, + installMode: "none", + restoreCli: true, + exposeCliBin: true, + environment: { NEMOCLAW_INFERENCE_ROUTING_PROVIDER_SMOKE: "openrouter" }, + }), managedRuntimeTarget("inference-routing", { displayName: "Inference: rejects unsafe routes and proves runtime identities", agentRuntime: "openclaw + langchain-deepagents-code", @@ -1904,9 +1899,7 @@ export function catalogueMatrix( e2eRuntimeProviders(entry.gatewayRuntimes, gatewayRuntimes).map((runtimeProvider) => ({ ...(profile === "hosted-inference" ? { - model_env: HOSTED_PROVIDER_SMOKE_CASES.find( - (selected) => entry.id === `hosted-inference-${selected.selector}`, - )!.modelEnv, + model_env: OPENROUTER_SMOKE.modelEnv, } : {}), id: entry.id, @@ -1945,8 +1938,8 @@ export async function runCatalogueTarget(id: string, testFile: string): Promise< } Object.assign(process.env, entry.environment); if (entry.profile === "hosted-inference") { - const selectedEnvironment = hostedProviderSmokeEnvironment(id, process.env); - for (const selected of HOSTED_PROVIDER_SMOKE_CASES) delete process.env[selected.credential]; + const selectedEnvironment = openRouterSmokeEnvironment(process.env); + delete process.env.OPENROUTER_API_KEY; delete process.env.HOSTED_INFERENCE_API_KEY; Object.assign(process.env, selectedEnvironment); } diff --git a/tools/e2e/workflow-plan.mts b/tools/e2e/workflow-plan.mts index 1e3925195e9..cd3db1890eb 100644 --- a/tools/e2e/workflow-plan.mts +++ b/tools/e2e/workflow-plan.mts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { appendFileSync } from "node:fs"; -import { HOSTED_PROVIDER_SMOKE_CASES } from "./hosted-provider-smoke.mts"; +import { OPENROUTER_SMOKE } from "./hosted-provider-smoke.mts"; import { requiresManagedImages } from "./workflow-prerequisites.mts"; import path from "node:path"; import { fileURLToPath } from "node:url"; @@ -402,9 +402,7 @@ function isCatalogueMatrixRowForProfile( return ( target?.profile === profile && value.model_env === - HOSTED_PROVIDER_SMOKE_CASES.find( - (selected) => target.id === `hosted-inference-${selected.selector}`, - )?.modelEnv && + (target.id === "hosted-inference-openrouter" ? OPENROUTER_SMOKE.modelEnv : undefined) && target.targetId === value.target_id && target.displayName === value.display_name && target.agentRuntime === value.agent_runtime && From 481d7cc1adea97c14a970ed8b0ec470a4202679a Mon Sep 17 00:00:00 2001 From: Rebecca Sliter <571084+rsliter@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:50:33 -0700 Subject: [PATCH 5/5] fix(e2e): isolate OpenRouter smoke credentials --- test/e2e/README.md | 7 ++----- .../hosted-provider-smoke-selection.test.ts | 19 +++++++++++++++++++ tools/e2e/hosted-provider-smoke.mts | 16 +++++++++++++++- tools/e2e/target-catalogue.mts | 7 ++----- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index 46ff6281191..e150ec51833 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -2402,12 +2402,9 @@ the native TOML route, and one fresh `dcode -n --json` response. The OpenClaw case checks the native endpoint, credential placeholder, selected adapter, response model, and nonempty answer. The OpenRouter case switches the running sandbox to a second model and back. -It requires a fresh agent response with that model after each switch and checks that the return route is readable. -Each `nemoclaw inference set` switch also verifies its selected model with a sandbox-side inference request. +After each successful switch, it requires a fresh OpenClaw response whose reported model matches the selection. An unavailable or rate-limited intermediate model fails the first switch. -The alternate route read and return-route model assertion were removed from this live case: -agent responses prove the effective model after each restart, while the recorded-model behavior -belongs to the `inference get` source tests. Both switch exit checks and the return route read remain. +The case does not read either route. The `inference get` source tests cover recorded-model behavior. After onboarding, the OpenRouter case runs one sandbox probe before its first native agent request. The OpenRouter model-switch requests and follow-up agent responses do not repeat that scan. The probe checks the raw environment and a bounded file sample for a salted fingerprint of the selected credential. diff --git a/test/e2e/support/hosted-provider-smoke-selection.test.ts b/test/e2e/support/hosted-provider-smoke-selection.test.ts index 77b2eb31089..de4dfd6405d 100644 --- a/test/e2e/support/hosted-provider-smoke-selection.test.ts +++ b/test/e2e/support/hosted-provider-smoke-selection.test.ts @@ -7,6 +7,7 @@ import YAML from "yaml"; import { afterEach, describe, expect, it, vi } from "vitest"; import { OPENROUTER_SMOKE, + configureOpenRouterSmokeEnvironment, openRouterSmokeEnvironment, } from "../../../tools/e2e/hosted-provider-smoke.mts"; import { @@ -60,6 +61,24 @@ describe("OpenRouter qualification selection", () => { openRouterSmokeEnvironment({ HOSTED_INFERENCE_API_KEY: "selected-canary" }), ).toThrow("requires"); }); + it("removes inherited retired provider credentials before the OpenRouter smoke", () => { + const environment: NodeJS.ProcessEnv = { + HOSTED_INFERENCE_API_KEY: "selected-canary", + HOSTED_INFERENCE_MODEL: "approved-model", + OPENAI_API_KEY: "retired-openai-canary", + ANTHROPIC_API_KEY: "retired-anthropic-canary", + GEMINI_API_KEY: "retired-gemini-canary", + NOUS_API_KEY: "retired-hermes-canary", + KEEP: "unrelated", + }; + configureOpenRouterSmokeEnvironment(environment); + expect(environment).toEqual({ + HOSTED_INFERENCE_MODEL: "approved-model", + OPENROUTER_API_KEY: "selected-canary", + NEMOCLAW_OPENROUTER_MODEL: "approved-model", + KEEP: "unrelated", + }); + }); }); it.each(["openai", "anthropic", "gemini", "hermes"])( diff --git a/tools/e2e/hosted-provider-smoke.mts b/tools/e2e/hosted-provider-smoke.mts index 30b99d30995..76cd144d90e 100644 --- a/tools/e2e/hosted-provider-smoke.mts +++ b/tools/e2e/hosted-provider-smoke.mts @@ -13,7 +13,7 @@ export const OPENROUTER_SMOKE = { placeholder: "OPENROUTER_API_KEY", } as const; -/** Only the OpenRouter credential reaches the existing smoke test process. */ +/** Select only the OpenRouter credential and model for the smoke test. */ export function openRouterSmokeEnvironment(environment: NodeJS.ProcessEnv): NodeJS.ProcessEnv { const key = environment.HOSTED_INFERENCE_API_KEY || environment.OPENROUTER_API_KEY; const model = environment.HOSTED_INFERENCE_MODEL || environment.NEMOCLAW_OPENROUTER_MODEL; @@ -21,3 +21,17 @@ export function openRouterSmokeEnvironment(environment: NodeJS.ProcessEnv): Node throw new Error("OpenRouter qualification requires its approved credential and model"); return { OPENROUTER_API_KEY: key, NEMOCLAW_OPENROUTER_MODEL: model }; } + +export function configureOpenRouterSmokeEnvironment(environment: NodeJS.ProcessEnv): void { + const selected = openRouterSmokeEnvironment(environment); + for (const key of [ + "HOSTED_INFERENCE_API_KEY", + "OPENAI_API_KEY", + "ANTHROPIC_API_KEY", + "GEMINI_API_KEY", + "NOUS_API_KEY", + ]) { + delete environment[key]; + } + Object.assign(environment, selected); +} diff --git a/tools/e2e/target-catalogue.mts b/tools/e2e/target-catalogue.mts index d91ca54bb6d..700a39ba29a 100644 --- a/tools/e2e/target-catalogue.mts +++ b/tools/e2e/target-catalogue.mts @@ -32,7 +32,7 @@ import { import { SANDBOX_SURVIVAL_TARGET_TIMEOUT_MINUTES } from "./sandbox-survival-timeout-contract.mts"; import { normalizeE2eSelectorId } from "./selector-aliases.mts"; -import { OPENROUTER_SMOKE, openRouterSmokeEnvironment } from "./hosted-provider-smoke.mts"; +import { OPENROUTER_SMOKE, configureOpenRouterSmokeEnvironment } from "./hosted-provider-smoke.mts"; export const E2E_EXECUTION_PROFILES = [ "standard", @@ -1938,10 +1938,7 @@ export async function runCatalogueTarget(id: string, testFile: string): Promise< } Object.assign(process.env, entry.environment); if (entry.profile === "hosted-inference") { - const selectedEnvironment = openRouterSmokeEnvironment(process.env); - delete process.env.OPENROUTER_API_KEY; - delete process.env.HOSTED_INFERENCE_API_KEY; - Object.assign(process.env, selectedEnvironment); + configureOpenRouterSmokeEnvironment(process.env); } if (entry.exposeCliBin) { process.env.NEMOCLAW_CLI_BIN = path.join(process.cwd(), "bin", "nemoclaw.js");