Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(mcp-host): require CLERUM_CONTEXT_MAX_TOKENS to be a positive integer (#739)
Alfredo Lopezeba0bd319476
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 5d92d2349..f71610145 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.422",+ "version": "0.1.423","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.422",+ "version": "0.1.423","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex efb1c6de2..09dc463d7 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.422",+ "version": "0.1.423","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/config.contextMaxTokens.test.ts b/mcp-host/src/config.contextMaxTokens.test.tsnew file mode 100644index 000000000..672c5d70c--- /dev/null+++ b/mcp-host/src/config.contextMaxTokens.test.ts@@ -0,0 +1,37 @@+import { afterEach, describe, expect, it, vi } from 'vitest'++// `contextMaxTokens` divides every pressure ratio. A value that parses to NaN+// makes every ratio NaN, and `NaN < 0.8` is false, so a typo would compact on+// every iteration; 0 divides by zero. Both must stop the Host at config load+// (R9-15, N-3).+const NAME = 'CLERUM_CONTEXT_MAX_TOKENS'++afterEach(() => {+ vi.unstubAllEnvs()+ vi.resetModules()+})++describe('CLERUM_CONTEXT_MAX_TOKENS validation', () => {+ it.each(['abc', '0', '', '-1', '1.5', '100k'])(+ 'T-R9-15a rejects %j at config load, naming the variable',+ async value => {+ vi.resetModules()+ vi.stubEnv(NAME, value)+ await expect(import('./config')).rejects.toThrow(NAME)+ }+ )++ it('T-R9-15b loads an explicit positive integer', async () => {+ vi.resetModules()+ vi.stubEnv(NAME, '256000')+ const { config } = await import('./config')+ expect(config.contextMaxTokens).toBe(256_000)+ })++ it('T-R9-15c keeps the 100k default when the variable is absent', async () => {+ vi.resetModules()+ vi.stubEnv(NAME, undefined)+ const { config } = await import('./config')+ expect(config.contextMaxTokens).toBe(100_000)+ })+})