Skip to content

test(e2e): preserve MCP discovery diagnostics - #8751

Merged
senthilr-nv merged 3 commits into
mainfrom
codex/fix-mcp-tool-discovery
Aug 10, 2026
Merged

senthilr-nv merged 3 commits into
mainfrom
codex/fix-mcp-tool-discovery

Conversation

@senthilr-nv

@senthilr-nv senthilr-nv commented Aug 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Preserve redacted MCP tool-discovery status and request evidence before live E2E assertions run. This lets issue #8746 distinguish discovery-runtime startup, policy or credential handling, and MCP protocol failures without recording credentials or session identifiers.

Related Issue

Refs #8746

Changes

  • Write an explicit safe projection of provider, policy, adapter, trusted-private target, and toolDiscovery status to the live E2E artifact set.
  • Record request order, HTTP and RPC results, session-metadata presence, and synthetic credential-rewrite matches without recording secret or session values.
  • Add a real-artifact regression test proving diagnostics are written before a failed discovery assertion and exclude sensitive raw status, credential, and session values.

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: This changes internal live E2E evidence only; no supported user interface or behavior 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: Diagnostic status objects use an explicit safe projection, credential and session evidence is boolean-only, and real-artifact regression coverage verifies that seeded sensitive raw status, credential, and session values are absent.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: The PR adds sanitized internal E2E diagnostics and regression coverage without changing user-facing behavior or supported interfaces. The final follow-up only makes test cleanup unconditional. The focused E2E-support test, test-conditionals scanner, and normal Git hooks passed.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit:
  • Station profile/scenario:
  • Result:
  • Supporting evidence:

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 validate:pr passed after refreshing origin/main 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 test/e2e/support/mcp-bridge-tool-discovery.test.ts passed 25/25; npm run build:cli and npm run typecheck:cli passed. The OpenClaw MCP bridge passed twice on OpenShell v0.0.101 with two trusted-private tools discovered, artifact credential scans clear, and cleanup complete: run 31413260063 and run 31414578417.
  • 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: Senthil Ravichandran senthilr@nvidia.com

Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
@senthilr-nv senthilr-nv self-assigned this Aug 10, 2026
@senthilr-nv
senthilr-nv requested review from cv and jyaunches August 10, 2026 18:14
@github-code-quality

github-code-quality Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit aa148a0 in the codex/fix-mcp-tool-d... branch remains at 96%, unchanged from commit 286d3a1 in the main branch.


Updated August 10, 2026 18:28 UTC

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Authenticated MCP discovery now produces redacted JSON diagnostics after retries. Trusted-private and provider-specific tests pass artifact writers. Support tests validate diagnostic metadata, filenames, cleanup, rejection behavior, and secret exclusion.

Changes

MCP discovery diagnostics

Layer / File(s) Summary
Build and write discovery diagnostics
test/e2e/live/mcp-bridge-tool-discovery.ts
The status schema and diagnostic builder capture provider, policy, adapter, trusted-target, request, session, protocol, and credential-rewrite data. Diagnostics are written before the existing assertions.
Propagate artifact writers
test/e2e/live/mcp-bridge-trusted-private.ts, test/e2e/live/mcp-bridge.test.ts
Trusted-private validation and OpenClaw, Hermes, and Deep Agents scenarios pass the artifacts fixture to authenticated MCP discovery.
Validate artifact contents and redaction
test/e2e/support/mcp-bridge-tool-discovery.test.ts
The test covers failed discovery, diagnostic output, temporary-directory cleanup, metadata normalization, and exclusion of sensitive values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

  • NVIDIA/NemoClaw#8742: Enhances MCP tool-discovery failure diagnostics with secret-redacted structured validation in related test and Dockerfile paths.

Suggested reviewers: jyaunches, cv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 and concisely describes the main change: preserving MCP discovery diagnostics during end-to-end tests.
✨ 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 codex/fix-mcp-tool-discovery

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

@senthilr-nv senthilr-nv added chore Build, CI, dependency, or tooling maintenance area: e2e End-to-end tests, nightly failures, or validation infrastructure area: observability Logging, metrics, tracing, diagnostics, or debug output security v0.0.106 labels Aug 10, 2026

@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 `@test/e2e/live/mcp-bridge-tool-discovery.ts`:
- Around line 62-66: Sanitize the status projection used by the live diagnostics
artifact instead of copying unknown values from status fields; update the
projection around provider, policy, adapter, trustedPrivateTarget, and
toolDiscovery in test/e2e/live/mcp-bridge-tool-discovery.ts to include only
explicit secret-safe, non-sensitive values and exclude credential-resolution,
credentials, tokens, sessions, request payloads, and arbitrary environment data.
In test/e2e/support/mcp-bridge-tool-discovery.test.ts, use a real ArtifactSink,
write and read the artifact, seed sensitive values in raw status fields, and
assert those values are absent.
🪄 Autofix

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: 3ba3041b-6f80-4f1b-b1bf-4893fb19ded8

📥 Commits

Reviewing files that changed from the base of the PR and between 286d3a1 and e97cfaa.

📒 Files selected for processing (4)
  • test/e2e/live/mcp-bridge-tool-discovery.ts
  • test/e2e/live/mcp-bridge-trusted-private.ts
  • test/e2e/live/mcp-bridge.test.ts
  • test/e2e/support/mcp-bridge-tool-discovery.test.ts

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · medium confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Failed

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

2 semantic terminology decisions

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • established — trusted-private at test/e2e/support/mcp-bridge-tool-discovery.test.ts:241: Retain `trusted-private` for this established scenario modifier.
  • justified — boundary diagnostics at test/e2e/support/mcp-bridge-tool-discovery.test.ts:199: Retain `boundary diagnostics`; the modifier identifies the redacted artifact boundary.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite against this exact revision.

Recommended E2E: cloud-inference, cloud-onboard, security-posture, mcp-bridge, mcp-bridge-dev

Workflow run details

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

Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
Signed-off-by: Senthil Ravichandran <senthilr@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 `@test/e2e/support/mcp-bridge-tool-discovery.test.ts`:
- Around line 78-84: Update the afterEach teardown to capture compatibleMock and
artifactRoot, close the mock in a try block, and remove the artifact directory
in finally regardless of whether close rejects. Reset the shared compatibleMock
and artifactRoot state while preserving the existing cleanup behavior; no
additional Vitest restoration is needed.
🪄 Autofix

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: 3bed8943-fe13-4270-bb2a-1b0d7f1d0119

📥 Commits

Reviewing files that changed from the base of the PR and between e97cfaa and aa148a0.

📒 Files selected for processing (2)
  • test/e2e/live/mcp-bridge-tool-discovery.ts
  • test/e2e/support/mcp-bridge-tool-discovery.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/live/mcp-bridge-tool-discovery.ts

Comment on lines +78 to +84
let artifactRoot: string | undefined;

afterEach(async () => {
await compatibleMock?.close();
compatibleMock = undefined;
if (artifactRoot) await fs.rm(artifactRoot, { recursive: true, force: true });
artifactRoot = undefined;

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 3 '\bvi\.(spyOn|stubEnv|stubGlobal)\b|process\.env|globalThis' \
  test/e2e/support/mcp-bridge-tool-discovery.test.ts

Repository: NVIDIA/NemoClaw

Length of output: 153


Make teardown unconditional.

If compatibleMock.close() rejects, artifact removal does not run. Capture compatibleMock and artifactRoot, then remove the artifact directory in a finally block. The test does not call vi.spyOn, vi.stubEnv, or vi.stubGlobal, so no additional Vitest restoration is required.

🤖 Prompt for 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.

In `@test/e2e/support/mcp-bridge-tool-discovery.test.ts` around lines 78 - 84,
Update the afterEach teardown to capture compatibleMock and artifactRoot, close
the mock in a try block, and remove the artifact directory in finally regardless
of whether close rejects. Reset the shared compatibleMock and artifactRoot state
while preserving the existing cleanup behavior; no additional Vitest restoration
is needed.

Sources: Coding guidelines, Path instructions

@senthilr-nv
senthilr-nv enabled auto-merge (squash) August 10, 2026 18:31
@senthilr-nv
senthilr-nv merged commit 620f269 into main Aug 10, 2026
76 of 83 checks passed
@senthilr-nv
senthilr-nv deleted the codex/fix-mcp-tool-discovery branch August 10, 2026 18:32
@wscurran wscurran added area: security Security controls, permissions, secrets, or hardening and removed security labels Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure area: observability Logging, metrics, tracing, diagnostics, or debug output area: security Security controls, permissions, secrets, or hardening chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants