Skip to content

refactor(e2e): route live-Vitest invocations through a validated helper - #6996

Merged
cv merged 9 commits into
mainfrom
refactor/e2e-live-invocation-helpers
Jul 16, 2026
Merged

refactor(e2e): route live-Vitest invocations through a validated helper#6996
cv merged 9 commits into
mainfrom
refactor/e2e-live-invocation-helpers

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The live-Vitest command shape repeated across .github/workflows/e2e.yaml is now built by a validated first-party helper, tools/e2e/live-vitest-invocation.mts, so a job supplies only a test path and optional selector while the e2e-live project, reporters, and silence flag are fixed and matrix-derived inputs are checked before Vitest runs without a shell. The helper is adopted in the 70 jobs that share the exact invocation contract; the remaining jobs and the privileged setup stay explicit.

Related Issue

Refs #6961

Changes

  • Add tools/e2e/live-vitest-invocation.mts: fixes the e2e-live project, --reporter=default, --reporter=test/e2e/risk-signal-reporter.ts, and --silent=false; validates the test path (under test/e2e/live/, a .test.ts file, no .. traversal, no absolute path, no shell metacharacters) and the optional -t selector (no shell metacharacters); builds an argv array and spawns without a shell, fail-closed. Current consumer: the 70 adopted e2e.yaml jobs. A direct inline change is insufficient because the shape is duplicated across ~70 jobs and the matrix-derived path and selector cross a trust boundary that must be validated once in a directly tested unit. Protected by test/e2e/support/live-vitest-invocation.test.ts.
  • Adopt the helper in the 70 compatible live jobs in .github/workflows/e2e.yaml, including the templated security-posture matrix; per-job PATH/OpenShell resolution prefixes and env -u credential-scrubbing wrappers are unchanged.
  • Update the workflow-boundary validators (tools/e2e/workflow-boundary.mts and the per-job *-workflow-boundary.mts, plus the operations, MCP, and upload-artifact validators) to accept the helper invocation as the live-Vitest contract and as the risk-signal-reporter attachment.
  • Leave explicit, with reasons: the shared-e2e variable-project runner, the reordered-flag gateway-guard-recovery job, Docker Hub authentication (secret-bearing, trusted-revision only), and the four expect host installs (privileged setup).

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: CI-internal refactor; no user-facing behaviour or documented interface changes.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: npx vitest run --project e2e-support → 1082 passed; the single unrelated failure workflow-plan › reports CLI failures as workflow annotations is a local tsx module.register() deprecation-warning-on-stderr flake that reproduces on an unmodified base checkout and passes on CI's pinned Node. npx vitest run --project integration test/regression-e2e-workflow.test.ts test/e2e-recommendations.test.ts passed. npm run typecheck:cli, npm run test:projects:check, and Biome all clean.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • New Features

    • Standardized live end-to-end Vitest execution to use a shared runner command across affected jobs and workflow validations.
    • Improved safety by enforcing stricter validation for live test inputs (project, test path, and optional selector) and consistent reporting.
  • Tests

    • Added a new suite to verify runner validation, argument construction, and defensive fail-closed behavior.
    • Updated workflow boundary tests and command detection to align with the standardized live runner.

The repeated live-Vitest command shape in e2e.yaml now runs through
tools/e2e/live-vitest-invocation.mts, which fixes the e2e-live project, reporters,
and the silence flag and rejects unsafe test paths and selectors before spawning
without a shell. Adopted across the 69 jobs sharing the exact contract; the
variable-project, templated-file, and reordered-flag jobs, Docker Hub
authentication, and expect host installs stay explicit. Workflow-boundary
validators now assert the helper contract.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Live E2E workflows now use a validated live-vitest-invocation.mts wrapper for project, path, selector, reporter, and process handling. Workflow boundary validators and support tests were updated to enforce and test the new command shape.

Changes

Live Vitest invocation standardization

Layer / File(s) Summary
Validated live Vitest helper
tools/e2e/live-vitest-invocation.mts, test/e2e/support/live-vitest-invocation.test.ts
Adds validation, argument construction, CLI execution, and coverage for valid and invalid projects, paths, selectors, and arguments.
Workflow command migration
.github/workflows/e2e.yaml
Replaces direct live Vitest commands with the shared wrapper across matrix and dedicated E2E jobs.
Workflow boundary alignment
tools/e2e/*workflow-boundary.*, test/e2e/support/*workflow-boundary.test.ts
Updates live-command requirements, Vitest detection, reporter evidence handling, artifact-job detection, and mutation tests for the wrapper invocation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Workflow
  participant LiveVitestInvocation
  participant Vitest
  Workflow->>LiveVitestInvocation: invoke with test path and selector
  LiveVitestInvocation->>LiveVitestInvocation: validate invocation inputs
  LiveVitestInvocation->>Vitest: spawn npx vitest with reporters
Loading

Possibly related PRs

Suggested labels: area: ci, area: e2e, area: security

Suggested reviewers: cv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: routing live E2E Vitest runs through a validated helper.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/e2e-live-invocation-helpers

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.

TypeScript / code-coverage/cli

The overall coverage in the refactor/e2e-live-in... branch remains at 80%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main b528371 refactor/e2e-live-in... 30059b5 +/-
src/lib/inferen...lama/process.ts 100% 50% -50%
src/lib/inferen...er-lifecycle.ts 71% 65% -6%
src/lib/inference/local.ts 82% 80% -2%

Updated July 16, 2026 09:44 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@laitingsheng laitingsheng added the refactor PR restructures code without intended behavior change label Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: No actionable findings remain in the canonical review ledger.

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 2 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 2 more warnings, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: cloud-onboard, credential-sanitization, security-posture

1 optional E2E recommendation
  • ubuntu-repo-cloud-openclaw

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tools/e2e/live-vitest-invocation.mts`:
- Around line 97-98: Update the exit handling after spawnSync in the live Vitest
invocation to first surface result.error for launch failures, then preserve
result.signal by re-emitting the received signal, and only use result.status
when available; retain a fallback exit code for unexpected missing status.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e5d154c9-dda0-4f57-9de7-a8698f36b01e

📥 Commits

Reviewing files that changed from the base of the PR and between 3bc9620 and da4e6dc.

📒 Files selected for processing (14)
  • .github/workflows/e2e.yaml
  • test/e2e/support/e2e-operations-workflow-boundary.test.ts
  • test/e2e/support/live-vitest-invocation.test.ts
  • test/e2e/support/mcp-workflow-boundary.test.ts
  • tools/e2e/hermes-dashboard-workflow-boundary.mts
  • tools/e2e/hermes-gpu-startup-workflow-boundary.mts
  • tools/e2e/live-vitest-invocation.mts
  • tools/e2e/mcp-workflow-boundary.mts
  • tools/e2e/openclaw-plugin-runtime-exdev-workflow-boundary.mts
  • tools/e2e/openshell-gateway-auth-contract-workflow-boundary.mts
  • tools/e2e/operations-workflow-boundary.mts
  • tools/e2e/sandbox-operations-workflow-boundary.mts
  • tools/e2e/upload-e2e-artifacts-workflow-boundary.mts
  • tools/e2e/workflow-boundary.mts

Comment thread tools/e2e/live-vitest-invocation.mts Outdated
Missing npx and signal-terminated runs both exited 1, hiding launch
failures and interrupts behind identical diagnostics. Throw the spawn
error and reuse the shared exit-code mapping so each case reports
distinctly.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
cv added 2 commits July 16, 2026 01:31
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tools/e2e/live-vitest-invocation.mts`:
- Around line 103-109: Update parseArgs and the runLiveVitestCli argument flow
to reject unknown CLI options and throw or otherwise fail when a recognized
value-taking option such as --selector is provided without a value, while
preserving the distinction between an omitted selector and a supplied selector
value. Add regression tests covering an unknown option typo and a bare
--selector, ensuring neither silently runs the full test file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fc779e81-b959-490b-854d-fca8c378a0a8

📥 Commits

Reviewing files that changed from the base of the PR and between 6d41b33 and 65426da.

📒 Files selected for processing (14)
  • .github/workflows/e2e.yaml
  • test/e2e/support/e2e-operations-workflow-boundary.test.ts
  • test/e2e/support/live-vitest-invocation.test.ts
  • test/e2e/support/mcp-workflow-boundary.test.ts
  • tools/e2e/hermes-dashboard-workflow-boundary.mts
  • tools/e2e/hermes-gpu-startup-workflow-boundary.mts
  • tools/e2e/live-vitest-invocation.mts
  • tools/e2e/mcp-workflow-boundary.mts
  • tools/e2e/openclaw-plugin-runtime-exdev-workflow-boundary.mts
  • tools/e2e/openshell-gateway-auth-contract-workflow-boundary.mts
  • tools/e2e/operations-workflow-boundary.mts
  • tools/e2e/sandbox-operations-workflow-boundary.mts
  • tools/e2e/upload-e2e-artifacts-workflow-boundary.mts
  • tools/e2e/workflow-boundary.mts
🚧 Files skipped from review as they are similar to previous changes (10)
  • tools/e2e/sandbox-operations-workflow-boundary.mts
  • tools/e2e/openshell-gateway-auth-contract-workflow-boundary.mts
  • tools/e2e/upload-e2e-artifacts-workflow-boundary.mts
  • tools/e2e/hermes-gpu-startup-workflow-boundary.mts
  • tools/e2e/operations-workflow-boundary.mts
  • tools/e2e/hermes-dashboard-workflow-boundary.mts
  • test/e2e/support/mcp-workflow-boundary.test.ts
  • tools/e2e/mcp-workflow-boundary.mts
  • tools/e2e/workflow-boundary.mts
  • .github/workflows/e2e.yaml

Comment thread tools/e2e/live-vitest-invocation.mts Outdated
cv added 4 commits July 16, 2026 01:47
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved exact head 30059b5 against base b528371. All 54 current checks are green. Deterministic E2E plan f6e940c030389233afdbe4647e95cc6683fdc1a74165f1f5b7698844c669eb34 passed cloud-onboard, credential-sanitization, and both security-posture shards in controller 29488323832 / child 29488351352. Full e2e-support passed 121 files / 1096 tests; focused security-posture validation passed; CLI typecheck and check:diff passed. Canonical exact-head Advisor has 0 blockers, warnings, or suggestions; CodeRabbit has no unresolved threads. Nine-category security review passed: strict argv validation and no shell execution, no broader secret or authorization scope, and preserved reporter, environment, artifact, timeout, exit, and cleanup behavior. DCO is present and all 9 commits are GitHub Verified. Comparator selects this PR over #6984; #6984 remains changes-requested with incomplete compatible-job migration and unsafe direct-entry/process handling.

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at exact head 30059b5 on base b528371 after substantive security-posture helper migration; all 54 current checks green, credential sanitization/cloud onboard/OpenClaw+Hermes security posture E2E passed, focused 62 and full 1,096 E2E-support tests passed, DCO and 9/9 commits Verified, and no unresolved major security/advisor finding.

@cv
cv merged commit 079acbe into main Jul 16, 2026
104 checks passed
@cv
cv deleted the refactor/e2e-live-invocation-helpers branch July 16, 2026 15:23
jyaunches pushed a commit that referenced this pull request Jul 16, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Restore live E2E execution through the workflow's `npx tsx` command. The
shared helper now loads the root CommonJS exit utility correctly instead
of failing every converted live job during module initialization.

## Changes

- Normalize the CommonJS and ESM representations of
`src/lib/core/process-exit.ts` in
`tools/e2e/live-vitest-invocation.mts`. The current consumer is the live
E2E workflow introduced by #6996; `tsx` and Vitest expose the root
module differently, so the existing repository interop pattern is
required to keep one shared exit-code implementation.
- Run the helper's subprocess regression coverage through the local
`tsx` executable that `npx tsx` resolves, protecting the production
loader boundary that the previous native Node test did not exercise.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates

- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests not applicable — justification:
- [ ] Docs updated for user-facing behavior changes
- [x] Docs not applicable — justification: This is an internal CI loader
fix; the workflow command and all user-facing behavior remain unchanged.
- [ ] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [ ] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification:
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `npx vitest run --project e2e-support
test/e2e/support/live-vitest-invocation.test.ts` passed 24 tests; `npm
run typecheck:cli` and Biome also passed.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — not applicable to this focused CI helper
fix. The full E2E-support attempt reached five unrelated failures in an
unchanged platform-parity shell script under macOS Bash 3.2; the other
41 tests in the diagnostic subset passed.
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved handling of exit codes when running live Vitest commands
across different module export formats.
* Updated end-to-end workflow checks to invoke the CLI consistently,
preserving expected failure reporting.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants