Skip to content

test(e2e): surface Hermes MCP rebuild failures - #8659

Closed
apurvvkumaria wants to merge 1 commit into
mainfrom
codex/fix-hermes-mcp-post-rebuild
Closed

test(e2e): surface Hermes MCP rebuild failures#8659
apurvvkumaria wants to merge 1 commit into
mainfrom
codex/fix-hermes-mcp-post-rebuild

Conversation

@apurvvkumaria

@apurvvkumaria apurvvkumaria commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Hermes MCP post-rebuild checks now preserve bounded, redacted HTTP failure evidence while keeping successful responses content-free. This makes the first authenticated MCP failure diagnosable without retrying the request or exposing the sandbox API key.

Related Issue

Contributes to #8590.

Changes

  • Add a single-attempt authenticated Hermes MCP HTTP helper with strict transport, status, and result-token validation.
  • Bound raw response capture to 65,536 bytes, redact the complete captured body before display, and cap terminal evidence to 4,096 UTF-8 bytes.
  • Extend the Hermes MCP live target to surface the bounded redacted failure preview after rebuild.
  • Add adversarial coverage for repeated and boundary-spanning credentials, invalid UTF-8, hostile Python startup state, poisoned curl fixtures, oversized bodies, and spawn-time validation.
  • Document the bounded redacted terminal preview in test/e2e/README.md.

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:
  • 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: independent exact-diff correctness, security, and documentation review passed with no findings before publication; the subsequent scanner-safe synthetic test literal change was isolated and its affected test and secret scan passed.
  • 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: docs-updated
  • Evidence: test/e2e/README.md
  • Agent: Codex Desktop

DGX Station Hardware Evidence

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

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: 125 focused tests passed; after the scanner-safe synthetic literal adjustment, npx vitest run --project e2e-support test/e2e/support/mcp-bridge-hermes-http.test.ts passed 4/4 and the secret scan passed.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: Not applicable; this is a focused live-E2E diagnostic and support-test change.
  • 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: Apurv Kumaria akumaria@nvidia.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved end-to-end diagnostics with bounded, UTF-8-safe failure previews and credential redaction.
    • Added stricter validation for capture limits and subprocess execution settings.
    • Enhanced HTTP bridge checks for authentication, response status, result tokens, retries, and oversized responses.
  • Tests

    • Added comprehensive coverage for redaction, truncation, invalid limits, binary output, and authenticated tool-call behavior.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria apurvvkumaria self-assigned this Aug 9, 2026
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds post-redaction output limits to ShellProbe and introduces bounded, redacted Hermes MCP HTTP diagnostics. Tests cover invalid limits, response handling, credential redaction, oversized bodies, and authenticated request counts.

Changes

Hermes MCP diagnostics

Layer / File(s) Summary
Post-redaction shell capture limits
test/e2e/fixtures/shell-probe.ts, test/e2e/support/e2e-redaction-entry.test.ts
ShellProbe validates positive safe-integer limits and applies UTF-8-safe truncation after redaction. Tests verify invalid values fail before process execution or artifact creation.
Hermes HTTP probe and assertions
test/e2e/live/mcp-bridge-hermes-http.ts
The shared probe performs bounded authenticated HTTP calls and emits status and result markers. Assertions validate sanitized failures, required result tokens, and exactly one authenticated MCP tool call.
Hermes integration and safety coverage
test/e2e/README.md, test/e2e/live/mcp-bridge.test.ts, test/e2e/support/mcp-bridge-hermes-http.test.ts
Hermes integration uses the shared probe and capture limits. Tests cover redaction, UTF-8 boundaries, oversized bodies, strict failures, successful responses, and request tracking. Documentation records the subprocess and output-safety requirements.

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

Sequence Diagram(s)

sequenceDiagram
  participant mcpBridgeTest as mcp-bridge.test
  participant shellProbe as ShellProbe
  participant hermesEndpoint as Hermes MCP HTTP endpoint
  participant requestObservations as McpRequestObservation
  mcpBridgeTest->>shellProbe: Run the shared Hermes chat probe
  shellProbe->>hermesEndpoint: Send one authenticated /mcp request
  hermesEndpoint-->>shellProbe: Return bounded status and result markers
  shellProbe-->>mcpBridgeTest: Return redacted diagnostic output
  mcpBridgeTest->>requestObservations: Assert one authenticated tools/call request
Loading

Possibly related PRs

  • NVIDIA/NemoClaw#8309: Shares bounded execution, credential redaction, and diagnostic evidence concerns.
  • NVIDIA/NemoClaw#8583: Shares E2E subprocess, progress, redaction, and bounded-diagnostics infrastructure.

Suggested labels: integration: hermes, area: sandbox

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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the E2E test change that surfaces Hermes MCP rebuild failures.
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.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-hermes-mcp-post-rebuild

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

@github-code-quality

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit b24b8c9 in the codex/fix-hermes-mcp... branch remains at 96%, unchanged from commit 794c754 in the main branch.

@apurvvkumaria
apurvvkumaria deleted the codex/fix-hermes-mcp-post-rebuild branch August 9, 2026 23:48
@github-actions

github-actions Bot commented Aug 9, 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 · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Failed after a partial review · low confidence · 0 blockers · 0 warnings · 0 suggestions

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

3 semantic terminology decisions

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

  • justified — failure-only preview at test/e2e/README.md:719: Keep this term. Its modifier distinguishes failure diagnostics from content-free success output.
  • justified — post-redaction capture limit at test/e2e/support/e2e-redaction-entry.test.ts:445: Keep this term. It distinguishes the redaction-order security control from raw capture limiting.
  • established — bounded failure preview at test/e2e/live/mcp-bridge.test.ts:548: Keep this term. It consistently identifies the bounded diagnostic evidence.

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.

@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.

🧹 Nitpick comments (1)
test/e2e/support/mcp-bridge-hermes-http.test.ts (1)

383-411: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the transport-failure and missing-status branches.

This test covers the 2xx token rules and the tools/call count. Three failure branches of the new helpers stay uncovered:

  • assertHermesMcpHttpResponse transport branch, when exitCode !== 0 or signal is set. The transport= text and the joined stdout/stderr preview are never asserted.
  • assertHermesMcpHttpResponse status branch, when stderr carries zero or two status markers. parseHttpStatus returns null for both cases, and the "did not report one bounded HTTP status" message is never asserted.
  • assertAuthenticatedMcpToolCallOutcome path and credential branches at lines 131 and 134 of test/e2e/live/mcp-bridge-hermes-http.ts.

These branches produce the terminal evidence that the live Hermes target depends on. A regression in them would surface only during a live run.

🧪 Proposed additional cases
     expect(() =>
       assertAuthenticatedMcpToolCallOutcome({
         requests: [request, request],
         callsBefore: 0,
         expectedSecret: "rotated-fixture-secret",
       }),
     ).toThrowError(/exactly one tools\/call/u);
+    expect(() =>
+      assertAuthenticatedMcpToolCallOutcome({
+        requests: [{ ...request, path: "/other" }],
+        callsBefore: 0,
+        expectedSecret: "rotated-fixture-secret",
+      }),
+    ).toThrowError(/managed \/mcp endpoint/u);
+    expect(() =>
+      assertAuthenticatedMcpToolCallOutcome({
+        requests: [request],
+        callsBefore: 0,
+        expectedSecret: "unexpected-secret",
+      }),
+    ).toThrowError(/expected resolved bearer credential/u);
+  });
+
+  it("reports bounded redacted evidence for transport and status failures", () => {
+    const secret = "fixture-transport-secret";
+    expect(() =>
+      assertHermesMcpHttpResponse(
+        { exitCode: 7, signal: null, stdout: secret, stderr: "" },
+        [secret],
+      ),
+    ).toThrowError(/transport failed \(exit=7\)/u);
+    expect(() =>
+      assertHermesMcpHttpResponse(
+        { exitCode: null, signal: "SIGKILL", stdout: "", stderr: "" },
+        [],
+      ),
+    ).toThrowError(/transport failed \(signal=SIGKILL\)/u);
+    expect(() =>
+      assertHermesMcpHttpResponse({ exitCode: 0, signal: null, stdout: "", stderr: "" }, []),
+    ).toThrowError(/one bounded HTTP status/u);
+    expect(() =>
+      assertHermesMcpHttpResponse(
+        {
+          exitCode: 0,
+          signal: null,
+          stdout: "",
+          stderr: `${HERMES_MCP_HTTP_STATUS_MARKER}200\n${HERMES_MCP_HTTP_STATUS_MARKER}500\n`,
+        },
+        [],
+      ),
+    ).toThrowError(/one bounded HTTP status/u);
   });

Also assert that the transport message excludes the raw secret:

try {
  assertHermesMcpHttpResponse(
    { exitCode: 7, signal: null, stdout: "leak-me-secret", stderr: "" },
    ["leak-me-secret"],
  );
} catch (error) {
  const message = error instanceof Error ? error.message : String(error);
  expect(message).not.toContain("leak-me-secret");
  expect(message).toContain("[REDACTED]");
}
🤖 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-hermes-http.test.ts` around lines 383 - 411,
Extend the test around assertHermesMcpHttpResponse to cover nonzero exitCode or
signal transport failures, asserting the transport message includes joined
stdout/stderr evidence while redacting supplied secrets. Add cases for zero and
multiple HTTP status markers in stderr, asserting the bounded-status error.
Extend assertAuthenticatedMcpToolCallOutcome coverage for invalid request paths
and credentials, targeting its path and credential validation branches.
🤖 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.

Nitpick comments:
In `@test/e2e/support/mcp-bridge-hermes-http.test.ts`:
- Around line 383-411: Extend the test around assertHermesMcpHttpResponse to
cover nonzero exitCode or signal transport failures, asserting the transport
message includes joined stdout/stderr evidence while redacting supplied secrets.
Add cases for zero and multiple HTTP status markers in stderr, asserting the
bounded-status error. Extend assertAuthenticatedMcpToolCallOutcome coverage for
invalid request paths and credentials, targeting its path and credential
validation branches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 18379dac-a23f-4b42-ad2b-8b08224c6c35

📥 Commits

Reviewing files that changed from the base of the PR and between 794c754 and b24b8c9.

📒 Files selected for processing (6)
  • test/e2e/README.md
  • test/e2e/fixtures/shell-probe.ts
  • test/e2e/live/mcp-bridge-hermes-http.ts
  • test/e2e/live/mcp-bridge.test.ts
  • test/e2e/support/e2e-redaction-entry.test.ts
  • test/e2e/support/mcp-bridge-hermes-http.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant