Skip to content

test(e2e): restart Hermes before MCP rediscovery - #7866

Merged
jyaunches merged 13 commits into
mainfrom
codex/fix-hermes-mcp-tool-search
Jul 30, 2026
Merged

test(e2e): restart Hermes before MCP rediscovery#7866
jyaunches merged 13 commits into
mainfrom
codex/fix-hermes-mcp-tool-search

Conversation

@jyaunches

@jyaunches jyaunches commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

After the DNS rebinding proof removes its temporary MCP route, explicitly restart Hermes before invoking the deferred MCP tool. Hermes builds its MCP registry at gateway startup, so repeated tool_search calls in one model turn cannot discover a missing tool; the live shard now proves fresh authenticated rediscovery after restart and then executes one real deferred tool call.

Changes

  • Move the existing Hermes MCP restart ahead of the post-removal real adapter tool call.
  • Capture the rediscovery request offset after temporary route removal and immediately before explicit restart, so route-removal side effects cannot satisfy the restart proof.
  • Require one tool_searchtool_describetool_call sequence and fail immediately on a missing or malformed search result.
  • Verify fresh authenticated initializenotifications/initializedtools/list evidence with successful responses, complete negotiated metadata, and one session.
  • Protect the lifecycle order and missing-metadata branches with focused support and integration tests.

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 live E2E fixtures, orchestration, and assertions only; no supported product 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: The DNS rebinding denial and route-removal assertions remain before restart. Rediscovery evidence remains fail-closed and requires authenticated, ordered, successful requests in one negotiated session plus exactly one real tool call.
  • 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: Independent review covered the complete six-file PR and the exact two-file follow-up at commit 06406a3a2f960e37f6de24d591f7ce3902d28094. The follow-up captures the Hermes rediscovery offset after temporary MCP route removal and immediately before explicit restart; its source-contract test pins route removal → offset capture → restart → real tool call → authenticated rediscovery. This changes only live E2E evidence collection and support tests; no user-visible API, CLI, configuration, UI, workflow, default, error, or supported product behavior changes. The committed follow-up diff SHA-256 a8437d836fce7be9a3fc1a8f403bb35b93a91f780bddc038ec4271daf3ee9b95 exactly matches the reviewed worktree diff. Focused E2E-support and test:changed passed 14/14; the conditional scan, Biome, CLI typecheck, normal commit and pre-push hooks, and git diff --check passed. The prior head passed the trusted mcp-bridge (hermes) live E2E in 12m38s.
  • 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: E2E-support passed 25/25; the compatible-mock integration fixture passed 10/10; npm run test:changed passed 25/25. The exact offset-isolation follow-up passed its focused E2E-support and changed-test suites 14/14. Repository checks, conditional scan, CLI typecheck, clean CLI build, Biome, and git diff --check passed. The prior head passed trusted mcp-bridge (hermes) live E2E in 12m38s.
  • 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: Julie Yaunches jyaunches@nvidia.com
Signed-off-by: Carlos Villela cvillela@nvidia.com

Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
@jyaunches jyaunches self-assigned this Jul 30, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 30, 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

Authenticated MCP request evidence now records negotiated metadata and response outcomes. Hermes tool calls retry deferred tool-search misses, and the DNS rebinding scenario verifies rediscovery after route removal and the real adapter tool call.

Changes

MCP rediscovery and Hermes E2E flow

Layer / File(s) Summary
Fake MCP request ledger
test/e2e/live/mcp-bridge-servers.ts
Typed request records capture response outcomes and negotiated session metadata through shared response helpers.
Authenticated rediscovery helper
test/e2e/live/mcp-bridge-tool-discovery.ts, test/e2e/support/mcp-bridge-tool-discovery.test.ts
Adds ordered authenticated discovery detection, optional rediscovery targets, polling integration, and validation of ordering and negotiated session matching.
Hermes deferred tool retry
test/e2e/live/mcp-bridge-tool-discovery.ts, test/e2e/live/mcp-bridge.test.ts, test/e2e/support/mcp-bridge-tool-discovery.test.ts
Retries Hermes tool calls after the specified deferred tool-search miss and tests retry, stop, and attempt-limit behavior.
DNS rebinding teardown flow
test/e2e/live/mcp-bridge.test.ts
Restores DNS before MCP route removal, returns the surviving request offset, and verifies authenticated Hermes rediscovery afterward.
Sandbox ordering assertions
test/e2e/support/mcp-bridge-sandbox.test.ts
Checks that rediscovery follows the Hermes shard, DNS denial assertion, and real adapter tool call.

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

Possibly related PRs

Suggested labels: area: e2e, integration: hermes

Suggested reviewers: cv, prekshivyas, aasthajh

🚥 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 accurately reflects the main change: Hermes is restarted before MCP rediscovery is asserted.
✨ Finishing Touches 💡 1
📝 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-hermes-mcp-tool-search

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

@github-code-quality

github-code-quality Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 06406a3 in the codex/fix-hermes-mcp... branch remains at 96%, unchanged from commit 4dcb89e in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 06406a3 in the codex/fix-hermes-mcp... branch remains at 81%, unchanged from commit 4dcb89e in the main branch.

Show a code coverage summary of the most impacted files.
File main 4dcb89e codex/fix-hermes-mcp... 06406a3 +/-
src/lib/sandbox...rce-identity.ts 88% 88% 0%
src/lib/domain/.../connect-env.ts 89% 97% +8%

Updated July 30, 2026 13:05 UTC

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / low confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: PR review advisor failed: PR review advisor SDK execution failed: session: scope-risk-map-analysis omitted required analysis; turn: scope-risk-map-analysis: scope-risk-map-analysis omitted required analysis

Model lanes

  • GPT-5.6 Terra (primary): Failed
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 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-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.

@cv
cv marked this pull request as ready for review July 30, 2026 02:50

@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 17-27: Strengthen assertAuthenticatedMcpRediscovery to validate a
fresh, valid MCP session after requestOffset, requiring an ordered initialize
followed by tools/list exchange and successful responses tied to the same
negotiated session. Update or replace the delegated
assertAuthenticatedMcpDiscovery behavior so recorded requests alone cannot
satisfy the teardown check.
🪄 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: 795eaceb-87ce-425c-8b61-a93e715814f1

📥 Commits

Reviewing files that changed from the base of the PR and between 376beb5 and aac4db7.

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

Comment thread test/e2e/live/mcp-bridge-tool-discovery.ts

@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 69-80: Refactor the parameterized test around failedMethod so it
no longer needs the runtime missing-request guard. Split the initialize and
tools/list failure scenarios into separate linear tests, or provide keyed
fixtures that select a guaranteed-defined request while preserving each existing
response override and assertion behavior.
🪄 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: e6921bd3-973b-43f6-a3cb-8228328a26f3

📥 Commits

Reviewing files that changed from the base of the PR and between aac4db7 and 4f4c046.

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

Comment thread test/e2e/support/mcp-bridge-tool-discovery.test.ts Outdated
cv added 5 commits July 29, 2026 22:58
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>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv

cv commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Investigation update: Hermes MCP rediscovery

Scope: PR SHA e0cf9ee19. The failing job is mcp-bridge (hermes).

CI evidence

  • Initial authenticated MCP discovery passed.
  • mcp status --tools --json listed fake_echo and fake_status.
  • The Shields restoration and gateway restart phase passed.
  • The DNS rebinding lifecycle then removed the temporary MCP bridge.
  • The next real Hermes tool call returned mock protocol error: Hermes tool_search did not return the deferred target.
  • The lifecycle phase failed after 174.616 seconds.
  • DNS rebinding bridge removal used 34.477 seconds.
  • The failed tool call used 30.919 seconds.
  • The OpenClaw and Deep Agents Code MCP bridge jobs passed in the same child run.

The failing call is therefore after successful initial discovery. It is also after a lifecycle operation that can change the Hermes MCP registry.

Source analysis

I inspected the Hermes v2026.7.20 runtime in the pinned base image. Hermes reports semver 0.19.0.

Hermes calls discover_mcp_tools() at these lifecycle boundaries:

  • Gateway startup, before runner.start.
  • The explicit /reload-mcp operation.

Hermes does not call discover_mcp_tools() from tool_search. The tool_search path searches the live in-memory registry. Repeating the call in one message history does not rebuild that registry.

The PR mock can issue 15 same-turn tool_search calls with two-second delays. Each call observes the same registry. The retries add latency but do not create a rediscovery event.

I also ran an exact-image probe with mcp__fake__fake_echo registered in the Hermes registry. One tool_search request returned the target. This result excludes the query, tool name, and search ranking as the cause.

The test already runs mcp restart fake, but it runs after the failing tool call. That restart is the lifecycle event that can rebuild the Hermes MCP registry. The MCP configuration transaction confirms an acknowledged reload and gateway health. It does not confirm that every remote MCP connection joined the registry.

Candidate correction

A local test-only candidate makes these changes:

  • Move the existing mcp restart fake immediately after removal of the DNS rebinding bridge.
  • Run one tool_searchtool_describetool_call sequence after that restart.
  • Require fresh authenticated discovery after the restart.
  • Require exactly one new tools/call request.
  • Remove the 15 same-turn search retries.
  • Remove the later duplicate restart and tool call.
  • Add the missing negotiated-session and negotiated-protocol cases from PRA-1.

This candidate does not change NemoClaw product behavior. It aligns the live E2E test with the Hermes registry lifecycle.

Local evidence

The local candidate has these passing results:

  • E2E-support tests: 25 passed.
  • MCP fixture integration tests: 10 passed.
  • npm run test:changed.
  • npm run checks:repository.
  • npm run typecheck:cli.
  • npm run test-conditionals:scan -- --top 25.

These results verify the fixture sequence and repository contracts. They do not establish a passing live E2E result.

The latest local live attempt stopped during onboarding because the host could not allocate a dashboard port. The sandbox was destroyed during cleanup. No MCP assertion ran in that attempt. A prior isolated run reproduced the same missing-discovery failure family locally.

Remaining verification

  • Complete one local Hermes live shard through the post-removal restart and tool call.
  • Commit and push the test-only candidate.
  • Repeat the documentation writer review for the new PR SHA.
  • Launch one trusted E2E controller run for the pushed PR SHA.

I have not launched another trusted controller run for the local candidate.

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv cv changed the title test(e2e): wait for Hermes MCP rediscovery test(e2e): restart Hermes before MCP rediscovery Jul 30, 2026
@cv
cv marked this pull request as draft July 30, 2026 12:06
@cv
cv marked this pull request as ready for review July 30, 2026 12:06
cv added 2 commits July 30, 2026 05:16
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@jyaunches
jyaunches merged commit 45d7e1a into main Jul 30, 2026
70 of 74 checks passed
@jyaunches
jyaunches deleted the codex/fix-hermes-mcp-tool-search branch July 30, 2026 13:56
@jyaunches jyaunches mentioned this pull request Jul 30, 2026
23 tasks
jyaunches added a commit that referenced this pull request Jul 30, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Update the canonical NemoClaw v0.0.98 release entry with the
managed-image security remediation that merged after the original
release documentation.
The entry now records reviewed Perl 5.44.0 packages across OpenClaw,
Hermes, and Deep Agents Code images and the native multi-platform
publication check.

## Changes

- Update `docs/changelog/2026-07-29.mdx` under the existing `## v0.0.98`
heading.
- Record the checksum-pinned Perl 5.44.0 packages and native
`linux/amd64` and `linux/arm64` digest checks from
[#7864](#7864).
- Confirm that the other post-entry merges,
[#7868](#7868) and
[#7866](#7866), change E2E
orchestration or tests without changing user-facing behavior.

### Source Summary

- [#7864](#7864) ->
`docs/changelog/2026-07-29.mdx`: Record the reviewed Perl 5.44.0
packages and native multi-platform publication checks for managed
OpenClaw, Hermes, and Deep Agents Code images.

## Type of Change

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

## Quality Gates

- [ ] Tests added or updated for changed behavior
- [x] Existing tests cover changed behavior — justification: The merged
source PR includes security-package, runtime, and publication tests.
`test/changelog-docs.test.ts` validates the release-entry structure.
- [ ] Tests not applicable — justification:
- [x] 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:
- [ ] 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: `blocked`
- Evidence: This side-conversation host does not permit subagents. The
primary author reviewed `docs/changelog/2026-07-29.mdx` against
`WRITING.md`, the controlled word list, and `docs/CONTRIBUTING.md`. The
changelog contract passed 6 tests, and the docs build completed with 0
errors and 2 existing Fern warnings.
- Agent: Codex Desktop side conversation
<!-- docs-review-head-sha: 8e92d96 -->
<!-- docs-review-agents-blob-sha: c052d60 -->

## DGX Station Hardware Evidence

- [ ] Tested on DGX Station
- Tested commit: Not applicable. `scripts/prepare-dgx-station-host.sh`
is unchanged.
- Station profile/scenario: Not applicable.
- Result: Not applicable.
- Supporting evidence: Not applicable.

## 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 validate:pr` passed after refreshing `origin/main` when hooks
were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `npm exec -- vitest run
test/changelog-docs.test.ts` passed 6 tests.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: Not run for this
documentation-only change.
- [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) — The
build completed with 0 errors and 2 existing Fern warnings.
- [x] 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)
— No new page was added.

---
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>

Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure integration: hermes Hermes integration behavior labels Aug 3, 2026
cv pushed a commit that referenced this pull request Aug 3, 2026
<!-- markdownlint-disable MD041 -->
## Summary

`nemoclaw shields down` replaced the complete live OpenShell policy and
dropped generated policy entries for registered Model Context Protocol
(MCP) servers. This change reconciles only exact NemoClaw-managed MCP
entries during Shields transitions, so a surviving server remains
reachable while removed servers stay removed.

Stacked on prerequisite #8130, which makes Shields deadline recovery
serialize with lifecycle mutations without signaling the lock owner,
this focused fix supersedes the MCP portion of #7980.

## Related Issue

Fixes #7952

## Changes

- Prove managed MCP policy ownership from exact agreement between the
sandbox registry, committed generated-policy record, and live gateway
policy.
- Save the owned MCP key manifest with the Shields snapshot, remove
snapshot-time managed entries during restoration, and overlay only
current exact entries.
- Fail closed on ambiguous, stale, incomplete, malformed, or legacy
ownership during manual transitions. At an expired deadline, omit
unproven managed MCP entries and audit the omission instead of extending
the Shields-down window.
- Preserve current managed MCP entries when building the permissive
runtime policy, while rejecting an unreadable or ambiguous live policy.
- Clean staged runtime policy files across early failure paths.
- Restore the Hermes live regression assertions at the actual failure
boundary and around the unrelated server lifecycle.
- Document MCP policy reconciliation for manual and automatic
restoration.

## Failure Timing and Hermes Upgrade Context

The original journey had a hidden Shields lifecycle between the first
successful call to server A and the later lifecycle for server B:

1. Run `shields up`.
2. Restart the Hermes gateway.
3. Run `shields down`.
4. Exercise the configuration rollback path.
5. Add and remove B.
6. Call A.

Boundary instrumentation recorded in #7952 showed that A remained
healthy through Shields up and the gateway restart. It became unusable
immediately after Shields down, which dropped A's generated MCP policy.
The later failure after B was removed was only where the test noticed
the already-broken route; B removal was a misleading correlation.

This surfaced during the Hermes upgrade work because new coverage and
upgrade repairs landed nearly back-to-back:

- #7761 added the Hermes MCP helper containing Shields up, gateway
restart, Shields down, and rollback. Its verification collected and
imported the live target but did not run the complete live E2E.
- #7771 upgraded Hermes the next day, but its selected E2Es skipped the
`mcp-bridge` target.
- #7849 repaired Hermes 0.19 migrations and updated MCP tool naming,
allowing the live test to progress far enough to expose the later
failure.
- #7866 moved the explicit `mcp restart A` before the first post-removal
call. Restart reapplied A's generated policy and masked the
missing-policy state.

The corrected regression order is:

1. Run `shields up`.
2. Restart the Hermes gateway.
3. Run `shields down`.
4. Call A immediately.
5. Exercise the configuration rollback path.
6. Add B, prove the DNS-rebinding connection is denied, remove B, and
verify that A's managed policy is unchanged while B's policy is gone.
7. Call A before the later explicit restart.
8. Capture the authenticated rediscovery offset.
9. Run `mcp restart A` without resupplying the secret.
10. Call A and verify authenticated rediscovery.

Whole-policy Shields replacement and the filesystem-only runtime merge
predate the Hermes upgrade. This is a latent NemoClaw Shields
policy-composition defect detected by expanded Hermes regression
coverage, not a Hermes upgrade regression.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [x] 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:
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: Independent exact-head
Codex security review passed all nine categories at
`18039569796d6ac7604de032edb7abf84f2c73c4`; no findings.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Documentation Writer Review

- [x] Documentation writer subagent reviewed the completed changes
- Result: `docs-updated`
- Evidence: Reviewed `docs/manage-sandboxes/runtime-controls.mdx` and
`docs/reference/commands.mdx`, all rendered guide variants, changed
operator-facing text, comments, test titles, and the Hermes E2E
chronology. Verified claims against source, issue #7952, and PRs #7761,
#7771, #7849, and #7866. `npm run docs` completed with 0 errors and 2
existing Fern warnings.
- Agent: Codex Desktop
<!-- docs-review-head-sha: 1803956 -->
<!-- docs-review-agents-blob-sha: 3dd7c24 -->

## DGX Station Hardware Evidence

- [ ] Tested on DGX Station
- Tested commit: Not applicable; `scripts/prepare-dgx-station-host.sh`
is unchanged.
- Station profile/scenario: Not applicable.
- Result: Not applicable.
- Supporting evidence: Not applicable.

## 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 validate:pr` passed after refreshing `origin/main` when hooks
were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — command/result or justification:
Focused CLI 123/123, integration 11/11, E2E support 13/13, `npm run
typecheck:cli`, `npm run checks:repository`, test-size guardrail, E2E
semantic phase plans, and serial `npm run test:changed` 674/674 passed.
- [x] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: [Standard PR CI run
30824992396](https://github.com/NVIDIA/NemoClaw/actions/runs/30824992396)
passed. One inherited 50 ms lifecycle-lock assertion timing flake passed
on the failed-job rerun without a code change.
- [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)
- [x] 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)

`npm run docs` passed with 0 errors and 2 existing Fern warnings, so the
warning-free checkbox remains unchecked. No new documentation pages were
added.

Trusted E2E [run
30826792180](https://github.com/NVIDIA/NemoClaw/actions/runs/30826792180)
passed all 10 selected checks: cloud inference, cloud onboard, security
posture, inference routing, MCP bridge, MCP bridge dev, network policy,
onboard repair, onboard resume, and OpenShell credential-generation
window. The primary review advisor reported no findings. Nemotron
completed after retrying a protocol-only failure; its one test warning
requested the exact transition/state ownership-mismatch deadline
regression already present in
`src/lib/shields/policy-transition.test.ts`, which passed.

---
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>

Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
jyaunches added a commit that referenced this pull request Aug 5, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Shields down previously replaced the complete live OpenShell policy,
which removed NemoClaw-generated MCP entries and made a surviving Hermes
MCP server unreachable. This change reconciles only exact, independently
proven NemoClaw-managed MCP entries so server A stays reachable while a
removed server B stays removed.

This is the focused MCP-policy change built on the lifecycle and
deadline prerequisite merged in #8130. It replaces the focused behavior
from the closed historical work in #7980 and #8141.

## Related Issue

Fixes #7952

## Changes

- Prove managed MCP ownership from the registry, generated-policy
record, and live gateway policy before preserving an entry.
- Save the managed-key manifest with the Shields snapshot, remove
snapshot-time managed entries during restoration, and overlay only the
current exact entries.
- Fail closed for ambiguous, malformed, or manually edited ownership;
deadline restoration omits unproven entries and records the omission
count.
- Preserve exact current managed entries in the permissive Shields
policy without copying unrelated live egress.
- Sanitize untrusted registry and policy identifiers before including
them in operator diagnostics.
- Clean staged policy files across success and failure paths.
- Reuse the validated unchanged snapshot when both saved and current
managed MCP sets are empty, so deadline restoration does not depend on
temporary staging.
- Update the Hermes MCP regression so it calls A immediately after
Shields down and again after B removal, before the later explicit `mcp
restart A` coverage.
- Document managed MCP policy behavior during Shields transitions.

### Why this appeared during the Hermes upgrade

The original live journey contained a hidden lifecycle between the first
successful call to A and the later B lifecycle:

1. Raise Shields.
2. Restart the Hermes gateway.
3. Lower Shields.
4. Exercise config rollback.
5. Add and remove B.
6. Call A.

A remained healthy through Shields up and the gateway restart. It became
unusable immediately after Shields down, which dropped A's generated MCP
policy. The later failure after B removal was only where the test
detected the damage; B removal was a misleading correlation.

This surfaced alongside the Hermes upgrade because coverage and upgrade
fixes landed close together:

- #7761 added the helper containing Shields up, gateway restart, Shields
down, and rollback, but did not run the complete live E2E.
- #7771 upgraded Hermes, while its selected E2E did not include the MCP
bridge target.
- #7849 fixed Hermes 0.19 migrations and the `mcp__fake__*` tool naming,
allowing the journey to progress far enough to expose the later failure.
- #7866 moved an explicit restart of A before the post-removal call,
which reapplied A's policy and masked the defect.

The whole-policy Shields replacement predates those changes. This is a
latent NemoClaw Shields policy-composition bug exposed by expanded
Hermes upgrade regression coverage, not evidence of a Hermes regression.

### Corrected live regression order

1. Raise Shields and restart the Hermes gateway.
2. Lower Shields and call A immediately.
3. Exercise config rollback.
4. Add B, prove DNS-rebinding access is denied, remove B, and verify A's
policy is unchanged while B is gone.
5. Call A before the later explicit restart.
6. Capture authenticated rediscovery state, restart A without
resupplying its secret, and call A again.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [x] 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:
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: Independent maintainer
security review of commit `5d46d4a2ee924edf743ac36d04807948eec01c96`
passed all nine categories. The review covered managed-policy ownership,
diagnostic sanitization, deadline restoration, empty-MCP staging
failure, and current-main integration.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Documentation Writer Review

- [x] Documentation writer subagent reviewed the completed changes
- Result: `docs-updated`
- Evidence: Reviewed the complete PR change at commit
`5d46d4a2ee924edf743ac36d04807948eec01c96` against current main,
including generated OpenClaw and Hermes variants, operator-facing
assertions, test titles, and the empty-MCP deadline-restore regression.
The current-main merge was mechanical, contributor attribution remains
intact, and the existing documentation remains accurate. Normal hooks
passed; GitHub CI is the current validation authority.
- Agent: Codex Desktop
<!-- docs-review-head-sha: 5d46d4a -->
<!-- docs-review-agents-blob-sha: 3dd7c24 -->

## DGX Station Hardware Evidence

- [ ] Tested on DGX Station
- Tested commit: Not applicable; `scripts/prepare-dgx-station-host.sh`
is unchanged.
- Station profile/scenario: Not applicable.
- Result: Not applicable.
- Supporting evidence: Not applicable.

## 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 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:
GitHub CI is running for commit
`5d46d4a2ee924edf743ac36d04807948eec01c96`.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: GitHub CI is running for
commit `5d46d4a2ee924edf743ac36d04807948eec01c96`.
- [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) — GitHub
CI is running for commit `5d46d4a2ee924edf743ac36d04807948eec01c96`.
- [x] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [x] New doc pages include SPDX header and frontmatter (new pages only)
— no new pages

---
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>


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

## Summary by CodeRabbit

* **New Features**
* Shields transitions now securely track and reconcile managed MCP
policies.
* Existing MCP servers retain verified endpoints and address pins during
unlock and restoration.
* Removed MCP servers remain removed instead of being unintentionally
restored.
* Automatic restoration omits policies that cannot be independently
verified and records clear warnings.

* **Bug Fixes**
* Improved fail-closed behavior for malformed, mismatched, incomplete,
or unavailable policy data.

* **Documentation**
* Expanded guidance on MCP policy handling during manual and automatic
Shields transitions.

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

---------

Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
@coderabbitai coderabbitai Bot mentioned this pull request Aug 25, 2026
21 tasks
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 integration: hermes Hermes integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants