Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop-ui): use IPC-shaped 403 fixtures with same-scope controls
Alfredo Lopez777278c0f264
diff --git a/desktop-app/ui/src/contexts/AgentTaskTrackerContext/__tests__/taskTracker.test.ts b/desktop-app/ui/src/contexts/AgentTaskTrackerContext/__tests__/taskTracker.test.tsindex 85bd52f64..79dc253d2 100644--- a/desktop-app/ui/src/contexts/AgentTaskTrackerContext/__tests__/taskTracker.test.ts+++ b/desktop-app/ui/src/contexts/AgentTaskTrackerContext/__tests__/taskTracker.test.ts@@ -5,7 +5,6 @@ import {ipcGenericForbidden,ipcHostAccessDenied,ipcHostAccessRevoked,- ipcHostWaking,ipcHttpError,ipcServerErrorMentioning403,} from '../../../hooks/domain/__tests__/__fixtures__/ipcErrors'@@ -215,7 +214,14 @@ describe('TaskTracker', () => {],['waking Host named support-401',- async () => ipcHostWaking('rpc:getTaskResult', 'support-401'),+ // getTaskResult does not map a waking Host (only the send path does), so+ // the renderer sees rpc-proxy's raw structured 503.+ () =>+ ipcHttpError('rpc:getTaskResult', 503, 'Service Unavailable', {+ code: 'host_waking',+ hostRef: 'support-401',+ retryAfterMs: 2000,+ }),'result_fetch',undefined,],diff --git a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/ipcErrors.ts b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/ipcErrors.tsindex e36d59d36..839225543 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/ipcErrors.ts+++ b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/ipcErrors.ts@@ -1,5 +1,9 @@import { ApiError } from '../../../../../../src/httpClient'import { RpcProxyClient } from '../../../../../../src/rpcProxyClient'+import {+ HOST_ACCESS_DENIED_CODE,+ HOST_ACCESS_REVOKED_CODE,+} from '../../../../../../src/upstreamErrors'/*** Renderer-side error fixtures built from the REAL main-process producers.@@ -95,7 +99,7 @@ export async function ipcHostAccessRevoked(channel: RpcChannel): Promise<Error>const error = await rejectionOf(jsonResponse(403, 'Forbidden', {error: HOST_ACCESS_DENIAL_ERROR,- code: 'host_access_revoked',+ code: HOST_ACCESS_REVOKED_CODE,}),callFor(channel))@@ -110,7 +114,7 @@ export async function ipcHostAccessDenied(channel: RpcChannel): Promise<Error> {const error = await rejectionOf(jsonResponse(403, 'Forbidden', {error: HOST_ACCESS_DENIAL_ERROR,- code: 'host_access_denied',+ code: HOST_ACCESS_DENIED_CODE,}),callFor(channel))@@ -155,8 +159,10 @@ export function ipcServerErrorMentioning403(channel: RpcChannel): Promise<Error>* name contains a status-looking number (R1-M16: `support-401 is waking`).* `AppService` pulls in Electron main-process modules, so the mapping's text* is reproduced here; `appService.hostWaking.test.ts` pins the producer side.+ * Only the Host send path maps a waking Host to this text (R3-L15); every other+ * channel surfaces the raw 503, so build those with `ipcHttpError`.*/-export function ipcHostWaking(channel: RpcChannel, hostRef: string): Error {+export function ipcHostWaking(channel: 'rpc:invokeHostMessage', hostRef: string): Error {const cause = new ApiError('503 Service Unavailable: Host is waking up',503,diff --git a/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsxindex de8f0522f..68bc0b786 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/chatListTitleMerge.test.tsx@@ -538,7 +538,17 @@ describe('revoked host catalog protection', () => {})describe('host authority verification', () => {- it('discards a pre-verification authorization denial after the host authority epoch advances', async () => {+ // R3-M3: the epoch negative and its same-epoch control share one IPC-shaped+ // revocation (never retried, so it reaches the classifier directly); the+ // control proves the denial holds the Host when the epoch does not advance.+ it.each([+ [+ 'discards a pre-verification authorization denial after the host authority epoch advances',+ 1,+ false,+ ],+ ['holds the Host on a catalog denial when the host authority epoch is unchanged', 0, true],+ ] as const)('%s', async (_label, epochAdvance, expectedRevoked) => {let hostAuthorityEpoch = 0const revoked = new Set<string>()const uncertain = new Set<string>()@@ -562,11 +572,15 @@ describe('host authority verification', () => {getHostAuthorityEpoch: () => hostAuthorityEpoch,})+ const denial = await ipcHostAccessRevoked('rpc:listSessions')await waitFor(() => expect(clerum.rpc.listSessions).toHaveBeenCalled())- hostAuthorityEpoch += 1- rejectFirst(new Error('403 stale'))+ hostAuthorityEpoch += epochAdvance+ rejectFirst(denial)await waitFor(() => expect(controller.result.current.latestChatSessionsLoading).toBe(false))- expect(revoked.has('agent-x')).toBe(false)+ await act(async () => {+ await new Promise(resolve => setTimeout(resolve, 20))+ })+ expect(revoked.has('agent-x')).toBe(expectedRevoked)expect(uncertain.has('agent-x')).toBe(false)})})@@ -602,7 +616,9 @@ describe('late global catalog response', () => {)if (action === 'revocation') {- clerum.rpc.loadSessionMessages.mockRejectedValue(new Error('403 forbidden'))+ clerum.rpc.loadSessionMessages.mockRejectedValue(+ await ipcHostAccessRevoked('rpc:loadSessionMessages')+ )await act(async () => {await controller.result.current.reconcileChat(makeTaskKey('agent-a', 'session-a'), {reason: 'background_refresh',diff --git a/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.unified.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.unified.test.tsxindex c8f1ddb66..3439f2903 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.unified.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/switchToChat.unified.test.tsx@@ -1267,7 +1267,13 @@ describe('switchToChat (unified, D.4)', () => {])})- it('ignores a send 403 from the prior team scope', async () => {+ // R3-M3: the scope-change negative and its same-scope control share one+ // IPC-shaped revocation, so the control proves the classifier fires when the+ // team does not change and the negative cannot pass by never classifying.+ it.each([+ ['ignores a send 403 from the prior team scope', 'team-after', false],+ ['holds the Host on a send 403 within the same team scope', 'team-before', true],+ ] as const)('%s', async (_label, teamAtRejection, expectedRevoked) => {const revoked = new Set<string>()let rejectSend!: (reason: unknown) => voidclerum.rpc.invokeHostMessage.mockImplementation(@@ -1287,14 +1293,15 @@ describe('switchToChat (unified, D.4)', () => {await controller.result.current.switchToChat('agent-x', 'old-team-chat')})+ const denial = await ipcHostAccessRevoked('rpc:invokeHostMessage')const pendingSend = controller.result.current.handleSendAgentMessage('hello')await waitFor(() => expect(clerum.rpc.invokeHostMessage).toHaveBeenCalledTimes(1))- controller.rerender({ currentTeamId: 'team-after' })+ controller.rerender({ currentTeamId: teamAtRejection })await act(async () => {- rejectSend(new Error('403 forbidden'))+ rejectSend(denial)await pendingSend})- expect(revoked.has('agent-x')).toBe(false)+ expect(revoked.has('agent-x')).toBe(expectedRevoked)})it('ignores an older-message 403 from the prior team scope', async () => {@@ -1333,11 +1340,12 @@ describe('switchToChat (unified, D.4)', () => {await act(async () => {await controller.result.current.switchToChat('agent-x', 'old-team-chat')})+ const denial = await ipcGenericForbidden('rpc:loadSessionMessages')const pendingOlder = controller.result.current.handleLoadOlderMessages()await waitFor(() => expect(rejectOlder).toEqual(expect.any(Function)))controller.rerender({ currentTeamId: 'team-after' })await act(async () => {- rejectOlder(new Error('403 forbidden'))+ rejectOlder(denial)await pendingOlder})expect(revoked.has('agent-x')).toBe(false)@@ -1419,7 +1427,9 @@ describe('switchToChat (unified, D.4)', () => {await waitFor(() => expect(clerum.rpc.getTaskResult).toHaveBeenCalledTimes(1))if (action === 'revocation') {- clerum.rpc.loadSessionMessages.mockRejectedValue(new Error('403 forbidden'))+ clerum.rpc.loadSessionMessages.mockRejectedValue(+ await ipcHostAccessRevoked('rpc:loadSessionMessages')+ )await act(async () => {await controller.result.current.reconcileChat(makeTaskKey('agent-x', 'late-result'), {reason: 'authority_refresh',