diff --git a/.agents/skills/nemoclaw-maintainer-e2e/SKILL.md b/.agents/skills/nemoclaw-maintainer-e2e/SKILL.md index fca2403f207..7ad7c422274 100644 --- a/.agents/skills/nemoclaw-maintainer-e2e/SKILL.md +++ b/.agents/skills/nemoclaw-maintainer-e2e/SKILL.md @@ -73,16 +73,17 @@ Choose exactly one mode: The run skips `jetson-nvmap-gpu` unless `allow_jetson_dispatch` is `true`. It skips `llama-cpp-dgx-spark-plan` and `llama-cpp-dgx-spark-qualification` unless their runner-queue flag is `true`. - For protected managed-image runtime qualification, set `E2E_JOBS=managed-image-protected-runtime`. The exact candidate must contain `ci/protected-managed-image-multiarch-activation-v1.json` and `ci/protected-managed-image-runtime-activation-v1.json`. +- For native-runtime qualification evidence, set `E2E_JOBS=native-runtime-qualification-producer`. Use a same-repository open PR and the first workflow attempt. The trusted workflow runs each case under a credential-free candidate account on a reviewed ephemeral runner. The candidate must contain `test/e2e/live/native-runtime-qualification-case.test.ts` before the selector can pass. Leave `targets` empty and keep Launchable disabled: ```bash E2E_JOBS="${E2E_JOBS:-}" case "$E2E_JOBS" in - "" | managed-image-protected-runtime) ;; + "" | managed-image-protected-runtime | native-runtime-qualification-producer) ;; *) echo "Unsupported manual PR E2E job selector" >&2; exit 1 ;; esac -REVIEW_REASON='Reviewed the PR head commit for credentialed E2E.' +REVIEW_REASON='Reviewed the commit under review and selected E2E boundary.' CORRELATION_ID="$(python3 -c 'import uuid; print(uuid.uuid4())')" INFERENCE_MODE=mock ALLOW_JETSON_DISPATCH=false @@ -109,6 +110,10 @@ The trusted pre-checkout step requires current `maintain` or `admin` permission. It validates the actor, open PR, repository, head SHA, base SHA, workflow SHA, review reason, and allowed jobs, targets, and Launchable combination. A second validation after checkout rejects a changed PR identity before preparation. +The native-runtime producer binds the open PR, candidate commit, base commit, trusted workflow commit, and first workflow attempt. It runs the trusted plan from `main` and passes no GitHub, model-provider, API, or messaging credentials to candidate code. Configure `NATIVE_RUNTIME_EPHEMERAL_RUNNER_POOL=enabled` before dispatch. The ARM64 GPU case also requires `NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL`; the workflow provides no fallback runner. + +The producer stops Docker, masks its service and socket, removes Docker sockets, and rejects a usable `docker` command before candidate execution. It runs the candidate case under a temporary unprivileged account and uploads one evidence artifact for each planned case. Cleanup terminates processes owned by the candidate account and removes that account. If cleanup fails or the runner becomes unavailable, inspect the host and remove the ephemeral runner from service. Recover or replace the runner before dispatching a new run. Do not rerun the same workflow attempt; the producer rejects attempts after the first. + Find and verify the correlated run with bounded GitHub reads: ```bash diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 14926a1dd63..9aead5db647 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -221,7 +221,7 @@ jobs: matrix='[{"id":"ubuntu-policy-custom-missing-presets-negative","runner":"ubuntu-latest"},{"id":"ubuntu-repo-cloud-langchain-deepagents-code","runner":"ubuntu-latest"},{"id":"ubuntu-repo-cloud-openclaw","runner":"ubuntu-latest"},{"id":"ubuntu-repo-docker-post-reboot-recovery","runner":"ubuntu-latest"}]' test_matrix='[{"id":"onboard-managed-image-buildless-e2e","file":"test/onboard-managed-image-buildless-e2e.test.ts","project":"integration"},{"id":"vllm-docker-storage","file":"test/vllm-docker-storage.test.ts","project":"integration"}]' ;; - inference-routing: | managed-image-protected-runtime: | :jetson-nvmap-gpu) + inference-routing: | managed-image-protected-runtime: | native-runtime-qualification-producer: | :jetson-nvmap-gpu) matrix='[]' ;; :ubuntu-repo-cloud-langchain-deepagents-code) @@ -312,9 +312,9 @@ jobs: } [[ "$RUN_ATTEMPT" == "1" ]] || { echo "::error::Manual PR E2E cannot be rerun" >&2; exit 1; } case "${JOBS}:${TARGETS}:${INCLUDE_LAUNCHABLE}:${ALLOW_JETSON_DISPATCH}" in - ::false:false | inference-routing::false:false | managed-image-protected-runtime::false:false | :jetson-nvmap-gpu:false:true) ;; + ::false:false | inference-routing::false:false | managed-image-protected-runtime::false:false | native-runtime-qualification-producer::false:false | :jetson-nvmap-gpu:false:true) ;; *) - echo "::error::Manual PR E2E accepts only empty selectors, inference-routing, managed-image-protected-runtime, or jetson-nvmap-gpu with its dispatch flag" >&2 + echo "::error::Manual PR E2E accepts only empty selectors, inference-routing, managed-image-protected-runtime, native-runtime-qualification-producer, or jetson-nvmap-gpu with its dispatch flag" >&2 exit 1 ;; esac @@ -533,6 +533,7 @@ jobs: fi - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: ${{ inputs.checkout_sha == '' || inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '' }} with: repository: ${{ inputs.checkout_repository || github.repository }} ref: ${{ inputs.checkout_sha || github.sha }} @@ -540,7 +541,7 @@ jobs: persist-credentials: false - name: Validate manual PR checkout - if: ${{ inputs.checkout_sha != '' }} + if: ${{ inputs.checkout_sha != '' && (inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '') }} env: BASE_SHA: ${{ inputs.base_sha }} CHECKOUT_REPOSITORY: ${{ inputs.checkout_repository }} @@ -563,7 +564,7 @@ jobs: - id: e2e_credentials name: Authorize E2E credentials - if: ${{ inputs.checkout_sha != '' }} + if: ${{ inputs.checkout_sha != '' && (inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '') }} env: CHECKOUT_REPOSITORY: ${{ inputs.checkout_repository }} CHECKOUT_SHA: ${{ inputs.checkout_sha }} @@ -589,10 +590,12 @@ jobs: printf 'allowed=%s\n' "$credentials_allowed" >> "$GITHUB_OUTPUT" - name: Prepare E2E workspace + if: ${{ inputs.checkout_sha == '' || inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '' }} uses: NVIDIA/NemoClaw/.github/actions/prepare-e2e@f6304bc25fc35bfaa441c8c2fbfee38f72805a75 - id: package_cli_artifact name: Package exact-commit CLI + if: ${{ inputs.checkout_sha == '' || inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '' }} env: CANDIDATE_REPOSITORY: ${{ inputs.checkout_repository || github.repository }} CANDIDATE_SHA: ${{ inputs.checkout_sha || github.sha }} @@ -705,6 +708,7 @@ jobs: - id: upload_cli_artifact name: Publish content-addressed CLI artifact + if: ${{ inputs.checkout_sha == '' || inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '' }} uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: ${{ steps.package_cli_artifact.outputs.artifact_name }} @@ -715,6 +719,7 @@ jobs: - id: record_cli_artifact name: Record CLI artifact provenance + if: ${{ inputs.checkout_sha == '' || inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '' }} env: ARTIFACT_DIGEST: ${{ steps.upload_cli_artifact.outputs.artifact-digest }} ARTIFACT_ID: ${{ steps.upload_cli_artifact.outputs.artifact-id }} @@ -779,6 +784,24 @@ jobs: RELEASE_QUALIFICATION_WAIVED_JOBS: ${{ inputs.release_qualification_waived_jobs }} run: | set -euo pipefail + if [[ "${JOBS:-}" == "native-runtime-qualification-producer" && -z "${TARGETS:-}" ]]; then + { + echo 'matrix=[]' + echo 'test_matrix=[]' + echo 'catalogue_standard_matrix=[]' + echo 'catalogue_nvidia_api_matrix=[]' + echo 'catalogue_nvidia_inference_matrix=[]' + echo 'catalogue_github_read_matrix=[]' + echo 'catalogue_brave_nvidia_inference_matrix=[]' + echo 'selected_jobs=["native-runtime-qualification-producer"]' + echo 'selected_workflow_jobs=["native-runtime-qualification-producer"]' + echo 'hermes_selected=false' + echo 'explicit_only_jobs=native-runtime-qualification-producer' + echo 'release_qualification_waived_jobs=[]' + echo 'release_required_jobs=[]' + } >>"$GITHUB_OUTPUT" + exit 0 + fi if [ "${EVENT_NAME:-}" = "push" ]; then [[ "${BEFORE_SHA}" =~ ^[a-f0-9]{40}$ && "${CANDIDATE_SHA}" =~ ^[a-f0-9]{40}$ ]] || { echo "::error::Main push E2E requires exact before and candidate commit SHAs" >&2 @@ -803,6 +826,349 @@ jobs: fi fi + native-runtime-qualification-producer-plan: + needs: generate-matrix + if: ${{ github.event_name == 'workflow_dispatch' && github.repository == 'NVIDIA/NemoClaw' && github.ref == 'refs/heads/main' && inputs.checkout_sha != '' && inputs.jobs == 'native-runtime-qualification-producer' && inputs.targets == '' }} + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + actions: read + contents: read + pull-requests: read + outputs: + matrix: ${{ steps.plan.outputs.matrix }} + steps: + - name: Check out the trusted qualification producer + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.workflow_sha }} + persist-credentials: false + sparse-checkout: | + test/e2e/registry/native-runtime-qualification.ts + tools/e2e/native-runtime-qualification-producer-plan.mts + sparse-checkout-cone-mode: false + + - name: Check out the candidate for source authentication + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ inputs.checkout_repository || github.repository }} + ref: ${{ inputs.checkout_sha || github.sha }} + path: .candidate-source + fetch-depth: 1 + persist-credentials: false + + - name: Set up Node for trusted qualification planning + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 22 + + - id: source + name: Authenticate the candidate and dispatch artifact + env: + BASE_SHA: ${{ inputs.base_sha }} + CANDIDATE_REPOSITORY: ${{ inputs.checkout_repository }} + CANDIDATE_SHA: ${{ inputs.checkout_sha }} + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ inputs.pr_number }} + PRODUCER_RUN_ATTEMPT: ${{ github.run_attempt }} + PRODUCER_RUN_ID: ${{ github.run_id }} + WORKFLOW_SHA: ${{ github.workflow_sha }} + shell: bash + run: | + set -euo pipefail + [[ "$CANDIDATE_REPOSITORY" == "NVIDIA/NemoClaw" ]] || { + echo "::error::Native runtime qualification accepts only a branch in NVIDIA/NemoClaw" >&2 + exit 1 + } + [[ "$PRODUCER_RUN_ATTEMPT" == "1" ]] || { + echo "::error::Native runtime qualification producer runs cannot be rerun" >&2 + exit 1 + } + [[ "$BASE_SHA" == "$WORKFLOW_SHA" && "$CANDIDATE_SHA" != "$WORKFLOW_SHA" ]] || { + echo "::error::Native runtime qualification requires base_sha to equal workflow_sha and checkout_sha to name a different commit" >&2 + exit 1 + } + [[ "$(git -C .candidate-source rev-parse --verify 'HEAD^{commit}')" == "$CANDIDATE_SHA" ]] || { + echo "::error::Candidate checkout does not match the authenticated candidate commit" >&2 + exit 1 + } + pull="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}")" + jq -e \ + --arg baseSha "$BASE_SHA" \ + --arg candidateRepository "$CANDIDATE_REPOSITORY" \ + --arg candidateSha "$CANDIDATE_SHA" ' + .state == "open" and + .head.repo.full_name == $candidateRepository and + .head.sha == $candidateSha and + .base.repo.full_name == "NVIDIA/NemoClaw" and + .base.ref == "main" and + .base.sha == $baseSha + ' <<<"$pull" >/dev/null || { + echo "::error::Pull request identity changed before qualification planning" >&2 + exit 1 + } + artifact_name="e2e-dispatch-${PRODUCER_RUN_ID}-${PRODUCER_RUN_ATTEMPT}" + artifacts="$(gh api --method GET \ + "repos/${GITHUB_REPOSITORY}/actions/runs/${PRODUCER_RUN_ID}/artifacts" \ + -f name="$artifact_name" \ + -f per_page=100)" + artifact="$(jq -ce \ + --arg name "$artifact_name" \ + --arg runId "$PRODUCER_RUN_ID" \ + --arg workflowSha "$WORKFLOW_SHA" ' + select(.total_count == 1 and (.artifacts | length) == 1) | + .artifacts[0] | + select(.name == $name and .expired == false) | + select(.size_in_bytes > 0 and .size_in_bytes <= 1048576) | + select((.id | tostring | test("^[1-9][0-9]{0,19}$"))) | + select((.digest // "") | test("^sha256:[a-f0-9]{64}$")) | + select((.workflow_run.id | tostring) == $runId) | + select(.workflow_run.head_sha == $workflowSha) + ' <<<"$artifacts")" || { + echo "::error::Trusted dispatch artifact is missing or ambiguous" >&2 + exit 1 + } + installer_sha256="$(sha256sum .candidate-source/scripts/install.sh | awk '{print $1}')" + [[ "$installer_sha256" =~ ^[a-f0-9]{64}$ ]] || { + echo "::error::Candidate installer SHA-256 is invalid" >&2 + exit 1 + } + printf 'artifact_id=%s\n' "$(jq -r '.id | tostring' <<<"$artifact")" >>"$GITHUB_OUTPUT" + printf 'artifact_name=%s\n' "$artifact_name" >>"$GITHUB_OUTPUT" + printf 'artifact_digest=%s\n' "$(jq -r '.digest' <<<"$artifact")" >>"$GITHUB_OUTPUT" + printf 'artifact_size=%s\n' "$(jq -r '.size_in_bytes' <<<"$artifact")" >>"$GITHUB_OUTPUT" + printf 'installer_sha256=%s\n' "$installer_sha256" >>"$GITHUB_OUTPUT" + + - id: plan + name: Compile the trusted qualification producer matrix + env: + BASE_SHA: ${{ inputs.base_sha }} + CANDIDATE_REPOSITORY: ${{ inputs.checkout_repository }} + CANDIDATE_SHA: ${{ inputs.checkout_sha }} + DISPATCH_ARTIFACT_DIGEST: ${{ steps.source.outputs.artifact_digest }} + DISPATCH_ARTIFACT_ID: ${{ steps.source.outputs.artifact_id }} + DISPATCH_ARTIFACT_NAME: ${{ steps.source.outputs.artifact_name }} + DISPATCH_ARTIFACT_SIZE: ${{ steps.source.outputs.artifact_size }} + INSTALLER_SHA256: ${{ steps.source.outputs.installer_sha256 }} + NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL: ${{ vars.NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL }} + PR_NUMBER: ${{ inputs.pr_number }} + PRODUCER_RUN_ATTEMPT: ${{ github.run_attempt }} + PRODUCER_RUN_ID: ${{ github.run_id }} + WORKFLOW_SHA: ${{ github.workflow_sha }} + run: node --experimental-strip-types --no-warnings tools/e2e/native-runtime-qualification-producer-plan.mts --ci-output + + native-runtime-qualification-producer: + name: ${{ matrix.jobName }} + needs: [generate-matrix, native-runtime-qualification-producer-plan] + if: ${{ needs.native-runtime-qualification-producer-plan.result == 'success' && contains(fromJSON(needs.generate-matrix.outputs.selected_jobs), 'native-runtime-qualification-producer') }} + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.native-runtime-qualification-producer-plan.outputs.matrix) }} + runs-on: ${{ matrix.runner }} + timeout-minutes: 120 + permissions: + contents: read + env: + NEMOCLAW_RUN_LIVE_E2E: "1" + QUALIFICATION_ROW: ${{ toJSON(matrix) }} + steps: + - name: Require an ephemeral qualification runner + env: + REVIEWED_EPHEMERAL_POOL: ${{ vars.NATIVE_RUNTIME_EPHEMERAL_RUNNER_POOL }} + RUNNER_ENVIRONMENT: ${{ runner.environment }} + shell: bash + run: | + set -euo pipefail + if [[ "$RUNNER_ENVIRONMENT" != "github-hosted" && "$REVIEWED_EPHEMERAL_POOL" != "enabled" ]]; then + echo "::error::Self-hosted native runtime qualification requires the reviewed ephemeral runner pool" >&2 + exit 1 + fi + + - name: Check out the trusted qualification harness + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ matrix.source.workflowSha }} + path: .trusted-qualification + persist-credentials: false + sparse-checkout: | + scripts/checks/run-native-runtime-installer-qualification.sh + tools/e2e/native-runtime-qualification-producer-evidence.mts + sparse-checkout-cone-mode: false + + - name: Check out the candidate commit + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: ${{ matrix.source.candidateRepository }} + ref: ${{ matrix.source.candidateSha }} + path: .candidate-runtime + fetch-depth: 1 + persist-credentials: false + + - name: Set up Node for candidate execution + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 22.19.0 + + - name: Install locked candidate test dependencies without scripts + working-directory: .candidate-runtime + run: npm ci --ignore-scripts + + - name: Prepare the credential-free execution account and disable Docker + id: boundary + env: + CANDIDATE_DIRECTORY: ${{ github.workspace }}/.candidate-runtime + shell: bash + run: | + set -euo pipefail + for command in git jq node pgrep podman sha256sum systemctl; do + command -v "$command" >/dev/null || { + echo "::error::Protected runner is missing required command: $command" >&2 + exit 1 + } + done + [[ "$(podman --version)" =~ ^podman\ version\ 5[.] ]] || { + echo "::error::Protected runner must provide Podman 5" >&2 + exit 1 + } + sudo systemctl stop docker.service docker.socket 2>/dev/null || true + sudo systemctl mask --runtime docker.service docker.socket 2>/dev/null || true + sudo pkill -TERM -x dockerd 2>/dev/null || true + sudo rm -f /var/run/docker.sock /run/docker.sock + ! systemctl is-active --quiet docker.service + ! systemctl is-active --quiet docker.socket + ! pgrep -x dockerd >/dev/null + [[ ! -S /var/run/docker.sock && ! -S /run/docker.sock ]] + account="nemoclawq" + printf 'account=%s\n' "$account" >>"$GITHUB_OUTPUT" + sudo useradd --create-home --shell /usr/sbin/nologin "$account" + uid="$(id -u "$account")" + home="$(getent passwd "$account" | cut -d: -f6)" + runtime_dir="/run/user/${uid}" + sudo install -d -o "$uid" -g "$uid" -m 0700 "$runtime_dir" + sudo chown -R "$uid:$uid" "$CANDIDATE_DIRECTORY" + guard_dir="${RUNNER_TEMP}/native-runtime-docker-guard" + install -d -m 0700 "$guard_dir" + printf '%s\n' '#!/usr/bin/env bash' 'exit 97' >"$guard_dir/docker" + chmod 0500 "$guard_dir/docker" + printf 'home=%s\n' "$home" >>"$GITHUB_OUTPUT" + printf 'runtime_dir=%s\n' "$runtime_dir" >>"$GITHUB_OUTPUT" + printf 'guard_dir=%s\n' "$guard_dir" >>"$GITHUB_OUTPUT" + + - name: Run the authenticated installer qualification + env: + ACCOUNT: ${{ steps.boundary.outputs.account }} + ARCHITECTURE: ${{ matrix.case.architecture }} + CANDIDATE_DIRECTORY: ${{ github.workspace }}/.candidate-runtime + CANDIDATE_SHA: ${{ matrix.source.candidateSha }} + GUARD_DIRECTORY: ${{ steps.boundary.outputs.guard_dir }} + INSTALLER_RECEIPT_PARENT: ${{ runner.temp }}/native-runtime-installer + INSTALLER_SHA256: ${{ matrix.installerSha256 }} + QUALIFICATION_HOME: ${{ steps.boundary.outputs.home }} + shell: bash + run: | + set -euo pipefail + install -d -m 0700 "$INSTALLER_RECEIPT_PARENT" + sudo chown "$ACCOUNT:$ACCOUNT" "$INSTALLER_RECEIPT_PARENT" + sudo -u "$ACCOUNT" env -i \ + HOME="$QUALIFICATION_HOME" \ + LANG=C.UTF-8 \ + PATH="$GUARD_DIRECTORY:/usr/local/bin:/usr/bin:/bin" \ + bash .trusted-qualification/scripts/checks/run-native-runtime-installer-qualification.sh \ + --candidate-checkout "$CANDIDATE_DIRECTORY" \ + --candidate-sha "$CANDIDATE_SHA" \ + --installer-sha256 "$INSTALLER_SHA256" \ + --architecture "$ARCHITECTURE" \ + --artifact-dir "$INSTALLER_RECEIPT_PARENT/receipts" + sudo pkill -KILL -u "$(id -u "$ACCOUNT")" 2>/dev/null || true + [[ -d "$INSTALLER_RECEIPT_PARENT/receipts" && ! -L "$INSTALLER_RECEIPT_PARENT/receipts" ]] || { + echo "::error::Installer receipt directory is missing or invalid" >&2 + exit 1 + } + sudo chown -R -h root:root "$INSTALLER_RECEIPT_PARENT/receipts" + + - name: Execute the candidate qualification case without credentials + env: + ACCOUNT: ${{ steps.boundary.outputs.account }} + CANDIDATE_DIRECTORY: ${{ github.workspace }}/.candidate-runtime + GUARD_DIRECTORY: ${{ steps.boundary.outputs.guard_dir }} + QUALIFICATION_HOME: ${{ steps.boundary.outputs.home }} + RUNTIME_DIRECTORY: ${{ steps.boundary.outputs.runtime_dir }} + shell: bash + run: | + set -euo pipefail + live_test="$CANDIDATE_DIRECTORY/test/e2e/live/native-runtime-qualification-case.test.ts" + [[ -f "$live_test" && ! -L "$live_test" ]] || { + echo "::error::Candidate commit does not provide the native runtime qualification case executor" >&2 + exit 1 + } + receipt_directory="${RUNNER_TEMP}/native-runtime-case" + install -d -m 0700 "$receipt_directory" + sudo chown "$ACCOUNT:$ACCOUNT" "$receipt_directory" + sudo -u "$ACCOUNT" env -i \ + CI=true \ + E2E_DEFAULT_ENABLED=0 \ + E2E_JOB=1 \ + HOME="$QUALIFICATION_HOME" \ + LANG=C.UTF-8 \ + NEMOCLAW_NATIVE_RUNTIME_QUALIFICATION_RECEIPT="$receipt_directory/execution.json" \ + NEMOCLAW_NATIVE_RUNTIME_QUALIFICATION_ROW="$QUALIFICATION_ROW" \ + NEMOCLAW_RUN_LIVE_E2E=1 \ + PATH="$GUARD_DIRECTORY:/usr/local/bin:/usr/bin:/bin" \ + XDG_RUNTIME_DIR="$RUNTIME_DIRECTORY" \ + "$CANDIDATE_DIRECTORY/node_modules/.bin/vitest" run \ + --config "$CANDIDATE_DIRECTORY/vitest.config.ts" \ + --project e2e-live \ + "$live_test" + sudo pkill -KILL -u "$(id -u "$ACCOUNT")" 2>/dev/null || true + sudo chown -R root:root "$receipt_directory" + + - name: Verify Docker stayed unavailable + shell: bash + run: | + set -euo pipefail + ! systemctl is-active --quiet docker.service + ! systemctl is-active --quiet docker.socket + ! pgrep -x dockerd >/dev/null + [[ ! -S /var/run/docker.sock && ! -S /run/docker.sock ]] + + - name: Validate receipts and emit bounded evidence + env: + EVIDENCE_DIRECTORY: ${{ runner.temp }}/native-runtime-evidence + EXECUTION_RECEIPT_PATH: ${{ runner.temp }}/native-runtime-case/execution.json + INSTALLER_RECEIPT_DIRECTORY: ${{ runner.temp }}/native-runtime-installer/receipts + shell: bash + run: | + set -euo pipefail + sudo chown -R "$(id -u):$(id -g)" \ + "$INSTALLER_RECEIPT_DIRECTORY" \ + "$(dirname "$EXECUTION_RECEIPT_PATH")" + node --experimental-strip-types --no-warnings \ + .trusted-qualification/tools/e2e/native-runtime-qualification-producer-evidence.mts + + - name: Remove qualification resources + if: always() + env: + ACCOUNT: ${{ steps.boundary.outputs.account }} + shell: bash + run: | + set -euo pipefail + account="${ACCOUNT:-nemoclawq}" + if id "$account" >/dev/null 2>&1; then + sudo pkill -KILL -u "$(id -u "$account")" 2>/dev/null || true + sudo userdel --remove "$account" + fi + if id "$account" >/dev/null 2>&1; then + echo "::error::Qualification account still exists after cleanup" >&2 + exit 1 + fi + + - name: Upload the qualification case evidence + if: always() + uses: NVIDIA/NemoClaw/.github/actions/upload-e2e-artifacts@7768e15eb90d3ee2d33432f481dfe8747e4f6d57 + with: + name: ${{ matrix.artifactName }} + path: ${{ runner.temp }}/native-runtime-evidence/evidence.json + retired-selector-compatibility: needs: generate-matrix if: ${{ inputs.checkout_sha != '' && (contains(format(',{0},', inputs.jobs), ',credential-migration,') || contains(format(',{0},', inputs.jobs), ',credential-sanitization,') || contains(format(',{0},', inputs.jobs), ',diagnostics,') || contains(format(',{0},', inputs.jobs), ',docs-validation,') || contains(format(',{0},', inputs.jobs), ',gateway-drift-preflight,') || contains(format(',{0},', inputs.jobs), ',gateway-health-honest,') || contains(format(',{0},', inputs.jobs), ',onboard-negative-paths,') || contains(format(',{0},', inputs.jobs), ',openshell-version-pin,') || contains(format(',{0},', inputs.jobs), ',sandbox-rebuild,') || contains(format(',{0},', inputs.jobs), ',ubuntu-repo-cli-smoke,') || contains(format(',{0},', inputs.jobs), ',upgrade-stale-sandbox,') || contains(format(',{0},', inputs.targets), ',sandbox-rebuild,') || contains(format(',{0},', inputs.targets), ',upgrade-stale-sandbox,')) }} @@ -3780,6 +4146,7 @@ jobs: cloud-onboard, openclaw-plugin-runtime-exdev-release, openclaw-plugin-runtime-exdev, + native-runtime-qualification-producer, ] if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.checkout_sha == '' }} permissions: diff --git a/test/e2e/README.md b/test/e2e/README.md index 5481a1855c1..4cb3cc3b26f 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -1040,6 +1040,10 @@ After a failure, inspect the workflow artifacts and remove resources that target For `managed-image-protected-runtime`, the workflow supplies the long-lived `NVIDIA_API_KEY` repository secret only to the trusted qualification step. Trusted host code uses it for NGC login and passes it as `NGC_API_KEY` and `NIM_NGC_API_KEY` to the temporary, cohort-owned NIM container. Candidate managed sandboxes receive generated local route tokens instead of this key. Before starting NIM or vLLM, the live fixture rejects a pre-existing cohort container name. It records the full container ID, requested image, immutable image ID, cohort owner, and provider label, then removes only that exact container after revalidating every field. Missing, ambiguous, name-reused, drifted, or indeterminate cleanup evidence fails the test, as does any retained exact ID or name. A fail-closed refusal can leave the secret-bearing NIM container alive until runner teardown; inspect the redacted artifacts and remove only the verified container. The final workflow step removes the job's isolated Docker credential directory and fails if that removal does not complete. The workflow does not revoke the NVIDIA API key. Revoke it, or rotate it and disable the old value, in the issuing NVIDIA service. Verify that the exposed key is no longer valid. +For `native-runtime-qualification-producer`, use a same-repository open PR and the first workflow attempt. The trusted workflow binds the candidate commit, base commit, workflow commit, repository, PR, and plan from `main`. It passes no GitHub, model-provider, API, or messaging credentials to candidate code. Candidate execution uses `env -i` under a temporary unprivileged account on a reviewed ephemeral runner. Configure `NATIVE_RUNTIME_EPHEMERAL_RUNNER_POOL=enabled` before dispatch. The ARM64 GPU case also requires `NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL`; the workflow provides no fallback runner. The candidate must contain `test/e2e/live/native-runtime-qualification-case.test.ts`. Until that executor and the required runner capacity exist, the producer fails closed instead of claiming qualification. + +Before candidate execution, the producer stops Docker, masks its service and socket, removes Docker sockets, and rejects a usable `docker` command. It uploads one evidence artifact for each planned case. Cleanup terminates processes owned by the candidate account and removes that account. If cleanup fails or the runner becomes unavailable, inspect the host and remove the ephemeral runner from service. Recover or replace the runner before dispatching a new run. Do not rerun the same workflow attempt; the producer rejects attempts after the first. Dispatch a new run after recovery. + For a manual PR run, provide the current PR number, lowercase 40-character candidate commit SHA, PR source repository, lowercase 40-character base commit SHA, trusted `main` workflow SHA, and a review reason containing 10 to 500 printable characters. Leave `jobs` and `targets` empty and keep `include_staging_brev_launchable=false` to use this PR revision selection. Keep `allow_jetson_dispatch=false` and `allow_dgx_spark_runner_queue=false` for the default PR revision selection. @@ -1049,6 +1053,9 @@ To select the protected managed-image runtime qualification, set `jobs=managed-i Leave `targets` empty. Keep `include_staging_brev_launchable=false`. The exact candidate must contain `ci/protected-managed-image-multiarch-activation-v1.json` and `ci/protected-managed-image-runtime-activation-v1.json`. +To select native-runtime qualification evidence production, set `jobs=native-runtime-qualification-producer`. +Leave `targets` empty and keep `include_staging_brev_launchable=false`. +Confirm that the PR comes from `NVIDIA/NemoClaw`, the required ephemeral runner variables are configured, and the workflow has not been rerun. The trusted pre-checkout step requires current `maintain` or `admin` permission and validates the exact open PR and selected mode before candidate code runs. A second validation after checkout rejects a changed candidate commit, base commit, or PR source repository before preparation. diff --git a/test/e2e/support/e2e-operations-workflow-boundary.test.ts b/test/e2e/support/e2e-operations-workflow-boundary.test.ts index f56545f7f8c..2d43b6e76c2 100644 --- a/test/e2e/support/e2e-operations-workflow-boundary.test.ts +++ b/test/e2e/support/e2e-operations-workflow-boundary.test.ts @@ -414,12 +414,12 @@ const interpolatedNeeds = \${{ toJSON ( needs ) }}; (step) => step.name === "Authenticate manual PR dispatch", )!; authentication.run = authentication.run!.replace( - "Manual PR E2E accepts only empty selectors, inference-routing, managed-image-protected-runtime, or jetson-nvmap-gpu with its dispatch flag", + "Manual PR E2E accepts only empty selectors, inference-routing, managed-image-protected-runtime, native-runtime-qualification-producer, or jetson-nvmap-gpu with its dispatch flag", "Manual PR E2E accepts arbitrary selectors", ); expect(validateE2eOperationsWorkflow(workflow)).toContain( - "Manual PR authentication must retain Manual PR E2E accepts only empty selectors, inference-routing, managed-image-protected-runtime, or jetson-nvmap-gpu with its dispatch flag", + "Manual PR authentication must retain Manual PR E2E accepts only empty selectors, inference-routing, managed-image-protected-runtime, native-runtime-qualification-producer, or jetson-nvmap-gpu with its dispatch flag", ); }); @@ -431,7 +431,7 @@ const interpolatedNeeds = \${{ toJSON ( needs ) }}; authentication.run = authentication.run!.replace("inference-routing::false:false | ", ""); expect(validateE2eOperationsWorkflow(workflow)).toContain( - "Manual PR authentication must retain ::false:false | inference-routing::false:false | managed-image-protected-runtime::false:false | :jetson-nvmap-gpu:false:true) ;;", + "Manual PR authentication must retain ::false:false | inference-routing::false:false | managed-image-protected-runtime::false:false | native-runtime-qualification-producer::false:false | :jetson-nvmap-gpu:false:true) ;;", ); }); @@ -439,6 +439,7 @@ const interpolatedNeeds = \${{ toJSON ( needs ) }}; ["maintain", "", "", "false", 0, ""], ["maintain", "inference-routing", "", "false", 0, ""], ["maintain", "managed-image-protected-runtime", "", "false", 0, ""], + ["maintain", "native-runtime-qualification-producer", "", "false", 0, ""], ["maintain", "", "jetson-nvmap-gpu", "true", 0, ""], ["maintain", "", "jetson-nvmap-gpu", "false", 1, "accepts only empty selectors"], ["maintain", "network-policy", "", "false", 1, "accepts only empty selectors"], @@ -822,6 +823,22 @@ const interpolatedNeeds = \${{ toJSON ( needs ) }}; ); }); + it.each([ + ["a lowercase short write method", "gh api -X post repos/NVIDIA/NemoClaw/issues"], + ["a lowercase long write method", "gh api --method patch repos/NVIDIA/NemoClaw/issues/1"], + [ + "a GraphQL mutation", + "gh api graphql -f query='mutation { closeIssue(input: {}) { issue { id } } }'", + ], + ])("rejects %s in the qualification planning job", (_label, mutation) => { + const workflow = readE2eOperationsWorkflow(); + workflow.jobs["native-runtime-qualification-producer-plan"].steps!.push({ run: mutation }); + + expect(validateE2eOperationsWorkflow(workflow)).toContain( + "native-runtime-qualification-producer-plan must limit GitHub API access to the reviewed read-only contract", + ); + }); + it("reserves pull-request write permission for the validated PR reporter", () => { const workflow = readE2eOperationsWorkflow(); workflow.permissions = { "pull-requests": "write" }; diff --git a/test/e2e/support/native-runtime-qualification-producer-evidence.test.ts b/test/e2e/support/native-runtime-qualification-producer-evidence.test.ts new file mode 100644 index 00000000000..62babcb43aa --- /dev/null +++ b/test/e2e/support/native-runtime-qualification-producer-evidence.test.ts @@ -0,0 +1,252 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { createHash } from "node:crypto"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; + +import { afterEach, describe, expect, it } from "vitest"; + +import { writeNativeRuntimeQualificationProducerEvidence } from "../../../tools/e2e/native-runtime-qualification-producer-evidence.mts"; +import { + buildNativeRuntimeQualificationProducerPlan, + NATIVE_RUNTIME_QUALIFICATION_FOCUSED_CASE, +} from "../../../tools/e2e/native-runtime-qualification-producer-plan.mts"; + +const roots: string[] = []; +const INSTALLER = "#!/usr/bin/env bash\nexit 0\n"; +const INSTALLER_SHA256 = createHash("sha256").update(INSTALLER).digest("hex"); + +function fixture() { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "native-runtime-producer-evidence-")); + roots.push(root); + const row = buildNativeRuntimeQualificationProducerPlan({ + source: { + repository: "NVIDIA/NemoClaw", + producerWorkflow: ".github/workflows/e2e.yaml", + pullRequestNumber: 8064, + candidateRepository: "NVIDIA/NemoClaw", + candidateSha: "a".repeat(40), + baseRef: "main", + baseSha: "b".repeat(40), + workflowSha: "b".repeat(40), + producerRunId: "123456789", + producerRunAttempt: 1, + dispatchArtifact: { + id: "42", + name: "e2e-dispatch-123456789-1", + digest: `sha256:${"c".repeat(64)}`, + sizeInBytes: 4096, + }, + }, + installerSha256: INSTALLER_SHA256, + arm64GpuRunner: "reviewed-native-arm64-gpu-runner", + }).include.find((entry) => entry.id === NATIVE_RUNTIME_QUALIFICATION_FOCUSED_CASE)!; + const installerDirectory = path.join(root, "installer"); + const executionPath = path.join(root, "execution.json"); + const evidenceDirectory = path.join(root, "evidence"); + fs.mkdirSync(installerDirectory); + fs.writeFileSync(path.join(installerDirectory, "installer.sh"), INSTALLER); + fs.writeFileSync( + path.join(installerDirectory, "invocation.json"), + JSON.stringify({ + receiptVersion: 1, + script: "scripts/install.sh", + scriptSha256: INSTALLER_SHA256, + candidateSha: row.source.candidateSha, + architecture: row.case.architecture, + }), + ); + fs.writeFileSync( + path.join(installerDirectory, "candidate-source.json"), + JSON.stringify({ + receiptVersion: 1, + repository: "https://github.com/NVIDIA/NemoClaw.git", + revision: row.source.candidateSha, + installerSha256: INSTALLER_SHA256, + }), + ); + fs.writeFileSync( + path.join(installerDirectory, "installed-source.json"), + JSON.stringify({ + receiptVersion: 1, + repository: "https://github.com/NVIDIA/NemoClaw.git", + requestedRevision: row.source.candidateSha, + installedRevision: row.source.candidateSha, + installMode: "managed", + installerSha256: INSTALLER_SHA256, + }), + ); + fs.writeFileSync( + path.join(installerDirectory, "architecture.json"), + JSON.stringify({ receiptVersion: 1, requested: "amd64", runner: "amd64" }), + ); + const dockerPosture = { + dockerCommandGuarded: true, + dockerEnvironmentVariablesUnset: true, + dockerServiceInactive: true, + dockerSocketUnitInactive: true, + dockerdProcessNameAbsent: true, + defaultSocketPathsAbsent: true, + }; + fs.writeFileSync( + path.join(installerDirectory, "docker-absence.json"), + JSON.stringify({ + receiptVersion: 1, + preExecution: dockerPosture, + postExecution: dockerPosture, + }), + ); + const execution = { + schemaVersion: 1, + kind: "nemoclaw-native-runtime-qualification-execution-v1", + caseId: row.id, + candidateSha: row.source.candidateSha, + installerSha256: row.installerSha256, + architecture: row.case.architecture, + acceleration: row.case.acceleration, + agent: row.case.agent, + inference: row.case.inference, + rootModes: row.rootModes, + obligations: row.case.obligations, + focusedOperations: row.focusedOperations, + evidenceKinds: row.case.evidenceKinds, + dockerUnavailable: { beforeCandidate: true, afterCandidate: true }, + credentialBoundary: { + githubCredentialsAbsent: true, + modelCredentialsAbsent: true, + isolatedUid: true, + }, + result: "passed", + }; + fs.writeFileSync(executionPath, JSON.stringify(execution)); + return { evidenceDirectory, execution, executionPath, installerDirectory, root, row }; +} + +afterEach(() => { + for (const root of roots.splice(0)) fs.rmSync(root, { force: true, recursive: true }); +}); + +describe("native runtime qualification producer evidence", () => { + it("emits the bounded case-evidence envelope after validating installer and execution receipts", () => { + const value = fixture(); + + writeNativeRuntimeQualificationProducerEvidence( + value.row, + value.installerDirectory, + value.executionPath, + value.evidenceDirectory, + ); + + expect(fs.readdirSync(value.evidenceDirectory)).toEqual(["evidence.json"]); + expect( + JSON.parse(fs.readFileSync(path.join(value.evidenceDirectory, "evidence.json"), "utf8")), + ).toEqual({ + schemaVersion: 1, + kind: "nemoclaw-native-runtime-qualification-case-evidence-v1", + qualificationId: "podman-protected-host-local-inference", + providerId: "podman", + source: value.row.source, + case: value.row.case, + result: "passed", + }); + expect(fs.statSync(path.join(value.evidenceDirectory, "evidence.json")).mode & 0o777).toBe( + 0o600, + ); + }); + + it.each([ + [ + "candidate identity", + (value: ReturnType) => ({ ...value.execution, candidateSha: "d".repeat(40) }), + ], + [ + "rootful focus", + (value: ReturnType) => ({ ...value.execution, rootModes: ["rootless"] }), + ], + [ + "cleanup operation", + (value: ReturnType) => ({ + ...value.execution, + focusedOperations: value.row.focusedOperations.slice(0, -1), + }), + ], + [ + "credential boundary", + (value: ReturnType) => ({ + ...value.execution, + credentialBoundary: { + ...value.execution.credentialBoundary, + githubCredentialsAbsent: false, + }, + }), + ], + [ + "Docker boundary", + (value: ReturnType) => ({ + ...value.execution, + dockerUnavailable: { beforeCandidate: true, afterCandidate: false }, + }), + ], + ])("rejects an invalid %s receipt", (_label, mutate) => { + const value = fixture(); + fs.writeFileSync(value.executionPath, JSON.stringify(mutate(value))); + + expect(() => + writeNativeRuntimeQualificationProducerEvidence( + value.row, + value.installerDirectory, + value.executionPath, + value.evidenceDirectory, + ), + ).toThrow("Native runtime qualification"); + }); + + it("rejects a forged installer receipt", () => { + const value = fixture(); + fs.writeFileSync( + path.join(value.installerDirectory, "installer.sh"), + `${INSTALLER}echo forged\n`, + ); + + expect(() => + writeNativeRuntimeQualificationProducerEvidence( + value.row, + value.installerDirectory, + value.executionPath, + value.evidenceDirectory, + ), + ).toThrow("installer receipt is invalid"); + }); + + it("rejects unexpected files in the installer receipt directory", () => { + const value = fixture(); + fs.writeFileSync(path.join(value.installerDirectory, "log.txt"), "candidate output"); + + expect(() => + writeNativeRuntimeQualificationProducerEvidence( + value.row, + value.installerDirectory, + value.executionPath, + value.evidenceDirectory, + ), + ).toThrow("receipt files are invalid"); + }); + + it("rejects a symbolic link used as the execution receipt", () => { + const value = fixture(); + const target = path.join(value.root, "linked-execution.json"); + fs.renameSync(value.executionPath, target); + fs.symlinkSync(target, value.executionPath); + + expect(() => + writeNativeRuntimeQualificationProducerEvidence( + value.row, + value.installerDirectory, + value.executionPath, + value.evidenceDirectory, + ), + ).toThrow("receipt is missing or invalid"); + }); +}); diff --git a/test/e2e/support/native-runtime-qualification-producer-plan.test.ts b/test/e2e/support/native-runtime-qualification-producer-plan.test.ts new file mode 100644 index 00000000000..7075a8c7424 --- /dev/null +++ b/test/e2e/support/native-runtime-qualification-producer-plan.test.ts @@ -0,0 +1,121 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { describe, expect, it } from "vitest"; + +import { + buildNativeRuntimeQualificationProducerPlan, + NATIVE_RUNTIME_QUALIFICATION_FOCUSED_CASE, + NATIVE_RUNTIME_QUALIFICATION_FOCUSED_OPERATIONS, + type NativeRuntimeQualificationProducerPlanInput, +} from "../../../tools/e2e/native-runtime-qualification-producer-plan.mts"; + +const CANDIDATE_SHA = "a".repeat(40); + +function input(): NativeRuntimeQualificationProducerPlanInput { + return { + source: { + repository: "NVIDIA/NemoClaw", + producerWorkflow: ".github/workflows/e2e.yaml", + pullRequestNumber: 8064, + candidateRepository: "NVIDIA/NemoClaw", + candidateSha: CANDIDATE_SHA, + baseRef: "main", + baseSha: "b".repeat(40), + workflowSha: "b".repeat(40), + producerRunId: "123456789", + producerRunAttempt: 1, + dispatchArtifact: { + id: "42", + name: "e2e-dispatch-123456789-1", + digest: `sha256:${"c".repeat(64)}`, + sizeInBytes: 4096, + }, + }, + installerSha256: "d".repeat(64), + arm64GpuRunner: "reviewed-native-arm64-gpu-runner", + }; +} + +describe("native runtime qualification producer plan", () => { + it("routes every canonical case and preserves source and case identities", () => { + const plan = buildNativeRuntimeQualificationProducerPlan(input()); + + expect(plan.include).toHaveLength(24); + expect(new Set(plan.include.map((entry) => entry.id)).size).toBe(24); + for (const entry of plan.include) { + expect(entry.jobName).toBe(`Native runtime qualification / ${entry.id}`); + expect(entry.artifactName).toBe( + `native-runtime-qualification-evidence-${CANDIDATE_SHA}-${entry.id}`, + ); + expect(entry.source.candidateSha).toBe(CANDIDATE_SHA); + expect(entry.source.baseSha).toBe(entry.source.workflowSha); + expect(entry.case.id).toBe(entry.id); + expect(Object.isFrozen(entry)).toBe(true); + } + expect( + plan.include.find( + (entry) => entry.case.architecture === "amd64" && entry.case.acceleration === "cpu", + )?.runner, + ).toBe("ubuntu-26.04"); + expect( + plan.include.find( + (entry) => entry.case.architecture === "arm64" && entry.case.acceleration === "cpu", + )?.runner, + ).toBe("ubuntu-24.04-arm"); + expect( + plan.include.find( + (entry) => entry.case.architecture === "amd64" && entry.case.acceleration === "nvidia-gpu", + )?.runner, + ).toBe("linux-amd64-gpu-rtxpro6000-latest-1"); + expect( + plan.include.find( + (entry) => entry.case.architecture === "arm64" && entry.case.acceleration === "nvidia-gpu", + )?.runner, + ).toBe("reviewed-native-arm64-gpu-runner"); + }); + + it("adds rootful and extended lifecycle work to one focused canonical case", () => { + const plan = buildNativeRuntimeQualificationProducerPlan(input()); + const focused = plan.include.find( + (entry) => entry.id === NATIVE_RUNTIME_QUALIFICATION_FOCUSED_CASE, + ); + + expect(focused?.rootModes).toEqual(["rootless", "rootful"]); + expect(focused?.focusedOperations).toEqual(NATIVE_RUNTIME_QUALIFICATION_FOCUSED_OPERATIONS); + expect( + plan.include + .filter((entry) => entry.id !== NATIVE_RUNTIME_QUALIFICATION_FOCUSED_CASE) + .every( + (entry) => + JSON.stringify(entry.rootModes) === JSON.stringify(["rootless"]) && + entry.focusedOperations.length === 0, + ), + ).toBe(true); + }); + + it.each([ + ["fork candidate", { source: { ...input().source, candidateRepository: "fork/NemoClaw" } }], + ["candidate commit", { source: { ...input().source, candidateSha: "A".repeat(40) } }], + ["base authority", { source: { ...input().source, workflowSha: "e".repeat(40) } }], + ["run attempt", { source: { ...input().source, producerRunAttempt: 2 } }], + ["installer digest", { installerSha256: "short" }], + ["ARM64 GPU runner", { arm64GpuRunner: "" }], + [ + "dispatch artifact", + { + source: { + ...input().source, + dispatchArtifact: { ...input().source.dispatchArtifact, sizeInBytes: 1_048_577 }, + }, + }, + ], + ])("fails closed for an invalid %s", (_label, override) => { + expect(() => + buildNativeRuntimeQualificationProducerPlan({ + ...input(), + ...override, + } as NativeRuntimeQualificationProducerPlanInput), + ).toThrow("Native runtime qualification"); + }); +}); diff --git a/test/e2e/support/native-runtime-qualification-producer-workflow.test.ts b/test/e2e/support/native-runtime-qualification-producer-workflow.test.ts new file mode 100644 index 00000000000..d6cbd25fb79 --- /dev/null +++ b/test/e2e/support/native-runtime-qualification-producer-workflow.test.ts @@ -0,0 +1,124 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { describe, expect, it } from "vitest"; + +import { + readYaml, + type Workflow, + type WorkflowJob, + type WorkflowStep, +} from "../../helpers/e2e-workflow-contract"; + +function workflow(): Workflow { + return readYaml(".github/workflows/e2e.yaml") as Workflow; +} + +function job(name: string): WorkflowJob { + const value = workflow().jobs[name]; + expect(value, `missing workflow job '${name}'`).toBeDefined(); + return value!; +} + +function step(owner: WorkflowJob, name: string): WorkflowStep { + const value = owner.steps?.find((entry) => entry.name === name); + expect(value, `missing workflow step '${name}'`).toBeDefined(); + return value!; +} + +describe("native runtime qualification producer workflow", () => { + it("keeps candidate execution out of the authenticated controller", () => { + const generate = job("generate-matrix"); + const checkout = generate.steps?.find((entry) => entry.uses?.startsWith("actions/checkout@")); + + expect(checkout?.if).toContain("inputs.jobs != 'native-runtime-qualification-producer'"); + expect(step(generate, "Validate manual PR checkout").if).toContain( + "inputs.jobs != 'native-runtime-qualification-producer'", + ); + expect(step(generate, "Authorize E2E credentials").if).toContain( + "inputs.jobs != 'native-runtime-qualification-producer'", + ); + expect(step(generate, "Prepare E2E workspace").if).toContain( + "inputs.jobs != 'native-runtime-qualification-producer'", + ); + expect(step(generate, "Package exact-commit CLI").if).toContain( + "inputs.jobs != 'native-runtime-qualification-producer'", + ); + expect(step(generate, "Generate E2E target matrix").run).toContain( + 'selected_jobs=["native-runtime-qualification-producer"]', + ); + }); + + it("compiles the matrix only from authenticated source and repository-owned runner policy", () => { + const plan = job("native-runtime-qualification-producer-plan"); + const authenticate = step(plan, "Authenticate the candidate and dispatch artifact"); + const compile = step(plan, "Compile the trusted qualification producer matrix"); + + expect(plan.if).toContain("github.ref == 'refs/heads/main'"); + expect(plan.if).toContain("inputs.jobs == 'native-runtime-qualification-producer'"); + expect(plan.permissions).toEqual({ + actions: "read", + contents: "read", + "pull-requests": "read", + }); + expect(authenticate.run).toContain('"$CANDIDATE_REPOSITORY" == "NVIDIA/NemoClaw"'); + expect(authenticate.run).toContain('"$BASE_SHA" == "$WORKFLOW_SHA"'); + expect(authenticate.run).toContain(".head.sha == $candidateSha"); + expect(authenticate.run).toContain(".base.sha == $baseSha"); + expect(authenticate.run).toContain(".total_count == 1"); + expect(authenticate.run).toContain(".size_in_bytes <= 1048576"); + expect(authenticate.run).toContain("sha256sum .candidate-source/scripts/install.sh"); + expect(compile.env?.NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL).toBe( + "${{ vars.NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL }}", + ); + expect(compile.run).toContain("native-runtime-qualification-producer-plan.mts --ci-output"); + expect(JSON.stringify(plan)).not.toContain("linux-arm64-gpu-dgx-spark-gb10-protected-1"); + }); + + it("runs each candidate case in an isolated account and emits one trusted artifact", () => { + const producer = job("native-runtime-qualification-producer"); + const boundary = step( + producer, + "Prepare the credential-free execution account and disable Docker", + ); + const installer = step(producer, "Run the authenticated installer qualification"); + const execute = step(producer, "Execute the candidate qualification case without credentials"); + const validate = step(producer, "Validate receipts and emit bounded evidence"); + const upload = step(producer, "Upload the qualification case evidence"); + const cleanup = step(producer, "Remove qualification resources"); + const source = JSON.stringify(producer); + const boundaryRun = boundary.run ?? ""; + const installerRun = installer.run ?? ""; + + expect(producer.name).toBe("${{ matrix.jobName }}"); + expect(producer["runs-on"]).toBe("${{ matrix.runner }}"); + expect(producer.permissions).toEqual({ contents: "read" }); + expect(producer.strategy).toMatchObject({ "fail-fast": false }); + expect(source).not.toMatch(/NVIDIA_API_KEY|NVIDIA_INFERENCE_API_KEY|DOCKERHUB_TOKEN/u); + expect(boundary.run).toContain("mask --runtime docker.service docker.socket"); + expect(boundary.run).toContain("useradd --create-home --shell /usr/sbin/nologin"); + expect(boundaryRun.indexOf("printf 'account=%s")).toBeLessThan( + boundaryRun.indexOf("useradd --create-home"), + ); + expect(installer.run).toContain('sudo -u "$ACCOUNT" env -i'); + expect(installer.run).toContain("run-native-runtime-installer-qualification.sh"); + expect(installerRun.indexOf("pkill -KILL -u")).toBeLessThan( + installerRun.indexOf("chown -R -h root:root"), + ); + expect(installer.run).toContain('[[ -d "$INSTALLER_RECEIPT_PARENT/receipts" && ! -L'); + expect(execute.run).toContain('sudo -u "$ACCOUNT" env -i'); + expect(execute.run).toContain("native-runtime-qualification-case.test.ts"); + expect(execute.run).not.toContain("GITHUB_TOKEN"); + expect(execute.run).not.toContain("GH_TOKEN"); + expect(validate.run).toContain("native-runtime-qualification-producer-evidence.mts"); + expect(upload.with).toMatchObject({ + name: "${{ matrix.artifactName }}", + path: "${{ runner.temp }}/native-runtime-evidence/evidence.json", + }); + expect(cleanup.if).toBe("always()"); + expect(cleanup.run).toContain('account="${ACCOUNT:-nemoclawq}"'); + expect(cleanup.run).toContain("pkill -KILL -u"); + expect(cleanup.run).toContain("userdel --remove"); + expect(cleanup.run).toContain("Qualification account still exists after cleanup"); + }); +}); diff --git a/tools/e2e/native-runtime-qualification-producer-evidence.mts b/tools/e2e/native-runtime-qualification-producer-evidence.mts new file mode 100644 index 00000000000..a17f36095f2 --- /dev/null +++ b/tools/e2e/native-runtime-qualification-producer-evidence.mts @@ -0,0 +1,373 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { createHash } from "node:crypto"; +import { + closeSync, + constants, + fstatSync, + lstatSync, + mkdirSync, + openSync, + readFileSync, + readdirSync, + writeFileSync, +} from "node:fs"; +import path from "node:path"; + +import type { NativeRuntimeQualificationProducerPlanRow } from "./native-runtime-qualification-producer-plan.mts"; + +const MAX_RECEIPT_BYTES = 65_536; +const MAX_RECEIPT_DIRECTORY_BYTES = 1_048_576; +const EXPECTED_INSTALLER_FILES = [ + "architecture.json", + "candidate-source.json", + "docker-absence.json", + "installed-source.json", + "installer.sh", + "invocation.json", +] as const; + +interface CaseExecutionReceipt { + readonly schemaVersion: 1; + readonly kind: "nemoclaw-native-runtime-qualification-execution-v1"; + readonly caseId: string; + readonly candidateSha: string; + readonly installerSha256: string; + readonly architecture: string; + readonly acceleration: string; + readonly agent: string; + readonly inference: string; + readonly rootModes: readonly string[]; + readonly obligations: readonly string[]; + readonly focusedOperations: readonly string[]; + readonly evidenceKinds: readonly string[]; + readonly dockerUnavailable: { + readonly beforeCandidate: true; + readonly afterCandidate: true; + }; + readonly credentialBoundary: { + readonly githubCredentialsAbsent: true; + readonly modelCredentialsAbsent: true; + readonly isolatedUid: true; + }; + readonly result: "passed"; +} + +function record(value: unknown, label: string): Record { + if (!value || typeof value !== "object" || Array.isArray(value)) { + throw new Error(`${label} must be an object`); + } + return value as Record; +} + +function exactKeys(value: Record, keys: readonly string[], label: string): void { + const actual = Object.keys(value).sort(); + const expected = [...keys].sort(); + if (JSON.stringify(actual) !== JSON.stringify(expected)) { + throw new Error(`${label} fields are invalid`); + } +} + +function exactStrings(actual: unknown, expected: readonly string[], label: string): void { + if ( + !Array.isArray(actual) || + actual.some((entry) => typeof entry !== "string") || + JSON.stringify(actual) !== JSON.stringify(expected) + ) { + throw new Error(`${label} does not match the trusted plan`); + } +} + +function readBoundedFile(file: string, maximum = MAX_RECEIPT_BYTES): string { + let descriptor: number | undefined; + try { + descriptor = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW); + const status = fstatSync(descriptor); + if (!status.isFile() || status.size < 1 || status.size > maximum) { + throw new Error(`Native runtime qualification receipt is missing or invalid: ${file}`); + } + return readFileSync(descriptor, "utf8"); + } catch (error) { + if (error instanceof Error && error.message.startsWith("Native runtime qualification")) { + throw error; + } + throw new Error(`Native runtime qualification receipt is missing or invalid: ${file}`); + } finally { + if (descriptor !== undefined) closeSync(descriptor); + } +} + +function readJson(file: string): unknown { + try { + return JSON.parse(readBoundedFile(file)) as unknown; + } catch (error) { + if (error instanceof SyntaxError) { + throw new Error(`Native runtime qualification receipt is not valid JSON: ${file}`); + } + throw error; + } +} + +function validateDirectory(directory: string, expectedFiles: readonly string[]): void { + const status = lstatSync(directory, { throwIfNoEntry: false }); + if (!status?.isDirectory() || status.isSymbolicLink()) { + throw new Error(`Native runtime qualification receipt directory is invalid: ${directory}`); + } + const files = readdirSync(directory).sort(); + if (JSON.stringify(files) !== JSON.stringify([...expectedFiles].sort())) { + throw new Error(`Native runtime qualification receipt files are invalid: ${directory}`); + } + let total = 0; + for (const file of files) { + const child = path.join(directory, file); + const childStatus = lstatSync(child); + if (!childStatus.isFile() || childStatus.isSymbolicLink() || childStatus.size < 1) { + throw new Error(`Native runtime qualification receipt file is invalid: ${child}`); + } + total += childStatus.size; + } + if (total > MAX_RECEIPT_DIRECTORY_BYTES) { + throw new Error(`Native runtime qualification receipts exceed their size limit: ${directory}`); + } +} + +function validateInstallerReceipts( + row: NativeRuntimeQualificationProducerPlanRow, + directory: string, +) { + validateDirectory(directory, EXPECTED_INSTALLER_FILES); + const invocation = record( + readJson(path.join(directory, "invocation.json")), + "Installer invocation", + ); + exactKeys( + invocation, + ["receiptVersion", "script", "scriptSha256", "candidateSha", "architecture"], + "Installer invocation", + ); + if ( + invocation.receiptVersion !== 1 || + invocation.script !== "scripts/install.sh" || + invocation.scriptSha256 !== row.installerSha256 || + invocation.candidateSha !== row.source.candidateSha || + invocation.architecture !== row.case.architecture + ) { + throw new Error("Native runtime qualification installer invocation is invalid"); + } + const architecture = record( + readJson(path.join(directory, "architecture.json")), + "Installer architecture", + ); + exactKeys(architecture, ["receiptVersion", "requested", "runner"], "Installer architecture"); + if ( + architecture.receiptVersion !== 1 || + architecture.requested !== row.case.architecture || + architecture.runner !== row.case.architecture + ) { + throw new Error("Native runtime qualification installer architecture is invalid"); + } + const candidate = record( + readJson(path.join(directory, "candidate-source.json")), + "Installer candidate source", + ); + const installed = record( + readJson(path.join(directory, "installed-source.json")), + "Installed source", + ); + exactKeys( + candidate, + ["receiptVersion", "repository", "revision", "installerSha256"], + "Installer candidate source", + ); + exactKeys( + installed, + [ + "receiptVersion", + "repository", + "requestedRevision", + "installedRevision", + "installMode", + "installerSha256", + ], + "Installed source", + ); + const repository = "https://github.com/NVIDIA/NemoClaw.git"; + if ( + candidate.receiptVersion !== 1 || + candidate.repository !== repository || + candidate.revision !== row.source.candidateSha || + candidate.installerSha256 !== row.installerSha256 || + installed.receiptVersion !== 1 || + installed.repository !== repository || + installed.requestedRevision !== row.source.candidateSha || + installed.installedRevision !== row.source.candidateSha || + installed.installMode !== "managed" || + installed.installerSha256 !== row.installerSha256 + ) { + throw new Error("Native runtime qualification installer source identity is invalid"); + } + const docker = record( + readJson(path.join(directory, "docker-absence.json")), + "Installer Docker absence", + ); + exactKeys( + docker, + ["receiptVersion", "preExecution", "postExecution"], + "Installer Docker absence", + ); + const requiredDockerKeys = [ + "dockerCommandGuarded", + "dockerEnvironmentVariablesUnset", + "dockerServiceInactive", + "dockerSocketUnitInactive", + "dockerdProcessNameAbsent", + "defaultSocketPathsAbsent", + ]; + for (const phase of ["preExecution", "postExecution"] as const) { + const value = record(docker[phase], `Installer Docker absence ${phase}`); + exactKeys(value, requiredDockerKeys, `Installer Docker absence ${phase}`); + if (requiredDockerKeys.some((key) => value[key] !== true)) { + throw new Error("Native runtime qualification installer Docker absence is invalid"); + } + } + if (docker.receiptVersion !== 1) { + throw new Error("Native runtime qualification installer Docker absence is invalid"); + } + const installer = readBoundedFile(path.join(directory, "installer.sh"), 524_288); + if ( + !installer.startsWith("#!/") || + createHash("sha256").update(installer).digest("hex") !== row.installerSha256 + ) { + throw new Error("Native runtime qualification installer receipt is invalid"); + } +} + +function validateCaseExecution( + row: NativeRuntimeQualificationProducerPlanRow, + value: unknown, +): CaseExecutionReceipt { + const receipt = record(value, "Native runtime qualification execution receipt"); + exactKeys( + receipt, + [ + "schemaVersion", + "kind", + "caseId", + "candidateSha", + "installerSha256", + "architecture", + "acceleration", + "agent", + "inference", + "rootModes", + "obligations", + "focusedOperations", + "evidenceKinds", + "dockerUnavailable", + "credentialBoundary", + "result", + ], + "Native runtime qualification execution receipt", + ); + const docker = record(receipt.dockerUnavailable, "Docker-unavailable execution receipt"); + const credentials = record(receipt.credentialBoundary, "Credential-boundary execution receipt"); + exactKeys(docker, ["beforeCandidate", "afterCandidate"], "Docker-unavailable execution receipt"); + exactKeys( + credentials, + ["githubCredentialsAbsent", "modelCredentialsAbsent", "isolatedUid"], + "Credential-boundary execution receipt", + ); + exactStrings(receipt.rootModes, row.rootModes, "Native runtime qualification root modes"); + exactStrings( + receipt.obligations, + row.case.obligations, + "Native runtime qualification obligations", + ); + exactStrings( + receipt.focusedOperations, + row.focusedOperations, + "Native runtime qualification focused operations", + ); + exactStrings( + receipt.evidenceKinds, + row.case.evidenceKinds, + "Native runtime qualification evidence kinds", + ); + if ( + receipt.schemaVersion !== 1 || + receipt.kind !== "nemoclaw-native-runtime-qualification-execution-v1" || + receipt.caseId !== row.id || + receipt.candidateSha !== row.source.candidateSha || + receipt.installerSha256 !== row.installerSha256 || + receipt.architecture !== row.case.architecture || + receipt.acceleration !== row.case.acceleration || + receipt.agent !== row.case.agent || + receipt.inference !== row.case.inference || + docker.beforeCandidate !== true || + docker.afterCandidate !== true || + credentials.githubCredentialsAbsent !== true || + credentials.modelCredentialsAbsent !== true || + credentials.isolatedUid !== true || + receipt.result !== "passed" + ) { + throw new Error("Native runtime qualification execution receipt identity is invalid"); + } + return receipt as unknown as CaseExecutionReceipt; +} + +export function writeNativeRuntimeQualificationProducerEvidence( + row: NativeRuntimeQualificationProducerPlanRow, + installerReceiptDirectory: string, + executionReceiptPath: string, + evidenceDirectory: string, +): void { + validateInstallerReceipts(row, installerReceiptDirectory); + validateCaseExecution(row, readJson(executionReceiptPath)); + if (lstatSync(evidenceDirectory, { throwIfNoEntry: false })) { + throw new Error("Native runtime qualification evidence directory must not already exist"); + } + const parent = path.dirname(evidenceDirectory); + const parentStatus = lstatSync(parent, { throwIfNoEntry: false }); + if ( + !path.isAbsolute(evidenceDirectory) || + !parentStatus?.isDirectory() || + parentStatus.isSymbolicLink() + ) { + throw new Error("Native runtime qualification evidence parent is invalid"); + } + mkdirSync(evidenceDirectory, { mode: 0o700 }); + writeFileSync( + path.join(evidenceDirectory, "evidence.json"), + `${JSON.stringify({ + schemaVersion: 1, + kind: "nemoclaw-native-runtime-qualification-case-evidence-v1", + qualificationId: `${row.case.id.slice(0, row.case.id.indexOf("-"))}-protected-host-local-inference`, + providerId: row.case.id.slice(0, row.case.id.indexOf("-")), + source: row.source, + case: row.case, + result: "passed", + })}\n`, + { mode: 0o600 }, + ); +} + +if (process.argv[1]?.endsWith("native-runtime-qualification-producer-evidence.mts")) { + try { + if (process.argv.length !== 2) { + throw new Error("Usage: native-runtime-qualification-producer-evidence.mts"); + } + const row = JSON.parse( + process.env.QUALIFICATION_ROW ?? "null", + ) as NativeRuntimeQualificationProducerPlanRow; + writeNativeRuntimeQualificationProducerEvidence( + row, + process.env.INSTALLER_RECEIPT_DIRECTORY ?? "", + process.env.EXECUTION_RECEIPT_PATH ?? "", + process.env.EVIDENCE_DIRECTORY ?? "", + ); + } catch (error) { + console.error(`::error::${error instanceof Error ? error.message : String(error)}`); + process.exitCode = 1; + } +} diff --git a/tools/e2e/native-runtime-qualification-producer-plan.mts b/tools/e2e/native-runtime-qualification-producer-plan.mts new file mode 100644 index 00000000000..26b282e4414 --- /dev/null +++ b/tools/e2e/native-runtime-qualification-producer-plan.mts @@ -0,0 +1,213 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { appendFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +import { + PODMAN_PROTECTED_HOST_LOCAL_INFERENCE_QUALIFICATION, + type NativeRuntimeQualificationCase, +} from "../../test/e2e/registry/native-runtime-qualification.ts"; + +const COMMIT_SHA = /^[a-f0-9]{40}$/u; +const SHA256 = /^[a-f0-9]{64}$/u; +const RUN_ID = /^[1-9][0-9]{0,19}$/u; +const ARTIFACT_ID = RUN_ID; +const RUNNER_LABEL = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u; + +export const NATIVE_RUNTIME_QUALIFICATION_FOCUSED_CASE = "podman-openclaw-linux-amd64-cpu-ollama"; + +export const NATIVE_RUNTIME_QUALIFICATION_FOCUSED_OPERATIONS = [ + "restart", + "rebuild", + "snapshot-restore", + "clone", + "backup", + "crash-recovery", + "rollback", + "name-reuse", + "installer", + "cleanup", +] as const; + +export interface NativeRuntimeQualificationDispatchArtifact { + readonly id: string; + readonly name: string; + readonly digest: string; + readonly sizeInBytes: number; +} + +export interface NativeRuntimeQualificationProducerSource { + readonly repository: "NVIDIA/NemoClaw"; + readonly producerWorkflow: ".github/workflows/e2e.yaml"; + readonly pullRequestNumber: number; + readonly candidateRepository: "NVIDIA/NemoClaw"; + readonly candidateSha: string; + readonly baseRef: "main"; + readonly baseSha: string; + readonly workflowSha: string; + readonly producerRunId: string; + readonly producerRunAttempt: 1; + readonly dispatchArtifact: NativeRuntimeQualificationDispatchArtifact; +} + +export interface NativeRuntimeQualificationProducerPlanInput { + readonly source: NativeRuntimeQualificationProducerSource; + readonly installerSha256: string; + readonly arm64GpuRunner: string; +} + +export interface NativeRuntimeQualificationProducerPlanRow { + readonly id: string; + readonly jobName: string; + readonly artifactName: string; + readonly runner: string; + readonly installerSha256: string; + readonly source: NativeRuntimeQualificationProducerSource; + readonly case: NativeRuntimeQualificationCase; + readonly rootModes: readonly ("rootless" | "rootful")[]; + readonly focusedOperations: readonly string[]; +} + +export interface NativeRuntimeQualificationProducerPlan { + readonly include: readonly NativeRuntimeQualificationProducerPlanRow[]; +} + +function validateArtifact( + value: NativeRuntimeQualificationDispatchArtifact, + source: Pick, +): NativeRuntimeQualificationDispatchArtifact { + if ( + !ARTIFACT_ID.test(value.id) || + value.name !== `e2e-dispatch-${source.producerRunId}-${source.producerRunAttempt}` || + !/^sha256:[a-f0-9]{64}$/u.test(value.digest) || + !Number.isSafeInteger(value.sizeInBytes) || + value.sizeInBytes < 1 || + value.sizeInBytes > 1_048_576 + ) { + throw new Error("Native runtime qualification dispatch artifact is invalid"); + } + return Object.freeze({ ...value }); +} + +function validateSource( + value: NativeRuntimeQualificationProducerSource, +): NativeRuntimeQualificationProducerSource { + if ( + value.repository !== "NVIDIA/NemoClaw" || + value.producerWorkflow !== ".github/workflows/e2e.yaml" || + value.candidateRepository !== "NVIDIA/NemoClaw" || + value.baseRef !== "main" || + !Number.isSafeInteger(value.pullRequestNumber) || + value.pullRequestNumber < 1 || + !COMMIT_SHA.test(value.candidateSha) || + !COMMIT_SHA.test(value.baseSha) || + !COMMIT_SHA.test(value.workflowSha) || + value.candidateSha === value.baseSha || + value.baseSha !== value.workflowSha || + !RUN_ID.test(value.producerRunId) || + value.producerRunAttempt !== 1 + ) { + throw new Error("Native runtime qualification producer source is invalid"); + } + return Object.freeze({ + ...value, + dispatchArtifact: validateArtifact(value.dispatchArtifact, value), + }); +} + +function runnerForCase(entry: NativeRuntimeQualificationCase, arm64GpuRunner: string): string { + if (entry.architecture === "amd64" && entry.acceleration === "cpu") return "ubuntu-26.04"; + if (entry.architecture === "arm64" && entry.acceleration === "cpu") { + return "ubuntu-24.04-arm"; + } + if (entry.architecture === "amd64") return "linux-amd64-gpu-rtxpro6000-latest-1"; + if (!RUNNER_LABEL.test(arm64GpuRunner)) { + throw new Error( + "Native runtime qualification requires NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL to name a reviewed repository runner", + ); + } + return arm64GpuRunner; +} + +function immutableCase(value: NativeRuntimeQualificationCase): NativeRuntimeQualificationCase { + return Object.freeze({ + ...value, + capabilities: Object.freeze([...value.capabilities]), + obligations: Object.freeze([...value.obligations]), + evidenceKinds: Object.freeze([...value.evidenceKinds]), + }); +} + +export function buildNativeRuntimeQualificationProducerPlan( + input: NativeRuntimeQualificationProducerPlanInput, +): NativeRuntimeQualificationProducerPlan { + const source = validateSource(input.source); + if (!SHA256.test(input.installerSha256)) { + throw new Error("Native runtime qualification installer SHA-256 is invalid"); + } + const include = PODMAN_PROTECTED_HOST_LOCAL_INFERENCE_QUALIFICATION.cases.map((entry) => { + const focused = entry.id === NATIVE_RUNTIME_QUALIFICATION_FOCUSED_CASE; + const rootModes: readonly ("rootless" | "rootful")[] = focused + ? ["rootless", "rootful"] + : ["rootless"]; + return Object.freeze({ + id: entry.id, + jobName: `Native runtime qualification / ${entry.id}`, + artifactName: `native-runtime-qualification-evidence-${source.candidateSha}-${entry.id}`, + runner: runnerForCase(entry, input.arm64GpuRunner), + installerSha256: input.installerSha256, + source, + case: immutableCase(entry), + rootModes: Object.freeze(rootModes), + focusedOperations: Object.freeze( + focused ? [...NATIVE_RUNTIME_QUALIFICATION_FOCUSED_OPERATIONS] : [], + ), + }); + }); + return Object.freeze({ include: Object.freeze(include) }); +} + +export function writeNativeRuntimeQualificationProducerPlanCiOutput( + input: NativeRuntimeQualificationProducerPlanInput, + environment: NodeJS.ProcessEnv = process.env, +): void { + if (!environment.GITHUB_OUTPUT) throw new Error("GITHUB_OUTPUT is required"); + const plan = buildNativeRuntimeQualificationProducerPlan(input); + appendFileSync(environment.GITHUB_OUTPUT, `matrix=${JSON.stringify(plan)}\n`); +} + +const invokedFile = process.argv[1] ? path.resolve(process.argv[1]) : ""; +if (invokedFile === fileURLToPath(import.meta.url)) { + try { + if (process.argv.length !== 3 || process.argv[2] !== "--ci-output") { + throw new Error("Usage: native-runtime-qualification-producer-plan.mts --ci-output"); + } + writeNativeRuntimeQualificationProducerPlanCiOutput({ + source: { + repository: "NVIDIA/NemoClaw", + producerWorkflow: ".github/workflows/e2e.yaml", + pullRequestNumber: Number(process.env.PR_NUMBER ?? ""), + candidateRepository: process.env.CANDIDATE_REPOSITORY as "NVIDIA/NemoClaw", + candidateSha: process.env.CANDIDATE_SHA ?? "", + baseRef: "main", + baseSha: process.env.BASE_SHA ?? "", + workflowSha: process.env.WORKFLOW_SHA ?? "", + producerRunId: process.env.PRODUCER_RUN_ID ?? "", + producerRunAttempt: Number(process.env.PRODUCER_RUN_ATTEMPT ?? "") as 1, + dispatchArtifact: { + id: process.env.DISPATCH_ARTIFACT_ID ?? "", + name: process.env.DISPATCH_ARTIFACT_NAME ?? "", + digest: process.env.DISPATCH_ARTIFACT_DIGEST ?? "", + sizeInBytes: Number(process.env.DISPATCH_ARTIFACT_SIZE ?? ""), + }, + }, + installerSha256: process.env.INSTALLER_SHA256 ?? "", + arm64GpuRunner: process.env.NATIVE_RUNTIME_ARM64_GPU_RUNNER_LABEL ?? "", + }); + } catch (error) { + console.error(`::error::${error instanceof Error ? error.message : String(error)}`); + process.exitCode = 1; + } +} diff --git a/tools/e2e/operations-workflow-boundary.mts b/tools/e2e/operations-workflow-boundary.mts index debe76a50fe..ff57174011e 100644 --- a/tools/e2e/operations-workflow-boundary.mts +++ b/tools/e2e/operations-workflow-boundary.mts @@ -15,7 +15,13 @@ import { catalogueTarget, E2E_TARGET_CATALOGUE } from "./target-catalogue.mts"; const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", ".."); const DEFAULT_WORKFLOW_PATH = join(REPO_ROOT, ".github", "workflows", "e2e.yaml"); const DEFAULT_ADVISOR_PATH = join(REPO_ROOT, ".github", "workflows", "pr-review-advisor.yaml"); -const META_JOBS = new Set(["release-qualification", "relevant-e2e", "report-to-pr", "scorecard"]); +const META_JOBS = new Set([ + "native-runtime-qualification-producer-plan", + "release-qualification", + "relevant-e2e", + "report-to-pr", + "scorecard", +]); const FULL_SHA_ACTION = /^[^\s@]+@[0-9a-f]{40}$/u; const GITHUB_SCRIPT_NODE24_ACTION = "actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3"; @@ -47,6 +53,11 @@ const ISSUE_MUTATION_BEYOND_COMMENT = /github\.rest\.issues\.(?:addAssignees|addLabels|create|deleteComment|lock|removeAssignees|removeLabel|setLabels|unlock|update|updateComment)\s*\(/u; const GENERIC_GITHUB_WRITE_SURFACE = /github\s*(?:(?:\?\.|\.)\s*(?:graphql|request)\b|\[\s*["'](?:graphql|request)["']\s*\])|\b(?:const|let|var)\s+(?:[A-Za-z_$][\w$]*\s*=\s*github\b|\{[^}]*\b(?:graphql|request)\b[^}]*\}\s*=\s*github(?:\.rest)?\b)|\bfetch\b|\bgh\s+api\b/u; +const GH_API_WRITE_METHOD = + /\bgh\s+api\b[\s\S]{0,160}?(?:(?:--method|-X)\s+(?:POST|PUT|PATCH|DELETE)\b|graphql\b[\s\S]{0,160}?\bmutation\b)/iu; +const NATIVE_RUNTIME_QUALIFICATION_READ_JOBS = new Set([ + "native-runtime-qualification-producer-plan", +]); const GENERIC_ISSUE_REST_MUTATION = /github\.request\s*\(\s*["'`](?:POST|PATCH|PUT|DELETE)\s+\/repos\/[^/\s]+\/[^/\s]+\/issues(?:\/|\b)/u; const GENERIC_ISSUE_GRAPHQL_MUTATION = @@ -310,10 +321,12 @@ function validateManualPrDispatch(errors: string[], workflow: OperationsWorkflow const acceptedJobCases = [ "::false:false", ...PR_E2E_MANUAL_CONTROLLER_JOB_IDS.map((jobId) => `${jobId}::false:false`), + "native-runtime-qualification-producer::false:false", ":jetson-nvmap-gpu:false:true", ].join(" | "); const acceptedNames = [ ...PR_E2E_MANUAL_CONTROLLER_JOB_IDS, + "native-runtime-qualification-producer", "jetson-nvmap-gpu with its dispatch flag", ]; const acceptedJobNames = `${acceptedNames.slice(0, -1).join(", ")}, or ${acceptedNames.at(-1)}`; @@ -342,8 +355,11 @@ function validateManualPrDispatch(errors: string[], workflow: OperationsWorkflow } const validation = validationIndex >= 0 ? steps[validationIndex] : {}; - if (validation.if !== "${{ inputs.checkout_sha != '' }}") { - errors.push("Manual PR checkout validation must be activated only by checkout_sha"); + if ( + validation.if !== + "${{ inputs.checkout_sha != '' && (inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '') }}" + ) { + errors.push("Manual PR checkout validation must skip qualification producer dispatches"); } const validationSource = String(validation.run ?? ""); for (const fragment of [ @@ -365,7 +381,8 @@ function validateManualPrDispatch(errors: string[], workflow: OperationsWorkflow matrixJob.outputs?.e2e_credentials_allowed !== "${{ steps.e2e_credentials.outputs.allowed }}" || credentialAuthorization.id !== "e2e_credentials" || - credentialAuthorization.if !== "${{ inputs.checkout_sha != '' }}" || + credentialAuthorization.if !== + "${{ inputs.checkout_sha != '' && (inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '') }}" || credentialAuthorization.shell !== "bash" ) { errors.push("Manual PR credential authorization must expose only the authorization result"); @@ -462,6 +479,17 @@ function validateManualPrDispatch(errors: string[], workflow: OperationsWorkflow step.with?.repository === "${{ github.repository }}" && step.with?.ref === "${{ inputs.workflow_sha || github.workflow_sha }}" && step.with?.path === ".trusted-openshell-dev-artifact"; + const trustedNativeRuntimeCheckout = + ((jobName === "native-runtime-qualification-producer-plan" && + step.name === "Check out the trusted qualification producer" && + step.with?.ref === "${{ github.workflow_sha }}") || + (jobName === "native-runtime-qualification-producer" && + step.name === "Check out the trusted qualification harness" && + step.with?.ref === "${{ matrix.source.workflowSha }}") || + (jobName === "native-runtime-qualification-producer" && + step.name === "Check out the candidate commit" && + step.with?.repository === "${{ matrix.source.candidateRepository }}" && + step.with?.ref === "${{ matrix.source.candidateSha }}")); const trustedCheckout = trustedHermesFixtureCheckout || trustedReportHelperCheckout || @@ -473,6 +501,7 @@ function validateManualPrDispatch(errors: string[], workflow: OperationsWorkflow trustedLlamaCppPlanCheckout || trustedLlamaCppQualificationCheckout || trustedJetsonControllerCheckout || + trustedNativeRuntimeCheckout || trustedOpenShellDevToolingCheckout; if ( step.uses?.startsWith("actions/checkout@") && @@ -891,6 +920,21 @@ function validateIssueRoutingRetirement(errors: string[], workflow: OperationsWo name === "scorecard" ? jobSource.replace(/\bfetch\s*\(\s*webhookUrl\s*,/u, "validatedSlackFetch(") : jobSource; + const trustedQualificationReadJob = NATIVE_RUNTIME_QUALIFICATION_READ_JOBS.has(name); + if ( + trustedQualificationReadJob && + (!isDeepStrictEqual(permissions, { + actions: "read", + contents: "read", + "pull-requests": "read", + }) || + GH_API_WRITE_METHOD.test(jobSource)) + ) { + errors.push(`${name} must limit GitHub API access to the reviewed read-only contract`); + } + const sourceWithoutReviewedReads = trustedQualificationReadJob + ? sourceWithoutSlackPublisher.replace(/\bgh\s+api\b/gu, "validatedGhRead") + : sourceWithoutSlackPublisher; if ( ISSUE_API_REFERENCE.test(jobSource) || @@ -899,7 +943,7 @@ function validateIssueRoutingRetirement(errors: string[], workflow: OperationsWo ) { errors.push(`${name} must not mutate GitHub issues`); } - if (GENERIC_GITHUB_WRITE_SURFACE.test(sourceWithoutSlackPublisher)) { + if (GENERIC_GITHUB_WRITE_SURFACE.test(sourceWithoutReviewedReads)) { errors.push(`${name} must not use unvalidated generic write surfaces`); } } diff --git a/tools/e2e/prepare-e2e-workflow-boundary.mts b/tools/e2e/prepare-e2e-workflow-boundary.mts index a83c07e34ce..8e7cd7a9d09 100644 --- a/tools/e2e/prepare-e2e-workflow-boundary.mts +++ b/tools/e2e/prepare-e2e-workflow-boundary.mts @@ -21,6 +21,8 @@ export const PREPARE_E2E_STEP = "Prepare E2E workspace"; const CHECKOUT_LOCAL_PREPARE_E2E_ACTION = "./.github/actions/prepare-e2e"; export const CLI_ARTIFACT_PRODUCER_JOB = E2E_JOB_POLICY.cliArtifactProducer; const PREINSTALLED_E2E_JOBS = new Set(["staging-brev-launchable"]); +const NATIVE_RUNTIME_QUALIFICATION_PRODUCER_PREPARE_CONDITION = + "${{ inputs.checkout_sha == '' || inputs.jobs != 'native-runtime-qualification-producer' || inputs.targets != '' }}"; const RETIRED_SELECTOR_COMPATIBILITY_JOB = "retired-selector-compatibility"; export const PREPARE_E2E_NO_BUILD_JOBS = new Set(E2E_JOB_POLICY.prepareNoBuild); @@ -155,7 +157,19 @@ export function validatePrepareE2eInvocations(workflow: WorkflowRecord): string[ if (!shouldBuild && !isDeepStrictEqual(withInputs, { "build-cli": "false" })) { errors.push(`${jobName} prepare-e2e must set build-cli to false`); } - const allowedKeys = shouldBuild ? ["name", "uses"] : ["name", "uses", "with"]; + if ( + jobName === "generate-matrix" && + prepare.if !== NATIVE_RUNTIME_QUALIFICATION_PRODUCER_PREPARE_CONDITION + ) { + errors.push( + "generate-matrix prepare-e2e must skip native runtime qualification producer dispatches", + ); + } + const allowedKeys = shouldBuild + ? jobName === "generate-matrix" + ? ["if", "name", "uses"] + : ["name", "uses"] + : ["name", "uses", "with"]; if (!isDeepStrictEqual(Object.keys(prepare).sort(), allowedKeys.sort())) { errors.push(`${jobName} prepare-e2e invocation must not override its canonical contract`); } diff --git a/tools/e2e/upload-e2e-artifacts-workflow-boundary.mts b/tools/e2e/upload-e2e-artifacts-workflow-boundary.mts index 38d54bb9133..9d237248327 100644 --- a/tools/e2e/upload-e2e-artifacts-workflow-boundary.mts +++ b/tools/e2e/upload-e2e-artifacts-workflow-boundary.mts @@ -182,6 +182,13 @@ const EXPLICIT_UPLOAD_CONTRACTS = new Map([ path: "e2e-artifacts/live/managed-image-protected-runtime/", }, ], + [ + "native-runtime-qualification-producer", + { + name: "${{ matrix.artifactName }}", + path: "${{ runner.temp }}/native-runtime-evidence/evidence.json", + }, + ], [ "llama-cpp-dgx-spark-qualification", { diff --git a/tools/e2e/workflow-boundary.mts b/tools/e2e/workflow-boundary.mts index bfbf8f8214b..0475dd638a5 100644 --- a/tools/e2e/workflow-boundary.mts +++ b/tools/e2e/workflow-boundary.mts @@ -2343,7 +2343,7 @@ export function validateE2eWorkflow(workflowValue: unknown): string[] { `matrix='[${defaultMappings}]'`, `test_matrix='[${defaultTestMappings}]'`, ";;", - "inference-routing: | managed-image-protected-runtime: | :jetson-nvmap-gpu)", + "inference-routing: | managed-image-protected-runtime: | native-runtime-qualification-producer: | :jetson-nvmap-gpu)", "matrix='[]'", ";;", `:${deepAgentsTarget})`,