fix(rebuild): keep Hermes MCP runtime active after rebuild - #8703
Conversation
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
|
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. |
📝 WalkthroughWalkthroughThe PR adds Hermes MCP HTTP probe helpers, integrates them into live adapter tests, and adds coverage for authenticated requests, bounded redacted failures, HTTP status validation, and result-token validation. ChangesHermes MCP HTTP handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant LiveTest as Hermes live test
participant Probe as Hermes HTTP probe
participant Gateway as Hermes gateway
participant Fixture as MCP fixture
LiveTest->>Probe: Build payload and expected result-token probe
Probe->>Gateway: Send one authenticated chat request
Gateway->>Fixture: Invoke MCP tool
Fixture-->>Gateway: Return tool result
Gateway-->>Probe: Return HTTP status and response body
Probe-->>LiveTest: Return bounded command result
LiveTest->>Probe: Validate status, redaction, and result token
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in commit 0bf6625 in the TypeScript / code-coverage/cliThe overall coverage in commit 0bf6625 in the Show a code coverage summary of the most impacted files.
Updated |
PR Review Advisor — No blocking findings reportedAdvisor assessment: No blocking advisor findings reported Model lanes
3 terminology differences from the second opinionAdvisory only. These are normalized differences from the primary terminology receipt.
2 additional E2E selections from the second opinionAdvisory only. The primary lane did not select these E2E jobs or targets.
Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests. 2 semantic terminology decisionsTerminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.
E2E guidanceAdvisory only. A maintainer can dispatch the default E2E suite against this exact revision. Recommended E2E: This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge. |
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
test/e2e/support/mcp-bridge-hermes-http.test.ts (2)
35-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove source-text assertions.
The fake
curlat Lines 54-57 and the count assertion at Line 87 already verify authentication and one request through the shell boundary. Remove these generated-script text checks.Proposed change
- expect(script.match(/\bcurl "\$@"/gu)).toHaveLength(1); - expect(script).not.toMatch(/\bretry\b/iu); - expect(script).toContain("Authorization: Bearer ${API_SERVER_KEY}");As per path instructions, prefer observable outcomes through the public boundary over source-text assertions.
🤖 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 35 - 37, Remove the generated-script source-text assertions in the affected test, including the script.match count, retry absence, and Authorization string checks. Retain the fake curl boundary setup and the existing request-count assertion, which already verify authentication and a single request through observable behavior.Source: Path instructions
109-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTest duplicate result-token rejection.
hasResultTokenrequires exactly oneNEMOCLAW_HERMES_MCP_RESULT_TOKEN=presentmarker. Add a case with two present markers and assert thatassertHermesMcpHttpResponsethrows. This protects the single-marker protocol rule.🤖 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 109 - 120, Add a test beside the existing result-token assertions that passes two NEMOCLAW_HERMES_MCP_RESULT_TOKEN=present markers to assertHermesMcpHttpResponse and verifies it throws for violating the exactly-one-marker protocol rule.Source: Path instructions
🤖 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 35-37: Remove the generated-script source-text assertions in the
affected test, including the script.match count, retry absence, and
Authorization string checks. Retain the fake curl boundary setup and the
existing request-count assertion, which already verify authentication and a
single request through observable behavior.
- Around line 109-120: Add a test beside the existing result-token assertions
that passes two NEMOCLAW_HERMES_MCP_RESULT_TOKEN=present markers to
assertHermesMcpHttpResponse and verifies it throws for violating the
exactly-one-marker protocol rule.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 00d981ea-6284-435c-80d5-561bf3ef3016
📒 Files selected for processing (3)
test/e2e/live/mcp-bridge-hermes-http.tstest/e2e/live/mcp-bridge.test.tstest/e2e/support/mcp-bridge-hermes-http.test.ts
<!-- markdownlint-disable MD041 --> ## Summary A long Hermes rebuild can outlive an inherited Shields auto-restore timer. NemoClaw now settles an expired deferred timer through the existing fenced Shields-up path before reporting rebuild success, which prevents lockdown from racing the first post-rebuild tool call. The live E2E lane now records bounded, redacted HTTP, runtime, fixture, Shields, and cleanup evidence for this boundary. ## Related Issue Fixes #8697 ## Changes - Restrict the production change to rebuild windows that defer automatic Shields restoration while the lifecycle owner is alive. If that timer expires during rebuild, the existing Shields-up operation settles the timer before rebuild returns success. - Preserve ordinary backup behavior when the sandbox already had Shields down. - Record gateway process identity before rebuild and after MCP restoration. - Record post-rebuild fixture requests without credentials or request bodies. The record includes only the authentication result, method, path, response status, and result presence. - Capture bounded Hermes logs, filesystem permissions, managed-supervisor status, gateway identity, and Shields status. Existing artifact redaction removes known credentials. - Lower Shields before MCP and sandbox cleanup. The cleanup registry uses last-in, first-out order, so evidence capture runs first, Shields-down runs second, and older cleanup operations run afterward. ### Confirmed evidence - Merged PR #8703 added bounded HTTP failure diagnostics for #8697. - Trusted-main run `31364512126`, Hermes job `93380168425`, completed rebuild in 845,292 ms. - The first post-rebuild request returned HTTP 500 in 295 ms with `Permission denied: '/sandbox/.hermes/logs'`. - The inherited Shields timer deadline had elapsed while rebuild held the lifecycle lock. The detached timer applied lockdown when the lock became available. - The failed run predates the fixture-request ledger in this PR. Its failure location indicates that the request ended before the MCP fixture, but the artifact does not directly record that result. ### Root cause and correction The failure was not stale MCP configuration or credential rotation. The overdue Shields timer made `/sandbox/.hermes` read-only immediately after rebuild released its lifecycle lock. Rebuild now settles that timer with the existing fenced Shields-up state transition before it reports success. ### Remaining validation - Run the canonical trusted `mcp-bridge (hermes)` lane on the exact PR commit. - Confirm the first post-rebuild request returns `MCP_AUTH_REWRITE_OK::nemoclaw-authenticated-mcp-proof`. - Confirm the fixture records exactly one authenticated `tools/call` with the rotated provider credential. - Confirm the final evidence records the expected gateway identities, Shields state, redaction, and cleanup result. ## 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: The change corrects an internal timer-settlement race and adds test evidence. It does not change a command, option, configuration, output contract, or recovery procedure. - [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 Codex security review covered all nine repository categories and found no actionable finding. The trusted-main live E2E run remains pending. - [ ] 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: `no-docs-needed` - Evidence: Existing rebuild documentation already states that the detached auto-lock timer remains authoritative until rebuild commits a successful Shields-up state. `docs/` is unchanged. - Agent: Codex Desktop <!-- docs-review-head-sha: d5d0788 --> <!-- docs-review-agents-blob-sha: c4923a3 --> ## DGX Station Hardware Evidence - [ ] Tested on DGX Station - Tested commit: - Station profile/scenario: - Result: - Supporting evidence: ## 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: 8 timer tests, 63 rebuild/reconciliation tests, 88 Hermes transaction/convergence/integrity tests, 13 E2E support tests, and 2 bounded HTTP diagnostic tests passed. `npm run typecheck:cli` and `npx prek run --from-ref origin/main --to-ref HEAD` 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. The diff changes one lifecycle decision and focused live evidence. - [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: Apurv Kumaria <akumaria@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed backup protection windows that could remain unlocked after their automatic restore timer expired. * Rebuilding protection settings now correctly settles expired timers and reapplies lockdown when required. * **Tests** * Expanded coverage for timer expiration, relocking behavior, and rebuild workflows. * Improved diagnostics captured during runtime and gateway lifecycle testing, with sensitive values redacted. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Summary
This draft adds one-shot, credential-redacted diagnostics for the Hermes MCP request that fails immediately after a successful sandbox rebuild. The evidence distinguishes response status/body, result-token, and exact authenticated
tools/callreachability failures without retrying the paid completion request. The remaining work will confirm the causal boundary and add the narrow rebuild fix before this draft is marked ready.Related Issue
Fixes #8697
Changes
/v1/chat/completionsprobe and preserve its HTTP status plus a redacted, byte-limited failure body while keeping successful response contents out of artifacts.tools/callat the managed/mcpendpoint after an HTTP success.Current root-cause hypothesis: the scenario's pre-existing 15-minute Shields auto-lock begins before rebuild, while the rebuild path treats both mutable-default and temporarily-unlocked postures as already down and does not capture the old timer generation. The recorded rebuild holds the lifecycle lock across the old deadline, so the timer waits; after rebuild releases that lock, overdue recovery can harden the replacement before the first tool-backed request even though config/hash and gateway-health checks passed. The new HTTP and runtime evidence will confirm whether that handoff also causes the HTTP 500 before the fix is committed.
68129579827191770cfcf496715e4e272bc96129, GitHub Verified31357091338, Hermes job93361110199tools/callafter HTTP successType of Change
Quality Gates
Documentation Writer Review
no-docs-neededDGX Station Hardware Evidence
Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run validate:prpassed after refreshingorigin/mainwhen hooks were skipped or unavailablenpx vitest run --project e2e-support test/e2e/support/mcp-bridge-hermes-http.test.ts(2 tests passed)npm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — pending the causal fixnpm run docsbuilds without warnings (doc changes only)Signed-off-by: Apurv Kumaria akumaria@nvidia.com
Summary by CodeRabbit