Skip to content

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

TypeScript

test(llm-proxy): close historical admission coverage gaps

Alfredo Lopez4044848ed42a
diff --git a/codex-llm-proxy/test/server.security.test.ts b/codex-llm-proxy/test/server.security.test.ts
index e81c3e065..ba6407aa2 100644
--- a/codex-llm-proxy/test/server.security.test.ts
+++ b/codex-llm-proxy/test/server.security.test.ts
@@ -263,15 +263,18 @@ describe('codex-llm-proxy security surface', () => {
// A V2 body pushed past the ordinary cap by its ticket and one small image
// takes the visual gate, is refused at the schema, and frees its slot.
const acquire = vi.spyOn(visualStreamGate, 'acquire')
- const visual = await send('x'.repeat(8_000_000), {
- schemaVersion: 'codex-completion-request.v2',
- messages: [{ role: 'user', contentParts: [{ type: 'image', data: 'A'.repeat(1024 * 1024) }] }],
- })
- expect(visual.status).toBe(400)
- expect(visual.body.error).toBe('invalid_request')
- expect(acquire).toHaveBeenCalledTimes(1)
- expect(visualStreamGate.snapshot()).toEqual({ running: 0, queued: 0 })
- acquire.mockRestore()
+ try {
+ const visual = await send('x'.repeat(8_000_000), {
+ schemaVersion: 'codex-completion-request.v2',
+ messages: [{ role: 'user', contentParts: [{ type: 'image', data: 'A'.repeat(1024 * 1024) }] }],
+ })
+ expect(visual.status).toBe(400)
+ expect(visual.body.error).toBe('invalid_request')
+ expect(acquire).toHaveBeenCalledTimes(1)
+ expect(visualStreamGate.snapshot()).toEqual({ running: 0, queued: 0 })
+ } finally {
+ acquire.mockRestore()
+ }
}, 30_000)
it('answers a transport payload_too_large with HTTP 413 before any SSE byte', async () => {
@@ -2455,6 +2458,58 @@ describe('codex-llm-proxy ticket-aware stream-gate wait (#739 D1-bis)', () => {
warn.mockRestore()
}
}, 30_000)
+
+ // r11-L13: Codex had the negative aborted-waiter witness, but no positive
+ // overflow witness naming gate saturation. Grok already pins this twin; the
+ // queue is filled directly so the refusal under test is the global visual
+ // gate, not the per-principal share.
+ it('visual admission overflow answers 503 provider_unavailable and logs visual_gate', async () => {
+ const warn = vi.spyOn(logger, 'warn')
+ const held: Array<() => void> = []
+ const waiting: Array<Promise<() => void>> = []
+ try {
+ for (let i = 0; i < VISUAL_STREAM_LIMITS.maxConcurrentStreams; i += 1) {
+ held.push(await visualStreamGate.acquire())
+ }
+ for (let i = 0; i < VISUAL_STREAM_LIMITS.maxQueuedRequests; i += 1) {
+ const acquired = visualStreamGate.acquire()
+ acquired.catch(() => {})
+ waiting.push(acquired)
+ }
+ const control = countingClient('granted')
+ const apps = createProxyApps(config({ maxBodyBytes: 65_536 }), {
+ controlApiClient: control.client,
+ fetchFn: upstream,
+ lookup,
+ })
+ const res = await request(apps.runtimeApp)
+ .post(COMPLETIONS)
+ .set('Authorization', `Bearer ${platformToken({ sub: 'default/visual-gate-full' })}`)
+ .send(visualEnvelope('att-visual-gate-full', 60_000))
+ expect(res.status).toBe(503)
+ expect(res.body).toEqual({ error: 'provider_unavailable' })
+ expect(warn).toHaveBeenCalledWith(
+ expect.objectContaining({
+ event: 'codex_proxy_admission_refused',
+ reason: 'visual_gate',
+ code: 'provider_unavailable',
+ }),
+ 'admission refused'
+ )
+ expect(control.redeems()).toBe(0)
+ expect(visualStreamGate.snapshot()).toEqual({
+ running: VISUAL_STREAM_LIMITS.maxConcurrentStreams,
+ queued: VISUAL_STREAM_LIMITS.maxQueuedRequests,
+ })
+ } finally {
+ for (const release of held.splice(0)) release()
+ for (const acquired of waiting) {
+ const release = await acquired.catch(() => undefined)
+ release?.()
+ }
+ warn.mockRestore()
+ }
+ }, 30_000)
})
/**
diff --git a/codex-llm-proxy/test/streamGate.handoff.test.ts b/codex-llm-proxy/test/streamGate.handoff.test.ts
index e7bd99c9c..0d03ff10e 100644
--- a/codex-llm-proxy/test/streamGate.handoff.test.ts
+++ b/codex-llm-proxy/test/streamGate.handoff.test.ts
@@ -465,8 +465,44 @@ describe('visual stream-gate handoff', () => {
() => streamGate.snapshot().running === 1 && visualStreamGate.snapshot().running === 0,
'padded small V2 kept the visual slot instead of the ordinary stream gate'
)
+
+ // #871 / r11-M2: demotion must release the principal share too. While
+ // the demoted body is still resident, four more entries from this
+ // principal fill Codex's share of four; the fifth must answer
+ // visual_host_share.
+ const warn = vi.spyOn(logger, 'warn')
+ const largeContent = 'x'.repeat(maxBodyBytes)
+ const queued = Array.from({ length: VISUAL_PER_HOST_MAX_ADMITTED }, () =>
+ postCompletion(port, 'codex-completion-request.v2', largeContent)
+ )
+ await waitFor(
+ () => visualStreamGate.snapshot().running === 2 && visualStreamGate.snapshot().queued === 2,
+ 'a leaked demotion share stopped the same principal from filling its quota'
+ )
+ const fifth = await postCompletion(port, 'codex-completion-request.v2', largeContent)
+ expect(fifth.status).toBe(503)
+ expect(await fifth.json()).toEqual({ error: 'provider_unavailable' })
+ expect(warn).toHaveBeenCalledWith(
+ {
+ event: 'codex_proxy_admission_refused',
+ reason: 'visual_host_share',
+ limit: VISUAL_PER_HOST_MAX_ADMITTED,
+ sub: 'default/research-host',
+ hostRefs: ['research-host'],
+ },
+ 'admission refused'
+ )
+
hang.release()
await response
+ for (const queuedResponse of await Promise.all(queued)) {
+ expect(queuedResponse.status).toBe(200)
+ }
+ await waitFor(
+ () => visualStreamGate.snapshot().running === 0 && visualStreamGate.snapshot().queued === 0,
+ 'the visual gate did not drain after demotion'
+ )
+ await expectNextVisualAdmitted(port, maxBodyBytes)
})
describe('visual per-host share', () => {
@@ -630,6 +666,66 @@ describe('visual stream-gate handoff', () => {
await expectNextVisualAdmitted(port, maxBodyBytes)
})
+
+ it('releases the principal share when the visual queue is full before grant', async () => {
+ const maxBodyBytes =
+ Buffer.byteLength(completionPayload('codex-completion-request.v1').body) + 512
+ const acquire = vi.spyOn(visualStreamGate, 'acquire')
+ const warn = vi.spyOn(logger, 'warn')
+ const held: Array<() => void> = []
+ const port = listen(
+ createProxyApps(config({ maxBodyBytes, maxVisualBodyBytes: 1024 * 1024 }))
+ )
+ const fillers: Array<Promise<Response>> = []
+ try {
+ for (let i = 0; i < VISUAL_STREAM_LIMITS.maxConcurrentStreams; i += 1) {
+ held.push(await visualStreamGate.acquire())
+ }
+ for (let i = 0; i < VISUAL_STREAM_LIMITS.maxQueuedRequests; i += 1) {
+ fillers.push(
+ postBody(
+ port,
+ platformToken(['research-host'], `default/visual-queue-full-${i}`),
+ invalidTicketBody(maxBodyBytes)
+ )
+ )
+ }
+ await waitFor(
+ () =>
+ visualStreamGate.snapshot().running === VISUAL_STREAM_LIMITS.maxConcurrentStreams &&
+ visualStreamGate.snapshot().queued === VISUAL_STREAM_LIMITS.maxQueuedRequests,
+ 'the visual queue did not fill with distinct principals'
+ )
+
+ // Five same-principal refusals back to back: every pre-grant
+ // visual_gate refusal must release that request's share, or the fifth
+ // would be refused visual_host_share instead.
+ const targetCount = VISUAL_PER_HOST_MAX_ADMITTED + 1
+ for (let i = 0; i < targetCount; i += 1) {
+ const res = await postBody(port, platformToken(), invalidTicketBody(maxBodyBytes))
+ expect(res.status).toBe(503)
+ expect(await res.json()).toEqual({ error: 'provider_unavailable' })
+ }
+ expect(acquire).toHaveBeenCalledTimes(
+ VISUAL_STREAM_LIMITS.maxConcurrentStreams +
+ VISUAL_STREAM_LIMITS.maxQueuedRequests +
+ targetCount
+ )
+ const reasons = warn.mock.calls
+ .map(call => call[0] as unknown as Record<string, unknown>)
+ .filter(entry => entry?.event === 'codex_proxy_admission_refused')
+ .map(entry => entry.reason)
+ expect(reasons).toEqual(Array.from({ length: targetCount }, () => 'visual_gate'))
+ } finally {
+ for (const release of held.splice(0)) release()
+ for (const filler of fillers) await filler
+ }
+ await waitFor(
+ () => visualStreamGate.snapshot().running === 0 && visualStreamGate.snapshot().queued === 0,
+ 'the visual gate did not drain after queue-full refusals'
+ )
+ await expectNextVisualAdmitted(port, maxBodyBytes)
+ })
// Review R3-L8: the share key sorts hostRefs, so one principal cannot
// double its share by listing the same hosts in another order.
it('counts one principal once whatever order its hostRefs arrive in', async () => {
@@ -961,9 +1057,32 @@ describe('visual stream-gate handoff', () => {
'admission refused'
)
+ // #871 / r11-M3: the aborted waiter's share must be released before
+ // any slot frees. Both holders still run, so two fresh requests from
+ // the same principal must fill the remaining share and queue.
+ const reprobeBody = JSON.stringify({
+ executionTicket: 'invalid-ticket',
+ requestHash: 'a'.repeat(64),
+ request: completionRequest('codex-completion-request.v2', 'x'.repeat(maxBodyBytes)),
+ })
+ expect(Buffer.byteLength(reprobeBody)).toBeGreaterThan(maxBodyBytes)
+ const reprobes = Array.from(
+ { length: VISUAL_PER_HOST_MAX_ADMITTED - VISUAL_STREAM_LIMITS.maxConcurrentStreams },
+ () => postBody(port, platformToken(), reprobeBody)
+ )
+ await waitFor(
+ () => visualStreamGate.snapshot().queued === 2,
+ 'the aborted waiter leaked its principal share'
+ )
+ expect(acquire).toHaveBeenCalledTimes(5)
+
hang.release()
await holderA
await holderB
+ for (const reprobe of await Promise.all(reprobes)) {
+ expect(reprobe.status).toBe(403)
+ expect(await reprobe.json()).toEqual({ error: 'ticket_invalid' })
+ }
await expectGateEmpty()
await expectNextVisualAdmitted(port, maxBodyBytes)
})
@@ -1018,13 +1137,20 @@ describe('visual stream-gate handoff', () => {
await closed
expect(waiter.destroyed).toBe(true)
- await new Promise(resolve => setTimeout(resolve, 300))
+ // r11-L15: with the unread body paused there is no pre-grant server
+ // observable for this close. The snapshot records the state at the
+ // observed client close only; it is not a server-disconnect witness.
+ const waiterAcquire = acquire.mock.results[2]?.value as Promise<() => void>
expect(visualStreamGate.snapshot()).toEqual({ running: 2, queued: 1 })
expect(acquire).toHaveBeenCalledTimes(3)
hang.release()
await holderA
await holderB
+ // The positive proof is the grant itself: a premature abort or removal
+ // rejects or strands this acquire. After grant, resumed body processing
+ // releases the slot through an aborted read or a completed handler.
+ await waiterAcquire
await expectGateEmpty()
await expectNextVisualAdmitted(port, maxBodyBytes)
})
diff --git a/grok-llm-proxy/test/streamGate.handoff.test.ts b/grok-llm-proxy/test/streamGate.handoff.test.ts
index 4d82473a6..194c8e2fb 100644
--- a/grok-llm-proxy/test/streamGate.handoff.test.ts
+++ b/grok-llm-proxy/test/streamGate.handoff.test.ts
@@ -455,8 +455,42 @@ describe('grok visual stream-gate handoff', () => {
() => streamGate.snapshot().running === 1 && visualStreamGate.snapshot().running === 0,
'padded small V2 kept the visual slot instead of the ordinary stream gate'
)
+
+ // #871 / r11-M2: demotion must release the principal share too. While
+ // the demoted body is still resident, two more entries from this
+ // principal fill Grok's share of two; the third must answer
+ // visual_host_share.
+ const warn = vi.spyOn(logger, 'warn')
+ const largeContent = 'x'.repeat(maxBodyBytes)
+ const queuedFirst = postCompletion(port, 'grok-completion-request.v2', largeContent)
+ const queuedSecond = postCompletion(port, 'grok-completion-request.v2', largeContent)
+ await waitFor(
+ () => visualStreamGate.snapshot().running === 1 && visualStreamGate.snapshot().queued === 1,
+ 'a leaked demotion share stopped the same principal from filling its quota'
+ )
+ const third = await postCompletion(port, 'grok-completion-request.v2', largeContent)
+ expect(third.status).toBe(503)
+ expect(await third.json()).toEqual({ error: 'provider_unavailable' })
+ expect(warn).toHaveBeenCalledWith(
+ {
+ event: 'grok_proxy_admission_refused',
+ reason: 'visual_host_share',
+ limit: VISUAL_PER_HOST_MAX_ADMITTED,
+ sub: 'default/research-host',
+ hostRefs: ['research-host'],
+ },
+ 'admission refused'
+ )
+
hang.release()
await response
+ await queuedFirst
+ await queuedSecond
+ await waitFor(
+ () => visualStreamGate.snapshot().running === 0 && visualStreamGate.snapshot().queued === 0,
+ 'the visual gate did not drain after demotion'
+ )
+ await expectNextVisualAdmitted(port, maxBodyBytes)
})
describe('visual per-host share', () => {
@@ -614,6 +648,62 @@ describe('grok visual stream-gate handoff', () => {
await expectNextVisualAdmitted(port, maxBodyBytes)
})
+
+ it('releases the principal share when the visual queue is full before grant', async () => {
+ const maxBodyBytes =
+ Buffer.byteLength(completionPayload('grok-completion-request.v1').body) + 512
+ const acquire = vi.spyOn(visualStreamGate, 'acquire')
+ const warn = vi.spyOn(logger, 'warn')
+ const held: Array<() => void> = []
+ const port = listen(
+ createProxyApps(config({ maxBodyBytes, maxVisualBodyBytes: 1024 * 1024 }))
+ )
+ const fillers: Array<Promise<Response>> = []
+ try {
+ held.push(await visualStreamGate.acquire())
+ for (let i = 0; i < VISUAL_STREAM_LIMITS.maxQueuedRequests; i += 1) {
+ fillers.push(
+ postBody(
+ port,
+ platformToken(['research-host'], `default/visual-queue-full-${i}`),
+ invalidTicketBody(maxBodyBytes)
+ )
+ )
+ }
+ await waitFor(
+ () =>
+ visualStreamGate.snapshot().running === 1 &&
+ visualStreamGate.snapshot().queued === VISUAL_STREAM_LIMITS.maxQueuedRequests,
+ 'the visual queue did not fill with distinct principals'
+ )
+
+ // Three same-principal refusals back to back: every pre-grant
+ // visual_gate refusal must release that request's share, or the third
+ // would be refused visual_host_share instead.
+ const targetCount = VISUAL_PER_HOST_MAX_ADMITTED + 1
+ for (let i = 0; i < targetCount; i += 1) {
+ const res = await postBody(port, platformToken(), invalidTicketBody(maxBodyBytes))
+ expect(res.status).toBe(503)
+ expect(await res.json()).toEqual({ error: 'provider_unavailable' })
+ }
+ expect(acquire).toHaveBeenCalledTimes(
+ 1 + VISUAL_STREAM_LIMITS.maxQueuedRequests + targetCount
+ )
+ const reasons = warn.mock.calls
+ .map(call => call[0] as unknown as Record<string, unknown>)
+ .filter(entry => entry?.event === 'grok_proxy_admission_refused')
+ .map(entry => entry.reason)
+ expect(reasons).toEqual(Array.from({ length: targetCount }, () => 'visual_gate'))
+ } finally {
+ for (const release of held.splice(0)) release()
+ for (const filler of fillers) await filler
+ }
+ await waitFor(
+ () => visualStreamGate.snapshot().running === 0 && visualStreamGate.snapshot().queued === 0,
+ 'the visual gate did not drain after queue-full refusals'
+ )
+ await expectNextVisualAdmitted(port, maxBodyBytes)
+ })
// Review R3-L8: the share key sorts hostRefs, so one principal cannot
// double its share by listing the same hosts in another order.
it('counts one principal once whatever order its hostRefs arrive in', async () => {
@@ -929,8 +1019,27 @@ describe('grok visual stream-gate handoff', () => {
'admission refused'
)
+ // #871 / r11-M3: the aborted waiter's principal share must be released
+ // before any slot frees. The holder still runs, so a fresh request from
+ // the same principal must reach the visual gate and queue.
+ const reprobeBody = JSON.stringify({
+ executionTicket: 'invalid-ticket',
+ requestHash: 'a'.repeat(64),
+ request: completionRequest('grok-completion-request.v2', 'x'.repeat(maxBodyBytes)),
+ })
+ expect(Buffer.byteLength(reprobeBody)).toBeGreaterThan(maxBodyBytes)
+ const reprobe = postBody(port, platformToken(), reprobeBody)
+ await waitFor(
+ () => visualStreamGate.snapshot().queued === 1,
+ 'the aborted waiter leaked its principal share'
+ )
+ expect(acquire).toHaveBeenCalledTimes(3)
+
hang.release()
await holder
+ const reprobeRes = await reprobe
+ expect(reprobeRes.status).toBe(403)
+ expect(await reprobeRes.json()).toEqual({ error: 'ticket_invalid' })
await expectGateEmpty()
await expectNextVisualAdmitted(port, maxBodyBytes)
})
@@ -981,12 +1090,19 @@ describe('grok visual stream-gate handoff', () => {
await closed
expect(waiter.destroyed).toBe(true)
- await new Promise(resolve => setTimeout(resolve, 300))
+ // r11-L15: with the unread body paused there is no pre-grant server
+ // observable for this close. The snapshot records the state at the
+ // observed client close only; it is not a server-disconnect witness.
+ const waiterAcquire = acquire.mock.results[1]?.value as Promise<() => void>
expect(visualStreamGate.snapshot()).toEqual({ running: 1, queued: 1 })
expect(acquire).toHaveBeenCalledTimes(2)
hang.release()
await holder
+ // The positive proof is the grant itself: a premature abort or removal
+ // rejects or strands this acquire. After grant, resumed body processing
+ // releases the slot through an aborted read or a completed handler.
+ await waiterAcquire
await expectGateEmpty()
await expectNextVisualAdmitted(port, maxBodyBytes)
})
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 61b455759..7a702113a 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.485",
+ "version": "0.1.486",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.485",
+ "version": "0.1.486",
"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 b8971bd14..668c9959f 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.485",
+ "version": "0.1.486",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/llm/__tests__/codexSubscription.test.ts b/mcp-host/src/llm/__tests__/codexSubscription.test.ts
index 74bd6c95a..1ab985615 100644
--- a/mcp-host/src/llm/__tests__/codexSubscription.test.ts
+++ b/mcp-host/src/llm/__tests__/codexSubscription.test.ts
@@ -384,12 +384,11 @@ describe('CodexSubscriptionProvider', () => {
.mockRejectedValue(new CodexProxyError('payload_too_large', 'proxy refused the envelope')),
})
const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)
- // The member-bound twin of T-C3b. The proxy's raw-body scan refuses a
- // body over `BODY_STRUCTURE_LIMITS.maxMembers` with HTTP 413
- // `body.structure.too.many.members`, which reaches mcp-host as
- // `payload_too_large`. A small turn passes every local guard, so the
- // refusal can only come from the proxy's member scan: the classify call
- // sees the same `payload_too_large` code the real 413 carries.
+ // A member-bound proxy refusal reaches the Host as `payload_too_large`.
+ // The mock checks this generic code's classification after a small turn
+ // passes the local guards; it does not execute the proxy's member scanner
+ // or establish which bound produced the 413. T-C3d below uses the
+ // real local contract member bound and an accepted-body witness.
const rejected = provider.completeSingleTurn([{ role: 'user', content: 'hi' }])
await expect(rejected).rejects.toBeInstanceOf(CodexProxyError)
await expect(rejected).rejects.toMatchObject({
diff --git a/mcp-host/src/llm/__tests__/grokSubscription.test.ts b/mcp-host/src/llm/__tests__/grokSubscription.test.ts
index 17a0bde7f..ff97676d7 100644
--- a/mcp-host/src/llm/__tests__/grokSubscription.test.ts
+++ b/mcp-host/src/llm/__tests__/grokSubscription.test.ts
@@ -639,12 +639,11 @@ describe('GrokSubscriptionProvider', () => {
.mockRejectedValue(new GrokProxyError('payload_too_large', 'proxy refused the envelope')),
})
const provider = new GrokSubscriptionProvider('grok-4.6', wired as never)
- // The Grok twin of T-C3c. The proxy's raw-body scan refuses a body over
- // `BODY_STRUCTURE_LIMITS.maxMembers` with HTTP 413
- // `body.structure.too.many.members`, which reaches mcp-host as
- // `payload_too_large`. A small turn passes every local guard, so the
- // refusal can only come from the proxy's member scan: the classify call
- // sees the same `payload_too_large` code the real 413 carries.
+ // A member-bound proxy refusal reaches the Host as `payload_too_large`.
+ // The mock checks this generic code's classification after a small turn
+ // passes the local guards; it does not execute the proxy's member scanner
+ // or establish which bound produced the 413. T-C3d-grok below uses the
+ // real local contract member bound and an accepted-body witness.
const rejected = provider.completeSingleTurn([{ role: 'user', content: 'hi' }])
await expect(rejected).rejects.toBeInstanceOf(GrokProxyError)
await expect(rejected).rejects.toMatchObject({
diff --git a/packages/grok-provider-attempt-contract/index.cjs b/packages/grok-provider-attempt-contract/index.cjs
index 641d5b919..f7553ba9b 100644
--- a/packages/grok-provider-attempt-contract/index.cjs
+++ b/packages/grok-provider-attempt-contract/index.cjs
@@ -430,9 +430,9 @@ function rejectUnknown(obj, allowed, label) {
/**
* Iterative structural pre-check, safe on arbitrarily deep or cyclic input.
* Returns a failure when containers nest deeper than `maxDepth`, when the
- * value holds more than maxRequestElements JSON values or more than
- * maxRequestContainers objects and arrays. Shared references are counted per
- * occurrence, as JSON would serialize them.
+ * value holds more than maxRequestElements JSON values, maxRequestContainers
+ * objects and arrays, or maxRequestMembers object members. Shared references
+ * are counted per occurrence, as JSON would serialize them.
*/
function checkStructure(value, maxDepth) {
if (value === null || typeof value !== 'object') return null
diff --git a/packages/grok-provider-attempt-contract/index.test.cjs b/packages/grok-provider-attempt-contract/index.test.cjs
index 84740238a..12641086f 100644
--- a/packages/grok-provider-attempt-contract/index.test.cjs
+++ b/packages/grok-provider-attempt-contract/index.test.cjs
@@ -1803,6 +1803,7 @@ test("a request over maxRequestElements is refused with kind:'size'", () => {
const limit = contract.LIMITS.maxRequestElements
const at = requestWithElements(limit)
assert.equal(contract.parseGrokCompletionRequest(at).ok, true)
+ assert.equal(contract.hashCanonicalGrokRequest(at).ok, true)
const over = requestWithElements(limit + 1)
assert.ok(Buffer.byteLength(JSON.stringify(over), 'utf8') < contract.LIMITS.maxRequestBodyBytes)
const expected = {
diff --git a/packages/llm-provider-attempt-contract/index.cjs b/packages/llm-provider-attempt-contract/index.cjs
index 8741d051e..59f3cc004 100644
--- a/packages/llm-provider-attempt-contract/index.cjs
+++ b/packages/llm-provider-attempt-contract/index.cjs
@@ -396,9 +396,9 @@ function rejectUnknown(obj, allowed, label) {
/**
* Iterative structural pre-check, safe on arbitrarily deep or cyclic input.
* Returns a failure when containers nest deeper than `maxDepth`, when the
- * value holds more than maxRequestElements JSON values or more than
- * maxRequestContainers objects and arrays. Shared references are counted per
- * occurrence, as JSON would serialize them.
+ * value holds more than maxRequestElements JSON values, maxRequestContainers
+ * objects and arrays, or maxRequestMembers object members. Shared references
+ * are counted per occurrence, as JSON would serialize them.
*/
function checkStructure(value, maxDepth) {
if (value === null || typeof value !== 'object') return null
diff --git a/packages/llm-provider-attempt-contract/index.test.cjs b/packages/llm-provider-attempt-contract/index.test.cjs
index 8a4d2ef03..735099a51 100644
--- a/packages/llm-provider-attempt-contract/index.test.cjs
+++ b/packages/llm-provider-attempt-contract/index.test.cjs
@@ -2089,6 +2089,7 @@ test("a request over maxRequestElements is refused with kind:'size'", () => {
const limit = contract.LIMITS.maxRequestElements
const at = requestWithElements(limit)
assert.equal(contract.parseCodexCompletionRequest(at).ok, true)
+ assert.equal(contract.hashCanonicalCodexRequest(at).ok, true)
const over = requestWithElements(limit + 1)
assert.ok(Buffer.byteLength(JSON.stringify(over), 'utf8') < contract.LIMITS.maxRequestBodyBytes)
const expected = {
diff --git a/scripts/ci/pinned-vitest-cases/codex-llm-proxy.json b/scripts/ci/pinned-vitest-cases/codex-llm-proxy.json
index 537ffcdf4..d52dd3907 100644
--- a/scripts/ci/pinned-vitest-cases/codex-llm-proxy.json
+++ b/scripts/ci/pinned-vitest-cases/codex-llm-proxy.json
@@ -46,5 +46,25 @@
{
"suite": "server.security.test.ts",
"fullName": "codex-llm-proxy attempt telemetry (r4-l1b) logs a catalog DNS lookup failure by cause code on both admin routes"
+ },
+ {
+ "suite": "server.security.test.ts",
+ "fullName": "codex-llm-proxy ticket-aware stream-gate wait (#739 D1-bis) visual admission overflow answers 503 provider_unavailable and logs visual_gate"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "visual stream-gate handoff releases the visual slot for a whitespace-padded small V2"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "visual stream-gate handoff visual per-host share releases the principal share when the visual queue is full before grant"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "visual stream-gate handoff visual slot lifetime frees the queue place of a visual request aborted while it waited"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "visual stream-gate handoff visual slot lifetime holds the queue place of a disconnected large-body waiter until its grant"
}
]
diff --git a/scripts/ci/pinned-vitest-cases/grok-llm-proxy.json b/scripts/ci/pinned-vitest-cases/grok-llm-proxy.json
index 2ae82d744..27b8b6296 100644
--- a/scripts/ci/pinned-vitest-cases/grok-llm-proxy.json
+++ b/scripts/ci/pinned-vitest-cases/grok-llm-proxy.json
@@ -50,5 +50,21 @@
{
"suite": "server.security.test.ts",
"fullName": "grok-llm-proxy attempt telemetry (r4-l1b) logs a catalog DNS lookup failure by cause code on both admin routes"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "grok visual stream-gate handoff releases the visual slot for a whitespace-padded small V2"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "grok visual stream-gate handoff visual per-host share releases the principal share when the visual queue is full before grant"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "grok visual stream-gate handoff visual slot lifetime frees the queue place of a visual request aborted while it waited"
+ },
+ {
+ "suite": "streamGate.handoff.test.ts",
+ "fullName": "grok visual stream-gate handoff visual slot lifetime holds the queue place of a disconnected large-body waiter until its grant"
}
]