NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

Vitest E2E inference adapter for mock, hosted-compatible, and public NVIDIA modes

Open jyaunches opened this issue 5 months ago • 1 comments

Summary

The Vitest E2E suite still has inference wiring assumptions from the pre-June-13 flow. Several Vitest tests directly decide whether they are using public NVIDIA Endpoints, the hosted/internal NVIDIA OpenAI-compatible endpoint, or a local mocked endpoint. That makes the suite brittle and repeats the June 13 bash-suite pattern across individual tests.

Create a centralized Vitest inference adapter so each test receives an already-resolved inference configuration and does not know which endpoint mode is active.

Background / Evidence

June 13 bash-suite changes introduced/adapted these patterns:

  • PR #5366 changed credential/env expectations around NVIDIA inference.
  • PR #5373 centralized the fake OpenAI-compatible server (test/e2e-scenario/fixtures/fake-openai-compatible.ts, test/e2e/lib/fake-openai-compatible-api.mts).
  • PR #5380 added hosted-compatible Vitest helper coverage (test/e2e-scenario/fixtures/hosted-inference.ts).
  • PR #5385 and PR #5399 updated bash E2E hosted inference wiring via test/e2e/lib/ci-compatible-inference.sh.
  • PR #5411 avoided extra hosted inference calls in preflight probes.

The current Vitest suite still has tests that hard-code assumptions such as:

  • NVIDIA_INFERENCE_API_KEY must start with nvapi-
  • direct NVIDIA_INFERENCE_API_KEY use when the current hosted service should be staged as COMPATIBLE_API_KEY
  • per-test endpoint/model/provider construction

Observed failure:

  • E2E / Vitest Scenarios run 28057145830
  • hermes-e2e-vitest job 83062277906
  • Failure: AssertionError: NVIDIA_INFERENCE_API_KEY must start with nvapi-
  • Location: test/e2e-scenario/live/hermes-e2e.test.ts:222-223

Desired Strategy

Add one injected adapter above the test layer, controlled by suite/workflow configuration.

Tests should ask for an inference adapter/config fixture and consume:

  • provider selection
  • model name
  • endpoint URL
  • credential env vars
  • expected route provider
  • redaction values
  • optional mock server lifecycle
  • direct chat/probe helpers if needed

The test should not branch on public NVIDIA vs hosted-compatible vs mock.

Proposed Adapter Modes

1. mock (default)

Default for local and broad CI runs.

  • Starts the existing fake OpenAI-compatible endpoint.
  • Uses provider: custom.
  • Uses provider name / expected route: compatible-endpoint.
  • Sets NEMOCLAW_ENDPOINT_URL to the mock /v1 URL.
  • Sets COMPATIBLE_API_KEY to a deterministic fake credential when auth is required.
  • Sets NEMOCLAW_MODEL / NEMOCLAW_COMPAT_MODEL to the mock model.
  • Owns cleanup and request-log artifact capture.

This should be the safe default because it avoids quota, rate limits, and secret availability while preserving inference.local routing behavior.

2. internal-nvidia / hosted-compatible

For GitHub hosted E2E lanes using the repo-scoped hosted inference secret.

  • Source secret: NVIDIA_INFERENCE_API_KEY.
  • Staged runtime credential: COMPATIBLE_API_KEY.
  • Provider: custom.
  • Endpoint: https://inference-api.nvidia.com/v1 unless overridden.
  • Expected route provider: compatible-endpoint.
  • Model default should align with the current hosted-compatible model default in hosted-inference.ts / workflow env.

This captures the June 13 hosted-compatible behavior without requiring every test to duplicate it.

3. public-nvidia

For tests that specifically need the public NVIDIA Endpoints provider contract.

  • Requires an nvapi-prefixed key.
  • Uses direct NVIDIA provider semantics (build, cloud, nvidia, or nvidia-prod depending on the test contract).
  • Expected route provider: nvidia-prod.
  • Keeps strict nvapi validation, but only inside this adapter mode.

Proposed Shape

Add a new fixture, likely:

  • test/e2e-scenario/fixtures/inference-adapter.ts
  • injected from test/e2e-scenario/fixtures/e2e-test.ts as inference

Sketch:

interface E2EInferenceAdapter {
  mode: "mock" | "internal-nvidia" | "public-nvidia";
  model: string;
  provider: string;
  providerName: string;
  endpointUrl?: string;
  expectedRouteProvider: string;
  env(extra?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
  redactionValues(): string[];
  directChat?(prompt: string): Promise<unknown>;
  close?(): Promise<void>;
}

Configuration:

  • NEMOCLAW_E2E_INFERENCE_MODE=mock|internal-nvidia|public-nvidia
  • default: mock
  • workflow_dispatch input on .github/workflows/e2e-vitest-scenarios.yaml
  • applies whether running one, many, or all Vitest jobs/scenarios

Pilot Test

Start with test/e2e-scenario/live/hermes-e2e.test.ts.

Why:

  • It is currently failing on the old nvapi-prefix assumption.
  • It mirrors the bash-suite path updated on June 13.
  • It exercises real install/onboard, Hermes health, direct hosted/mock chat, and sandbox inference.local routing.
  • It is narrower than agent-turn-latency but representative enough to validate the adapter shape.

Acceptance Criteria

  • [ ] Add the adapter fixture with unit/support tests for all modes.
  • [ ] Add workflow input/env for selecting adapter mode; default is mock.
  • [ ] Convert hermes-e2e.test.ts to use the injected adapter and remove direct mode/key branching.
  • [ ] hermes-e2e-vitest passes in default mock mode.
  • [ ] hermes-e2e-vitest passes in hosted-compatible/internal mode on GitHub Actions with NVIDIA_INFERENCE_API_KEY staged as COMPATIBLE_API_KEY.
  • [ ] Public NVIDIA mode retains strict nvapi-prefix validation, but that validation is centralized in the adapter.
  • [ ] The fixture supports one selected test, multiple jobs, and full-suite dispatch without per-test special casing.
  • [ ] Add migration notes for follow-on tests: launchable-smoke, issue-4434-tui-unreachable-inference, model-router-provider-routed-inference, and agent-turn-latency.

Non-goals

  • Do not re-create the bash-suite ci-compatible-inference.sh pattern across Vitest tests.
  • Do not introduce a new scenario registry or broad E2E framework layer.
  • Do not change product provider behavior; this is test harness configuration only.

jyaunches avatar Jun 24 '26 13:06 jyaunches

Completion audit at current main 70d7d287f03f82355eafccfc8084de3741069281: seven of the eight acceptance criteria are satisfied. The only missing criterion is a trusted hosted-compatible Hermes live run.

Confirmed:

  • Adapter fixture and support tests cover mock, internal-nvidia, public-nvidia, invalid mode, redaction, timeout, and cleanup.
  • Workflow dispatch exposes inference_mode with default mock.
  • hermes-e2e consumes the injected adapter without direct endpoint-mode or NVIDIA-key branching.
  • Published mock-mode hermes-e2e jobs have passed.
  • Public NVIDIA nvapi-prefix validation is centralized in the adapter.
  • Selected-test, multi-job, and full-dispatch planning contracts are covered.
  • Migration notes name all four requested follow-on tests.
  • Current focused adapter/workflow/Hermes/planner verification passed 4 files and 80 tests.

Missing:

No published run proves hermes-e2e passes with inference_mode=internal-nvidia while NVIDIA_INFERENCE_API_KEY is staged as COMPATIBLE_API_KEY. Existing unit coverage proves the transformation, but not the trusted secret-bearing live boundary.

Maintainer action required:

gh workflow run e2e.yaml \
  --repo NVIDIA/NemoClaw \
  --ref main \
  -f jobs=hermes-e2e \
  -f inference_mode=internal-nvidia \
  -f checkout_sha=

checkout_sha must remain empty so this is a trusted main dispatch rather than a PR-controller run. If the job passes, link the run and close #5745. If it fails, constrain remediation to the observed failure in .github/workflows/e2e.yaml, test/e2e/fixtures/inference-adapter.ts, test/e2e/live/hermes-e2e.test.ts, and their support/boundary tests.

I cannot perform the dispatch: the authenticated account's current repository permissions are pull=true and push/triage/maintain/admin=false.

dfernandez365-rgb avatar Jul 20 '26 17:07 dfernandez365-rgb