Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(mcp-host): pin replaceServer keeps the representative (R4-M4)
Diego Zacarias9539da7f6b9f
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex eab30b201..979a62610 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.297",+ "version": "0.1.298","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.297",+ "version": "0.1.298","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex e8f686d8e..2be125db7 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.297",+ "version": "0.1.298","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/mcp/__tests__/managerPartition.test.ts b/mcp-host/src/mcp/__tests__/managerPartition.test.tsindex 33009a83b..1809cff5a 100644--- a/mcp-host/src/mcp/__tests__/managerPartition.test.ts+++ b/mcp-host/src/mcp/__tests__/managerPartition.test.ts@@ -611,3 +611,35 @@ describe('R4-M3 — detachServer purges the clients map for every ClientKey', ()expect(sdk.transports.length).toBe(3)})})++// ─── R4-M4 · replaceServer keeps the SHARED representative (keepKey) alive ─────+//+// evictPartitionsExcept skips `keepKey` (the freshly-installed SHARED+// representative). Removing `if (key === keepKey) continue` evicts it too, but+// that mutant is MASKED whenever a per-user partition exists (M2's+// representativeClient fallback returns the per-user client, so+// getConnectedServers/getAllTools stay green). This test pins the invariant with+// ZERO per-user partitions, where nothing can mask an evicted representative.+//+// NOTE (interdependence with M2, not fixed here): if a per-user partition were+// present, the M2 fallback would keep getConnectedServers green even with the+// representative evicted — this test deliberately holds no per-user partition so+// it pins keepKey directly given the current code.++describe('R4-M4 — replaceServer keeps the SHARED representative alive', () => {+ it('the SHARED representative survives the swap (no per-user partitions to mask it)', async () => {+ const { factory } = recordingFactory()+ const manager = new McpManager(undefined, undefined, factory)+ await manager.addServer(oauthUserServer())++ // No per-user calls: the only ClientKey is the SHARED representative.+ const outcome = await manager.replaceServer(oauthUserServer())+ expect(outcome).toBe('applied')++ // Representative survived → catalog + connectivity intact. With the keepKey+ // skip removed, evictPartitionsExcept would delete the SHARED key and both+ // would be empty.+ expect(manager.getConnectedServers()).toEqual(['gh'])+ expect(manager.getAllTools().map(t => t.name)).toEqual(['gh__do'])+ })+})