Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): resolve host ref by metadata.name instead of spec.host
Diego Zacariasb82cb327c9e2
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 1d99f9891..365674759 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.231",+ "version": "0.1.232","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.231",+ "version": "0.1.232","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 5af75af7b..92d6ef984 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.231",+ "version": "0.1.232","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/__tests__/resolveHostRef.test.ts b/mcp-host/src/__tests__/resolveHostRef.test.tsnew file mode 100644index 000000000..a7078260c--- /dev/null+++ b/mcp-host/src/__tests__/resolveHostRef.test.ts@@ -0,0 +1,56 @@+import { describe, expect, it } from 'vitest'+import { resolveHostRef } from '../main'+import type { Task } from '../queue/types'+import type { IncomingMessage } from '../server'+import type { HostCRD } from '../types'++// F0.1 / UT-8 — resolveHostRef must fall back to the CRD identifier+// (`metadata.name`, RFC1123, referenced across the whole system), NOT the+// freely-editable display name in `spec.host`. With an editable display,+// `spec.host` can be arbitrary free text (e.g. "Product Agents") that is not a+// valid ref, so using it as the identifier fallback would publish activity+// events under a non-existent hostRef. See spec §4 F0.1 and Locked decision #5.++function makeHost(overrides: Partial<HostCRD> = {}): HostCRD {+ return {+ name: 'product-agent',+ namespace: 'default',+ spec: {+ host: 'Product Agents',+ contextRef: 'product-context',+ secretRef: 'product-llm-secret',+ },+ ...overrides,+ }+}++function makeTask(hostRef: string): Task {+ const sourceMessage = {+ content: 'hi',+ channelType: 'rpc',+ channelId: 'chan-1',+ sender: 'user-1',+ timestamp: new Date().toISOString(),+ messageId: 'msg-1',+ hostRef,+ } as IncomingMessage+ return { sourceMessage } as unknown as Task+}++describe('resolveHostRef (F0.1 / UT-8)', () => {+ it('falls back to the CRD name, not the display spec.host, when the task carries no hostRef', () => {+ const host = makeHost({+ name: 'product-agent',+ spec: { ...makeHost().spec, host: 'Product Agents' },+ })++ // No sourceMessage.hostRef → must resolve to the identifier `product-agent`,+ // never the display `Product Agents`.+ expect(resolveHostRef(undefined, host)).toBe('product-agent')+ })++ it('still prefers an explicit sourceMessage.hostRef over the fallback', () => {+ const host = makeHost()+ expect(resolveHostRef(makeTask('explicit-ref'), host)).toBe('explicit-ref')+ })+})diff --git a/mcp-host/src/main.ts b/mcp-host/src/main.tsindex 6804f6be5..9dda1a5ee 100644--- a/mcp-host/src/main.ts+++ b/mcp-host/src/main.ts@@ -246,11 +246,8 @@ const pendingCronResults = new ResultStore<PendingCronResult>(30 * 60 * 1000, en*/const cronResultsInFlight = new Set<string>()-function resolveHostRef(task?: Task): string {- return (- String(task?.sourceMessage?.hostRef || currentHost?.spec.host || config.hostName).trim() ||- 'unknown'- )+export function resolveHostRef(task?: Task, host: HostCRD | null = currentHost): string {+ return String(task?.sourceMessage?.hostRef || host?.name || config.hostName).trim() || 'unknown'}function publishActivity(input: {