Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(deploy): pin the 35 MiB Grok visual envelope on authorize and the proxy
Alfredo Lopezff8a3daece88
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 404ca1cdf..c0d3f00d5 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.635",+ "version": "0.1.636","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.635",+ "version": "0.1.636","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex 3199e881b..7bab7053e 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.635",+ "version": "0.1.636","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/test/deploy.llmAuthorizeBodyLimit.test.ts b/control-api/test/deploy.llmAuthorizeBodyLimit.test.tsindex 2318d6228..00220ad83 100644--- a/control-api/test/deploy.llmAuthorizeBodyLimit.test.ts+++ b/control-api/test/deploy.llmAuthorizeBodyLimit.test.ts@@ -33,11 +33,15 @@ describe('LLM authorize route body limit (#731 R3-3)', () => {expect(block.match(/client_max_body_size/g)).toHaveLength(1)// Without the directive nginx applies its 1m default and refuses a// contract-valid request before control-api sees it. The same directive- // also carries the Codex V2 visual envelope (#660), so it is the larger of- // the two budgets.+ // also carries the Codex (#660) and Grok (#784) V2 visual envelopes, so it+ // is the largest of the three budgets.const cap = Math.max(CODEX_LIMITS.maxRequestBodyBytes, GROK_LIMITS.maxRequestBodyBytes)expect(Number(directive![1])).toBe(- Math.max(cap + AUTHORIZE_ENVELOPE_ALLOWANCE_BYTES, CODEX_LIMITS.maxVisualRequestBodyBytes)+ Math.max(+ cap + AUTHORIZE_ENVELOPE_ALLOWANCE_BYTES,+ CODEX_LIMITS.maxVisualRequestBodyBytes,+ GROK_LIMITS.maxVisualRequestBodyBytes+ ))expect(Number(directive![1])).toBeGreaterThanOrEqual(cap + AUTHORIZE_ENVELOPE_ALLOWANCE_BYTES)})diff --git a/control-api/test/network.gateway.intent.test.ts b/control-api/test/network.gateway.intent.test.tsindex e142493cf..897b75717 100644--- a/control-api/test/network.gateway.intent.test.ts+++ b/control-api/test/network.gateway.intent.test.ts@@ -369,14 +369,14 @@ describe('network/gateway intent (manifest-level)', () => {expect(gatewayConf).not.toContain('/api/v1/external/')})- it('keeps the Codex authorize route at the 24MiB visual envelope', () => {+ it('keeps the shared authorize route at the 35MiB Grok visual envelope', () => {const configmaps = read(`${BASE}/control-plane/configmaps.yaml`)const gatewayConf = docContaining(yamlDocs(configmaps), 'name: nginx-workflow-approval-gateway')const authorize = locationBlock(gatewayConf,'location = /api/v1/mcp-host/llm/provider-attempts/authorize')- expect(authorize).toContain('client_max_body_size 25165824;')+ expect(authorize).toContain('client_max_body_size 36700160;')expect(gatewayConf.match(/client_max_body_size/g)).toHaveLength(1)})@@ -388,6 +388,14 @@ describe('network/gateway intent (manifest-level)', () => {expect(proxy).toContain('CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES: "25165824"')})+ it('pins the shipped Grok proxy visual envelope to 35MiB', () => {+ const proxy = read(`${BASE}/control-plane/grok-llm-proxy.yaml`)+ // #731: the ordinary body limit is derived from the contract cap plus the+ // envelope allowance, so the manifest must not pin it to a literal.+ expect(proxy).not.toMatch(/^\s*GROK_LLM_PROXY_MAX_BODY_BYTES:/m)+ expect(proxy).toContain('GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES: "36700160"')+ })+it('keeps the profile-control-funnel body cap at gfsc write-cap parity (24MiB)', () => {const configmaps = read(`${BASE}/profiles/configmaps.yaml`)const funnelConf = docContaining(yamlDocs(configmaps), 'name: profile-control-funnel-nginx')diff --git a/control-api/test/routes.mcp-host.llmProviderAttempts.createApp.test.ts b/control-api/test/routes.mcp-host.llmProviderAttempts.createApp.test.tsindex 36a0b11b7..8228470e7 100644--- a/control-api/test/routes.mcp-host.llmProviderAttempts.createApp.test.ts+++ b/control-api/test/routes.mcp-host.llmProviderAttempts.createApp.test.ts@@ -59,7 +59,7 @@ describe('createApp POST /api/v1/mcp-host/llm/provider-attempts/authorize', () =vi.mocked(authorizer.authorizeLlmProviderAttempt).mockReset()})- it('returns 401 for an unauthenticated body over 24 MiB without calling authorize', async () => {+ it('returns 401 for an unauthenticated body over 35 MiB without calling authorize', async () => {const { createApp } = await import('../src/app.js')const app = createApp(new MockGateway() as never)const listener = createServer(app).listen(0)@@ -71,7 +71,8 @@ describe('createApp POST /api/v1/mcp-host/llm/provider-attempts/authorize', () ={method: 'POST',headers: { 'content-type': 'application/json' },- body: `{"pad":"${'x'.repeat(25 * 1024 * 1024)}"}`,+ // One byte past the shared 35 MiB (Grok) visual envelope (#784).+ body: `{"pad":"${'x'.repeat(36700160 + 1 - '{"pad":""}'.length)}"}`,})expect(oversized.status).toBe(401)diff --git a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts b/control-api/test/routes.mcp-host.llmProviderAttempts.test.tsindex 9760e36a2..444d8b1d1 100644--- a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts+++ b/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts@@ -2,6 +2,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'import express from 'express'import { createServer } from 'node:http'import request from 'supertest'+import { LIMITS as GROK_LIMITS } from '@clerum/grok-provider-attempt-contract'+import { LIMITS as CODEX_LIMITS } from '@clerum/llm-provider-attempt-contract'import {createMcpHostLlmProviderAttemptRoutes,resolveHostAssignedAssignment,@@ -105,26 +107,36 @@ describe('POST /api/v1/mcp-host/llm/provider-attempts/authorize', () => {}})- it('returns 413 for an authenticated body over the 24 MiB visual envelope', async () => {+ it('returns 413 for an authenticated body one byte over the 35 MiB Grok visual envelope', async () => {const app = buildApp()const listener = createServer(app).listen(0)+ // The shared route parser admits the larger of the two visual envelopes (#784).+ const limit = Math.max(+ CODEX_LIMITS.maxVisualRequestBodyBytes,+ GROK_LIMITS.maxVisualRequestBodyBytes+ )+ expect(limit).toBe(36700160)+ /** A JSON body of exactly `bytes` bytes. */+ const bodyOf = (bytes: number) => `{"pad":"${'x'.repeat(bytes - '{"pad":""}'.length)}"}`try {const address = listener.address()if (!address || typeof address === 'string') throw new Error('listener has no port')- const oversized = await fetch(- `http://127.0.0.1:${address.port}/api/v1/mcp-host/llm/provider-attempts/authorize`,- {- method: 'POST',- headers: {- Authorization: `Bearer ${token()}`,- 'content-type': 'application/json',- },- body: `{"pad":"${'x'.repeat(25 * 1024 * 1024)}"}`,- }- )+ const url = `http://127.0.0.1:${address.port}/api/v1/mcp-host/llm/provider-attempts/authorize`+ const headers = {+ Authorization: `Bearer ${token(['llm:grok:execute'])}`,+ 'content-type': 'application/json',+ }+ const oversized = await fetch(url, { method: 'POST', headers, body: bodyOf(limit + 1) })expect(oversized.status).toBe(413)expect(await oversized.json()).toEqual({ error: 'payload_too_large' })expect(authorizer.authorizeLlmProviderAttempt).not.toHaveBeenCalled()+ // Witness: a body at the limit passes the parser and reaches the authorizer.+ vi.mocked(authorizer.authorizeLlmProviderAttempt).mockRejectedValueOnce(+ new LlmProviderAttemptAuthorizeError('invalid_request', 'fixture body')+ )+ const atLimit = await fetch(url, { method: 'POST', headers, body: bodyOf(limit) })+ expect(atLimit.status).toBe(400)+ expect(authorizer.authorizeLlmProviderAttempt).toHaveBeenCalledTimes(1)} finally {await new Promise<void>((resolve, reject) =>listener.close(err => (err ? reject(err) : resolve()))diff --git a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh b/scripts/tests/test-grok-llm-proxy-deploy-contract.shindex e80a0d7f5..a6d777fae 100755--- a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh+++ b/scripts/tests/test-grok-llm-proxy-deploy-contract.sh@@ -151,6 +151,12 @@ if 'GROK_LLM_PROXY_EXECUTION_ENABLED: "false"' not in text:# allowance; a literal in base would freeze it at a stale value.if "GROK_LLM_PROXY_MAX_BODY_BYTES" in text:errors.append("base grok-llm-proxy config must not set GROK_LLM_PROXY_MAX_BODY_BYTES")+# The visual limit equals the Grok contract's maxVisualRequestBodyBytes (35 MiB,+# no allowance on top), as the Codex proxy pins its own (#784).+if 'GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES: "36700160"' not in text:+ errors.append('base grok-llm-proxy config must set GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES: "36700160"')+if 'client_max_body_size 36700160;' not in cm:+ errors.append("workflow-approval gateway authorize route must allow the 35 MiB Grok visual envelope")wrc_disabled = re.compile(r'- name: WRC_GROK_SUBSCRIPTION_ENABLED\n\s+value: "false"\n')if not wrc_disabled.search(active(manifest.parent / "workflow-recipes.yaml")):errors.append("base workflow-recipes must keep Grok subscriptions disabled")diff --git a/tests/e2e/integration/codex-subscription-contract-freeze.test.ts b/tests/e2e/integration/codex-subscription-contract-freeze.test.tsindex fe8f42b53..48ec14513 100644--- a/tests/e2e/integration/codex-subscription-contract-freeze.test.ts+++ b/tests/e2e/integration/codex-subscription-contract-freeze.test.ts@@ -34,7 +34,7 @@ it('admits visual authorization envelopes only on the exact gateway route', () =const route = gateway.match(/location = \/api\/v1\/mcp-host\/llm\/provider-attempts\/authorize \{([\s\S]*?)\n \}/)?.[1]- expect(route).toContain('client_max_body_size 25165824;')+ expect(route).toContain('client_max_body_size 36700160;')expect(route).toMatch(/limit_except POST\s*\{\s*deny all;/)expect(route).toContain('proxy_set_header Authorization $http_authorization;')expect(route).toContain('proxy_pass http://control_api_upstream;')diff --git a/tests/e2e/package-lock.json b/tests/e2e/package-lock.jsonindex 3e074b47d..c4e9efb72 100644--- a/tests/e2e/package-lock.json+++ b/tests/e2e/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-e2e-tests",- "version": "0.1.96",+ "version": "0.1.97","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-e2e-tests",- "version": "0.1.96",+ "version": "0.1.97","devDependencies": {"@clerum/llm-provider-attempt-contract": "file:../../packages/llm-provider-attempt-contract","@types/jsonwebtoken": "^9.0.10",diff --git a/tests/e2e/package.json b/tests/e2e/package.jsonindex 125b1df5d..e3c2c5a98 100644--- a/tests/e2e/package.json+++ b/tests/e2e/package.json@@ -1,6 +1,6 @@{"name": "clerum-e2e-tests",- "version": "0.1.96",+ "version": "0.1.97","private": true,"type": "module","scripts": {