Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(contracts): require the execution ticket TTL published in LIMITS and the fixtures (#739)
Alfredo Lopeze9cc42b9de94
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 5d5f667a3..72acf9df8 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.626",+ "version": "0.1.627","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.626",+ "version": "0.1.627","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 2359d4712..a570f1957 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.626",+ "version": "0.1.627","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/test/services.llmProviderAttemptEnvelope.test.ts b/control-api/test/services.llmProviderAttemptEnvelope.test.tsindex c6f287fb7..f72323254 100644--- a/control-api/test/services.llmProviderAttemptEnvelope.test.ts+++ b/control-api/test/services.llmProviderAttemptEnvelope.test.ts@@ -1,4 +1,6 @@import { describe, expect, it } from 'vitest'+import { LIMITS as GROK_CONTRACT_LIMITS } from '@clerum/grok-provider-attempt-contract'+import { LIMITS as CODEX_CONTRACT_LIMITS } from '@clerum/llm-provider-attempt-contract'import { config } from '../src/config.js'import { GROK_MAX_STREAM_DURATION_MS } from '../src/services/grokProviderAttemptRedemption.js'import { GROK_EXECUTION_TICKET_TTL_SECONDS } from '../src/services/grokProviderAttemptTicket.js'@@ -29,6 +31,18 @@ describe('provider attempt lifetime envelope', () => {expect(GROK_ATTEMPT_MAX_LIFETIME_MS).toBe(1_860_000)})+ it('derives each execution ticket TTL from the TTL the contract publishes', () => {+ // The proxies bound their admission waits against the contract value and+ // the fixtures publish it, so the TTL control-api signs must be that value,+ // not a second literal (#739). Witness: the contract values were read.+ expect(Number.isSafeInteger(CODEX_CONTRACT_LIMITS.executionTicketTtlMs)).toBe(true)+ expect(Number.isSafeInteger(GROK_CONTRACT_LIMITS.executionTicketTtlMs)).toBe(true)+ expect(CODEX_EXECUTION_TICKET_TTL_SECONDS).toBe(+ CODEX_CONTRACT_LIMITS.executionTicketTtlMs / 1000+ )+ expect(GROK_EXECUTION_TICKET_TTL_SECONDS).toBe(GROK_CONTRACT_LIMITS.executionTicketTtlMs / 1000)+ })+it('keeps each attempt reservation alive for the attempt plus the rollup margin', () => {// The task-level reservation TTL is the rollup margin added to the lifetime.expect(config.budgetReservationTtlSeconds).toBe(300)diff --git a/grok-llm-proxy/test/contractFreeze.test.ts b/grok-llm-proxy/test/contractFreeze.test.tsindex da885d93a..92cd52ce9 100644--- a/grok-llm-proxy/test/contractFreeze.test.ts+++ b/grok-llm-proxy/test/contractFreeze.test.ts@@ -42,11 +42,13 @@ const FIXTURE_LIMIT_KEYS = ['maxQueueWaitMs','upstreamIdleTimeoutMs','maxRetriesPerAttempt',+ 'executionTicketTtlMs',] as const// Contract `LIMITS` keys that the fixture also publishes. Each must carry the// same value on both sides.const SHARED_LIMIT_KEYS = [+ 'executionTicketTtlMs','maxDeadlineMs','maxMessages','maxOutputTokens',@@ -177,6 +179,8 @@ describe('grok-subscription contract freeze', () => {expect(limits.maxToolCalls).toBe(256)expect(limits.maxMessages).toBe(1024)expect(limits.maxRetriesPerAttempt).toBe(1)+ // control-api derives the Grok execution ticket TTL from LIMITS (#739).+ expect(limits.executionTicketTtlMs).toBe(60000)})it('pins the architecture doc limits table to the limits the fixture publishes', () => {diff --git a/packages/grok-provider-attempt-contract/index.test.cjs b/packages/grok-provider-attempt-contract/index.test.cjsindex 0f78a0c75..e156dcf68 100644--- a/packages/grok-provider-attempt-contract/index.test.cjs+++ b/packages/grok-provider-attempt-contract/index.test.cjs@@ -54,6 +54,18 @@ test('declared LIMITS literals match the runtime values', () => {assert.deepEqual(declared, { ...contract.LIMITS })})+// control-api signs Grok execution tickets for this long and derives its ticket+// TTL from this value; the proxy bounds its admission waits against it (#739).+test('LIMITS publishes the execution ticket TTL, declared as the same literal', () => {+ assert.equal(contract.LIMITS.executionTicketTtlMs, 60000)+ const declarations = fs.readFileSync(path.join(__dirname, 'index.d.ts'), 'utf8')+ const block = declarations.match(/export declare const LIMITS: \{([\s\S]*?)\n\}/)+ // Witness: the declaration block was found and read.+ assert.ok(block, 'index.d.ts must declare a LIMITS object literal')+ assert.match(block[1], /^\s*readonly maxRequestBodyBytes: 8388608$/m)+ assert.match(block[1], /^\s*readonly executionTicketTtlMs: 60000$/m)+})+// The proxy, control-api and mcp-host all import this allowance instead of// writing their own literal, so the declared literal type has to follow the// runtime value too.diff --git a/packages/llm-provider-attempt-contract/index.test.cjs b/packages/llm-provider-attempt-contract/index.test.cjsindex 27c8a5e17..9bbedf0f2 100644--- a/packages/llm-provider-attempt-contract/index.test.cjs+++ b/packages/llm-provider-attempt-contract/index.test.cjs@@ -87,6 +87,18 @@ test('declared LIMITS literals match the runtime values', () => {assert.deepEqual(declared, { ...contract.LIMITS })})+// control-api signs execution tickets for this long and derives its ticket TTL+// from this value; the proxies bound their admission waits against it (#739).+test('LIMITS publishes the execution ticket TTL, declared as the same literal', () => {+ assert.equal(contract.LIMITS.executionTicketTtlMs, 60000)+ const declarations = fs.readFileSync(path.join(__dirname, 'index.d.ts'), 'utf8')+ const block = declarations.match(/export declare const LIMITS: \{([\s\S]*?)\n\}/)+ // Witness: the declaration block was found and read.+ assert.ok(block, 'index.d.ts must declare a LIMITS object literal')+ assert.match(block[1], /^\s*readonly maxRequestBodyBytes: 8388608$/m)+ assert.match(block[1], /^\s*readonly executionTicketTtlMs: 60000$/m)+})+test('parses the bounded V1 request and hashes with SHA-256', () => {const parsed = contract.parseCodexCompletionRequestV1(BASE)assert.equal(parsed.ok, true)diff --git a/tests/e2e/integration/codex-subscription-contract-freeze.test.ts b/tests/e2e/integration/codex-subscription-contract-freeze.test.tsindex c73be1c9f..3c24e04cb 100644--- a/tests/e2e/integration/codex-subscription-contract-freeze.test.ts+++ b/tests/e2e/integration/codex-subscription-contract-freeze.test.ts@@ -66,11 +66,13 @@ const REQUIRED_LIMIT_KEYS = ['maxQueueWaitMs','upstreamIdleTimeoutMs','maxRetriesPerAttempt',+ 'executionTicketTtlMs',] as const// Runtime `LIMITS` keys that the fixture also publishes. Each must carry the// same value on both sides.const PUBLISHED_RUNTIME_LIMIT_KEYS = [+ 'executionTicketTtlMs','maxDeadlineMs','maxMessages','maxOutputTokens',@@ -291,6 +293,8 @@ describe('codex-subscription contract freeze', () => {expect(limits?.maxMessages).toBe(1024)expect(limits?.maxRequestBodyBytes).toBe(8388608)expect(limits?.maxVisualRequestBodyBytes).toBe(25165824)+ // control-api derives the execution ticket TTL from LIMITS (#739).+ expect(limits?.executionTicketTtlMs).toBe(60000)// The architecture doc publishes the same limits as a table; a row that// drifts from the fixture misdescribes what the runtime enforces. The tablediff --git a/tests/e2e/package-lock.json b/tests/e2e/package-lock.jsonindex c8fa4d356..81e806c40 100644--- a/tests/e2e/package-lock.json+++ b/tests/e2e/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-e2e-tests",- "version": "0.1.93",+ "version": "0.1.94","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-e2e-tests",- "version": "0.1.93",+ "version": "0.1.94","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 573ff5dd0..78e368b58 100644--- a/tests/e2e/package.json+++ b/tests/e2e/package.json@@ -1,6 +1,6 @@{"name": "clerum-e2e-tests",- "version": "0.1.93",+ "version": "0.1.94","private": true,"type": "module","scripts": {