Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
49c18e4
test(e2e): add interactive onboard policy-preset step-ordering test (…
wakqasahmed Aug 8, 2026
6b2fe72
fix(e2e): use the shared docker fixture instead of an inline Docker c…
wakqasahmed Aug 8, 2026
9ce0eda
fix(e2e): redact the generated API key from onboard test assertion me…
wakqasahmed Aug 8, 2026
a79fdb7
Merge branch 'main' into test/onboard-policy-preset-sequencing-6042
cv Aug 8, 2026
4b0ea3d
Merge branch 'main' into test/onboard-policy-preset-sequencing-6042
cv Aug 9, 2026
eb5cfb4
fix(e2e): address maintainer review on the onboard PTY regression
wakqasahmed Aug 9, 2026
abe9231
merge(main): refresh PR #8618
apurvvkumaria Aug 11, 2026
b237902
merge(main): refresh PR #8618
apurvvkumaria Aug 11, 2026
6aa218c
merge(main): refresh PR #8618
apurvvkumaria Aug 11, 2026
38b5d26
test(e2e): complete onboard PTY review coverage
apurvvkumaria Aug 11, 2026
006518e
merge: refresh onboard policy sequencing base
apurvvkumaria Aug 11, 2026
7868381
test(e2e): terminate the PTY child session
prekshivyas Aug 11, 2026
b19cbeb
merge(main): refresh PR #8618
apurvvkumaria Aug 11, 2026
a27049e
Merge branch 'main' into test/onboard-policy-preset-sequencing-6042
cv Aug 11, 2026
ffaecff
Merge branch 'main' into test/onboard-policy-preset-sequencing-6042
cv Aug 11, 2026
20df452
Merge branch 'main' into test/onboard-policy-preset-sequencing-6042
cv Aug 12, 2026
747579b
merge(e2e): update #8618 with main
apurvvkumaria Aug 13, 2026
df8299c
Merge branch 'main' into test/onboard-policy-preset-sequencing-6042
cv Aug 13, 2026
b8cface
merge(main): refresh PR #8618
cv Aug 13, 2026
c4b5e05
ci(e2e): incorporate current main checks
cv Aug 13, 2026
9172a61
ci(e2e): incorporate current main checks
cv Aug 13, 2026
9bf0d0b
merge(e2e): retain formatted current-main checks
cv Aug 13, 2026
3895ca5
merge(main): resolve PR #8618 conflict
cv Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4916,6 +4916,72 @@ jobs:
shell: bash
run: bash .github/scripts/docker-auth-cleanup.sh

onboard-policy-preset-sequencing:
needs: generate-matrix
if: ${{ (github.event_name != 'workflow_dispatch' || (inputs.jobs == '' && inputs.targets == '')) || contains(format(',{0},', inputs.jobs), ',onboard-policy-preset-sequencing,') || contains(format(',{0},', inputs.targets), ',onboard-policy-preset-sequencing,') }}
runs-on: ubuntu-latest
timeout-minutes: 60
env:
E2E_JOB: "1"
E2E_TARGET_ID: "onboard-policy-preset-sequencing"
E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/live/onboard-policy-preset-sequencing
NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js
NEMOCLAW_RUN_LIVE_E2E: "1"
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ inputs.checkout_repository || github.repository }}
ref: ${{ inputs.checkout_sha || github.sha }}
persist-credentials: false

- *dockerhub-auth

- name: Prepare E2E workspace
uses: NVIDIA/NemoClaw/.github/actions/prepare-e2e@f6304bc25fc35bfaa441c8c2fbfee38f72805a75
with:
build-cli: "false"

- name: Restore exact-commit CLI artifact
uses: NVIDIA/NemoClaw/.github/actions/restore-e2e-cli-artifact@c246409193a31133cab10c8a3589001cc0d59eb3
with:
provenance-json: ${{ needs.generate-matrix.outputs.cli_artifact_provenance }}

- name: Install OpenShell CLI
run: bash scripts/install-openshell.sh

# #6042 regression: the interactive onboard wizard must reach Policy
# presets in order. This drives a real PTY, so this job (unlike
# cloud-onboard/double-onboard) must NOT set NEMOCLAW_NON_INTERACTIVE=1
# -- doing so would force the wizard non-interactive and defeat the
# test. Hermetic mock-provider journey; no NVIDIA credential needed.
- name: Run onboard-policy-preset-sequencing live Vitest test
run: |
set -euo pipefail
export PATH="$HOME/.local/bin:$HOME/.npm-global/bin:$PATH"
if command -v openshell >/dev/null 2>&1; then
OPENSHELL_BIN="$(command -v openshell)"
elif [ -x "$HOME/.local/bin/openshell" ]; then
OPENSHELL_BIN="$HOME/.local/bin/openshell"
else
echo "::error::OpenShell CLI not found after install"
ls -la /usr/local/bin/openshell "$HOME/.local/bin/openshell" 2>&1 || true
exit 1
fi
export OPENSHELL_BIN
echo "Using OPENSHELL_BIN=$OPENSHELL_BIN"
"$OPENSHELL_BIN" --version
npx tsx tools/e2e/live-vitest-invocation.mts run --test-path test/e2e/live/onboard-policy-preset-sequencing.test.ts

- name: Upload onboard-policy-preset-sequencing Vitest artifacts
if: always()
uses: NVIDIA/NemoClaw/.github/actions/upload-e2e-artifacts@7768e15eb90d3ee2d33432f481dfe8747e4f6d57

- name: Clean up Docker auth
if: always()
shell: bash
run: bash .github/scripts/docker-auth-cleanup.sh

jetson-nvmap-gpu:
needs: generate-matrix
# The opt-in flag prevents assignment to an unavailable Jetson runner.
Expand Down Expand Up @@ -7403,6 +7469,7 @@ jobs:
messaging-providers,
bootstrap-install-smoke,
double-onboard,
onboard-policy-preset-sequencing,
jetson-nvmap-gpu,
concurrent-gateway-ports,
full-e2e,
Expand Down
10 changes: 10 additions & 0 deletions ci/source-shape-test-budget.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@
"test": "routes only the measured heavy lanes on trusted main (#7145)",
"category": "security"
},
{
"file": "test/e2e/support/onboard-policy-preset-sequencing-workflow-boundary.test.ts",
"test": "rejects onboard-policy-preset-sequencing forced back into non-interactive mode",
"category": "security"
},
{
"file": "test/e2e/support/onboard-policy-preset-sequencing-workflow-boundary.test.ts",
"test": "selects onboard-policy-preset-sequencing.test.ts with interactive mode enabled",
"category": "compatibility"
},
{
"file": "test/e2e/support/podman-cpu-proof-workflow.test.ts",
"test": "runs as a credential-free exact-head PR workflow",
Expand Down
199 changes: 199 additions & 0 deletions test/e2e/live/onboard-interactive-pty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { ChildProcessProgress } from "../fixtures/observed-child-process.ts";
import { spawnObservedChild } from "../fixtures/observed-child-process.ts";

// Drives an interactive CLI through a real PTY, the same technique
// `test/helpers/installer-express-prompt-pty-harness.ts` uses for the
// installer's express prompt. The real onboard wizard behaves differently
// under a piped, non-TTY stdin than under a real terminal (raw-mode
// keypress selectors, `isTTY`-gated prompts), so a faithful regression test
// for interactive-only behavior must drive a real PTY rather than pipe
// stdin.
//
// Rules fire independently and out of order: a rule whose trigger never
// appears (for example, a first-run license notice already accepted on a
// prior run) must not block a later rule from firing when its own trigger
// appears.
//
// The child process itself is launched through the shared
// `spawnObservedChild` boundary (the suite's single audited asynchronous
// child-process call) so it still tracks a content-free progress activity
// and canonical lifecycle checkpoints; this module attaches its own
// listeners on top to capture output and match rule triggers.

export interface InteractiveCommandRule {
readonly trigger: string;
readonly response: string;
}

export interface InteractiveCommandResult {
readonly exitCode: number;
readonly output: string;
readonly firedTriggers: readonly string[];
readonly timedOut: boolean;
}

export interface DriveInteractiveCommandOptions {
readonly activityLabel: string;
readonly cmd: readonly [string, ...string[]];
readonly cwd?: string;
readonly env: NodeJS.ProcessEnv;
readonly progress: ChildProcessProgress;
readonly rules: readonly InteractiveCommandRule[];
readonly timeoutMs: number;
}

// Runs inside a Python child so it can fork a real pseudo-terminal;
// Node has no built-in PTY primitive and this repo does not depend on
// node-pty. The child's own deadline is generous; the Node-side timer
// below is the enforced hard bound and SIGKILLs the whole process tree.
const PTY_DRIVER_SCRIPT = `
import json, os, pty, select, signal, sys, time

# Read from stdin, not argv: the payload embeds every scripted response,
# including any credential a rule supplies (e.g. an onboard API key), and a
# process argument stays visible to anything that can list the command
# line for as long as the child runs.
payload = json.loads(sys.stdin.read())
cmd = payload["cmd"]
rules = payload["rules"]
timeout_s = payload["timeoutSeconds"]

pid, fd = pty.fork()
if pid == 0:
os.execvp(cmd[0], cmd)

output = bytearray()
os.set_blocking(fd, False)
deadline = time.monotonic() + timeout_s
fired = [False] * len(rules)
exit_code = None
while time.monotonic() < deadline:
ready, _, _ = select.select([fd], [], [], 0.2)
if ready:
try:
chunk = os.read(fd, 65536)
except OSError:
chunk = b""
if not chunk:
# PTY close (EOF, or EIO on Linux) after the child has already
# exited normally must not fall through to the timeout branch
# below: reap it here and record its real exit code so a
# successful run is never misreported as DRIVER_TIMEOUT.
_, status = os.waitpid(pid, 0)
exit_code = os.waitstatus_to_exitcode(status)
break
output.extend(chunk)
sys.stdout.buffer.write(chunk)
sys.stdout.flush()
text = output.decode("utf-8", errors="ignore")
for i, rule in enumerate(rules):
if fired[i]:
continue
if rule["trigger"] in text:
os.write(fd, rule["response"].encode())
sys.stderr.write("FIRED\\t" + rule["trigger"] + "\\n")
fired[i] = True
waited = os.waitpid(pid, os.WNOHANG)
if waited[0] == pid:
exit_code = os.waitstatus_to_exitcode(waited[1])
break
if exit_code is None:
try:
os.kill(pid, signal.SIGKILL)
except ProcessLookupError:
pass
os.waitpid(pid, 0)
sys.stderr.write("DRIVER_TIMEOUT\\n")
sys.exit(124)
sys.exit(exit_code)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
`;

function resolvePython(): string {
return process.env.NEMOCLAW_E2E_PYTHON3_BIN || "python3";
}

export function driveInteractiveCommand(
options: DriveInteractiveCommandOptions,
): Promise<InteractiveCommandResult> {
const payload = JSON.stringify({
cmd: options.cmd,
rules: options.rules.map((rule) => ({ trigger: rule.trigger, response: rule.response })),
// Comfortably longer than the Node-side hard timeout below so the
// driver's own bookkeeping never races the enforced bound.
timeoutSeconds: Math.ceil(options.timeoutMs / 1000) + 30,
});
// Kept directly in this function's body, not inside the Promise executor
// below, so the sole audited async child-process boundary stays attached
// to a named, reviewed callsite. `detached: true` makes the Python driver
// the leader of its own process group/session, so its pty.fork()'d
// onboard child (which inherits that group) can be reaped as a unit on
// timeout instead of surviving as an orphan.
const child = spawnObservedChild(resolvePython(), ["-c", PTY_DRIVER_SCRIPT], {
activityLabel: options.activityLabel,
progress: options.progress,
spawn: { cwd: options.cwd, env: options.env, detached: true },
});
// Written to stdin rather than passed as a process argument: the payload
// carries every scripted response, including any credential a rule
// supplies (see PTY_DRIVER_SCRIPT's matching comment).
child.stdin?.end(payload);

return new Promise((resolve, reject) => {
let output = "";
const firedTriggers: string[] = [];
let stderrRest = "";
let timedOut = false;
let settled = false;

const timer = setTimeout(() => {
timedOut = true;
// Kill the whole process group (negative pid), not just the driver
// pid: the driver's forked onboard child shares that group and would
// otherwise keep running past this test.
try {
if (child.pid) process.kill(-child.pid, "SIGKILL");
} catch {
// Group may already be gone (driver exited between the deadline
// check and this signal); fall back to the direct pid below.
}
child.kill("SIGKILL");
}, options.timeoutMs);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

// Additional listeners alongside spawnObservedChild's own content-free
// observer; this module needs the real transcript to match rule
// triggers and to report ordered step evidence.
child.stdout?.on("data", (chunk: Buffer) => {
output += chunk.toString("utf-8");
});
child.stderr?.on("data", (chunk: Buffer) => {
const lines = (stderrRest + chunk.toString("utf-8")).split("\n");
stderrRest = lines.pop() ?? "";
for (const line of lines) {
const fired = line.match(/^FIRED\t(.*)$/);
if (fired) firedTriggers.push(fired[1]);
}
});
child.once("error", (error) => {
if (settled) return;
settled = true;
clearTimeout(timer);
reject(error);
});
child.once("close", (code) => {
if (settled) return;
settled = true;
clearTimeout(timer);
const fired = stderrRest.match(/^FIRED\t(.*)$/);
if (fired) firedTriggers.push(fired[1]);
resolve({
exitCode: timedOut ? 124 : (code ?? 1),
output,
firedTriggers,
timedOut,
});
});
});
}
Loading
Loading