Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(mcp-host): derive verified caller roots in workflow fixtures

Alfredo Lopez356870d66597
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 4aa4e61e7..8549293fa 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.493",
+ "version": "0.1.494",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.493",
+ "version": "0.1.494",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index 20ace91f0..0076aed62 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.493",
+ "version": "0.1.494",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/agent/__tests__/taskExecutor.gfsLiveApproval.integration.test.ts b/mcp-host/src/agent/__tests__/taskExecutor.gfsLiveApproval.integration.test.ts
index 960254a36..9e2efd0b6 100644
--- a/mcp-host/src/agent/__tests__/taskExecutor.gfsLiveApproval.integration.test.ts
+++ b/mcp-host/src/agent/__tests__/taskExecutor.gfsLiveApproval.integration.test.ts
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { spawn } from 'child_process'
import { randomUUID } from 'node:crypto'
-import { mkdir, mkdtemp, rm } from 'node:fs/promises'
+import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { config as appConfig } from '../../config'
@@ -18,6 +18,8 @@ import { TaskLifecycle } from '../../lifecycle/taskLifecycle'
import type { SingleTurnProvider } from '../../llm/types'
import { MessageQueue } from '../../queue'
import type { Task } from '../../queue/types'
+import { resolveCallerRootBinding } from '../../workspace/callerRootBinding'
+import { ScopedWorkspaceProvider } from '../../workspace/scopedWorkspace'
import { CronScheduler } from '../cronScheduler'
import { TaskExecutor, type TaskExecutorDeps, resolveTaskSessionKey } from '../taskExecutor'
@@ -78,11 +80,36 @@ async function scenario(
) {
const root = await mkdtemp(join(tmpdir(), 'gfs-live-approval-'))
roots.push(root)
- const callerWorkspace = join(root, 'caller')
- await mkdir(callerWorkspace, { mode: 0o700 })
const store = new GfsDownloadStore(root)
stores.push(store)
await store.initialize()
+ const task: Task = {
+ id: randomUUID(),
+ source: 'channel',
+ status: 'pending',
+ priority: 'normal',
+ createdAt: new Date(),
+ sourceMessage: {
+ sender: 'gfs-caller',
+ content: 'Process the governed file',
+ channelType: 'rpc',
+ channelId: 'gfs-live-approval-channel',
+ messageId: 'gfs-live-approval-message',
+ timestamp: new Date().toISOString(),
+ hostRef: 'gfs-live-approval-host',
+ },
+ conversationHistory: [
+ { role: 'user', content: 'Process the governed file', timestamp: new Date() },
+ ],
+ responseCallback: vi.fn(async () => undefined),
+ }
+ const callerBinding = resolveCallerRootBinding(
+ new ScopedWorkspaceProvider(root),
+ task.sourceMessage
+ )
+ if (!callerBinding.root)
+ throw new Error(`Test caller binding failed: ${callerBinding.failureCode}`)
+ const callerWorkspace = callerBinding.root
const releaseReceiptOwner = vi.spyOn(store, 'releaseReceiptOwner')
const processingLeases = store.processingLeaseProvider('gfs-caller')
const acquireLease = vi.spyOn(processingLeases, 'acquireProcessingLease')
@@ -110,27 +137,6 @@ async function scenario(
},
}
- const task: Task = {
- id: randomUUID(),
- source: 'channel',
- status: 'pending',
- priority: 'normal',
- createdAt: new Date(),
- sourceMessage: {
- sender: 'gfs-caller',
- content: 'Process the governed file',
- channelType: 'rpc',
- channelId: 'gfs-live-approval-channel',
- messageId: 'gfs-live-approval-message',
- timestamp: new Date().toISOString(),
- hostRef: 'gfs-live-approval-host',
- },
- conversationHistory: [
- { role: 'user', content: 'Process the governed file', timestamp: new Date() },
- ],
- responseCallback: vi.fn(async () => undefined),
- }
-
const sessionKey = resolveTaskSessionKey(task)
const conversation = await conversationManager.getOrCreate(sessionKey, {
userId: task.sourceMessage!.sender,
diff --git a/mcp-host/src/agent/__tests__/taskExecutor.gfsOutputBounds.test.ts b/mcp-host/src/agent/__tests__/taskExecutor.gfsOutputBounds.test.ts
index 5460a239c..afe385329 100644
--- a/mcp-host/src/agent/__tests__/taskExecutor.gfsOutputBounds.test.ts
+++ b/mcp-host/src/agent/__tests__/taskExecutor.gfsOutputBounds.test.ts
@@ -15,6 +15,8 @@ import { SseProgressReporter, progressReporterRegistry } from '../../progress/ss
import type { SuspendedEvent } from '../../progress/types'
import type { Task } from '../../queue/types'
import { createSessionRouteHandlers } from '../../server/sessionRouteHandlers'
+import { resolveCallerRootBinding } from '../../workspace/callerRootBinding'
+import { ScopedWorkspaceProvider } from '../../workspace/scopedWorkspace'
import { TaskExecutor, type TaskExecutorDeps, resolveTaskSessionKey } from '../taskExecutor'
const savedConfig = {
@@ -26,11 +28,12 @@ const savedConfig = {
}
let callerWorkspace: string
+let hostRoot: string
let store: GfsDownloadStore
beforeEach(async () => {
- callerWorkspace = fs.mkdtempSync(path.join(os.tmpdir(), 'gfs-output-bounds-'))
- store = new GfsDownloadStore(callerWorkspace)
+ hostRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gfs-output-bounds-'))
+ store = new GfsDownloadStore(hostRoot)
await store.initialize()
Object.assign(appConfig, {
enableApproval: true,
@@ -43,7 +46,7 @@ beforeEach(async () => {
afterEach(async () => {
await store.close()
Object.assign(appConfig, savedConfig)
- fs.rmSync(callerWorkspace, { recursive: true, force: true })
+ fs.rmSync(hostRoot, { recursive: true, force: true })
})
function makeScenario(options: {
@@ -110,6 +113,13 @@ function makeScenario(options: {
],
responseCallback: vi.fn(async () => undefined),
}
+ const callerBinding = resolveCallerRootBinding(
+ new ScopedWorkspaceProvider(hostRoot),
+ task.sourceMessage
+ )
+ if (!callerBinding.root)
+ throw new Error(`Test caller binding failed: ${callerBinding.failureCode}`)
+ callerWorkspace = callerBinding.root
const conversationManager = new ConversationManager()
const sessionKey = resolveTaskSessionKey(task)