Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test: make the silence guards fail when they are removed
Jose Ramirez96fc538d485b
diff --git a/channel-reader/package-lock.json b/channel-reader/package-lock.jsonindex 447c2a445..6fc4b35a5 100644--- a/channel-reader/package-lock.json+++ b/channel-reader/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-channel-reader",- "version": "0.1.90",+ "version": "0.1.91","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-channel-reader",- "version": "0.1.90",+ "version": "0.1.91","license": "SEE LICENSE IN LICENSE","dependencies": {"@kubernetes/client-node": "^1.0.0",diff --git a/channel-reader/package.json b/channel-reader/package.jsonindex 32c356b42..d3d1885d0 100644--- a/channel-reader/package.json+++ b/channel-reader/package.json@@ -1,6 +1,6 @@{"name": "clerum-channel-reader",- "version": "0.1.90",+ "version": "0.1.91","description": "Watches CommunicationChannel CRDs and fetches messages from Telegram, Email, and Slack","main": "dist/main.js","engines": {diff --git a/channel-reader/test/unresolvedSenderNotice.test.ts b/channel-reader/test/unresolvedSenderNotice.test.tsindex 151e65d2d..2d2eab4d5 100644--- a/channel-reader/test/unresolvedSenderNotice.test.ts+++ b/channel-reader/test/unresolvedSenderNotice.test.ts@@ -39,10 +39,18 @@ describe('authorizeProviderMessage response shape', () => {})})+ // The body is deliberately a WELL-FORMED unresolved payload. An unparseable+ // body would exercise the catch path instead, which returns the same shape, so+ // the assertion would hold with the `!response.ok` guard deleted. Only a+ // parseable `reason: 'unresolved'` on a non-2xx proves the status is what+ // suppresses the reason.it('returns no reason when the response is not ok, so callers stay silent', async () => {vi.stubGlobal('fetch',- vi.fn(async () => new Response('nope', { status: 503 }))+ vi.fn(+ async () =>+ new Response(JSON.stringify({ authorized: false, reason: 'unresolved' }), { status: 503 })+ ))const client = new RPCClient('http://mcp-host.test')expect(await client.authorizeProviderMessage(identity as never)).toEqual({ authorized: false })diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 569d33be4..db7f63476 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.235",+ "version": "0.1.236","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.235",+ "version": "0.1.236","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 77575d6ee..e3f15e2b6 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.235",+ "version": "0.1.236","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__/providerMessageAuthorization.handler.test.ts b/mcp-host/src/__tests__/providerMessageAuthorization.handler.test.tsindex bc32340dc..ea658934a 100644--- a/mcp-host/src/__tests__/providerMessageAuthorization.handler.test.ts+++ b/mcp-host/src/__tests__/providerMessageAuthorization.handler.test.ts@@ -45,4 +45,28 @@ describe('handleProviderMessageAuthorization', () => {reason: 'error',})})++ // A null context is not a thrown broker failure, so classifyAuthorizationFailure+ // never sees it and its reason is hardcoded. 'error' keeps channel-reader silent:+ // we have no 404/403 substantiating "this account is unlinked", so we must not+ // claim it.+ it('reports a null caller context as authorized:false, reason:error', async () => {+ vi.mocked(resolveProviderWorkflowCallerContext).mockResolvedValueOnce(null)++ await expect(handleProviderMessageAuthorization({ providerIdentity })).resolves.toEqual({+ authorized: false,+ reason: 'error',+ })+ })++ it('reports a context with no targetUserId as authorized:false, reason:error', async () => {+ vi.mocked(resolveProviderWorkflowCallerContext).mockResolvedValueOnce({+ targetUserId: '',+ } as never)++ await expect(handleProviderMessageAuthorization({ providerIdentity })).resolves.toEqual({+ authorized: false,+ reason: 'error',+ })+ })})diff --git a/mcp-host/src/__tests__/providerMessageAuthorization.reason.test.ts b/mcp-host/src/__tests__/providerMessageAuthorization.reason.test.tsindex a79855faa..79a1bb541 100644--- a/mcp-host/src/__tests__/providerMessageAuthorization.reason.test.ts+++ b/mcp-host/src/__tests__/providerMessageAuthorization.reason.test.ts@@ -33,4 +33,22 @@ describe('classifyAuthorizationFailure', () => {const err = new WorkflowBrokerRequestError(404, 'something_else', 'nope')expect(classifyAuthorizationFailure(err)).toBe('error')})++ // The status check carries its own weight: a whitelisted code can ride along on+ // a non-404/403 body (a control-api 5xx error wrapper, a gateway 502 echoing+ // upstream). Without the status guard those classify 'unresolved' and tell+ // linked users they are unlinked for the length of an outage.+ it('maps a 500 carrying a whitelisted code to error', () => {+ const err = new WorkflowBrokerRequestError(500, 'medium_account_not_found', 'boom')+ expect(classifyAuthorizationFailure(err)).toBe('error')+ })++ it('maps a 502 carrying a whitelisted code to error', () => {+ const err = new WorkflowBrokerRequestError(+ 502,+ 'communication_channel_access_denied',+ 'gateway'+ )+ expect(classifyAuthorizationFailure(err)).toBe('error')+ })})