Skip to content

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

TypeScript

test(e2e): retain and validate isolated journey input

Alfredo Lopez65449d05b192
diff --git a/scripts/e2e/fixtures/subscription-image-decoder.mjs b/scripts/e2e/fixtures/subscription-image-decoder.mjs
new file mode 100644
index 000000000..895229257
--- /dev/null
+++ b/scripts/e2e/fixtures/subscription-image-decoder.mjs
@@ -0,0 +1,103 @@
+// E2E_GUARDIAN_IPC_FLOW: pure native codec child for private fixture bytes; no renderer transition.
+// Pure test-only native decoder boundary. It installs no vendor hooks and
+// never imports login, seeding, runtime mutation or external service modules.
+import { spawn } from 'node:child_process'
+
+// The native image loader can fault on a truncated PNG/JPEG container. Reject
+// known-incomplete bytes before it is invoked so a malformed tool image remains
+// a bounded HTTP source failure instead of crashing the inspected runtime.
+export function hasCompleteImageContainer(bytes, mimeType) {
+ if (mimeType === 'image/png') {
+ return bytes.length >= 24 && bytes.subarray(0, 8).equals(Buffer.from([
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
+ ])) && bytes.subarray(-12, -8).equals(Buffer.from([0, 0, 0, 0])) &&
+ bytes.subarray(-8).equals(Buffer.from([0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82]))
+ }
+ return bytes.length >= 4 && bytes[0] === 0xff && bytes[1] === 0xd8 &&
+ bytes[bytes.length - 2] === 0xff && bytes[bytes.length - 1] === 0xd9
+}
+
+// A malformed image can SIGSEGV @napi-rs/canvas directly in the fixture PID
+// (reproduced with an eight-byte PNG). Valid 20-image series do not crash the
+// addon, so the causal boundary is malformed input, not cumulative decoder use.
+// Decode each received image in a throwaway process with empty env, no shell,
+// a fixed timeout, and bounded stdin/stdout. The vendor itself remains the
+// long-lived state machine and keeps all attempt state in its own PID.
+const DECODER_TIMEOUT_MS = 10_000
+const MAX_DECODER_STDOUT_BYTES = 1024 * 1024
+
+function decoderChildScript() {
+ const decoderUrl = new URL('./subscription-image-challenge.cjs', import.meta.url).href
+ return `
+import { decodeTileChallenge, requirePixelRenderer } from ${JSON.stringify(decoderUrl)}
+const chunks = []
+let byteLength = 0
+for await (const chunk of process.stdin) {
+ byteLength += chunk.length
+ if (byteLength > 20 * 1024 * 1024) throw new Error('decoder input bound exceeded')
+ chunks.push(chunk)
+}
+const bytes = Buffer.concat(chunks)
+const native = requirePixelRenderer()
+const image = await native.loadImage(bytes)
+const code = await decodeTileChallenge(bytes)
+if (!Number.isSafeInteger(image.width) || image.width < 1 ||
+ !Number.isSafeInteger(image.height) || image.height < 1 ||
+ !/^[A-F0-9]{16}$/.test(code)) throw new Error('invalid decoder result')
+process.stdout.write(JSON.stringify({ width: image.width, height: image.height, code }))
+`
+}
+
+export function decodeInChild(bytes, signal) {
+ if (signal?.aborted) return Promise.reject(signal.reason)
+ return new Promise((resolve, reject) => {
+ const child = spawn(process.execPath, ['--input-type=module', '--eval', decoderChildScript()], {
+ cwd: '/',
+ env: {},
+ stdio: ['pipe', 'pipe', 'pipe'],
+ })
+ const stdout = []
+ let stdoutBytes = 0
+ const stderr = []
+ let stderrBytes = 0
+ let settled = false
+ const fail = error => {
+ if (settled) return
+ settled = true
+ clearTimeout(timer)
+ signal?.removeEventListener('abort', abort)
+ reject(error)
+ }
+ const abort = () => child.kill('SIGKILL')
+ const timer = setTimeout(() => child.kill('SIGKILL'), DECODER_TIMEOUT_MS)
+ signal?.addEventListener('abort', abort, { once: true })
+ child.stdout.on('data', chunk => {
+ stdoutBytes += chunk.length
+ if (stdoutBytes <= MAX_DECODER_STDOUT_BYTES) stdout.push(chunk)
+ })
+ child.stderr.on('data', chunk => {
+ stderrBytes += chunk.length
+ if (stderrBytes <= 64 * 1024) stderr.push(chunk)
+ })
+ child.on('error', fail)
+ child.on('close', (code, receivedSignal) => {
+ try {
+ if (settled) return
+ clearTimeout(timer)
+ signal?.removeEventListener('abort', abort)
+ if (code !== 0) throw new Error(`image decoder exited with ${code ?? receivedSignal}`)
+ if (stdoutBytes > MAX_DECODER_STDOUT_BYTES) throw new Error('image decoder output bound exceeded')
+ const result = JSON.parse(Buffer.concat(stdout).toString('utf8'))
+ if (!Number.isSafeInteger(result.width) || result.width < 1 ||
+ !Number.isSafeInteger(result.height) || result.height < 1 ||
+ !/^[A-F0-9]{16}$/.test(result.code)) throw new Error('image decoder result invalid')
+ settled = true
+ resolve({ width: result.width, height: result.height, code: result.code })
+ } catch (error) {
+ fail(error)
+ }
+ })
+ child.stdin.on('error', () => {})
+ child.stdin.end(bytes)
+ })
+}
diff --git a/scripts/e2e/fixtures/subscription-image-provider.mjs b/scripts/e2e/fixtures/subscription-image-provider.mjs
index 367609b10..9ea0d0300 100644
--- a/scripts/e2e/fixtures/subscription-image-provider.mjs
+++ b/scripts/e2e/fixtures/subscription-image-provider.mjs
@@ -7,10 +7,10 @@
import { createHash, randomUUID } from 'node:crypto'
import { deepStrictEqual } from 'node:assert/strict'
import { createRequire } from 'node:module'
-import { spawn } from 'node:child_process'
import fs from 'node:fs'
import path from 'node:path'
import { requirePixelRenderer } from './subscription-image-challenge.cjs'
+import { decodeInChild, hasCompleteImageContainer } from './subscription-image-decoder.mjs'
const require = createRequire(import.meta.url)
const grok = require('../../../packages/grok-provider-attempt-contract/index.cjs')
@@ -36,105 +36,6 @@ const same = (left, right) => {
}
}
-// The native image loader can fault on a truncated PNG/JPEG container. Reject
-// known-incomplete bytes before it is invoked so a malformed tool image remains
-// a bounded HTTP source failure instead of crashing the inspected runtime.
-function hasCompleteImageContainer(bytes, mimeType) {
- if (mimeType === 'image/png') {
- return bytes.length >= 24 && bytes.subarray(0, 8).equals(Buffer.from([
- 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
- ])) && bytes.subarray(-12, -8).equals(Buffer.from([0, 0, 0, 0])) &&
- bytes.subarray(-8).equals(Buffer.from([0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82]))
- }
- return bytes.length >= 4 && bytes[0] === 0xff && bytes[1] === 0xd8 &&
- bytes[bytes.length - 2] === 0xff && bytes[bytes.length - 1] === 0xd9
-}
-
-// A malformed image can SIGSEGV @napi-rs/canvas directly in the fixture PID
-// (reproduced with an eight-byte PNG). Valid 20-image series do not crash the
-// addon, so the causal boundary is malformed input, not cumulative decoder use.
-// Decode each received image in a throwaway process with empty env, no shell,
-// a fixed timeout, and bounded stdin/stdout. The vendor itself remains the
-// long-lived state machine and keeps all attempt state in its own PID.
-const DECODER_TIMEOUT_MS = 10_000
-const MAX_DECODER_STDOUT_BYTES = 1024 * 1024
-
-function decoderChildScript() {
- const decoderUrl = new URL('./subscription-image-challenge.cjs', import.meta.url).href
- return `
-import { decodeTileChallenge, requirePixelRenderer } from ${JSON.stringify(decoderUrl)}
-const chunks = []
-let byteLength = 0
-for await (const chunk of process.stdin) {
- byteLength += chunk.length
- if (byteLength > 20 * 1024 * 1024) throw new Error('decoder input bound exceeded')
- chunks.push(chunk)
-}
-const bytes = Buffer.concat(chunks)
-const native = requirePixelRenderer()
-const image = await native.loadImage(bytes)
-const code = await decodeTileChallenge(bytes)
-if (!Number.isSafeInteger(image.width) || image.width < 1 ||
- !Number.isSafeInteger(image.height) || image.height < 1 ||
- !/^[A-F0-9]{16}$/.test(code)) throw new Error('invalid decoder result')
-process.stdout.write(JSON.stringify({ width: image.width, height: image.height, code }))
-`
-}
-
-function decodeInChild(bytes, signal) {
- if (signal?.aborted) return Promise.reject(signal.reason)
- return new Promise((resolve, reject) => {
- const child = spawn(process.execPath, ['--input-type=module', '--eval', decoderChildScript()], {
- cwd: '/',
- env: {},
- stdio: ['pipe', 'pipe', 'pipe'],
- })
- const stdout = []
- let stdoutBytes = 0
- const stderr = []
- let stderrBytes = 0
- let settled = false
- const fail = error => {
- if (settled) return
- settled = true
- clearTimeout(timer)
- signal?.removeEventListener('abort', abort)
- reject(error)
- }
- const abort = () => child.kill('SIGKILL')
- const timer = setTimeout(() => child.kill('SIGKILL'), DECODER_TIMEOUT_MS)
- signal?.addEventListener('abort', abort, { once: true })
- child.stdout.on('data', chunk => {
- stdoutBytes += chunk.length
- if (stdoutBytes <= MAX_DECODER_STDOUT_BYTES) stdout.push(chunk)
- })
- child.stderr.on('data', chunk => {
- stderrBytes += chunk.length
- if (stderrBytes <= 64 * 1024) stderr.push(chunk)
- })
- child.on('error', fail)
- child.on('close', (code, receivedSignal) => {
- try {
- if (settled) return
- clearTimeout(timer)
- signal?.removeEventListener('abort', abort)
- if (code !== 0) throw new Error(`image decoder exited with ${code ?? receivedSignal}`)
- if (stdoutBytes > MAX_DECODER_STDOUT_BYTES) throw new Error('image decoder output bound exceeded')
- const result = JSON.parse(Buffer.concat(stdout).toString('utf8'))
- if (!Number.isSafeInteger(result.width) || result.width < 1 ||
- !Number.isSafeInteger(result.height) || result.height < 1 ||
- !/^[A-F0-9]{16}$/.test(result.code)) throw new Error('image decoder result invalid')
- settled = true
- resolve({ width: result.width, height: result.height, code: result.code })
- } catch (error) {
- fail(error)
- }
- })
- child.stdin.on('error', () => {})
- child.stdin.end(bytes)
- })
-}
-
function wireText(item) {
if (typeof item?.content === 'string') return item.content
if (!Array.isArray(item?.content)) return ''
diff --git a/scripts/e2e/fixtures/subscription-image-runner.Dockerfile b/scripts/e2e/fixtures/subscription-image-runner.Dockerfile
index 909458689..77e1fef5e 100644
--- a/scripts/e2e/fixtures/subscription-image-runner.Dockerfile
+++ b/scripts/e2e/fixtures/subscription-image-runner.Dockerfile
@@ -115,6 +115,7 @@ COPY scripts/e2e/prepare-subscription-remaining-fixtures.mjs \
scripts/e2e/prepare-subscription-remaining-fixtures.prepare.mjs ./scripts/e2e/
COPY scripts/e2e/fixtures/subscription-image-provider.mjs \
scripts/e2e/fixtures/subscription-image-challenge.cjs \
+ scripts/e2e/fixtures/subscription-image-decoder.mjs \
scripts/e2e/fixtures/subscription-image-session.mjs \
scripts/e2e/fixtures/subscription-image-admission-pressure.mjs \
scripts/e2e/fixtures/subscription-image-runner.base-image ./scripts/e2e/fixtures/
diff --git a/scripts/e2e/prepare-subscription-remaining-fixtures.mjs b/scripts/e2e/prepare-subscription-remaining-fixtures.mjs
index 380419849..10a7384fe 100644
--- a/scripts/e2e/prepare-subscription-remaining-fixtures.mjs
+++ b/scripts/e2e/prepare-subscription-remaining-fixtures.mjs
@@ -5,6 +5,7 @@ import fs from 'node:fs'
import path from 'node:path'
import { createRequire } from 'node:module'
import { validateRemainingFixture } from '../../desktop-app/test/e2e-playwright/subscriptionRemainingJourneysContract.ts'
+import { decodeInChild, hasCompleteImageContainer } from './fixtures/subscription-image-decoder.mjs'
const codec = createRequire(import.meta.url)('./fixtures/subscription-image-challenge.cjs')
const sha256 = bytes => createHash('sha256').update(bytes).digest('hex')
@@ -127,9 +128,10 @@ async function validateFrame(frame, admission, root) {
(asset.mimeType === 'image/png' && !bytes.subarray(0, 8).equals(Buffer.from([137,80,78,71,13,10,26,10]))) ||
(asset.mimeType === 'image/jpeg' && !bytes.subarray(0, 3).equals(Buffer.from([255,216,255]))) ||
(matches[0].sizeBytes !== undefined && matches[0].sizeBytes !== bytes.length)) fail('REMAINING_FIXTURE_ASSET_MISMATCH')
- // Decoding each received byte sequence rules out shape-only images and an
- // answer table keyed by file names, digests or PNG metadata.
- await codec.decodeTileChallenge(bytes)
+ // A malformed native container can crash the addon. Reuse the vendor's
+ // isolated decoder so rejected bytes cannot kill the runner or preparer.
+ if (!hasCompleteImageContainer(bytes, asset.mimeType)) fail('REMAINING_FIXTURE_ASSET_MISMATCH')
+ await decodeInChild(bytes)
decoded.push({ filename, bytes })
}
return { receipt, receiptPath, decoded }
diff --git a/scripts/e2e/run-subscription-image-journeys.mjs b/scripts/e2e/run-subscription-image-journeys.mjs
index d7594d327..d8135c559 100644
--- a/scripts/e2e/run-subscription-image-journeys.mjs
+++ b/scripts/e2e/run-subscription-image-journeys.mjs
@@ -33,11 +33,14 @@ import {
verifySourceManifest,
} from '../tests/lib/subscription-image-runner-contract.mjs'
import { startPrivateSession } from './fixtures/subscription-image-session.mjs'
+import { acceptRemainingFixtureFrame } from './prepare-subscription-remaining-fixtures.mjs'
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
const RUN_BASE = RUNNER_RUN_BASE
const ADMISSION_ROOT = RUNNER_ADMISSION_ROOT
-const MAX_FRAME_BYTES = 4 * 1024 * 1024
+const MAX_FRAME_BYTES = 8 * 1024 * 1024
+const MAX_PENDING_INPUT_BYTES = 2 * MAX_FRAME_BYTES
+const MAX_PENDING_INPUT_FRAMES = 32
const SESSION_ADMISSION_DEADLINE_MS = 2_700_000
const VOLUME_MANIFEST_FILE = 'volume-manifest.json'
const refuse = code => {
@@ -138,6 +141,10 @@ export function sealSourceManifest(repoRoot) {
'mcp-host/package.json',
'mcp-host/package-lock.json',
'scripts/e2e/run-subscription-image-journeys.mjs',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.mjs',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.gfs.mjs',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.runtime.mjs',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.prepare.mjs',
'scripts/e2e/fixtures',
'scripts/tests/lib/subscription-image-runner-contract.mjs',
'scripts/tests/lib/subscription-image-source-context.mjs',
@@ -228,9 +235,21 @@ async function loopbackRelay(target) {
}
}
-function inputFrames(admission, root) {
+export function inputFrames(
+ admission,
+ root,
+ { input = process.stdin, loginEnv = process.env, deadlineMs = 30_000 } = {}
+) {
+ const suite = resolveSuite(admission.suiteId)
let buffered = Buffer.alloc(0),
- receivedLogin = false
+ receivedLogin = false,
+ remainingFixture,
+ pendingBytes = 0,
+ draining = false,
+ ended = false,
+ closed = false,
+ failed
+ const pending = []
const previous = new Map(admission.bindings.map(binding => [binding.provider, []]))
const vendorReady = new Set()
let resolveReady, rejectReady, rejectFailure
@@ -242,16 +261,32 @@ function inputFrames(admission, root) {
rejectFailure = reject
})
// Retain a handler immediately, including before the runner starts waiting.
+ void ready.catch(() => {})
void failure.catch(() => {})
+ const erasePending = () => {
+ buffered.fill(0)
+ buffered = Buffer.alloc(0)
+ for (const line of pending.splice(0)) {
+ pendingBytes -= line.length + 1
+ line.fill(0)
+ }
+ }
const fail = err => {
+ if (failed || closed) return
+ failed = err
+ clearTimeout(timer)
+ input.pause()
+ erasePending()
rejectReady(err)
rejectFailure(err)
}
const timer = setTimeout(
- () => rejectReady(new RunnerAdmissionError('PRIVATE_INPUT_DEADLINE')),
- 30_000
+ () => fail(new RunnerAdmissionError('PRIVATE_INPUT_DEADLINE')),
+ deadlineMs
)
- const accept = frame => {
+ const accept = async frame => {
+ if (!frame || typeof frame !== 'object' || Array.isArray(frame))
+ refuse('PRIVATE_INPUT_FRAME_INVALID')
if (frame.kind === 'evenfire-subscription-image-login-v1') {
if (
receivedLogin ||
@@ -265,9 +300,13 @@ function inputFrames(admission, root) {
refuse('PRIVATE_LOGIN_FRAME')
// The authorized test login stays only in this process and the existing
// visible-login fixture's child environment. Never persist or echo it.
- process.env.E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL = frame.email
- process.env.E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD = frame.password
+ loginEnv.E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL = frame.email
+ loginEnv.E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD = frame.password
receivedLogin = true
+ } else if (frame.kind === 'evenfire-subscription-remaining-fixture-frame-v1') {
+ if (!suite.fixtureReceiptEnv || remainingFixture)
+ refuse('REMAINING_FIXTURE_NOT_AUTHORIZED')
+ remainingFixture = await acceptRemainingFixtureFrame(frame, { admission, runRoot: root })
} else {
const binding = admission.bindings.find(candidate => candidate.provider === frame.provider)
if (admission.mode !== 'fixture' || !binding) refuse('VENDOR_FRAME_NOT_AUTHORIZED')
@@ -297,48 +336,103 @@ function inputFrames(admission, root) {
previous.set(frame.provider, ledger.attempts)
vendorReady.add(frame.provider)
}
- if (receivedLogin && (admission.mode === 'real' || vendorReady.size === 2)) {
- clearTimeout(timer)
- resolveReady()
+ }
+ const drain = async () => {
+ if (draining || failed || closed) return
+ draining = true
+ try {
+ for (let line; !failed && !closed && (line = pending.shift()); ) {
+ const bytes = line.length + 1
+ try {
+ const frame = JSON.parse(line.toString('utf8'))
+ line.fill(0)
+ await accept(frame)
+ } finally {
+ line.fill(0)
+ pendingBytes -= bytes
+ }
+ }
+ if (failed || closed) return
+ if (ended && (!receivedLogin || buffered.length)) refuse('PRIVATE_INPUT_ENDED')
+ if (
+ !buffered.length &&
+ receivedLogin &&
+ (admission.mode === 'real' || vendorReady.size === 2) &&
+ (!suite.fixtureReceiptEnv || remainingFixture)
+ ) {
+ clearTimeout(timer)
+ resolveReady(
+ suite.fixtureReceiptEnv
+ ? { [suite.optInEnv]: '1', [suite.fixtureReceiptEnv]: remainingFixture.receiptPath }
+ : {}
+ )
+ }
+ } catch (err) {
+ fail(err)
+ } finally {
+ draining = false
+ if (!failed && !closed && !ended) input.resume()
}
}
const onData = chunk => {
+ if (failed || closed) return
+ input.pause()
try {
- if (buffered.length + chunk.length > MAX_FRAME_BYTES) refuse('PRIVATE_INPUT_FRAME_BOUND')
+ if (!Buffer.isBuffer(chunk)) refuse('PRIVATE_INPUT_FRAME_INVALID')
+ // Includes the frame currently decoding, queued frames and incomplete
+ // bytes. Pausing stdin also applies native pipe backpressure during decode.
+ if (pendingBytes + buffered.length + chunk.length > MAX_PENDING_INPUT_BYTES)
+ refuse('PRIVATE_INPUT_PENDING_BYTES_BOUND')
buffered = Buffer.concat([buffered, chunk])
for (let end; (end = buffered.indexOf(10)) !== -1; ) {
const line = buffered.subarray(0, end)
buffered = buffered.subarray(end + 1)
if (!line.length) refuse('PRIVATE_INPUT_FRAME_EMPTY')
- try {
- accept(JSON.parse(line.toString('utf8')))
- } finally {
+ if (line.length > MAX_FRAME_BYTES) {
+ line.fill(0)
+ refuse('PRIVATE_INPUT_FRAME_BOUND')
+ }
+ if (pending.length + Number(draining) >= MAX_PENDING_INPUT_FRAMES) {
line.fill(0)
+ refuse('PRIVATE_INPUT_PENDING_FRAMES_BOUND')
}
+ pending.push(line)
+ pendingBytes += line.length + 1
}
+ if (buffered.length > MAX_FRAME_BYTES) refuse('PRIVATE_INPUT_FRAME_BOUND')
+ void drain()
} catch (err) {
fail(err)
- process.stdin.pause()
}
}
- process.stdin.on('data', onData)
const onEnd = () => {
- if (!receivedLogin || admission.mode === 'fixture')
- fail(new RunnerAdmissionError('PRIVATE_INPUT_ENDED'))
+ ended = true
+ if (admission.mode === 'fixture') fail(new RunnerAdmissionError('PRIVATE_INPUT_ENDED'))
+ else void drain()
}
- process.stdin.once('end', onEnd)
const onError = () => fail(new RunnerAdmissionError('PRIVATE_INPUT_FAILED'))
- process.stdin.once('error', onError)
+ const onClose = () => {
+ if (!ended) fail(new RunnerAdmissionError('PRIVATE_INPUT_ENDED'))
+ }
+ input.on('data', onData)
+ input.once('end', onEnd)
+ input.once('error', onError)
+ input.once('close', onClose)
return {
ready,
failure,
+ assertHealthy: () => {
+ if (failed) throw failed
+ },
close: () => {
+ closed = true
clearTimeout(timer)
- process.stdin.off('data', onData)
- process.stdin.off('end', onEnd)
- process.stdin.off('error', onError)
- process.stdin.pause()
- buffered.fill(0)
+ input.off('data', onData)
+ input.off('end', onEnd)
+ input.off('error', onError)
+ input.off('close', onClose)
+ input.pause()
+ erasePending()
},
}
}
@@ -439,7 +533,7 @@ async function prepare(admissionFile) {
)
}
channel = inputFrames(admission, root)
- await channel.ready
+ Object.assign(env, await channel.ready)
env.E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL = process.env.E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL
env.E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD = process.env.E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD
const contract = await import(
@@ -506,6 +600,7 @@ async function prepare(admissionFile) {
root,
desktopRequire,
inputFailure: channel.failure,
+ assertInputHealthy: channel.assertHealthy,
close: async () => {
channel.close()
await Promise.all([rest.close(), rpc.close()])
@@ -519,6 +614,7 @@ async function prepare(admissionFile) {
}
async function runJourneys(prepared) {
+ prepared.assertInputHealthy()
const cli = prepared.desktopRequire.resolve('@playwright/test/cli')
const child = spawn(
process.execPath,
diff --git a/scripts/tests/lib/subscription-image-runner-contract.mjs b/scripts/tests/lib/subscription-image-runner-contract.mjs
index 39019054a..8bc4c6a5e 100644
--- a/scripts/tests/lib/subscription-image-runner-contract.mjs
+++ b/scripts/tests/lib/subscription-image-runner-contract.mjs
@@ -1319,6 +1319,12 @@ export function verifySourceManifest(manifest, repoRoot) {
'desktop-app/test/e2e-playwright/subscriptionImageRunContract.ts',
'desktop-app/test/e2e-playwright/subscription-image-input.spec.ts',
'desktop-app/test/e2e-playwright/playwright.subscription-image.config.ts',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.mjs',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.gfs.mjs',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.runtime.mjs',
+ 'scripts/e2e/prepare-subscription-remaining-fixtures.prepare.mjs',
+ 'desktop-app/test/e2e-playwright/subscriptionRemainingJourneysContract.ts',
+ 'scripts/e2e/fixtures/subscription-image-decoder.mjs',
'scripts/e2e/fixtures/subscription-image-challenge.cjs',
'scripts/e2e/fixtures/subscription-image-session.mjs',
'scripts/e2e/fixtures/subscription-image-runner.base-image',
diff --git a/scripts/tests/lib/subscription-image-source-context.mjs b/scripts/tests/lib/subscription-image-source-context.mjs
index 8e4bc5e34..beeda91dd 100644
--- a/scripts/tests/lib/subscription-image-source-context.mjs
+++ b/scripts/tests/lib/subscription-image-source-context.mjs
@@ -43,6 +43,7 @@ const fixedFiles = [
'scripts/e2e/prepare-subscription-remaining-fixtures.prepare.mjs',
'scripts/e2e/fixtures/subscription-image-runner.Dockerfile',
'scripts/e2e/fixtures/subscription-image-provider.mjs',
+ 'scripts/e2e/fixtures/subscription-image-decoder.mjs',
'scripts/e2e/fixtures/subscription-image-challenge.cjs',
'scripts/e2e/fixtures/subscription-image-session.mjs',
'scripts/e2e/fixtures/subscription-image-runner.base-image',
diff --git a/scripts/tests/subscription-image-input-frames.test.mjs b/scripts/tests/subscription-image-input-frames.test.mjs
new file mode 100644
index 000000000..621e242d7
--- /dev/null
+++ b/scripts/tests/subscription-image-input-frames.test.mjs
@@ -0,0 +1,401 @@
+// Protocol tests use actual Node stdin and native PNG/JPEG assets. Unit pod
+// metadata never reaches a cluster and is not browser or G8 evidence.
+// E2E_GUARDIAN_IPC_FLOW: private frame admission and materialization only.
+import assert from 'node:assert/strict'
+import { spawn } from 'node:child_process'
+import { randomUUID } from 'node:crypto'
+import fs from 'node:fs'
+import os from 'node:os'
+import path from 'node:path'
+import { PassThrough } from 'node:stream'
+import test from 'node:test'
+import { fileURLToPath, pathToFileURL } from 'node:url'
+import { inputFrames, sealSourceManifest } from '../e2e/run-subscription-image-journeys.mjs'
+import { buildRemainingFixtureFrame, createRemainingPixelAssets, remainingAssetPath } from '../e2e/prepare-subscription-remaining-fixtures.mjs'
+import { decodeInChild } from '../e2e/fixtures/subscription-image-decoder.mjs'
+import { digest, expectedJourneyNames, resolveSuite } from './lib/subscription-image-runner-contract.mjs'
+
+const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
+const uuid = index => `00000000-0000-4000-8000-${String(index).padStart(12, '0')}`
+const privateRoot = () => {
+ const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'subscription-input-unit-')))
+ fs.chmodSync(root, 0o700)
+ return root
+}
+function unitAdmission(suiteId = 'subscription-image-input', mode = 'fixture') {
+ const admission = {
+ runId: 'subscription-image-123456789abc', mode, suiteId,
+ profile: 'qa-owned-unit', context: 'qa-owned-unit', gitHead: 'a'.repeat(40),
+ sourceManifestSha256: 'b'.repeat(64),
+ bindings: ['grok', 'codex'].map(kind => ({ provider: `${kind}-subscription`,
+ hostRef: `qa-${kind}`, hostLabel: `QA ${kind}`, modelId: `${kind}-image`,
+ modelLabel: `${kind} Image`, unsupportedModelId: `${kind}-text` })),
+ }
+ admission.vendorSources = Object.fromEntries(admission.bindings.map((binding, index) =>
+ [binding.provider, { profile: admission.profile, gitHead: admission.gitHead,
+ podUid: uuid(index + 1), imageId: `sha256:${'c'.repeat(64)}`,
+ fixtureImportSha256: 'd'.repeat(64) }]))
+ return admission
+}
+// Random throwaway values test in-memory delivery without using a real account.
+const UNIT_LOGIN_EMAIL = `${randomUUID()}@example.invalid`
+const UNIT_LOGIN_VALUE = randomUUID()
+const login = admission => ({ kind: 'evenfire-subscription-image-login-v1',
+ runId: admission.runId, email: UNIT_LOGIN_EMAIL, password: UNIT_LOGIN_VALUE })
+const vendor = (admission, binding, attempts = []) => ({
+ kind: 'evenfire-subscription-image-vendor-frame-v1', runId: admission.runId,
+ provider: binding.provider, source: admission.vendorSources[binding.provider],
+ ledger: { kind: 'evenfire-subscription-image-vendor-v1', runId: admission.runId, attempts },
+})
+const initialFrames = admission => [login(admission), ...admission.bindings.map(binding => vendor(admission, binding))]
+const ndjson = frames => Buffer.from(frames.map(frame => JSON.stringify(frame)).join('\n') + '\n')
+
+async function remainingFrame(admission, root) {
+ const assets = createRemainingPixelAssets({ admission, runRoot: root })
+ const fixtures = Object.fromEntries(admission.bindings.map((binding, index) => {
+ const identity = { hostRef: binding.hostRef, podUid: uuid(index + 1), imageId: `sha256:${'c'.repeat(64)}` }
+ const selected = assets.filter(asset => asset.provider === binding.provider)
+ if (admission.suiteId === 'tool-screenshot') {
+ const asset = selected[0]
+ return [binding.provider, { ...identity, hostImagePath: `/tmp/evenfire-qa-screen-${uuid(index + 3)}.png`,
+ fixtureImagePath: remainingAssetPath(root, admission.suiteId, asset.name), imageSha256: asset.sha256,
+ region: { x: 0, y: 0, w: 512, h: 512 } }]
+ }
+ if (admission.suiteId === 'gfs-image') return [binding.provider, { ...identity, folderNames: ['QA protocol images'],
+ files: selected.map((asset, assetIndex) => {
+ const pickerResourceId = uuid(index * 10 + assetIndex + 11)
+ const resourceId = pickerResourceId.replaceAll('-', '')
+ return { name: asset.name, drive: 'main', pickerResourceId, resourceId, version: 1,
+ gfsUri: `gfs://main/${resourceId}`, mimeType: asset.mimeType,
+ sizeBytes: Buffer.from(asset.contentsBase64, 'base64').length,
+ fixtureImagePath: remainingAssetPath(root, admission.suiteId, asset.name), imageSha256: asset.sha256,
+ width: 512, height: 512 }
+ }) }]
+ const other = admission.bindings.find(candidate => candidate.provider !== binding.provider)
+ return [binding.provider, { ...identity, controlApiPodUid: uuid(40), controlApiImageId: `sha256:${'e'.repeat(64)}`,
+ maxInFlight: 2, readDeadlineMs: 500,
+ pressure: { receiptFile: '/runner-admission/pressure-metadata.json' },
+ fallback: { provider: other.provider, modelId: other.modelId } }]
+ }))
+ return buildRemainingFixtureFrame({ admission, runRoot: root, fixtures, assets })
+}
+
+function unexpectedReceiverStderr(value) {
+ // Node 24 reparses this pure TS fixture contract as ESM. Admit only this
+ // exact known warning block; all other warnings/diagnostics remain failures.
+ const contract = pathToFileURL(path.join(repoRoot, 'desktop-app/test/e2e-playwright/subscriptionRemainingJourneysContract.ts')).href
+ const warning = [
+ `[MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of ${contract} is not specified and it doesn't parse as CommonJS.`,
+ 'Reparsing as ES module because module syntax was detected. This incurs a performance overhead.',
+ `To eliminate this warning, add "type": "module" to ${path.join(repoRoot, 'desktop-app/package.json')}.`,
+ '(Use `node --trace-warnings ...` to show where the warning was created)',
+ '',
+ ].join('\n')
+ const escaped = warning.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+ return value.replace(new RegExp(`\\(node:[0-9]+\\) ${escaped}`, 'g'), '')
+}
+
+async function nativeReceiver(t, admission, root, deadlineMs = 5_000) {
+ const runner = pathToFileURL(path.join(repoRoot, 'scripts/e2e/run-subscription-image-journeys.mjs')).href
+ // The child uses the actual runner receiver. IPC only controls unit lifecycle
+ // and probes; all admitted frames cross the native stdin pipe.
+ const code = `
+ import fs from 'node:fs';
+ import { inputFrames } from ${JSON.stringify(runner)};
+ const loginEnv = {}, channel = inputFrames(${JSON.stringify(admission)}, ${JSON.stringify(root)},
+ { loginEnv, deadlineMs: ${deadlineMs} });
+ let ready = false;
+ const emit = value => console.log(JSON.stringify(value));
+ channel.ready.then(env => { ready = true; emit({ kind: 'ready', env }); }).catch(() => {});
+ channel.failure.catch(error => {
+ emit({ kind: 'failed', code: error.code ?? error.message });
+ channel.close(); process.stdin.destroy(); process.disconnect(); process.exitCode = 1;
+ });
+ process.on('message', message => {
+ if (message === 'probe') emit({ kind: 'probe', ready, inputEnded: process.stdin.readableEnded,
+ vendors: ['grok-subscription', 'codex-subscription'].map(provider => {
+ const filename = ${JSON.stringify(root)} + '/' + provider + '-vendor.json';
+ return fs.existsSync(filename) ? JSON.parse(fs.readFileSync(filename, 'utf8')).attempts.length : null;
+ }) });
+ if (message === 'finish') {
+ channel.assertHealthy();
+ if (!ready) throw Error('UNIT_RECEIVER_NOT_READY');
+ channel.close(); process.stdin.destroy(); process.disconnect(); process.exitCode = 0;
+ }
+ });
+ emit({ kind: 'listening' });
+ `
+ const child = spawn(process.execPath, ['--input-type=module', '-e', code], {
+ stdio: ['pipe', 'pipe', 'pipe', 'ipc'], timeout: 15_000,
+ env: { PATH: path.dirname(process.execPath) },
+ })
+ const events = [], waiters = []
+ let stdout = '', stderr = '', closed = false, exitResult
+ const completion = new Promise((resolve, reject) => {
+ child.once('error', reject)
+ child.once('close', (producerExit, signal) => {
+ closed = true
+ exitResult = { producerExit, signal, stderr }
+ resolve(exitResult)
+ for (const notify of [...waiters]) notify()
+ })
+ })
+ child.stdin.on('error', () => {})
+ child.stderr.on('data', chunk => { stderr += chunk; assert.ok(stderr.length < 64 * 1024) })
+ child.stdout.on('data', chunk => {
+ stdout += chunk
+ assert.ok(stdout.length < 64 * 1024)
+ for (let end; (end = stdout.indexOf('\n')) !== -1;) {
+ events.push(JSON.parse(stdout.slice(0, end)))
+ stdout = stdout.slice(end + 1)
+ for (const notify of [...waiters]) notify()
+ }
+ })
+ const next = kind => new Promise((resolve, reject) => {
+ const timer = setTimeout(() => { waiters.splice(waiters.indexOf(check), 1); reject(Error(`UNIT_RECEIVER_${kind}_TIMEOUT`)) }, 10_000)
+ const check = () => {
+ const index = events.findIndex(value => value.kind === kind)
+ if (index < 0 && !closed) return
+ clearTimeout(timer)
+ const queued = waiters.indexOf(check)
+ if (queued >= 0) waiters.splice(queued, 1)
+ if (index >= 0) resolve(events.splice(index, 1)[0])
+ else reject(Error(`UNIT_RECEIVER_EXIT_BEFORE_${kind}: exit=${exitResult.producerExit}, signal=${exitResult.signal}`))
+ }
+ waiters.push(check); check()
+ })
+ const probeUntil = async predicate => {
+ const deadline = Date.now() + 5_000
+ for (let probes = 0; probes < 128 && Date.now() <= deadline; probes++) {
+ child.send('probe')
+ const state = await next('probe')
+ if (predicate(state)) return state
+ // Yield to actual IPC/stdin events; no clock delay is used as readiness.
+ await new Promise(resolve => setImmediate(resolve))
+ }
+ throw Error('UNIT_RECEIVER_STATE_DEADLINE')
+ }
+ t.after(async () => {
+ if (!closed) child.kill('SIGTERM')
+ await completion
+ })
+ await next('listening')
+ return { child, events, next, completion, probeUntil,
+ send: frames => child.stdin.write(ndjson(frames)),
+ finish: async () => {
+ child.send('finish')
+ const result = await completion
+ assert.equal(result.producerExit, 0)
+ assert.equal(result.signal, null)
+ assert.equal(unexpectedReceiverStderr(result.stderr), '')
+ } }
+}
+
+for (const suiteId of ['tool-screenshot', 'gfs-image', 'admission-recovery']) {
+ test(`native stdin accepts ${suiteId} before returning its exact suite opt-in and private receipt`, async t => {
+ const root = privateRoot(), admission = unitAdmission(suiteId)
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }))
+ const frame = await remainingFrame(admission, root), receiver = await nativeReceiver(t, admission, root)
+ const inputs = initialFrames(admission)
+ receiver.send([...inputs, frame])
+ const ready = await receiver.next('ready'), suite = resolveSuite(suiteId)
+ const receiptPath = path.join(root, `remaining-${suiteId}.json`)
+ assert.deepEqual(ready.env, { [suite.optInEnv]: '1', [suite.fixtureReceiptEnv]: receiptPath })
+ assert.equal(fs.statSync(receiptPath).mode & 0o777, 0o600)
+ assert.equal(fs.statSync(path.join(root, `remaining-${suiteId}`)).mode & 0o777, 0o700)
+ for (const asset of frame.assets) {
+ const filename = remainingAssetPath(root, suiteId, asset.name)
+ assert.equal(fs.statSync(filename).mode & 0o777, 0o600)
+ assert.equal(digest(fs.readFileSync(filename)), asset.sha256)
+ }
+ for (const filename of fs.readdirSync(root).filter(name => name.endsWith('.json'))) {
+ const contents = fs.readFileSync(path.join(root, filename), 'utf8')
+ assert.equal(contents.includes(inputs[0].email), false)
+ assert.equal(contents.includes(inputs[0].password), false)
+ }
+ await receiver.finish()
+ })
+}
+
+test('native stdin waits for a delayed remaining fixture after both vendor frames and login are accepted', async t => {
+ const root = privateRoot(), admission = unitAdmission('gfs-image')
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }))
+ const frame = await remainingFrame(admission, root), receiver = await nativeReceiver(t, admission, root)
+ receiver.send(initialFrames(admission))
+ assert.deepEqual(await receiver.probeUntil(state => state.vendors.every(count => count === 0)),
+ { kind: 'probe', ready: false, inputEnded: false, vendors: [0, 0] })
+ receiver.send([frame]); await receiver.next('ready'); await receiver.finish()
+})
+
+test('native async decode failure never becomes ready and cannot publish a preparation receipt', async t => {
+ const root = privateRoot(), admission = unitAdmission('gfs-image')
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }))
+ const frame = await remainingFrame(admission, root), receiver = await nativeReceiver(t, admission, root)
+ const asset = frame.assets[1], valid = Buffer.from(asset.contentsBase64, 'base64'), corrupt = Buffer.alloc(valid.length)
+ valid.copy(corrupt, 0, 0, 3)
+ valid.copy(corrupt, corrupt.length - 2, valid.length - 2)
+ asset.contentsBase64 = corrupt.toString('base64'); asset.sha256 = digest(corrupt)
+ frame.receipt.fixtures[asset.provider].files.find(file => file.name === asset.name).imageSha256 = asset.sha256
+ receiver.send([...initialFrames(admission), frame])
+ assert.match((await receiver.next('failed')).code, /image decoder exited/)
+ assert.equal(receiver.events.some(value => value.kind === 'ready'), false)
+ assert.equal(fs.existsSync(path.join(root, 'remaining-gfs-image.json')), false)
+ assert.equal(fs.existsSync(path.join(root, 'remaining-gfs-image')), false)
+ assert.equal((await receiver.completion).producerExit, 1)
+ // The same parent process must survive malformed native decoding and then
+ // decode real pixels. Recovery cannot be inferred from a rejection alone.
+ const parentPid = process.pid
+ await assert.rejects(decodeInChild(corrupt), /image decoder exited/)
+ const decoded = await decodeInChild(valid)
+ assert.equal(process.pid, parentPid)
+ assert.equal(decoded.width, 512)
+ assert.equal(decoded.height, 512)
+ assert.match(decoded.code, /^[A-F0-9]{16}$/)
+})
+
+test('serial async draining rejects a duplicate fixture queued behind valid native preparation before ready', async () => {
+ const root = privateRoot(), admission = unitAdmission('tool-screenshot'), input = new PassThrough()
+ const channel = inputFrames(admission, root, { input, loginEnv: {} })
+ try {
+ const frame = await remainingFrame(admission, root)
+ input.write(ndjson([...initialFrames(admission), frame, frame]))
+ await assert.rejects(channel.ready, /REMAINING_FIXTURE_NOT_AUTHORIZED/)
+ await assert.rejects(channel.failure, /REMAINING_FIXTURE_NOT_AUTHORIZED/)
+ assert.throws(channel.assertHealthy, /REMAINING_FIXTURE_NOT_AUTHORIZED/)
+ assert.equal(fs.existsSync(path.join(root, 'remaining-tool-screenshot.json')), true)
+ } finally { channel.close(); input.destroy(); fs.rmSync(root, { recursive: true, force: true }) }
+})
+
+test('native stream retains validated append-only vendor frames and rejects a changed accepted history', async t => {
+ const root = privateRoot(), admission = unitAdmission()
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }))
+ const receiver = await nativeReceiver(t, admission, root)
+ receiver.send(initialFrames(admission))
+ assert.deepEqual((await receiver.next('ready')).env, {})
+ const binding = admission.bindings[0], row = { sequence: 1, provider: binding.provider, model: binding.modelId,
+ receiptId: uuid(50), imageSha256: [], mimeTypes: [], requestSha256: 'f'.repeat(64), responseKind: 'text' }
+ const filename = path.join(root, `${binding.provider}-vendor.json`)
+ receiver.send([vendor(admission, binding, [row])])
+ assert.deepEqual(await receiver.probeUntil(state => state.vendors[0] === 1),
+ { kind: 'probe', ready: true, inputEnded: false, vendors: [1, 0] })
+ receiver.send([vendor(admission, binding, [{ ...row, requestSha256: 'e'.repeat(64) }])])
+ assert.equal((await receiver.next('failed')).code, 'VENDOR_EVIDENCE_HISTORY_CHANGED')
+ assert.deepEqual(JSON.parse(fs.readFileSync(filename, 'utf8')).attempts, [row])
+ assert.equal((await receiver.completion).producerExit, 1)
+})
+
+test('native fixture EOF after readiness remains an input failure; real composer login may end cleanly', async t => {
+ for (const mode of ['fixture', 'real']) {
+ const root = privateRoot(), admission = unitAdmission('subscription-image-input', mode)
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }))
+ const receiver = await nativeReceiver(t, admission, root)
+ receiver.send(mode === 'fixture' ? initialFrames(admission) : [login(admission)])
+ await receiver.next('ready')
+ receiver.child.stdin.end()
+ if (mode === 'fixture') {
+ assert.equal((await receiver.next('failed')).code, 'PRIVATE_INPUT_ENDED')
+ assert.equal((await receiver.completion).producerExit, 1)
+ } else {
+ await receiver.probeUntil(state => state.inputEnded)
+ await receiver.finish()
+ }
+ }
+})
+
+test('native dropped stdin, malformed input and admission deadline fail instead of leaving readiness pending', async t => {
+ for (const control of ['drop', 'malformed', 'deadline']) {
+ const root = privateRoot(), admission = unitAdmission('tool-screenshot')
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }))
+ const receiver = await nativeReceiver(t, admission, root, control === 'deadline' ? 75 : 5_000)
+ if (control === 'drop') receiver.child.stdin.end()
+ if (control === 'malformed') receiver.child.stdin.write('{invalid}\n')
+ const failure = await receiver.next('failed')
+ assert.match(failure.code, control === 'drop' ? /PRIVATE_INPUT_ENDED/ : control === 'deadline' ? /PRIVATE_INPUT_DEADLINE/ : /JSON/)
+ assert.equal(receiver.events.some(value => value.kind === 'ready'), false)
+ assert.equal((await receiver.completion).producerExit, 1)
+ }
+})
+
+test('a readable error or unexpected close rejects both readiness and ongoing input health', async () => {
+ for (const control of ['error', 'close']) {
+ const root = privateRoot(), input = new PassThrough()
+ const channel = inputFrames(unitAdmission('gfs-image'), root, { input, loginEnv: {} })
+ try {
+ input.destroy(control === 'error' ? new Error('Unit transport interruption') : undefined)
+ const code = control === 'error' ? 'PRIVATE_INPUT_FAILED' : 'PRIVATE_INPUT_ENDED'
+ await assert.rejects(channel.ready, error => error.code === code)
+ await assert.rejects(channel.failure, error => error.code === code)
+ assert.throws(channel.assertHealthy, error => error.code === code)
+ assert.deepEqual(fs.readdirSync(root), [])
+ } finally { channel.close(); fs.rmSync(root, { recursive: true, force: true }) }
+ }
+})
+
+test('private receiver bounds a single frame, queued bytes and queued frames before accepting them', async () => {
+ const admission = unitAdmission(), binding = admission.bindings[0]
+ for (const [bytes, code] of [
+ [Buffer.alloc(8 * 1024 * 1024 + 1, 32), 'PRIVATE_INPUT_FRAME_BOUND'],
+ [Buffer.alloc(16 * 1024 * 1024 + 1, 32), 'PRIVATE_INPUT_PENDING_BYTES_BOUND'],
+ [ndjson(Array.from({ length: 33 }, () => vendor(admission, binding))), 'PRIVATE_INPUT_PENDING_FRAMES_BOUND'],
+ ]) {
+ const root = privateRoot(), input = new PassThrough(), channel = inputFrames(admission, root, { input, loginEnv: {} })
+ try {
+ input.write(bytes)
+ await assert.rejects(channel.ready, error => error.code === code)
+ await assert.rejects(channel.failure, error => error.code === code)
+ assert.deepEqual(fs.readdirSync(root), [])
+ } finally { channel.close(); input.destroy(); fs.rmSync(root, { recursive: true, force: true }) }
+ }
+})
+
+test('remaining fixtures cannot activate the composer inventory or a real preparation lane', async () => {
+ for (const admission of [unitAdmission(), unitAdmission('tool-screenshot', 'real')]) {
+ const root = privateRoot(), input = new PassThrough(), channel = inputFrames(admission, root, { input, loginEnv: {} })
+ try {
+ const fixtureAdmission = { ...admission, suiteId: 'tool-screenshot', mode: 'fixture' }
+ const frame = await remainingFrame(fixtureAdmission, root)
+ input.write(ndjson([frame]))
+ await assert.rejects(channel.ready, admission.mode === 'real' ? /REQUIRES_OPERATOR/ : /NOT_AUTHORIZED/)
+ assert.deepEqual(fs.readdirSync(root), [])
+ } finally { channel.close(); input.destroy(); fs.rmSync(root, { recursive: true, force: true }) }
+ }
+ assert.equal(expectedJourneyNames('fixture').length, 14)
+ assert.equal(expectedJourneyNames('real').length, 15)
+})
+
+test('sealing the exact runner source includes all four preparation helpers and refuses an omitted helper', () => {
+ const helpers = ['prepare-subscription-remaining-fixtures.mjs', 'prepare-subscription-remaining-fixtures.gfs.mjs',
+ 'prepare-subscription-remaining-fixtures.runtime.mjs', 'prepare-subscription-remaining-fixtures.prepare.mjs']
+ const root = privateRoot()
+ try {
+ // Tiny prebuilt-output fixtures model manifest closure only. They are never
+ // executed, installed, sent to an image build, or claimed as UI evidence.
+ for (const relative of [
+ 'desktop-app/dist/main.js', 'desktop-app/ui-dist/index.html', 'desktop-app/package.json',
+ 'desktop-app/package-lock.json', 'mcp-host/package.json', 'mcp-host/package-lock.json',
+ 'desktop-app/test/e2e-playwright/subscriptionImageFixtures.ts',
+ 'desktop-app/test/e2e-playwright/subscriptionImageRunContract.ts',
+ 'desktop-app/test/e2e-playwright/subscriptionRemainingJourneysContract.ts',
+ 'desktop-app/test/e2e-playwright/subscription-image-input.spec.ts',
+ 'desktop-app/test/e2e-playwright/playwright.subscription-image.config.ts',
+ 'scripts/e2e/fixtures/subscription-image-challenge.cjs', 'scripts/e2e/fixtures/subscription-image-session.mjs',
+ 'scripts/e2e/fixtures/subscription-image-decoder.mjs',
+ 'scripts/e2e/fixtures/subscription-image-runner.base-image',
+ 'scripts/tests/lib/subscription-image-runner-contract.mjs', 'scripts/tests/lib/subscription-image-source-context.mjs',
+ ]) {
+ fs.mkdirSync(path.dirname(path.join(root, relative)), { recursive: true })
+ fs.writeFileSync(path.join(root, relative), '// Unit manifest artifact; never executed.\n')
+ }
+ fs.mkdirSync(path.join(root, 'packages'))
+ fs.copyFileSync(path.join(repoRoot, 'scripts/e2e/run-subscription-image-journeys.mjs'), path.join(root, 'scripts/e2e/run-subscription-image-journeys.mjs'))
+ for (const name of helpers) fs.copyFileSync(path.join(repoRoot, 'scripts/e2e', name), path.join(root, 'scripts/e2e', name))
+ fs.writeFileSync(path.join(root, 'subscription-image-input-source.json'), JSON.stringify({ gitHead: 'a'.repeat(40), gitTree: 'b'.repeat(40) }))
+ sealSourceManifest(root)
+ const manifest = JSON.parse(fs.readFileSync(path.join(root, 'subscription-image-source.json'), 'utf8'))
+ assert.ok(helpers.every(name => manifest.files.some(file => file.path === `scripts/e2e/${name}`)))
+ fs.unlinkSync(path.join(root, 'subscription-image-source.json'))
+ fs.unlinkSync(path.join(root, 'scripts/e2e', helpers[1]))
+ assert.throws(() => sealSourceManifest(root), /ENOENT/)
+ assert.equal(fs.existsSync(path.join(root, 'subscription-image-source.json')), false)
+ } finally { fs.rmSync(root, { recursive: true, force: true }) }
+})
diff --git a/scripts/tests/test-codex-subscription-t0.sh b/scripts/tests/test-codex-subscription-t0.sh
index 4c99dd776..5f88a66da 100755
--- a/scripts/tests/test-codex-subscription-t0.sh
+++ b/scripts/tests/test-codex-subscription-t0.sh
@@ -240,6 +240,8 @@ run_group "codex-upstream-contract-freeze" "tests/e2e" "integration/codex-subscr
run_node_group "approved-tools-fixtures-and-runner" \
"scripts/tests/subscription-t0-discovery.test.mjs" \
"scripts/tests/subscription-image-runner.test.mjs" \
+ "scripts/tests/subscription-image-input-frames.test.mjs" \
+ "scripts/e2e/prepare-subscription-remaining-fixtures.test.mjs" \
"scripts/e2e/fixtures/subscription-image-provider.test.mjs" \
"scripts/tests/run-node-test-files.test.mjs" \
"tests/e2e/fixtures/codex-subscription/approved-tools/server.test.mjs" \
diff --git a/scripts/tests/test-grok-subscription-t0.sh b/scripts/tests/test-grok-subscription-t0.sh
index c1f3c3678..d5d57c930 100755
--- a/scripts/tests/test-grok-subscription-t0.sh
+++ b/scripts/tests/test-grok-subscription-t0.sh
@@ -238,6 +238,8 @@ echo "Grok subscription T0 aggregator"
run_node_group "subscription-discovery-and-offline-image-provider" \
"scripts/tests/subscription-t0-discovery.test.mjs" \
"scripts/tests/subscription-image-runner.test.mjs" \
+ "scripts/tests/subscription-image-input-frames.test.mjs" \
+ "scripts/e2e/prepare-subscription-remaining-fixtures.test.mjs" \
"scripts/e2e/fixtures/subscription-image-provider.test.mjs"
require_ci_matrix_entry "grok-llm-proxy"