diff --git a/.agents/skills/nemoclaw-maintainer-e2e/references/manual-pr.md b/.agents/skills/nemoclaw-maintainer-e2e/references/manual-pr.md index e55c30cca67..aeabbd8d91a 100644 --- a/.agents/skills/nemoclaw-maintainer-e2e/references/manual-pr.md +++ b/.agents/skills/nemoclaw-maintainer-e2e/references/manual-pr.md @@ -84,7 +84,7 @@ Before either candidate dispatch or base replay: 1. Read the shared task record with `node tools/task-continuation/checkpoint.mts resume "$TASK_RECORD"`. 2. Compare the requested PR, jobs, targets, credential flags, cost bounds, and cleanup obligations with its recorded authorization. -3. Check expiry, remaining run and comparison budgets, spent retries, and active matching runs. +3. Check expiry, remaining run and comparison budgets, spent retries, and active matching runs, including the diagnostic flag. 4. Stop before dispatch if authorization is absent, mismatched, expired, exhausted, or cannot be established from the record. 5. Reuse a matching active run. Reconcile pending operations before another dispatch. 6. Persist dispatch intent and its budget consumption through the shared task-continuation procedure before the external write. @@ -145,11 +145,13 @@ save_dispatch_intent() { --arg owner "$E2E_CLEANUP_OWNER" --arg cleanup "$E2E_CLEANUP_OBLIGATION" \ --arg cost "$E2E_COST_BOUNDS" --argjson jetson "$jetson" \ --argjson launchable "$INCLUDE_STAGING_BREV_LAUNCHABLE" \ + --argjson nativeDiagnostic "${NATIVE_HERMES_GPU_DIAGNOSTIC:-false}" \ '{phase:$phase,prNumber:$pr,checkoutSha:$checkout,repository:$repository, baseSha:$base,workflowSha:$workflow,jobs:$jobs,targets:$targets, correlationId:$correlation,budgetKey:$budget,cleanupOwner:$owner, cleanupObligation:$cleanup,costBounds:$cost,inferenceMode:"mock", - allowJetsonDispatch:$jetson,includeStagingBrevLaunchable:$launchable}')" + allowJetsonDispatch:$jetson,includeStagingBrevLaunchable:$launchable} + + (if $nativeDiagnostic then {nativeHermesGpuDiagnostic:true} else {} end)')" jq -e --arg key "manualE2E.authorization.${budget}" --argjson action "$action" ' (.identities[$key] | fromjson) == ($action | del(.correlationId)) ' <<<"$view" >/dev/null || { @@ -160,7 +162,8 @@ save_dispatch_intent() { jq -e --arg key "manualE2E.authorization.${E2E_CANDIDATE_BUDGET:?Use the authorized candidate budget key}" \ --argjson action "$action" ' (.identities[$key] | fromjson) as $candidate | - $candidate.jobs == $action.jobs and $candidate.targets == $action.targets + $candidate.jobs == $action.jobs and $candidate.targets == $action.targets and + ($candidate.nativeHermesGpuDiagnostic // false) == ($action.nativeHermesGpuDiagnostic // false) ' <<<"$view" >/dev/null || { echo "Base selectors differ from recorded candidate authorization; stop before replay" >&2 return 1 @@ -224,6 +227,15 @@ find_dispatch_run() { Use the values verified against that record. Set an unused selector explicitly to an empty string; at least one selector must be nonempty. Enumerate authorized jobs for a full run instead of using controller defaults. Do not populate missing authorization from environment values or from this recipe. +For a native Hermes GPU diagnostic, record `nativeHermesGpuDiagnostic: true` in the grant. +Set `NATIVE_HERMES_GPU_DIAGNOSTIC=true`, `E2E_JOBS=hermes-gpu-startup`, and empty `E2E_TARGETS`. +Retain this flag for base replay. Omit the grant field and optional dispatch input for normal runs. +For diagnostics, verify support in the pinned trusted controller before recording dispatch intent. +The diagnostic runs only the existing native scenario. Full qualification still requires native, fallback, and compatibility-only. +Native diagnostics use a separate concurrency group from full qualification. +The run’s E2E Execution Plan summary identifies native-only scope and the two unqualified scenarios. +Pinned PR-candidate diagnostics retain the existing reporting restriction and do not post a PR comment. + Retain these values for base replay; recheck its separate authorization and remaining comparison budget before dispatch: ```bash @@ -241,6 +253,24 @@ ALLOW_JETSON_DISPATCH="${ALLOW_JETSON_DISPATCH:?Set the recorded credential flag INCLUDE_STAGING_BREV_LAUNCHABLE="${INCLUDE_STAGING_BREV_LAUNCHABLE:?Set the recorded credential flag}" [[ "$ALLOW_JETSON_DISPATCH" = true || "$ALLOW_JETSON_DISPATCH" = false ]] [[ "$INCLUDE_STAGING_BREV_LAUNCHABLE" = true || "$INCLUDE_STAGING_BREV_LAUNCHABLE" = false ]] +NATIVE_HERMES_GPU_DIAGNOSTIC="${NATIVE_HERMES_GPU_DIAGNOSTIC:-false}" +case "$NATIVE_HERMES_GPU_DIAGNOSTIC" in + true|false) ;; + *) echo "Native Hermes GPU diagnostic flag must be true or false" >&2; exit 1 ;; +esac +NATIVE_DIAGNOSTIC_ARGS=() +if [[ "$NATIVE_HERMES_GPU_DIAGNOSTIC" = true ]]; then + # Inspect the pinned trusted controller before consuming dispatch budget. + node --input-type=module - "$WORKFLOW_SHA" <<'JS' +import { execFileSync } from 'node:child_process'; +import YAML from 'yaml'; +const workflow = YAML.parse(execFileSync('git', ['show', `${process.argv[2]}:.github/workflows/e2e.yaml`], { encoding: 'utf8' })); +if (workflow.on?.workflow_dispatch?.inputs?.native_hermes_gpu_diagnostic?.type !== 'boolean') { + throw new Error('Trusted main does not support native Hermes GPU diagnostics'); +} +JS + NATIVE_DIAGNOSTIC_ARGS=(-f native_hermes_gpu_diagnostic=true) +fi HEAD_CORRELATION_ID="$(python3 -c 'import uuid; print(uuid.uuid4())')" save_dispatch_intent candidate "$HEAD_CORRELATION_ID" \ "${E2E_CANDIDATE_BUDGET:?Use the authorized candidate budget key}" \ @@ -252,6 +282,7 @@ gh workflow run .github/workflows/e2e.yaml \ -f "jobs=${E2E_JOBS}" \ -f inference_mode=mock \ -f "include_staging_brev_launchable=${INCLUDE_STAGING_BREV_LAUNCHABLE}" \ + ${NATIVE_DIAGNOSTIC_ARGS[@]+"${NATIVE_DIAGNOSTIC_ARGS[@]}"} \ -f "allow_jetson_dispatch=${ALLOW_JETSON_DISPATCH}" \ -f "pr_number=${PR_NUMBER}" \ -f "checkout_sha=${HEAD_SHA}" \ @@ -349,6 +380,7 @@ gh workflow run .github/workflows/e2e.yaml \ -f "jobs=${E2E_JOBS}" \ -f inference_mode=mock \ -f "include_staging_brev_launchable=${INCLUDE_STAGING_BREV_LAUNCHABLE}" \ + ${NATIVE_DIAGNOSTIC_ARGS[@]+"${NATIVE_DIAGNOSTIC_ARGS[@]}"} \ -f allow_jetson_dispatch=false \ -f "pr_number=${PR_NUMBER}" \ -f "checkout_sha=${BASE_SHA}" \ diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 7b045ed0831..f3a31581c7c 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -25,6 +25,11 @@ on: required: false default: false type: boolean + native_hermes_gpu_diagnostic: + description: "Run only the existing native Hermes GPU scenario for diagnosis. Requires jobs=hermes-gpu-startup and no targets; full qualification still requires every scenario." + required: false + default: false + type: boolean inference_mode: description: "Inference adapter mode for compatible Vitest E2E jobs: mock, internal-nvidia, or public-nvidia." required: false @@ -104,7 +109,7 @@ permissions: pull-requests: read concurrency: - group: e2e-${{ github.ref }}-${{ inputs.jobs == 'llama-cpp-dgx-spark-qualification' && format('spark-{0}', github.run_id) || (inputs.jobs == 'staging-brev-launchable' || inputs.jobs == 'staging-brev-launchable-identity' || inputs.include_staging_brev_launchable) && format('launchable-{0}', github.run_id) || inputs.checkout_sha != '' && (inputs.checkout_sha == inputs.base_sha && format('pr-{0}-base-{1}-jobs-{2}-targets-{3}', inputs.pr_number, inputs.base_sha, toJSON(inputs.jobs), toJSON(inputs.targets)) || format('pr-{0}-candidate', inputs.pr_number)) || inputs.targets || 'supported' }}-${{ inputs.checkout_sha != '' && 'manual-pr' || inputs.jobs || 'all-jobs' }} + group: e2e-${{ github.ref }}-${{ inputs.jobs == 'llama-cpp-dgx-spark-qualification' && format('spark-{0}', github.run_id) || (inputs.jobs == 'staging-brev-launchable' || inputs.jobs == 'staging-brev-launchable-identity' || inputs.include_staging_brev_launchable) && format('launchable-{0}', github.run_id) || inputs.checkout_sha != '' && (inputs.checkout_sha == inputs.base_sha && format('pr-{0}-base-{1}-jobs-{2}-targets-{3}', inputs.pr_number, inputs.base_sha, toJSON(inputs.jobs), toJSON(inputs.targets)) || format('pr-{0}-candidate', inputs.pr_number)) || inputs.targets || 'supported' }}-${{ inputs.checkout_sha != '' && 'manual-pr' || inputs.jobs || 'all-jobs' }}${{ inputs.native_hermes_gpu_diagnostic && '-native-hermes-gpu-diagnostic' || '' }} cancel-in-progress: ${{ inputs.checkout_sha != '' && inputs.checkout_sha != inputs.base_sha && inputs.jobs != 'llama-cpp-dgx-spark-qualification' && !inputs.allow_jetson_dispatch && !contains(format(',{0},{1},', inputs.jobs, inputs.targets), ',dgx-station-express,') && !contains(format(',{0},', inputs.jobs), ',staging-brev-launchable,') && !contains(format(',{0},', inputs.jobs), ',staging-brev-launchable-identity,') && !inputs.include_staging_brev_launchable }} env: @@ -410,6 +415,7 @@ jobs: matrix: ${{ steps.matrix.outputs.matrix }} test_matrix: ${{ steps.matrix.outputs.test_matrix }} hermes_selected: ${{ steps.matrix.outputs.hermes_selected }} + hermes_gpu_native_diagnostic_matrix: ${{ steps.matrix.outputs.hermes_gpu_native_diagnostic_matrix }} explicit_only_jobs: ${{ steps.matrix.outputs.explicit_only_jobs }} release_required_jobs: ${{ steps.matrix.outputs.release_required_jobs }} selected_jobs: ${{ steps.matrix.outputs.selected_jobs }} @@ -534,6 +540,7 @@ jobs: DISPATCH_TARGETS: ${{ inputs.targets }} EVENT_NAME: ${{ github.event_name }} INCLUDE_STAGING_BREV_LAUNCHABLE: ${{ inputs.include_staging_brev_launchable && 'true' || 'false' }} + NATIVE_HERMES_GPU_DIAGNOSTIC: ${{ inputs.native_hermes_gpu_diagnostic && 'true' || 'false' }} PR_NUMBER: ${{ inputs.checkout_sha != '' && inputs.pr_number || '' }} REPOSITORY: ${{ github.repository }} RUN_ATTEMPT: ${{ github.run_attempt }} @@ -561,6 +568,7 @@ jobs: --argjson allowDgxSparkRunnerQueue "$ALLOW_DGX_SPARK_RUNNER_QUEUE" \ --argjson allowJetsonRunnerQueue "$ALLOW_JETSON_RUNNER_QUEUE" \ --argjson includeStagingBrevLaunchable "$INCLUDE_STAGING_BREV_LAUNCHABLE" \ + --argjson nativeHermesGpuDiagnostic "$NATIVE_HERMES_GPU_DIAGNOSTIC" \ --argjson workflowRunAttempt "$RUN_ATTEMPT" \ '{ kind: "nemoclaw-e2e-dispatch-v2", @@ -582,7 +590,7 @@ jobs: includeStagingBrevLaunchable: $includeStagingBrevLaunchable, triggeringActor: $triggeringActor, emptySelectors: ($jobs == "" and $targets == "") - }' >"$DISPATCH_RECEIPT_DIR/dispatch.json" + } + (if $nativeHermesGpuDiagnostic then {nativeHermesGpuDiagnostic: true} else {} end)' >"$DISPATCH_RECEIPT_DIR/dispatch.json" - name: Upload trusted E2E dispatch receipt if: ${{ github.event_name == 'workflow_dispatch' }} @@ -706,6 +714,7 @@ jobs: - id: matrix name: Generate E2E target matrix env: + NEMOCLAW_E2E_NATIVE_HERMES_GPU_DIAGNOSTIC: ${{ github.event_name == 'workflow_dispatch' && inputs.native_hermes_gpu_diagnostic && 'true' || 'false' }} NEMOCLAW_E2E_INCLUDE_STAGING_BREV_LAUNCHABLE: ${{ github.repository == 'NVIDIA/NemoClaw' && github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && inputs.include_staging_brev_launchable && 'true' || 'false' }} INFERENCE_MODE: ${{ inputs.inference_mode || 'mock' }} NEMOCLAW_GATEWAY_RUNTIMES: ${{ inputs.jobs == 'portable-hermes-finalization' && 'podman' || inputs.gateway_runtimes || inputs.gateway_runtime || 'docker' }} @@ -717,6 +726,11 @@ jobs: NEMOCLAW_E2E_CREDENTIALS_ALLOWED: ${{ (inputs.checkout_sha == '' || steps.candidate_authorization.outputs.nvidia_owned == 'true') && 'true' || 'false' }} run: | set -euo pipefail + if [[ "${NEMOCLAW_E2E_NATIVE_HERMES_GPU_DIAGNOSTIC:-false}" == true && + ( "${JOBS:-}" != hermes-gpu-startup || -n "${TARGETS:-}" ) ]]; then + echo "::error::Native Hermes GPU diagnostics require only jobs=hermes-gpu-startup and no targets" + exit 1 + fi if [[ "${JOBS:-}" == "llama-cpp-dgx-spark-qualification" && -z "${TARGETS:-}" ]]; then { echo 'matrix=[]' @@ -731,6 +745,7 @@ jobs: echo 'selected_jobs=["llama-cpp-dgx-spark-qualification"]' echo 'selected_workflow_jobs=["llama-cpp-dgx-spark-qualification"]' echo 'hermes_selected=false' + echo 'hermes_gpu_native_diagnostic_matrix=[false]' echo 'explicit_only_jobs=llama-cpp-dgx-spark-qualification' echo 'release_required_jobs=[]' echo 'managed_image_required=false' @@ -751,6 +766,7 @@ jobs: echo 'selected_jobs=["native-runtime-qualification-producer"]' echo 'selected_workflow_jobs=["native-runtime-qualification-producer"]' echo 'hermes_selected=false' + echo 'hermes_gpu_native_diagnostic_matrix=[false]' echo 'explicit_only_jobs=native-runtime-qualification-producer' echo 'release_required_jobs=[]' echo 'managed_image_required=false' @@ -6381,12 +6397,17 @@ jobs: max-parallel: 2 matrix: scenario: [native, fallback, compatibility-only] + native_diagnostic: ${{ fromJSON(needs.generate-matrix.outputs.hermes_gpu_native_diagnostic_matrix) }} runtime_provider: ${{ fromJSON(needs.generate-matrix.outputs.runtime_providers_by_job)['hermes-gpu-startup'] }} exclude: - scenario: fallback runtime_provider: podman - scenario: compatibility-only runtime_provider: podman + - scenario: fallback + native_diagnostic: true + - scenario: compatibility-only + native_diagnostic: true env: E2E_MANAGED_IMAGE_REVISION: ${{ needs.base-image-publication.outputs.managed_image_revision }} E2E_MANAGED_IMAGE_COHORT_RECEIPT: ${{ needs.base-image-publication.outputs.managed_image_receipt }} @@ -7132,6 +7153,7 @@ jobs: SELECTED_WORKFLOW_JOBS: ${{ needs.generate-matrix.outputs.selected_workflow_jobs }} JOB_PR_NUMBER: ${{ inputs.pr_number }} JOB_TARGETS: ${{ inputs.targets }} + JOB_NATIVE_HERMES_GPU_DIAGNOSTIC: ${{ inputs.native_hermes_gpu_diagnostic && 'true' || 'false' }} JOBS: ${{ inputs.jobs }} NEEDS_JSON: ${{ toJSON(needs) }} with: diff --git a/test/e2e/README.md b/test/e2e/README.md index 56de6e0d1c9..d9850d84bd3 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -1451,6 +1451,7 @@ Add the existing `--jobs` or `--targets` selector to render a filtered plan: ```bash npx tsx tools/e2e/workflow-plan.mts --summary --jobs hermes-e2e +npx tsx tools/e2e/workflow-plan.mts --summary --jobs hermes-gpu-startup --native-hermes-gpu-diagnostic npx tsx tools/e2e/workflow-plan.mts --summary --targets ubuntu-repo-cloud-openclaw ``` @@ -1490,6 +1491,15 @@ snake-case include entries and use `coverage_variant` when one job contributes multiple rows. `tools/e2e/workflow-plan.mts` composes and validates these sources. Do not add a separate hand-maintained execution list. +The optional `native_hermes_gpu_diagnostic` workflow input selects only the existing native Hermes GPU scenario. +It requires `jobs=hermes-gpu-startup` and empty `targets`. It defaults to false. +Use it to diagnose native startup without invoking legacy fallback fixtures. +It does not qualify fallback or compatibility-only; full qualification retains all three scenarios. +Record the selection in the dispatch grant and preserve it for base replay. +Native diagnostics use a separate concurrency group from full qualification. +The run’s E2E Execution Plan summary identifies native-only scope and the two unqualified scenarios. +Pinned PR-candidate diagnostics retain the existing reporting restriction and do not post a PR comment. + The typed registry contains executable matrix cells only. Each cell must name executable platform, install, runtime, and onboarding routes plus resolved coverage metadata. A declared lifecycle route must also be executable. Registry 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 70f5755acc6..45c27993a3a 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 @@ -1139,3 +1139,19 @@ it.each(["failure", "skipped"])( expect(report.body).not.toContain("All requested tests passed"); }, ); + +it("labels a native Hermes GPU diagnostic as partial scenario evidence", () => { + const report = renderE2eReport({ + needs: { + "generate-matrix": { result: "success" }, + "hermes-gpu-startup": { result: "success" }, + }, + env: { JOBS: "hermes-gpu-startup", JOB_NATIVE_HERMES_GPU_DIAGNOSTIC: "true" }, + apiJobs: [], + apiJobsLoaded: true, + context: REPORT_CONTEXT, + }); + expect(report.body).toContain( + "Native Hermes GPU diagnostic only. Fallback and compatibility-only remain unqualified.", + ); +}); diff --git a/test/e2e/support/manual-pr-concurrency.test.ts b/test/e2e/support/manual-pr-concurrency.test.ts index aa139d645ca..4525edaab7c 100644 --- a/test/e2e/support/manual-pr-concurrency.test.ts +++ b/test/e2e/support/manual-pr-concurrency.test.ts @@ -16,6 +16,7 @@ function scheduling(overrides: Record = {}) { targets: "", allow_jetson_dispatch: false, include_staging_brev_launchable: false, + native_hermes_gpu_diagnostic: false, ...overrides, }; // Evaluate the checked-in expressions with concrete inputs in a credential-free child. @@ -71,7 +72,7 @@ describe("manual PR comparison scheduling", () => { "format('pr-{0}-base-{1}', inputs.pr_number, inputs.base_sha)", ); expect(validateE2eWorkflow(workflow)).toContain( - "workflow concurrency must isolate baseline comparisons and each Launchable dispatch", + "workflow concurrency must isolate baseline comparisons, Launchable dispatches, and native Hermes GPU diagnostics", ); }); @@ -109,7 +110,38 @@ describe("manual PR comparison scheduling", () => { (workflow.concurrency as Record).group = "e2e-${{ github.ref }}-pr-${{ inputs.pr_number }}-manual-pr"; expect(validateE2eWorkflow(workflow)).toContain( - "workflow concurrency must isolate baseline comparisons and each Launchable dispatch", + "workflow concurrency must isolate baseline comparisons, Launchable dispatches, and native Hermes GPU diagnostics", + ); + }); + + it.each([ + { checkout_sha: "a".repeat(40), expectedCancel: true }, + { checkout_sha: "b".repeat(40), expectedCancel: false }, + ])( + "isolates native diagnostics from qualification for %j", + ({ checkout_sha, expectedCancel }) => { + const selected = { checkout_sha, jobs: "hermes-gpu-startup" }; + const qualification = scheduling(selected); + const diagnostic = scheduling({ ...selected, native_hermes_gpu_diagnostic: true }); + expect(diagnostic.group).not.toBe(qualification.group); + expect(diagnostic.group).not.toBe(scheduling({ checkout_sha, jobs: "full-e2e" }).group); + expect(diagnostic.cancel).toBe(expectedCancel); + expect(qualification.cancel).toBe(expectedCancel); + expect(qualification).toEqual( + scheduling({ ...selected, native_hermes_gpu_diagnostic: false }), + ); + }, + ); + + it("rejects a diagnostic that shares a qualification concurrency group", () => { + const workflow = readWorkflow(); + const concurrency = workflow.concurrency as Record; + concurrency.group = String(concurrency.group).replace( + "${{ inputs.native_hermes_gpu_diagnostic && '-native-hermes-gpu-diagnostic' || '' }}", + "", + ); + expect(validateE2eWorkflow(workflow)).toContain( + "workflow concurrency must isolate baseline comparisons, Launchable dispatches, and native Hermes GPU diagnostics", ); }); diff --git a/test/e2e/support/staging-brev-launchable-identity-workflow-boundary.test.ts b/test/e2e/support/staging-brev-launchable-identity-workflow-boundary.test.ts index 1bf6885ae87..536b1b13ac1 100644 --- a/test/e2e/support/staging-brev-launchable-identity-workflow-boundary.test.ts +++ b/test/e2e/support/staging-brev-launchable-identity-workflow-boundary.test.ts @@ -168,7 +168,7 @@ describe("staging Brev Launchable identity workflow boundary", () => { it("rejects outer concurrency that lets focused Launchable dispatches replace each other", () => { const value = readWorkflow(); const validationError = - "workflow concurrency must isolate baseline comparisons and each Launchable dispatch"; + "workflow concurrency must isolate baseline comparisons, Launchable dispatches, and native Hermes GPU diagnostics"; expect(validateE2eWorkflow(value)).not.toContain(validationError); (value.concurrency as Record).group = "e2e-${{ github.ref }}-${{ inputs.jobs }}"; diff --git a/test/e2e/support/workflow-plan-hermes-gpu-diagnostic.test.ts b/test/e2e/support/workflow-plan-hermes-gpu-diagnostic.test.ts new file mode 100644 index 00000000000..7f36c06c6ba --- /dev/null +++ b/test/e2e/support/workflow-plan-hermes-gpu-diagnostic.test.ts @@ -0,0 +1,230 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { spawnSync } from "node:child_process"; +import { mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { describe, expect, it } from "vitest"; +import { + buildE2eWorkflowPlan, + validateE2eWorkflowPlan, + writeE2eWorkflowPlanCiOutput, +} from "../../../tools/e2e/workflow-plan.mts"; +import { validateE2eWorkflow } from "../../../tools/e2e/workflow-boundary.mts"; +import { validateHermesGpuStartupWorkflow } from "../../../tools/e2e/hermes-gpu-startup-workflow-boundary.mts"; +import { readWorkflow } from "../../helpers/e2e-workflow-contract"; + +type DiagnosticWorkflow = { + on: { workflow_dispatch: { inputs: Record } }; + jobs: Record< + string, + { + strategy: { matrix: Record }; + outputs: Record; + steps: Array<{ name: string; env: Record; run: string }>; + } + >; +}; + +function readDiagnosticWorkflow(): DiagnosticWorkflow { + return readWorkflow() as unknown as DiagnosticWorkflow; +} + +const jobs = "hermes-gpu-startup"; + +describe("native Hermes GPU diagnostic selection", () => { + it("retains Docker's three scenarios and Podman's native scenario by default", () => { + const plan = buildE2eWorkflowPlan({ jobs }, { gatewayRuntimes: ["docker", "podman"] }); + expect(plan.coverageMatrix.map((row) => `${row.id}:${row.variant}`).sort()).toEqual([ + "hermes-gpu-startup:compatibility-only-docker", + "hermes-gpu-startup:fallback-docker", + "hermes-gpu-startup:native-docker", + "hermes-gpu-startup:native-podman", + ]); + expect( + buildE2eWorkflowPlan( + { jobs, nativeHermesGpuDiagnostic: false }, + { + gatewayRuntimes: ["docker", "podman"], + }, + ), + ).toEqual(plan); + expect(plan).not.toHaveProperty("nativeHermesGpuDiagnostic"); + }); + + it("selects native Docker coverage and rejects forged diagnostic coverage", () => { + const plan = buildE2eWorkflowPlan({ jobs, nativeHermesGpuDiagnostic: true }); + expect(plan.coverageMatrix.map((row) => `${row.id}:${row.variant}`)).toEqual([ + "hermes-gpu-startup:native-docker", + ]); + expect(validateE2eWorkflowPlan(plan)).toEqual(plan); + expect(() => validateE2eWorkflowPlan({ ...plan, nativeHermesGpuDiagnostic: false })).toThrow(); + expect(() => validateE2eWorkflowPlan({ ...plan, coverageMatrix: [] })).toThrow(); + expect(() => + validateE2eWorkflowPlan({ ...buildE2eWorkflowPlan(), nativeHermesGpuDiagnostic: true }), + ).toThrow(); + }); + + it.each([ + {}, + { jobs: "" }, + { jobs: "hermes-e2e" }, + { jobs: "hermes-gpu-startup,hermes-e2e" }, + { jobs, targets: "ubuntu-repo-cloud-openclaw" }, + { targets: jobs }, + ])("rejects diagnostic selectors outside the sole GPU job: %j", (selectors) => { + expect(() => buildE2eWorkflowPlan({ ...selectors, nativeHermesGpuDiagnostic: true })).toThrow(); + }); + + it("rejects a nonboolean diagnostic selector", () => { + expect(() => + buildE2eWorkflowPlan({ jobs, nativeHermesGpuDiagnostic: "true" as unknown as boolean }), + ).toThrow("must be boolean"); + }); + + it.each([false, true])( + "emits the trusted CI axis with matching coverage when diagnostic=%s", + (diagnostic) => { + const directory = mkdtempSync(path.join(tmpdir(), "hermes-gpu-diagnostic-")); + try { + const output = path.join(directory, "output"); + writeE2eWorkflowPlanCiOutput( + { jobs }, + { + GITHUB_OUTPUT: output, + GITHUB_STEP_SUMMARY: path.join(directory, "summary"), + INFERENCE_MODE: "mock", + EVENT_NAME: "workflow_dispatch", + NEMOCLAW_E2E_NATIVE_HERMES_GPU_DIAGNOSTIC: String(diagnostic), + }, + ); + const line = readFileSync(output, "utf8") + .split("\n") + .find((value) => value.startsWith("hermes_gpu_native_diagnostic_matrix="))!; + const axis = JSON.parse(line.slice(line.indexOf("=") + 1)) as boolean[]; + expect(axis).toEqual([diagnostic]); + expect( + readFileSync(path.join(directory, "summary"), "utf8").includes( + "**Scope:** Native Hermes GPU diagnostic only. Fallback and compatibility-only remain unqualified.", + ), + ).toBe(diagnostic); + const plan = buildE2eWorkflowPlan({ jobs, nativeHermesGpuDiagnostic: axis[0] }); + expect(plan.coverageMatrix.map((row) => row.variant).sort()).toEqual( + diagnostic + ? ["native-docker"] + : ["compatibility-only-docker", "fallback-docker", "native-docker"], + ); + } finally { + rmSync(directory, { recursive: true, force: true }); + } + }, + ); + + it.each(["push", "pull_request"])("rejects diagnostic CI input for %s", (EVENT_NAME) => { + expect(() => + writeE2eWorkflowPlanCiOutput( + { jobs }, + { + EVENT_NAME, + INFERENCE_MODE: "mock", + NEMOCLAW_E2E_NATIVE_HERMES_GPU_DIAGNOSTIC: "true", + }, + ), + ).toThrow("workflow_dispatch"); + }); + + it("rejects invalid environment input and selector bypasses in CI", () => { + expect(() => + writeE2eWorkflowPlanCiOutput( + { jobs }, + { + INFERENCE_MODE: "mock", + NEMOCLAW_E2E_NATIVE_HERMES_GPU_DIAGNOSTIC: "1", + }, + ), + ).toThrow("must be true or false"); + expect(() => + writeE2eWorkflowPlanCiOutput( + { jobs, nativeHermesGpuDiagnostic: true }, + { INFERENCE_MODE: "mock" }, + ), + ).toThrow("environment input"); + }); + + it.each([ + [ + "forced matrix axis", + (matrix: Record) => { + matrix.native_diagnostic = [true]; + }, + ], + [ + "missing exclusions", + (matrix: Record) => { + matrix.exclude = []; + }, + ], + [ + "reduced default scenarios", + (matrix: Record) => { + matrix.scenario = ["native"]; + }, + ], + ] as const)("rejects %s", (_label, mutation) => { + const workflow = readDiagnosticWorkflow(); + mutation(workflow.jobs[jobs].strategy.matrix); + expect(validateHermesGpuStartupWorkflow(workflow)).toContain( + "hermes-gpu-startup must expand reviewed GPU scenarios by supported runtime", + ); + }); + + it("rejects an enabled default input and missing planner output binding", () => { + const workflow = readDiagnosticWorkflow(); + workflow.on.workflow_dispatch.inputs.native_hermes_gpu_diagnostic.default = true; + delete workflow.jobs["generate-matrix"].outputs.hermes_gpu_native_diagnostic_matrix; + const errors = validateE2eWorkflow(workflow); + expect(errors).toContain("native_hermes_gpu_diagnostic must be boolean and default to false"); + expect(errors).toContain( + "native Hermes GPU diagnostics must use the trusted planner matrix output", + ); + }); +}); + +it.each([false, true])( + "records diagnostic=%s in the actual dispatch receipt command", + (diagnostic) => { + const directory = mkdtempSync(path.join(tmpdir(), "hermes-gpu-receipt-")); + try { + const step = readDiagnosticWorkflow().jobs["generate-matrix"].steps.find( + (entry: { name?: string }) => entry.name === "Record trusted E2E dispatch receipt", + ); + const env = Object.fromEntries(Object.keys(step!.env).map((key) => [key, "fixture"])); + Object.assign(env, { + PATH: process.env.PATH, + DISPATCH_RECEIPT_DIR: directory, + DISPATCH_JOBS: "hermes-gpu-startup", + DISPATCH_TARGETS: "", + PR_NUMBER: "12603", + RUN_ATTEMPT: "1", + ALLOW_JETSON_DISPATCH: "false", + ALLOW_DGX_SPARK_RUNNER_QUEUE: "false", + ALLOW_JETSON_RUNNER_QUEUE: "false", + INCLUDE_STAGING_BREV_LAUNCHABLE: "false", + NATIVE_HERMES_GPU_DIAGNOSTIC: String(diagnostic), + }); + const result = spawnSync("/bin/bash", ["--noprofile", "--norc", "-c", step!.run], { + env, + encoding: "utf8", + }); + expect(result.status, result.stderr).toBe(0); + const receipt = JSON.parse(readFileSync(path.join(directory, "dispatch.json"), "utf8")); + expect(receipt.jobs).toBe("hermes-gpu-startup"); + expect(receipt.emptySelectors).toBe(false); + expect(Object.hasOwn(receipt, "nativeHermesGpuDiagnostic")).toBe(diagnostic); + expect(receipt.nativeHermesGpuDiagnostic).toBe(diagnostic ? true : undefined); + } finally { + rmSync(directory, { recursive: true, force: true }); + } + }, +); diff --git a/test/e2e/support/workflow-plan-test-assertions.ts b/test/e2e/support/workflow-plan-test-assertions.ts index 65a4366ed3f..444e5dce3fb 100644 --- a/test/e2e/support/workflow-plan-test-assertions.ts +++ b/test/e2e/support/workflow-plan-test-assertions.ts @@ -25,6 +25,7 @@ export function expectedWorkflowPlanCiOutput( `selected_workflow_jobs=${JSON.stringify(selectedWorkflowJobs(plan))}`, `managed_image_required=${requiresManagedImages(selectedWorkflowJobs(plan))}`, `hermes_selected=${plan.hermesSelected}`, + `hermes_gpu_native_diagnostic_matrix=${JSON.stringify([plan.nativeHermesGpuDiagnostic === true])}`, `explicit_only_jobs=${plan.explicitOnlyJobs.join(",")}`, `release_required_jobs=${JSON.stringify(releaseRequiredWorkflowJobs())}`, "", diff --git a/tools/e2e/hermes-gpu-startup-workflow-boundary.mts b/tools/e2e/hermes-gpu-startup-workflow-boundary.mts index 8bba3f8a7e4..039d1ac7a5c 100644 --- a/tools/e2e/hermes-gpu-startup-workflow-boundary.mts +++ b/tools/e2e/hermes-gpu-startup-workflow-boundary.mts @@ -143,6 +143,8 @@ export function validateHermesGpuStartupWorkflow( strategy["max-parallel"] !== 2 || JSON.stringify(matrix.scenario) !== JSON.stringify(["native", "fallback", "compatibility-only"]) || + matrix.native_diagnostic !== + "${{ fromJSON(needs.generate-matrix.outputs.hermes_gpu_native_diagnostic_matrix) }}" || matrix.runtime_provider !== "${{ fromJSON(needs.generate-matrix.outputs.runtime_providers_by_job)['hermes-gpu-startup'] }}" || matrix.include !== undefined || @@ -150,6 +152,8 @@ export function validateHermesGpuStartupWorkflow( JSON.stringify([ { scenario: "fallback", runtime_provider: "podman" }, { scenario: "compatibility-only", runtime_provider: "podman" }, + { scenario: "fallback", native_diagnostic: true }, + { scenario: "compatibility-only", native_diagnostic: true }, ]) ) { errors.push(`${JOB_NAME} must expand reviewed GPU scenarios by supported runtime`); diff --git a/tools/e2e/operations-workflow-boundary.mts b/tools/e2e/operations-workflow-boundary.mts index 745ae7555d3..0ccd18595a0 100644 --- a/tools/e2e/operations-workflow-boundary.mts +++ b/tools/e2e/operations-workflow-boundary.mts @@ -1388,6 +1388,8 @@ function validateIssueRoutingRetirement(errors: string[], workflow: OperationsWo } requireNode24GithubScript(errors, report, "report-to-pr"); const candidateReportEnv = { + JOB_NATIVE_HERMES_GPU_DIAGNOSTIC: + "${{ inputs.native_hermes_gpu_diagnostic && 'true' || 'false' }}", JOB_CHECKOUT_SHA: "${{ inputs.checkout_sha }}", JOB_CHECKOUT_REPOSITORY: "${{ inputs.checkout_repository }}", JOB_BASE_SHA: "${{ inputs.base_sha }}", diff --git a/tools/e2e/pre-candidate-workflow-contract.mts b/tools/e2e/pre-candidate-workflow-contract.mts index 33148b78407..f86258342eb 100644 --- a/tools/e2e/pre-candidate-workflow-contract.mts +++ b/tools/e2e/pre-candidate-workflow-contract.mts @@ -47,6 +47,7 @@ export const PRE_CANDIDATE_STEP_ENV: Readonly"$DISPATCH_RECEIPT_DIR/dispatch.json"', @@ -2676,10 +2678,10 @@ const PRE_CANDIDATE_RUN_SHA256: Readonly> = { "Authenticate manual PR dispatch": "25c1a828bd0034722e9f01a1da7c76b26f069120929a7d820fd0873ed1d98d5f", "Record trusted E2E dispatch receipt": - "a18d190cda0c9dd348b42811a532eb83792218f2927a1a98e32c8fa9424b2931", + "2e7b6855f48b461af88745639cb23b08dc33b0b6d279bf4e55d8c89b972ef93e", "Authorize Launchable E2E maintainer dispatch": "bbf442a006b47016eda56133eb400a48c6931c55364c1220b84327b5ffd6f171", - "Generate E2E target matrix": "5081ec27df9f26cc0a8767881bffdaaa5d4142932714805df4acf0bb53b45eb7", + "Generate E2E target matrix": "79b86ef51dbb0c98b1d0682037f79310336a9e15bd38aeb72d7aefdf1755274b", }; function requirePreCandidateEnvironment( @@ -3141,6 +3143,14 @@ export function validateE2eWorkflow(workflowValue: unknown): string[] { requireInput(errors, dispatchInputs, "targets"); validateFullE2eConcurrency(errors, workflow); validateStagingBrevLaunchableInput(errors, dispatchInputs); + const nativeDiagnosticInput = requireInput( + errors, + dispatchInputs, + "native_hermes_gpu_diagnostic", + ); + if (nativeDiagnosticInput.type !== "boolean" || nativeDiagnosticInput.default !== false) { + errors.push("native_hermes_gpu_diagnostic must be boolean and default to false"); + } validateInferenceModeInput(errors, workflow, dispatchInputs); const jobsInput = requireInput(errors, dispatchInputs, "jobs"); const jobsDescription = stringValue(jobsInput.description); @@ -3162,6 +3172,12 @@ export function validateE2eWorkflow(workflowValue: unknown): string[] { if (permissions.contents !== "read") errors.push("workflow permissions.contents must be read"); const jobs = asRecord(workflow.jobs); + if ( + asRecord(asRecord(jobs["generate-matrix"]).outputs).hermes_gpu_native_diagnostic_matrix !== + "${{ steps.matrix.outputs.hermes_gpu_native_diagnostic_matrix }}" + ) { + errors.push("native Hermes GPU diagnostics must use the trusted planner matrix output"); + } if (Object.hasOwn(jobs, "staging-brev-launchable-readiness")) { errors.push("workflow must not define superseded staging-brev-launchable-readiness job"); } diff --git a/tools/e2e/workflow-plan.mts b/tools/e2e/workflow-plan.mts index a45ff06feff..4c327256095 100644 --- a/tools/e2e/workflow-plan.mts +++ b/tools/e2e/workflow-plan.mts @@ -67,9 +67,11 @@ import { export type WorkflowPlanSelectors = { jobs?: string; targets?: string; + nativeHermesGpuDiagnostic?: boolean; }; export type E2eWorkflowPlan = { + nativeHermesGpuDiagnostic?: true; gatewayRuntimes: E2eGatewayRuntime[]; matrix: LiveTargetMatrixEntry[]; testMatrix: CredentialFreeTestMatrixRow[]; @@ -94,6 +96,7 @@ type WorkflowPlanCliOptions = WorkflowPlanSelectors & { const SAFE_SELECTOR_LIST_PATTERN = /^[A-Za-z0-9_-]+(?:,[A-Za-z0-9_-]+)*$/; const HERMES_JOB_ID = "hermes-e2e"; +const HERMES_GPU_JOB_ID = "hermes-gpu-startup"; const STAGING_BREV_IDENTITY_JOB_ID = "staging-brev-launchable-identity"; const COMMIT_SHA_PATTERN = /^[a-f0-9]{40}$/; const INFERENCE_MODES = new Set(["mock", "internal-nvidia", "public-nvidia"]); @@ -575,6 +578,10 @@ function coverageMatrixForPlan( const selectedJobs = new Set(plan.selectedJobs); const workflowRows = inventory.coverageRows .filter((row) => selectedJobs.has(row.id)) + .filter( + (row) => + !plan.nativeHermesGpuDiagnostic || row.id !== HERMES_GPU_JOB_ID || row.variant === "native", + ) .flatMap((row) => { const support = inventory.gatewayRuntimesByCoverageRow.get(`${row.id}:${row.variant}`) ?? @@ -640,6 +647,21 @@ export function buildE2eWorkflowPlan( const jobs = selectorIds(selectors.jobs, "jobs"); const targets = selectorIds(selectors.targets, "targets"); + if ( + selectors.nativeHermesGpuDiagnostic !== undefined && + typeof selectors.nativeHermesGpuDiagnostic !== "boolean" + ) { + throw new Error("nativeHermesGpuDiagnostic must be boolean"); + } + if ( + selectors.nativeHermesGpuDiagnostic && + (selectors.jobs !== HERMES_GPU_JOB_ID || Boolean(selectors.targets)) + ) { + throw new Error( + "Native Hermes GPU diagnostics require only jobs=hermes-gpu-startup and no targets", + ); + } + if ( (jobs.includes(DGX_STATION_DISPATCH_TARGET) || targets.includes(DGX_STATION_DISPATCH_TARGET)) && !( @@ -767,6 +789,9 @@ export function buildE2eWorkflowPlan( ), hermesSelected: selectedJobs.includes(HERMES_JOB_ID), explicitOnlyJobs: [...inventory.explicitOnlyJobs], + ...(selectors.nativeHermesGpuDiagnostic + ? { nativeHermesGpuDiagnostic: true as const } + : {}), }, inventory, ); @@ -923,6 +948,7 @@ export function validateE2eWorkflowPlan(plan: unknown): E2eWorkflowPlan { "runtimeProvidersByJob", "selectedJobs", "testMatrix", + ...(Object.hasOwn(plan, "nativeHermesGpuDiagnostic") ? ["nativeHermesGpuDiagnostic"] : []), ]) ) { throw new Error("E2E planner returned an invalid output schema"); @@ -968,6 +994,15 @@ export function validateE2eWorkflowPlan(plan: unknown): E2eWorkflowPlan { plan.gatewayRuntimes.every((runtime) => runtime === "docker" || runtime === "podman") && new Set(plan.gatewayRuntimes).size === plan.gatewayRuntimes.length; const selectedJobsValue = plan.selectedJobs; + const validNativeHermesGpuDiagnostic = + !Object.hasOwn(plan, "nativeHermesGpuDiagnostic") || + (plan.nativeHermesGpuDiagnostic === true && + isDeepStrictEqual(selectedJobsValue, [HERMES_GPU_JOB_ID]) && + Array.isArray(plan.matrix) && + plan.matrix.length === 0 && + Array.isArray(plan.testMatrix) && + plan.testMatrix.length === 0 && + Object.values(catalogueMatricesValue).every((rows) => rows.length === 0)); const validRuntimeProvidersByJob = isRecord(plan.runtimeProvidersByJob) && isStringArray(selectedJobsValue) && @@ -992,6 +1027,7 @@ export function validateE2eWorkflowPlan(plan: unknown): E2eWorkflowPlan { !selectedJobsValue.every((job) => /^[A-Za-z0-9_-]+$/u.test(job)) || !hasUniqueValues(selectedJobsValue, (id) => id) || !validRuntimeProvidersByJob || + !validNativeHermesGpuDiagnostic || typeof plan.hermesSelected !== "boolean" || !isStringArray(plan.explicitOnlyJobs) || !plan.explicitOnlyJobs.every((job) => /^[A-Za-z0-9_-]+$/u.test(job)) || @@ -1089,6 +1125,14 @@ export function renderE2eWorkflowPlanSummary( "| Target or job | Agent runtime | Observable outcome | Environment or inference endpoint | Source | Unresolved reason |", "| --- | --- | --- | --- | --- | --- |", ]; + if (plan.nativeHermesGpuDiagnostic) { + lines.splice( + 2, + 0, + "**Scope:** Native Hermes GPU diagnostic only. Fallback and compatibility-only remain unqualified.", + "", + ); + } for (const row of plan.coverageMatrix) { lines.push( `| \`${e2eExecutionLabel(row)}\` | ${row.agentRuntime} | ${row.observableOutcome} | ${row.environmentOrInferenceEndpoint} | ${row.source} | ${row.unresolvedReason} |`, @@ -1171,13 +1215,30 @@ export function writeE2eWorkflowPlanCiOutput( environment.NEMOCLAW_GATEWAY_RUNTIMES ?? environment.NEMOCLAW_GATEWAY_RUNTIME, ); const hasPlannerSelectors = Boolean(selectors.jobs || selectors.targets); + const nativeDiagnostic = environment.NEMOCLAW_E2E_NATIVE_HERMES_GPU_DIAGNOSTIC ?? "false"; + if (nativeDiagnostic !== "true" && nativeDiagnostic !== "false") { + throw new Error("NEMOCLAW_E2E_NATIVE_HERMES_GPU_DIAGNOSTIC must be true or false"); + } + if (selectors.nativeHermesGpuDiagnostic !== undefined) { + throw new Error("CI native Hermes GPU diagnostics must use the diagnostic environment input"); + } + if (nativeDiagnostic === "true" && environment.EVENT_NAME !== "workflow_dispatch") { + throw new Error("Native Hermes GPU diagnostics require workflow_dispatch"); + } const changedFiles = hasPlannerSelectors ? undefined : changedFilesFromEnvironment(environment); - const planned = buildE2eWorkflowPlan(selectors, { - changedFiles, - gatewayRuntimes, - includeStagingBrevLaunchable: - environment.NEMOCLAW_E2E_INCLUDE_STAGING_BREV_LAUNCHABLE === "true", - }); + const planned = buildE2eWorkflowPlan( + { + jobs: selectors.jobs, + targets: selectors.targets, + ...(nativeDiagnostic === "true" ? { nativeHermesGpuDiagnostic: true } : {}), + }, + { + changedFiles, + gatewayRuntimes, + includeStagingBrevLaunchable: + environment.NEMOCLAW_E2E_INCLUDE_STAGING_BREV_LAUNCHABLE === "true", + }, + ); const plan = validateE2eWorkflowPlan(planned); const expectedHermes = expectedHermesSelection(selectors); if (!changedFiles && plan.hermesSelected !== expectedHermes) { @@ -1202,6 +1263,7 @@ export function writeE2eWorkflowPlanCiOutput( `selected_workflow_jobs=${JSON.stringify(selectedWorkflowJobs(plan))}`, `managed_image_required=${requiresManagedImages(selectedWorkflowJobs(plan))}`, `hermes_selected=${plan.hermesSelected}`, + `hermes_gpu_native_diagnostic_matrix=${JSON.stringify([plan.nativeHermesGpuDiagnostic === true])}`, `explicit_only_jobs=${plan.explicitOnlyJobs.join(",")}`, `release_required_jobs=${JSON.stringify(releaseRequiredWorkflowJobs())}`, "", @@ -1227,6 +1289,10 @@ function parseArgs(argv: readonly string[]): WorkflowPlanCliOptions { options.summary = true; continue; } + if (arg === "--native-hermes-gpu-diagnostic") { + options.nativeHermesGpuDiagnostic = true; + continue; + } if (arg !== "--jobs" && arg !== "--targets") { throw new Error(`Unknown argument: ${arg}`); } @@ -1239,6 +1305,9 @@ function parseArgs(argv: readonly string[]): WorkflowPlanCliOptions { if (options.ciOutput && options.summary) { throw new Error("--ci-output and --summary cannot be combined"); } + if (options.ciOutput && options.nativeHermesGpuDiagnostic) { + throw new Error("--ci-output requires the diagnostic environment input"); + } return options; }