Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(review): address Astra audit findings on scopes, timeouts, and access
Alfredo Lopez3076e85afbc9
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsxindex 2d1ee4713..5f1714469 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsx@@ -284,7 +284,7 @@ describe('revoked host catalog protection', () => {})it.each([401, 403])(- 'hides cached sessions when the catalog returns an uncertain %i',+ 'keeps cached sessions visible when the catalog returns a generic %i twice',async status => {const blocked = new Set<string>()clerum.chat.getIndex.mockResolvedValue(@@ -299,14 +299,15 @@ describe('revoked host catalog protection', () => {isHostAccessBlocked: agentRef => blocked.has(agentRef),})- await waitFor(() => expect(blocked.has('agent-a')).toBe(true))- expect(result.current.latestChatSessions.some(chat => chat.agentRef === 'agent-a')).toBe(- false+ await waitFor(() =>+ expect(result.current.latestChatSessions.some(chat => chat.id === 'protected-a')).toBe(true))+ expect(clerum.rpc.listSessions).toHaveBeenCalledTimes(2)+ expect(blocked.has('agent-a')).toBe(false)})- it('retains cached sessions when a 503 body merely mentions 403', async () => {+ it('marks Host authority uncertain after a 503 catalog failure', async () => {const blocked = new Set<string>()clerum.chat.getIndex.mockResolvedValue(localIndex([{ id: 'cached-a', title: 'Cached chat' }]))clerum.rpc.listSessions.mockRejectedValue(@@ -319,12 +320,9 @@ describe('revoked host catalog protection', () => {onHostAuthorityUncertain: agentRef => blocked.add(agentRef),isHostAccessBlocked: agentRef => blocked.has(agentRef),})- await waitFor(() =>- expect(result.current.latestChatSessions.some(chat => chat.id === 'cached-a')).toBe(true)- )await waitFor(() => expect(clerum.rpc.listSessions).toHaveBeenCalled())- expect(blocked.has('agent-a')).toBe(false)- expect(result.current.latestChatSessions.some(chat => chat.id === 'cached-a')).toBe(true)+ await waitFor(() => expect(blocked.has('agent-a')).toBe(true))+ expect(result.current.latestChatSessions.some(chat => chat.id === 'cached-a')).toBe(false)})})diff --git a/desktop-app/ui/src/hooks/domain/__tests__/renameSessionQueue.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/renameSessionQueue.test.tsxindex b5d8ca28c..08685ed5e 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/renameSessionQueue.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/renameSessionQueue.test.tsx@@ -171,7 +171,7 @@ describe('rename pending queue (spec 15 §2.5)', () => {renameError: 'Rename session failed (403)',readStatus: null,shouldRevoke: false,- shouldBeUncertain: true,+ shouldBeUncertain: false,},{label: 'read also denied',@@ -200,7 +200,7 @@ describe('rename pending queue (spec 15 §2.5)', () => {return reportedSessions([{ chatId: 'c1', title: 'old' }])})- const { result } = renderController({+ const { result, spies } = renderController({selectedAgent: 'agent-x',agentNames: ['agent-x'],onHostAccessRevoked: agentRef => revoked.add(agentRef),@@ -214,7 +214,14 @@ describe('rename pending queue (spec 15 §2.5)', () => {expect(revoked.has('agent-x')).toBe(shouldRevoke)expect(uncertain.has('agent-x')).toBe(shouldBeUncertain)if (shouldRevoke) expect(result.current.chatList).toEqual([])- else expect(titleInList(result.current, 'c1')).toBe('new')+ else if (shouldBeUncertain) expect(titleInList(result.current, 'c1')).toBe('new')+ else {+ expect(titleInList(result.current, 'c1')).toBe('old')+ expect(spies.pushToast).toHaveBeenCalledWith(+ 'You do not have permission to rename this chat.',+ 'error'+ )+ }})diff --git a/desktop-app/ui/src/hooks/domain/useChatListController.ts b/desktop-app/ui/src/hooks/domain/useChatListController.tsindex 4bca30e5b..fb3585643 100644--- a/desktop-app/ui/src/hooks/domain/useChatListController.ts+++ b/desktop-app/ui/src/hooks/domain/useChatListController.ts@@ -16,6 +16,23 @@ import { type SessionFsmEvent, type SessionFsmStore, seedSessionSnapshots } fromconst SESSION_CATALOG_PAGE_LIMIT = 50+async function readSessionCatalog(+ chatStore: ReturnType<typeof useChatStore>,+ agentRef: string,+ query: Parameters<ReturnType<typeof useChatStore>['listSessions']>[1],+ options: { force?: boolean } = {}+): Promise<SessionsListResult> {+ try {+ return await chatStore.listSessions(agentRef, query, options)+ } catch (error) {+ // listSessions in the main process already refreshes an expired RPC token+ // and retries once on 401. A second uncached read also distinguishes a+ // catalog-specific denial from loss of Host authority.+ if (!isAuthorizationError(error) || isConfirmedHostAccessRevoked(error)) throw error+ return chatStore.listSessions(agentRef, query, { force: true })+ }+}+// R1-M1: an 'offline' pending rename (a genuine network / 5xx failure) retries on// every listSessions poll and every `window 'online'` event. A deterministic 5xx// / 501 would otherwise re-issue the PATCH forever, so cap the auto-retries per@@ -208,6 +225,7 @@ export function useChatListController({// Cross-agent "Latest sessions" list (badges live in the FSM, seeded below).const [latestChatSessions, setLatestChatSessions] = useState<LatestSidebarChatEntry[]>([])const [latestChatSessionsLoading, setLatestChatSessionsLoading] = useState(false)+ const catalogOfflineByAgentRef = useRef(new Set<string>())const [latestCatalogMutationRevision, setLatestCatalogMutationRevision] = useState(0)// Selection requested for an agent before its chats have loaded, consumed by// the parent's agent-selection effect. Ref (not state): imperative, per-agent.@@ -281,6 +299,7 @@ export function useChatListController({requestGenerationRef.current += 1authorityScopeGenerationRef.current += 1deletedChatIdsByAgentRef.current.clear()+ catalogOfflineByAgentRef.current.clear()}, [isAuthenticated, scopeKey])// R1-H1 — the pending-rename queue is per-USER identity. mcp-host keys a chat@@ -398,23 +417,30 @@ export function useChatListController({scheduleAfterFirstPaint(async () => {let serverResult: SessionsListResulttry {- serverResult = await chatStore.listSessions(agentRef, {+ serverResult = await readSessionCatalog(chatStore, agentRef, {agent: agentRef,limit: SESSION_CATALOG_PAGE_LIMIT,})} catch (error) {if (- isAuthorizationError(error) &&authorityScopeGenerationRef.current === authorityScopeGeneration &&getHostAuthorityEpoch(agentRef) === hostAuthorityEpoch &¤tAuthorityScopeRef.current === authorityScopeAtRequest &&!isHostAccessBlocked(agentRef)) {if (isConfirmedHostAccessRevoked(error)) onHostAccessRevoked(agentRef)- else onHostAuthorityUncertain(agentRef)+ else if (!isAuthorizationError(error)) onHostAuthorityUncertain(agentRef)+ if (+ !isConfirmedHostAccessRevoked(error) &&+ !catalogOfflineByAgentRef.current.has(agentRef)+ ) {+ catalogOfflineByAgentRef.current.add(agentRef)+ host.current?.pushToast('Chat list is offline. Showing saved chats.', 'info')+ }}return}+ catalogOfflineByAgentRef.current.delete(agentRef)if (selectedAgentRef.current !== agentRef ||requestGenerationRef.current !== requestGeneration ||@@ -581,21 +607,28 @@ export function useChatListController({try {let serverResult: SessionsListResulttry {- serverResult = await chatStore.listSessions(+ serverResult = await readSessionCatalog(+ chatStore,agentRef,{ agent: agentRef, limit: SESSION_CATALOG_PAGE_LIMIT, cursor },{ force: true })} catch (error) {if (- isAuthorizationError(error) &&authorityScopeGenerationRef.current === authorityScopeGeneration &&getHostAuthorityEpoch(agentRef) === hostAuthorityEpoch &¤tAuthorityScopeRef.current === authorityScopeAtRequest &&!isHostAccessBlocked(agentRef)) {if (isConfirmedHostAccessRevoked(error)) onHostAccessRevoked(agentRef)- else onHostAuthorityUncertain(agentRef)+ else if (!isAuthorizationError(error)) onHostAuthorityUncertain(agentRef)+ if (+ !isConfirmedHostAccessRevoked(error) &&+ !catalogOfflineByAgentRef.current.has(agentRef)+ ) {+ catalogOfflineByAgentRef.current.add(agentRef)+ host.current?.pushToast('Chat list is offline. Showing saved chats.', 'info')+ }return}if (@@ -613,6 +646,7 @@ export function useChatListController({}return}+ catalogOfflineByAgentRef.current.delete(agentRef)if (requestGenerationRef.current !== requestGeneration ||getHostAuthorityEpoch(agentRef) !== hostAuthorityEpoch ||@@ -1006,13 +1040,21 @@ export function useChatListController({return}if (isAuthorizationError(error)) {- if (!requestStillCurrent() || isHostAccessBlocked(entry.agentRef)) return+ if (+ !requestStillCurrent() ||+ isHostAccessBlocked(entry.agentRef) ||+ pendingRenamesRef.current.get(key) !== entry+ ) {+ return+ }+ let readSucceeded = falsetry {await chatStore.listSessions(entry.agentRef,{ agent: entry.agentRef, limit: 1 },{ force: true })+ readSucceeded = true} catch (readError) {if (!requestStillCurrent() || isHostAccessBlocked(entry.agentRef)) returnif (isConfirmedHostAccessRevoked(readError)) {@@ -1023,10 +1065,26 @@ export function useChatListController({return}}- if (!requestStillCurrent() || isHostAccessBlocked(entry.agentRef)) return+ if (+ !requestStillCurrent() ||+ isHostAccessBlocked(entry.agentRef) ||+ pendingRenamesRef.current.get(key) !== entry+ ) {+ return+ }+ if (readSucceeded) {+ if (pendingRenamesRef.current.get(key) === entry) {+ pendingRenamesRef.current.delete(key)+ if (entry.previousTitle) {+ await applyLocalTitleOnly(entry.agentRef, entry.chatId, entry.previousTitle)+ }+ }+ host.current?.pushToast('You do not have permission to rename this chat.', 'error')+ return+ }// Only the structured host denial proves revocation. A generic 403- // may be a stale/missing write capability, so block the host as- // uncertain and retain the optimistic rename for a later retry.+ // may be a stale/missing write capability. If the read check also+ // fails, preserve the existing uncertain-authority handling.onHostAuthorityUncertain(entry.agentRef)if (pendingRenamesRef.current.get(key) === entry) {entry.state = 'offline'@@ -1402,13 +1460,12 @@ export function useChatListController({// on-demand pagination through `loadMoreChatSessions`.let serverResult: SessionsListResulttry {- serverResult = await chatStore.listSessions(agentRef, {+ serverResult = await readSessionCatalog(chatStore, agentRef, {agent: agentRef,limit: SESSION_CATALOG_PAGE_LIMIT,})} catch (error) {if (- isAuthorizationError(error) &&!cancelled &&authorityScopeGenerationRef.current === authorityScopeGeneration &¤tAuthorityScopeRef.current === authorityScopeAtRequest &&@@ -1416,10 +1473,18 @@ export function useChatListController({!isHostAccessBlocked(agentRef)) {if (isConfirmedHostAccessRevoked(error)) onHostAccessRevoked(agentRef)- else onHostAuthorityUncertain(agentRef)+ else if (!isAuthorizationError(error)) onHostAuthorityUncertain(agentRef)+ if (+ !isConfirmedHostAccessRevoked(error) &&+ !catalogOfflineByAgentRef.current.has(agentRef)+ ) {+ catalogOfflineByAgentRef.current.add(agentRef)+ host.current?.pushToast('Chat list is offline. Showing saved chats.', 'info')+ }}return { agentRef, sessions: [] as SessionsListResult['items'] }}+ catalogOfflineByAgentRef.current.delete(agentRef)if (currentAuthorityScopeRef.current !== authorityScopeAtRequest ||getHostAuthorityEpoch(agentRef) !== hostAuthorityEpochByAgent.get(agentRef) ||diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.tsindex 8c1fbebd7..cc554377c 100644--- a/external-rest-api/src/releaseManifest.ts+++ b/external-rest-api/src/releaseManifest.ts@@ -9,7 +9,7 @@ export type ReleaseManifest = {export const releaseManifest: ReleaseManifest = {releaseId: 'v0.9.0',externalRestApiVersion: '0.1.84',- rpcProxyVersion: '0.1.97',+ rpcProxyVersion: '0.1.98',desktopVersion: '0.9.0',minimumDesktopVersion: '0.1.252',}diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 0626fc239..623c9384c 100644--- a/host-context-controller/package-lock.json+++ b/host-context-controller/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-host-context-controller",- "version": "0.1.359",+ "version": "0.1.360","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.359",+ "version": "0.1.360","license": "SEE LICENSE IN LICENSE","dependencies": {"@clerum/codex-catalog-projection": "file:../packages/codex-catalog-projection",diff --git a/host-context-controller/package.json b/host-context-controller/package.jsonindex d87e0b8af..69bebc426 100644--- a/host-context-controller/package.json+++ b/host-context-controller/package.json@@ -1,6 +1,6 @@{"name": "clerum-host-context-controller",- "version": "0.1.359",+ "version": "0.1.360","description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API","main": "dist/main.js","engines": {diff --git a/host-context-controller/src/hostReconciler.ts b/host-context-controller/src/hostReconciler.tsindex 97d69af83..87f5a4c79 100644--- a/host-context-controller/src/hostReconciler.ts+++ b/host-context-controller/src/hostReconciler.ts@@ -4801,11 +4801,16 @@ export class HostReconciler {}}const holdAppliedRuntime = async (allowScaleUp: boolean): Promise<void> => {- await this.provisionRuntimeTokenRevision(host, {- forceFreshForWake: allowScaleUp,- targetSuspended: lifecycle.effective.state === 'suspended',- })- revalidateHostMutationBoundary()+ if (this.ccCacheSyncedFn()) {+ await this.provisionRuntimeTokenRevision(host, {+ forceFreshForWake: allowScaleUp,+ targetSuspended: lifecycle.effective.state === 'suspended',+ })+ revalidateHostMutationBoundary()+ }+ // The channel inventory is incomplete while its cache is unsynced. Defer+ // scope-sensitive token minting until the next authoritative reconcile so+ // a missing channel count cannot narrow the running Host's token scopes.const applied = await this.ensureDeployment(host,mounts,diff --git a/host-context-controller/test/hostReconciler.lifecycle.test.ts b/host-context-controller/test/hostReconciler.lifecycle.test.tsindex e65b11ad8..4661a4c01 100644--- a/host-context-controller/test/hostReconciler.lifecycle.test.ts+++ b/host-context-controller/test/hostReconciler.lifecycle.test.ts@@ -971,7 +971,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {expect(appsApi.replaceNamespacedDeployment).not.toHaveBeenCalled()})- it('refreshes runtime credentials while holding the existing template during cache loss', async () => {+ it('preserves runtime credentials and the existing template during cache loss', async () => {const host = makeStatelessHost({status: { lifecycle: { state: 'active', wakeHandledGeneration: 1 } },})@@ -986,7 +986,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {.spyOn(reconciler as any, 'provisionRuntimeTokenRevision').mockResolvedValue(runtimeTokenProvision(host))await reconciler.reconcile(host)- expect(provision).toHaveBeenCalledOnce()+ expect(provision).not.toHaveBeenCalled()expect(live().spec!.replicas).toBe(1)expect(live().spec!.template).toEqual(applied.spec!.template)expect(rejectedCondition(lifecycleStatusWrites(customApi).at(-1)!).reason).toBe(@@ -1010,10 +1010,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {await reconciler.reconcile(host)- expect(provision).toHaveBeenCalledWith(host, {- forceFreshForWake: false,- targetSuspended: true,- })+ expect(provision).not.toHaveBeenCalled()expect(live().spec!.replicas).toBe(0)expect(live().spec!.template).toEqual(applied.spec!.template)expect(lifecycleStatusWrites(customApi).at(-1)?.lifecycle).toMatchObject({@@ -1035,10 +1032,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {.spyOn(reconciler as any, 'provisionRuntimeTokenRevision').mockResolvedValue(runtimeTokenProvision(host))await reconciler.reconcile(host)- expect(provision).toHaveBeenCalledWith(host, {- forceFreshForWake: true,- targetSuspended: false,- })+ expect(provision).not.toHaveBeenCalled()expect(appsApi.patchNamespacedDeployment).not.toHaveBeenCalled()expect(live().spec!.replicas).toBe(1)expect(live().spec!.template).toEqual(applied.spec!.template)@@ -1199,7 +1193,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {await reconciler.reconcile(host)expect(networkingApi.readNamespacedNetworkPolicy).toHaveBeenCalled()- expect(provision).toHaveBeenCalledOnce()+ expect(provision).not.toHaveBeenCalled()const deployment = live()expect(deployment.spec?.replicas).toBe(0)expect(envValue(deployment, 'CLERUM_STATELESS_LIFECYCLE')).toBe('true')@@ -1476,7 +1470,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {expect(provision).toHaveBeenCalledOnce()})- it('refreshes runtime credentials for active cache loss without changing replicas', async () => {+ it('preserves runtime credentials during active cache loss without changing replicas', async () => {let cacheSynced = trueconst { reconciler, appsApi, customApi, networkingApi } = createReconciler({isCommunicationChannelCacheSynced: () => cacheSynced,@@ -1498,7 +1492,7 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {await reconciler.reconcile(host)expect(networkingApi.readNamespacedNetworkPolicy).toHaveBeenCalled()- expect(provision).toHaveBeenCalledOnce()+ expect(provision).not.toHaveBeenCalled()const deployment = live()expect(deployment.spec?.replicas).toBe(1)expect(envValue(deployment, 'CLERUM_STATELESS_LIFECYCLE')).toBe('true')diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.jsonindex ec06f26a3..ff5167503 100644--- a/rpc-proxy/package-lock.json+++ b/rpc-proxy/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-rpc-proxy",- "version": "0.1.97",+ "version": "0.1.98","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-rpc-proxy",- "version": "0.1.97",+ "version": "0.1.98","dependencies": {"cors": "^2.8.5","express": "^4.21.2",diff --git a/rpc-proxy/package.json b/rpc-proxy/package.jsonindex e2c973b6a..10f1bbbd8 100644--- a/rpc-proxy/package.json+++ b/rpc-proxy/package.json@@ -1,6 +1,6 @@{"name": "clerum-rpc-proxy",- "version": "0.1.97",+ "version": "0.1.98","description": "External-facing RPC proxy for tenant-scoped MCP access","main": "dist/main.js","engines": {diff --git a/rpc-proxy/src/__tests__/approval-artifacts.test.ts b/rpc-proxy/src/__tests__/approval-artifacts.test.tsindex b3d9accf9..24cd5d5c4 100644--- a/rpc-proxy/src/__tests__/approval-artifacts.test.ts+++ b/rpc-proxy/src/__tests__/approval-artifacts.test.ts@@ -490,7 +490,8 @@ describe('POST /rpc/hosts/:hostRef/tasks/:taskId/cancel', () => {expect(serviceMock.forwardCancelToHost).toHaveBeenCalledWith(expect.objectContaining({ name: 'chatllm' }),'abc',- VALID_CLAIMS.sub+ VALID_CLAIMS.sub,+ expect.anything())})diff --git a/rpc-proxy/src/routes/rpc.ts b/rpc-proxy/src/routes/rpc.tsindex f6bed2a6e..75e764723 100644--- a/rpc-proxy/src/routes/rpc.ts+++ b/rpc-proxy/src/routes/rpc.ts@@ -625,11 +625,12 @@ export function createRpcRouter(): Router {// host:approval:write; wake capability rides on the token. A suspended// (network-down) or draining Host triggers a wake-and-hold instead of a// bare next(error)/passthrough.- const attempt = async () => {+ const attempt = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(`${baseUrl}/v1/runtime/approvals/approve`, {method: 'POST',headers: { 'content-type': 'application/json', ...host.headers },body: JSON.stringify(upstreamBody),+ signal: AbortSignal.timeout(timeoutMs),})const body = await response.text()const draining = sessionDrainingFence(response, body)@@ -688,11 +689,12 @@ export function createRpcRouter(): Router {requestId: parsed.toolCallId || parsed.requestId,}// Wake-eligible finite operation (§11.4): scope stays host:approval:write.- const attempt = async () => {+ const attempt = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(`${baseUrl}/v1/runtime/approvals/deny`, {method: 'POST',headers: { 'content-type': 'application/json', ...host.headers },body: JSON.stringify(upstreamBody),+ signal: AbortSignal.timeout(timeoutMs),})const body = await response.text()const draining = sessionDrainingFence(response, body)@@ -771,11 +773,11 @@ export function createRpcRouter(): Router {// host:session:read; wake capability rides on the token. A suspended// (network-down) or draining Host triggers a wake-and-hold instead of a// bare next(error)/passthrough.- const forwardSessionList = async () => {+ const forwardSessionList = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(upstreamUrl, {method: 'GET',headers: { ...host.headers },- signal: AbortSignal.timeout(config.upstreamTimeoutMs),+ signal: AbortSignal.timeout(timeoutMs),})const body = await response.text()const draining = sessionDrainingFence(response, body)@@ -872,11 +874,11 @@ export function createRpcRouter(): Router {`[RPC_PROXY] user=${auth.sub} host=${hostRef} method=get-session-messages agent=${agent} chatId=${chatId}`)// Wake-eligible finite operation (§11.4): scope stays host:session:read.- const forwardTranscript = async () => {+ const forwardTranscript = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(upstreamUrl, {method: 'GET',headers: { ...host.headers },- signal: AbortSignal.timeout(config.upstreamTimeoutMs),+ signal: AbortSignal.timeout(timeoutMs),})const body = await response.text()const draining = sessionDrainingFence(response, body)@@ -945,13 +947,13 @@ export function createRpcRouter(): Router {`[RPC_PROXY] user=${auth.sub} host=${hostRef} method=get-context-breakdown agent=${agent} chatId=${chatId}`)// Wake-eligible finite operation (§11.4): scope stays host:session:read.- const attempt = async () => {+ const attempt = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(`${baseUrl}/v1/runtime/sessions/${encodeURIComponent(agent)}/${encodeURIComponent(chatId)}/context-breakdown`,{method: 'GET',headers: { ...host.headers },- signal: AbortSignal.timeout(config.upstreamTimeoutMs),+ signal: AbortSignal.timeout(timeoutMs),})const body = await response.text()@@ -1094,11 +1096,11 @@ export function createRpcRouter(): Router {: `${baseUrl}/v1/runtime/models`console.info(`[RPC_PROXY] user=${auth.sub} host=${hostRef} method=list-models`)// Wake-eligible finite operation (§11.4): scope stays host:session:read.- const attempt = async () => {+ const attempt = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(upstreamUrl, {method: 'GET',headers: { ...host.headers },- signal: AbortSignal.timeout(config.upstreamTimeoutMs),+ signal: AbortSignal.timeout(timeoutMs),})const body = await response.text()const draining = sessionDrainingFence(response, body)@@ -1160,11 +1162,12 @@ export function createRpcRouter(): Router {const baseUrl = host.url.replace(/\/+$/, '')console.info(`[RPC_PROXY] user=${auth.sub} host=${hostRef} method=set-model`)// Wake-eligible finite operation (§11.4): scope stays host:model:write.- const attempt = async () => {+ const attempt = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(`${baseUrl}/v1/runtime/model`, {method: 'POST',headers: { 'content-type': 'application/json', ...host.headers },body: JSON.stringify(body),+ signal: AbortSignal.timeout(timeoutMs),})const upstreamBody = await response.text()const draining = sessionDrainingFence(response, upstreamBody)@@ -1224,8 +1227,8 @@ export function createRpcRouter(): Router {console.info(`[RPC_PROXY] user=${auth.sub} host=${hostRef} method=get-task-result taskId=${taskId}`)- const attemptTaskResult = async () => {- const result = await forwardTaskResultFromHost(host, taskId)+ const attemptTaskResult = async (timeoutMs = config.upstreamTimeoutMs) => {+ const result = await forwardTaskResultFromHost(host, taskId, timeoutMs)if (!result) {res.status(404).json({ error: 'Task result not found' })return@@ -1292,8 +1295,8 @@ export function createRpcRouter(): Router {`[RPC_PROXY] user=${auth.sub} host=${hostRef} method=cancel-task taskId=${taskId}`)- const attemptCancel = async () => {- const result = await forwardCancelToHost(host, taskId, auth.sub)+ const attemptCancel = async (timeoutMs = config.upstreamTimeoutMs) => {+ const result = await forwardCancelToHost(host, taskId, auth.sub, timeoutMs)if (result.body) {res.status(result.status)@@ -1359,9 +1362,10 @@ export function createRpcRouter(): Router {}const baseUrl = host.url.replace(/\/+$/, '')// Wake-eligible finite operation (§11.4): scope stays host:task:read.- const attempt = async () => {+ const attempt = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(`${baseUrl}/v1/runtime/artifacts`, {headers: { ...host.headers },+ signal: AbortSignal.timeout(timeoutMs),})const body = await response.text()const draining = sessionDrainingFence(response, body)@@ -1428,11 +1432,12 @@ export function createRpcRouter(): Router {// Wake-eligible finite operation (§11.4): scope stays host:task:read.// The success path only commits (`res.send`) at the very end, so a// wake retry before that point is safe from duplicate delivery.- const attemptDownload = async () => {+ const attemptDownload = async (timeoutMs = config.upstreamTimeoutMs) => {const response = await fetch(`${baseUrl}/v1/runtime/artifacts/${encodeURIComponent(filename)}/download`,{headers: { ...host.headers },+ signal: AbortSignal.timeout(timeoutMs),})if (!response.ok) {diff --git a/rpc-proxy/src/services/mcpHostRestService.ts b/rpc-proxy/src/services/mcpHostRestService.tsindex 8646c6263..48a197389 100644--- a/rpc-proxy/src/services/mcpHostRestService.ts+++ b/rpc-proxy/src/services/mcpHostRestService.ts@@ -179,11 +179,12 @@ export async function forwardHostMessageToHost(export async function forwardTaskResultFromHost(host: ResolvedServerConnection,- taskId: string+ taskId: string,+ timeoutMs = config.upstreamTimeoutMs): Promise<Record<string, unknown> | null> {const baseUrl = host.url.replace(/\/+$/, '')const abortController = new AbortController()- const timeout = setTimeout(() => abortController.abort(), config.upstreamTimeoutMs)+ const timeout = setTimeout(() => abortController.abort(), timeoutMs)try {const response = await fetch(`${baseUrl}/v1/runtime/tasks/${encodeURIComponent(taskId)}/result`,@@ -222,11 +223,12 @@ export type CancelUpstreamResult = {export async function forwardCancelToHost(host: ResolvedServerConnection,taskId: string,- userId?: string+ userId?: string,+ timeoutMs = config.upstreamTimeoutMs): Promise<CancelUpstreamResult> {const baseUrl = host.url.replace(/\/+$/, '')const abortController = new AbortController()- const timeout = setTimeout(() => abortController.abort(), config.upstreamTimeoutMs)+ const timeout = setTimeout(() => abortController.abort(), timeoutMs)// Mirrors the approve/deny pattern: always forward userId so mcp-host can// apply the ownership check. Falls back to 'desktop-app' when absent.const upstreamBody = { userId: userId || 'desktop-app' }