Repository navigation
fix(mcp): preserve Hermes credential revisions #10270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
3a49dc0
test(mcp): reproduce Hermes credential revision loss
rsliter ff64f5c
fix(mcp): preserve Hermes credential revisions
cjagwani dbdfb29
fix(mcp): align Hermes credential revision contract
prekshivyas 3fa0229
test(mcp): execute Hermes config assertions
apurvvkumaria 8a0127e
merge: refresh from main
apurvvkumaria 0a17735
fix(mcp): preserve revision during teardown rollback
ericksoa bd3ce57
fix(hermes): avoid duplicate applied anchor writes
prekshivyas bcf9ebd
fix(mcp): retain scrub rollback revision state
ericksoa 2547e0f
merge: resolve conflicts with main
github-actions[bot] 1692806
fix(mcp): preserve invoked recovery command
apurvvkumaria 98374ee
fix(mcp): reconcile Hermes revision metadata after main merge
prekshivyas 9a4668e
merge: synchronize current main
apurvvkumaria 6c6f0e1
test(mcp): cover Hermes lifecycle rollback revisions
prekshivyas 7d735f9
merge: preserve concurrent PR repairs
apurvvkumaria 6861810
merge: preserve concurrent lifecycle coverage
apurvvkumaria f445921
merge: synchronize current main
apurvvkumaria e8c1200
fix(mcp): remove Hermes helper metadata
apurvvkumaria d4ce801
refactor(mcp): use Hermes branding owner directly
prekshivyas 057e5e8
merge: synchronize current main
apurvvkumaria f78f84a
refactor(snapshot): inject CLI name into Hermes hint
ericksoa 2f6fc2b
fix(mcp): keep recovery branding within budget
apurvvkumaria 9904cda
merge: preserve concurrent architecture repair
apurvvkumaria 7b45f8a
merge: synchronize current main
apurvvkumaria 78a6282
chore(architecture): lower branding fan-in budget
apurvvkumaria 35ddb05
refactor(mcp): remove recovery command wrapper
apurvvkumaria 594a508
refactor(mcp): inline Hermes recovery branding
prekshivyas 6505f05
merge: preserve contributor architecture repair
apurvvkumaria 302435a
chore(architecture): retain branding fan-in budget
apurvvkumaria 42bc649
docs(mcp): describe Hermes credential revisions
rsliter 1219dc2
fix(mcp): wait for stable credential revision
prekshivyas 4b59c3d
test(mcp): expect stable credential revision
rsliter e5263dd
Merge branch 'main' into codex/fix-hermes-mcp-runtime-contract-10155
rsliter 4d7ac91
fix(mcp): await exact credential revision
prekshivyas 0cff15f
fix(mcp): keep credential revisions opaque
rsliter da46392
ci(e2e): reuse exact PR image cohort
ericksoa f152596
merge: synchronize exact E2E evidence
rsliter c87835b
ci(e2e): remove temporary exact cohort reuse
rsliter 557b3c6
fix(mcp): fence opaque credential revisions
prekshivyas f7cf37c
test(mcp): mock credential revision fence
prekshivyas 1613083
merge: synchronize latest main
prekshivyas 286818d
fix(mcp): keep teardown revisions opaque
prekshivyas cbf312d
docs(mcp): document teardown revision recovery
rsliter 90cc104
Merge remote-tracking branch 'origin/main' into codex/10155-hermes-mc…
prekshivyas d7a0a6a
test(repository): remove duplicate advisor watch trigger
prekshivyas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/lib/actions/sandbox/mcp-bridge-adapter-hermes-branding.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| isShieldsDown: vi.fn(), | ||
| runOpenshellProviderCommand: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("../../adapters/openshell/provider-command", () => ({ | ||
| runOpenshellProviderCommand: mocks.runOpenshellProviderCommand, | ||
| })); | ||
|
|
||
| vi.mock("../../shields", () => ({ | ||
| isShieldsDown: mocks.isShieldsDown, | ||
| })); | ||
|
|
||
| import { assertHermesMcpMutationRuntimeCapability } from "./mcp-bridge-adapter-hermes"; | ||
|
|
||
| describe("Hermes MCP recovery guidance", () => { | ||
| beforeEach(() => { | ||
| vi.stubEnv("NEMOCLAW_INVOKED_AS", "nemohermes"); | ||
| mocks.isShieldsDown.mockReset().mockReturnValue(true); | ||
| mocks.runOpenshellProviderCommand.mockReset().mockReturnValue({ | ||
| status: 1, | ||
| stdout: "", | ||
| stderr: "Hermes gateway is not running under the managed service lifecycle", | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllEnvs(); | ||
| }); | ||
|
|
||
| it("uses the invoked CLI name when the managed lifecycle is unavailable", () => { | ||
| expect(() => assertHermesMcpMutationRuntimeCapability("alpha")).toThrow( | ||
| "Run `nemohermes alpha recover` and retry.", | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
src/lib/actions/sandbox/mcp-bridge-adapter-teardown.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import type { McpBridgeEntry, SandboxEntry } from "../../state/registry"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| assertMcpDestroyNotPending: vi.fn(), | ||
| bridgeState: vi.fn(), | ||
| discardSafeIncompleteMcpAdds: vi.fn(), | ||
| ensureSandboxGatewaySelected: vi.fn(), | ||
| getBridgeAdapter: vi.fn(), | ||
| getSandboxAgent: vi.fn(), | ||
| getSandboxOrThrow: vi.fn(), | ||
| inspectMcpProvider: vi.fn(), | ||
| observeMcpCredentialRevision: vi.fn(), | ||
| removeGeneratedPolicy: vi.fn(), | ||
| registerAgentAdapter: vi.fn(), | ||
| restoreExistingMcpBridgeRuntime: vi.fn(), | ||
| unregisterAgentAdapter: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("../../state/registry", () => ({ | ||
| getSandbox: vi.fn(), | ||
| updateSandbox: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-adapters", () => ({ | ||
| registerAgentAdapter: mocks.registerAgentAdapter, | ||
| unregisterAgentAdapter: mocks.unregisterAgentAdapter, | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-provider-readiness", () => ({ | ||
| observeMcpCredentialRevision: mocks.observeMcpCredentialRevision, | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-provider", () => ({ | ||
| assertMcpProviderRecoverable: vi.fn(), | ||
| assertNoProviderCredentialCollisions: vi.fn(), | ||
| assertNoRegisteredProviderCredentialCollisions: vi.fn(), | ||
| detachProvider: vi.fn(), | ||
| inspectMcpProvider: mocks.inspectMcpProvider, | ||
| preflightMcpEntryTargets: vi.fn(), | ||
| waitForDetachedMcpCredential: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-destroy-preflight", () => ({ | ||
| cloneMcpBridgeEntry: vi.fn((entry: McpBridgeEntry) => ({ ...entry, env: [...entry.env] })), | ||
| discardSafeIncompleteMcpAdds: mocks.discardSafeIncompleteMcpAdds, | ||
| inspectExactMcpDestroyProvider: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-policy", () => ({ | ||
| assertGeneratedPolicyMutationSafe: vi.fn(), | ||
| assertGeneratedPolicyRegistrationMutationSafe: vi.fn(), | ||
| removeGeneratedPolicy: mocks.removeGeneratedPolicy, | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-restart", () => ({ | ||
| restoreExistingMcpBridgeRuntime: mocks.restoreExistingMcpBridgeRuntime, | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-runtime-capabilities", () => ({ | ||
| assertMcpAdapterConfigMutationsAllowed: vi.fn(), | ||
| assertMcpAdapterTeardownRuntimeCapabilities: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-state", () => ({ | ||
| assertMcpDestroyNotPending: mocks.assertMcpDestroyNotPending, | ||
| bridgeState: mocks.bridgeState, | ||
| ensureSandboxGatewaySelected: mocks.ensureSandboxGatewaySelected, | ||
| getBridgeAdapter: mocks.getBridgeAdapter, | ||
| getSandboxAgent: mocks.getSandboxAgent, | ||
| getSandboxOrThrow: mocks.getSandboxOrThrow, | ||
| nowIso: vi.fn(() => new Date(0).toISOString()), | ||
| setBridgeState: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("./mcp-bridge-validation", () => ({ | ||
| assertAuthenticatedBridgeEntry: vi.fn(), | ||
| validateSandboxName: vi.fn(), | ||
| })); | ||
|
|
||
| import { prepareMcpBridgesForDestroy } from "./mcp-bridge-destroy"; | ||
| import { prepareMcpBridgesForRebuild } from "./mcp-bridge-rebuild"; | ||
| import { scrubManagedMcpAdapterOrThrow } from "./mcp-bridge-adapter-teardown"; | ||
|
|
||
| const sandbox = { agent: "hermes" } as SandboxEntry; | ||
| const entry: McpBridgeEntry = { | ||
| server: "github", | ||
| agent: "hermes", | ||
| adapter: "hermes-config", | ||
| url: "https://api.githubcopilot.com/mcp/", | ||
| env: ["GITHUB_TOKEN"], | ||
| providerName: "alpha-mcp-github", | ||
| policyName: "mcp-bridge-github", | ||
| addedAt: new Date(0).toISOString(), | ||
| }; | ||
|
|
||
| describe("MCP adapter teardown rollback", () => { | ||
| beforeEach(() => { | ||
| mocks.bridgeState.mockReset().mockReturnValue({ github: entry }); | ||
| mocks.discardSafeIncompleteMcpAdds.mockReset().mockResolvedValue(sandbox); | ||
| mocks.ensureSandboxGatewaySelected.mockReset().mockResolvedValue(undefined); | ||
| mocks.getBridgeAdapter.mockReset().mockReturnValue("hermes-config"); | ||
| mocks.getSandboxAgent.mockReset().mockReturnValue("hermes"); | ||
| mocks.getSandboxOrThrow.mockReset().mockReturnValue(sandbox); | ||
| mocks.inspectMcpProvider.mockReset().mockReturnValue({ exists: false }); | ||
| mocks.observeMcpCredentialRevision.mockReset().mockReturnValue("v12"); | ||
| mocks.removeGeneratedPolicy.mockReset().mockImplementation(() => { | ||
| throw new Error("forced lifecycle failure after adapter scrub"); | ||
| }); | ||
| mocks.registerAgentAdapter.mockReset(); | ||
| mocks.restoreExistingMcpBridgeRuntime.mockReset(); | ||
| mocks.unregisterAgentAdapter.mockReset().mockReturnValue("removed"); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ["rebuild", prepareMcpBridgesForRebuild], | ||
| ["destroy", prepareMcpBridgesForDestroy], | ||
| ] as const)( | ||
| "restores the revision observed before a later %s step fails (#10155)", | ||
| async (_lifecycle, prepare) => { | ||
| mocks.observeMcpCredentialRevision | ||
| .mockReset() | ||
| .mockReturnValueOnce("v12") | ||
| .mockReturnValueOnce("absent"); | ||
|
|
||
| await expect(prepare("alpha")).rejects.toThrow( | ||
| "forced lifecycle failure after adapter scrub", | ||
| ); | ||
| expect(mocks.unregisterAgentAdapter).toHaveBeenCalledOnce(); | ||
| expect(mocks.registerAgentAdapter).toHaveBeenCalledWith( | ||
| "alpha", | ||
| "hermes-config", | ||
| expect.objectContaining({ ...entry, credentialRevision: "v12" }), | ||
| {}, | ||
| { | ||
| credentialRevision: "v12", | ||
| replaceExisting: true, | ||
| teardownRollback: true, | ||
| }, | ||
| ); | ||
| expect(mocks.restoreExistingMcpBridgeRuntime).not.toHaveBeenCalled(); | ||
| }, | ||
| ); | ||
|
|
||
| it("does not scrub Hermes when no attached revision can be proved", () => { | ||
| mocks.observeMcpCredentialRevision.mockReturnValue("absent"); | ||
|
|
||
| expect(() => scrubManagedMcpAdapterOrThrow("alpha", sandbox, entry)).toThrow( | ||
| "Could not prove a revision-scoped credential before removing the managed adapter entry for MCP server 'github'.", | ||
| ); | ||
| expect(mocks.inspectMcpProvider).toHaveBeenCalledWith("alpha-mcp-github"); | ||
| expect(mocks.unregisterAgentAdapter).not.toHaveBeenCalled(); | ||
| expect(mocks.registerAgentAdapter).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.