Skip to content

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

TypeScript

test: make GFS visual and JWT fixtures portable

Alfredo Lopezc63059a0bee5
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 1676feae0..6ad274302 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.706",
+ "version": "0.1.707",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.706",
+ "version": "0.1.707",
"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.json
index 0a2d8963e..32cb8e0a1 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.706",
+ "version": "0.1.707",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/devSigningKeys.test.ts b/control-api/test/devSigningKeys.test.ts
index 374e430a8..28e090ae2 100644
--- a/control-api/test/devSigningKeys.test.ts
+++ b/control-api/test/devSigningKeys.test.ts
@@ -353,7 +353,9 @@ describe('devSigningKeys persistence contract', () => {
const expected = createPublicKey(signing).export({ type: 'spki', format: 'pem' }).toString()
const fd = openSync(join(store, 'rpc.public.pem'), 'r')
try {
- expect(fstatSync(fd).mode & 0o777).toBe(0o644)
+ // Creation respects the caller's umask, including the harness's 077.
+ // Reading the mask is supported in Vitest workers; changing it is not.
+ expect(fstatSync(fd).mode & 0o777).toBe(0o644 & ~process.umask())
expect(readFileSync(fd, 'utf8').trim()).toBe(expected.trim())
} finally {
closeSync(fd)
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/internalTools/gfsManagedImage.test.ts b/mcp-host/src/internalTools/gfsManagedImage.test.ts
index 054f18f71..1dad5588a 100644
--- a/mcp-host/src/internalTools/gfsManagedImage.test.ts
+++ b/mcp-host/src/internalTools/gfsManagedImage.test.ts
@@ -28,6 +28,35 @@ const largePng = realPngOfSize(3 * MIB + 1, 2, 2, 7)
const largeJpeg = padJpegToSize(Buffer.from(JPEG_2X2_BASE64, 'base64'), 3 * MIB + 1)
const smallPng = Buffer.from(PNG_2X2_BASE64, 'base64')
+/**
+ * Keep the byte-boundary fixture decoder-cheap. A single multi-MiB tEXt chunk
+ * can exhaust the native decoder's five-second limit on Linux; small ancillary
+ * chunks preserve the exact source size and independently decoded 2x2 raster.
+ */
+function pngWithBoundedTextChunks(size: number): Buffer {
+ const maxChunkBytes = 512 * 1024
+ let remaining = size - smallPng.byteLength
+ const chunks: Buffer[] = [smallPng.subarray(0, smallPng.byteLength - 12)]
+ while (remaining > 0) {
+ let chunkBytes = Math.min(remaining, maxChunkBytes)
+ if (remaining > chunkBytes && remaining - chunkBytes < 16) chunkBytes -= 16
+ if (chunkBytes < 16) throw new Error('PNG fixture needs space for a complete tEXt chunk')
+ const type = Buffer.from('tEXt', 'ascii')
+ const data = Buffer.alloc(chunkBytes - 12, 0x20)
+ Buffer.from('pad\0', 'latin1').copy(data)
+ const length = Buffer.alloc(4)
+ length.writeUInt32BE(data.byteLength)
+ const checksum = Buffer.alloc(4)
+ checksum.writeUInt32BE(crc32(Buffer.concat([type, data])))
+ chunks.push(Buffer.concat([length, type, data, checksum]))
+ remaining -= chunkBytes
+ }
+ chunks.push(smallPng.subarray(smallPng.byteLength - 12))
+ const png = Buffer.concat(chunks)
+ if (png.byteLength !== size) throw new Error('PNG fixture source size mismatch')
+ return png
+}
+
/** A valid one-bit grayscale PNG whose real decoder verifies the raster. */
function compressed2048Png(): Buffer {
const chunk = (name: string, data: Buffer): Buffer => {
@@ -150,12 +179,24 @@ describe('GFS managed image projection', () => {
it.each([8 * MIB, 16 * MIB])(
'accepts %i source bytes through the Codex visual boundary',
async size => {
- const png = realPngOfSize(size, 2, 2, 7)
+ const png = pngWithBoundedTextChunks(size)
+ expect(png.byteLength).toBe(size)
const subject = scenario(png)
const result = await subject.run()
expect(result.success).toBe(true)
- expect(JSON.parse(result.content!)).toMatchObject({
+ const receipt = JSON.parse(result.content!)
+ expect(
+ receipt.visualReason,
+ JSON.stringify({
+ sizeBytes: size,
+ visualReason: receipt.visualReason ?? null,
+ imageCount: result.images?.length ?? 0,
+ readBytes: subject.budget.readBytes,
+ residentBytes: subject.budget.residentBytes,
+ })
+ ).toBeUndefined()
+ expect(receipt).toMatchObject({
sizeBytes: size,
visualDelivery: 'included',
usage: { visualDelivery: 'included' },