Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(llm): enforce pixel and isolated image journeys
Alfredo Lopez03fe2bf1927c
diff --git a/desktop-app/test/codexImageChallenge.test.ts b/desktop-app/test/codexImageChallenge.test.tsindex b556c5e07..aaaa81777 100644--- a/desktop-app/test/codexImageChallenge.test.ts+++ b/desktop-app/test/codexImageChallenge.test.ts@@ -1,4 +1,4 @@-import { describe, expect, it } from 'vitest'+import { afterEach, describe, expect, it, vi } from 'vitest'import { createRequire } from 'node:module'import {challengeImage,@@ -6,6 +6,27 @@ import {paddedChallengeImage,} from './e2e-playwright/codexImageChallenge.js'+const renderer = vi.hoisted(() => ({ unavailable: false }))+vi.mock('node:module', async importOriginal => {+ const actual = await importOriginal<typeof import('node:module')>()+ return {+ ...actual,+ createRequire: (filename: string | URL) => {+ const require = actual.createRequire(filename)+ return (id: string) => {+ if (id === '@napi-rs/canvas' && renderer.unavailable)+ throw new Error('native renderer absent')+ return require(id)+ }+ },+ }+})++afterEach(() => {+ renderer.unavailable = false+ vi.unstubAllEnvs()+})+const MIB = 1024 * 1024const { inspectVisualImage } = createRequire(import.meta.url)('../../packages/llm-provider-attempt-contract/visualPayload.cjs'@@ -73,3 +94,50 @@ describe('Codex image challenge fixtures', () => {expect(inspected.ok, inspected.message).toBe(true)})})++describe('strict pixel rendering admission', () => {+ it.each(['png', 'jpeg'] as const)(+ 'refuses missing native %s pixels independently of Codex opt-in',+ format => {+ renderer.unavailable = true+ vi.stubEnv('E2E_CODEX_IMAGE_INPUT', undefined)+ expect(() => challengeImage(format, { requirePixels: true })).toThrow(/native.*pixels/i)+ expect(() => challengeImageAt(format, 800, 120, { requirePixels: true })).toThrow(+ /native.*pixels/i+ )+ expect(() => paddedChallengeImage(format, MIB, { requirePixels: true })).toThrow(+ /native.*pixels/i+ )+ }+ )++ it('preserves the explicitly non-strict container-only geometry fixture', () => {+ renderer.unavailable = true+ vi.stubEnv('E2E_CODEX_IMAGE_INPUT', undefined)+ const image = challengeImageAt('png', 2049, 128)+ expect(+ inspectVisualImage({ mimeType: 'image/png', data: image.bytes.toString('base64') }).ok+ ).toBe(false)+ })+})++describe('strict native image content', () => {+ it.each(['png', 'jpeg'] as const)('contains painted pixels in strict %s output', async format => {+ const native = createRequire(new URL('../../mcp-host/package.json', import.meta.url))(+ '@napi-rs/canvas'+ )+ const image = challengeImage(format, { requirePixels: true })+ const decoded = await native.loadImage(image.bytes)+ const canvas = native.createCanvas(800, 120),+ context = canvas.getContext('2d')+ context.drawImage(decoded, 0, 0)+ const rgba = context.getImageData(0, 0, 800, 120).data+ let darkPixels = 0+ for (let offset = 0; offset < rgba.length; offset += 4) {+ if (rgba[offset] < 100 && rgba[offset + 1] < 100 && rgba[offset + 2] < 100) darkPixels+++ }+ expect(darkPixels).toBeGreaterThan(1000)+ expect(decoded.width).toBe(800)+ expect(decoded.height).toBe(120)+ })+})diff --git a/desktop-app/test/e2e-playwright/codex-image-input.spec.ts b/desktop-app/test/e2e-playwright/codex-image-input.spec.tsindex 2a8d6d93b..fabcd128c 100644--- a/desktop-app/test/e2e-playwright/codex-image-input.spec.ts+++ b/desktop-app/test/e2e-playwright/codex-image-input.spec.ts@@ -150,7 +150,7 @@ for (const format of ['png', 'jpeg'] as const) {test.setTimeout(240_000)// The random answer exists only in pixels, never the filename or prompt.// A generic response or discarded image cannot satisfy this 64-bit challenge.- const image = challengeImage(format)+ const image = challengeImage(format, { requirePixels: true })const filename = `visual-${randomUUID()}.${format}`await test.step('select the owned Codex Host and model through UI', async () => {await startOwnedChat(appPage)@@ -173,7 +173,7 @@ for (const format of ['png', 'jpeg'] as const) {test('2048 px JPEG follows the Codex long-side pixel bound', async ({ appPage }) => {test.setTimeout(360_000)- const image = challengeImageAt('jpeg', 2048, 256)+ const image = challengeImageAt('jpeg', 2048, 256, { requirePixels: true })const filename = `visual-${randomUUID()}.jpeg`await startOwnedChat(appPage)await uploadThroughChooser(appPage, [@@ -189,7 +189,7 @@ test('2048 px JPEG follows the Codex long-side pixel bound', async ({ appPage })test('2048 by 2048 JPEG stays at the Codex pixel ceiling', async ({ appPage }) => {test.setTimeout(360_000)- const image = challengeImageAt('jpeg', 2048, 2048)+ const image = challengeImageAt('jpeg', 2048, 2048, { requirePixels: true })const filename = `visual-${randomUUID()}.jpeg`await startOwnedChat(appPage)await uploadThroughChooser(appPage, [@@ -204,7 +204,7 @@ test('2048 by 2048 JPEG stays at the Codex pixel ceiling', async ({ appPage }) =})test('refuses a 2049 px image before send', async ({ appPage }) => {- const image = challengeImageAt('png', 2049, 128)+ const image = challengeImageAt('png', 2049, 128, { requirePixels: true })const filename = `over-res-${randomUUID()}.png`await startOwnedChat(appPage)await uploadThroughChooser(appPage, [@@ -219,7 +219,7 @@ test('refuses a 2049 px image before send', async ({ appPage }) => {test('5 MiB JPEG follows the same visual path as a small image', async ({ appPage }) => {test.setTimeout(360_000)- const image = paddedChallengeImage('jpeg', 5 * MIB)+ const image = paddedChallengeImage('jpeg', 5 * MIB, { requirePixels: true })const filename = `visual-${randomUUID()}.jpeg`await startOwnedChat(appPage)await uploadThroughChooser(appPage, [@@ -235,7 +235,7 @@ test('5 MiB JPEG follows the same visual path as a small image', async ({ appPagtest('12 MiB PNG follows the exceptional hard ceiling above 10 MiB', async ({ appPage }) => {test.setTimeout(360_000)- const image = paddedChallengeImage('png', 12 * MIB)+ const image = paddedChallengeImage('png', 12 * MIB, { requirePixels: true })const filename = `visual-${randomUUID()}.png`await startOwnedChat(appPage)await uploadThroughChooser(appPage, [@@ -251,8 +251,8 @@ test('12 MiB PNG follows the exceptional hard ceiling above 10 MiB', async ({ aptest('10 MiB PNG + 5 MiB JPEG stay under the 16 MiB combined hard ceiling', async ({ appPage }) => {test.setTimeout(360_000)- const ten = paddedChallengeImage('png', 10 * MIB)- const five = paddedChallengeImage('jpeg', 5 * MIB)+ const ten = paddedChallengeImage('png', 10 * MIB, { requirePixels: true })+ const five = paddedChallengeImage('jpeg', 5 * MIB, { requirePixels: true })const tenName = `visual-${randomUUID()}.png`const fiveName = `visual-${randomUUID()}.jpeg`await startOwnedChat(appPage)@@ -271,9 +271,9 @@ test('10 MiB PNG + 5 MiB JPEG stay under the 16 MiB combined hard ceiling', asyntest('three 5 MiB images follow the combined budget', async ({ appPage }) => {test.setTimeout(360_000)- const first = paddedChallengeImage('png', 5 * MIB)- const second = paddedChallengeImage('jpeg', 5 * MIB)- const third = paddedChallengeImage('png', 5 * MIB)+ const first = paddedChallengeImage('png', 5 * MIB, { requirePixels: true })+ const second = paddedChallengeImage('jpeg', 5 * MIB, { requirePixels: true })+ const third = paddedChallengeImage('png', 5 * MIB, { requirePixels: true })const files: UploadFile[] = [{ name: `visual-${randomUUID()}.png`, mimeType: 'image/png', buffer: first.bytes },{ name: `visual-${randomUUID()}.jpeg`, mimeType: 'image/jpeg', buffer: second.bytes },@@ -290,7 +290,7 @@ test('three 5 MiB images follow the combined budget', async ({ appPage }) => {})test('refuses a single image over the 16 MiB limit before send', async ({ appPage }) => {- const image = paddedChallengeImage('png', 17 * MIB)+ const image = paddedChallengeImage('png', 17 * MIB, { requirePixels: true })const filename = `over-${randomUUID()}.png`await startOwnedChat(appPage)await uploadThroughChooser(appPage, [@@ -304,8 +304,8 @@ test('refuses a single image over the 16 MiB limit before send', async ({ appPag})test('composer attaches a pair that exceeds the hop aggregate', async ({ appPage }) => {- const fits = paddedChallengeImage('png', 10 * MIB)- const over = paddedChallengeImage('jpeg', 7 * MIB)+ const fits = paddedChallengeImage('png', 10 * MIB, { requirePixels: true })+ const over = paddedChallengeImage('jpeg', 7 * MIB, { requirePixels: true })const fitsName = `fits-${randomUUID()}.png`const overName = `over-total-${randomUUID()}.jpeg`await startOwnedChat(appPage)@@ -321,7 +321,7 @@ test('composer attaches a pair that exceeds the hop aggregate', async ({ appPagetest('explains a 21st image instead of dropping it silently', async ({ appPage }) => {const files = Array.from({ length: 20 }, (_, index) => {- const image = challengeImage(index === 1 ? 'jpeg' : 'png')+ const image = challengeImage(index === 1 ? 'jpeg' : 'png', { requirePixels: true })const format = index === 1 ? 'jpeg' : 'png'return {name: `visual-${randomUUID()}.${format}`,@@ -329,7 +329,7 @@ test('explains a 21st image instead of dropping it silently', async ({ appPage }buffer: image.bytes,}})- const extra = challengeImage('png')+ const extra = challengeImage('png', { requirePixels: true })const extraName = `visual-${randomUUID()}.png`await startOwnedChat(appPage)await uploadThroughChooser(appPage, files)diff --git a/desktop-app/test/e2e-playwright/codexImageChallenge.ts b/desktop-app/test/e2e-playwright/codexImageChallenge.tsindex 658c6b907..46f659da9 100644--- a/desktop-app/test/e2e-playwright/codexImageChallenge.ts+++ b/desktop-app/test/e2e-playwright/codexImageChallenge.ts@@ -1,3 +1,4 @@+// E2E_GUARDIAN_IPC_FLOW: test-only generation/collection for Electron IPC journeys; no renderer HTTP transition.import { randomBytes } from 'node:crypto'import { createRequire } from 'node:module'import path from 'node:path'@@ -34,22 +35,23 @@ function loadHostCreateCanvas():}}+export type PixelRenderingOptions = { requirePixels?: boolean }+/** A neutral image with an answer absent from the filename and user prompt. */export function challengeImageAt(format: 'png' | 'jpeg',width: number,- height: number+ height: number,+ options: PixelRenderingOptions = {}): { code: string; bytes: Buffer; width: number; height: number } {const code = randomBytes(8).toString('hex').toUpperCase()- // Prefer the Host renderer when mcp-host is installed (T0 / Playwright OCR).- // Desktop CI does not install that package; fall back to contract-framed- // containers so unit tests still prove size and pixel bounds.+ // Non-strict containers exist only for geometry/size unit fixtures when+ // Desktop CI lacks the Host native addon. Every visual journey opts into+ // requirePixels; an unrendered declared header cannot prove image perception.const createCanvas = loadHostCreateCanvas()if (!createCanvas) {- if (process.env.E2E_CODEX_IMAGE_INPUT === '1') {- throw new Error(- 'Codex image E2E requires mcp-host/@napi-rs/canvas so the hex is painted in pixels'- )+ if (options.requirePixels || process.env.E2E_CODEX_IMAGE_INPUT === '1') {+ throw new Error('Image challenge requires native mcp-host/@napi-rs/canvas pixels')}const bytes =format === 'png'@@ -74,17 +76,21 @@ export function challengeImageAt(}}-export function challengeImage(format: 'png' | 'jpeg'): { code: string; bytes: Buffer } {- const image = challengeImageAt(format, 800, 120)+export function challengeImage(+ format: 'png' | 'jpeg',+ options: PixelRenderingOptions = {}+): { code: string; bytes: Buffer } {+ const image = challengeImageAt(format, 800, 120, options)return { code: image.code, bytes: image.bytes }}/** Same pixel challenge, grown to an exact decoded size the contract still accepts. */export function paddedChallengeImage(format: 'png' | 'jpeg',- targetBytes: number+ targetBytes: number,+ options: PixelRenderingOptions = {}): { code: string; bytes: Buffer } {- const image = challengeImage(format)+ const image = challengeImage(format, options)const bytes =format === 'png'? fixtures.padPngToSize(image.bytes, targetBytes)diff --git a/desktop-app/test/e2e-playwright/playwright.config.ts b/desktop-app/test/e2e-playwright/playwright.config.tsindex 569b56cd2..07e4b6fe6 100644--- a/desktop-app/test/e2e-playwright/playwright.config.ts+++ b/desktop-app/test/e2e-playwright/playwright.config.ts@@ -1,3 +1,4 @@+// E2E_GUARDIAN_IPC_FLOW: test-only generation/collection for Electron IPC journeys; no renderer HTTP transition.// desktop-app/test/e2e-playwright/playwright.config.tsimport { defineConfig } from '@playwright/test'import fs from 'node:fs'@@ -118,7 +119,7 @@ function loadCanonicalRootEnv(): void {loadCanonicalFile(path.join(repoRoot, '.env'))return}- const worktreeGitDir = path.resolve(repoRoot, gitdirMatch[1])+ const worktreeGitDir = path.resolve(repoRoot, gitdirMatch[1]!)const commonDirFile = path.join(worktreeGitDir, 'commondir')const commonDirValue = readOptionalFile(commonDirFile)if (commonDirValue === null) {@@ -163,7 +164,11 @@ export default defineConfig({projects: [{name: 'default',- testIgnore: ['**/gfs-upload-v2.test.ts', '**/codex-image-input.spec.ts'],+ testIgnore: [+ '**/gfs-upload-v2.test.ts',+ '**/codex-image-input.spec.ts',+ '**/subscription-image-input.spec.ts',+ ],},{name: 'packaged-gfs-upload-v2',diff --git a/desktop-app/test/e2e-playwright/playwright.subscription-image.config.ts b/desktop-app/test/e2e-playwright/playwright.subscription-image.config.tsnew file mode 100644index 000000000..3b12c4f9a--- /dev/null+++ b/desktop-app/test/e2e-playwright/playwright.subscription-image.config.ts@@ -0,0 +1,22 @@+// E2E_GUARDIAN_IPC_FLOW: collection admission is pure; physical runner verification happens before Electron launch.+import { defineConfig } from '@playwright/test'+import path from 'node:path'+import { requireSubscriptionImageRun } from './subscriptionImageRunContract.js'++// This must run before any fixture, setup, renderer probe, or network activity.+const run = requireSubscriptionImageRun()++export default defineConfig({+ testDir: '.',+ testMatch: '**/subscription-image-input.spec.ts',+ projects: [{ name: 'subscription-image-input' }],+ timeout: 240_000,+ expect: { timeout: 20_000 },+ retries: 0,+ workers: 1,+ fullyParallel: false,+ reporter: [['list']],+ outputDir: path.join(run.runRoot, 'playwright-results'),+ metadata: { mode: run.mode, runId: run.runId, profile: run.profile },+ use: { screenshot: 'only-on-failure', trace: 'retain-on-failure', video: 'retain-on-failure' },+})diff --git a/desktop-app/test/e2e-playwright/subscription-image-input.spec.ts b/desktop-app/test/e2e-playwright/subscription-image-input.spec.tsnew file mode 100644index 000000000..556cf13d3--- /dev/null+++ b/desktop-app/test/e2e-playwright/subscription-image-input.spec.ts@@ -0,0 +1,368 @@+/**+ * E2E_GUARDIAN_IPC_FLOW: visible login -> Agents -> owned Host -> model picker+ * -> chooser -> preview -> Send -> settled UI -> one durable completed task.+ * Electron has no renderer HTTP request for these IPC transitions. The only+ * deterministic peer is the external Grok/Codex vendor; all core paths stay real.+ * Real mode is G8 evidence only after actual execution. Static/unit checks are separate.+ */+import type { Page, TestInfo } from '@playwright/test'+import { randomUUID } from 'node:crypto'+import { createRequire } from 'node:module'+import { challengeImage, challengeImageAt, paddedChallengeImage } from './codexImageChallenge.js'+import { tileChallengeImage } from './subscriptionImageChallenge.js'+import {+ expect,+ readVendorAttempts,+ subscriptionImageRun as run,+ sha256,+ test,+} from './subscriptionImageFixtures.js'+import type { ProviderBinding } from './subscriptionImageRunContract.js'++const MIB = 1024 * 1024+const pad = createRequire(__filename)(+ '../../../packages/llm-provider-attempt-contract/testImageFixtures.cjs'+) as {+ padPngToSize: (bytes: Buffer, size: number) => Buffer+ padJpegToSize: (bytes: Buffer, size: number) => Buffer+}+type Image = { code: string; bytes: Buffer }+type Upload = { name: string; mimeType: 'image/png' | 'image/jpeg'; buffer: Buffer }+const escapeRegex = (value: string): string => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')++function image(format: 'png' | 'jpeg', bytes?: number): Image {+ if (run.mode === 'real')+ return bytes+ ? paddedChallengeImage(format, bytes, { requirePixels: true })+ : challengeImage(format, { requirePixels: true })+ const challenge = tileChallengeImage(format, { requirePixels: true })+ return bytes+ ? {+ code: challenge.code,+ bytes:+ format === 'png'+ ? pad.padPngToSize(challenge.bytes, bytes)+ : pad.padJpegToSize(challenge.bytes, bytes),+ }+ : challenge+}+function upload(input: Image, format: 'png' | 'jpeg'): Upload {+ return {+ name: `visual-${randomUUID()}.${format}`,+ mimeType: `image/${format}`,+ buffer: input.bytes,+ }+}++async function selectModel(+ page: Page,+ binding: ProviderBinding,+ unsupported = false+): Promise<void> {+ const selector = page.getByTestId('model-selector-up')+ await expect(selector).toHaveAttribute('data-host-ref', binding.hostRef)+ await expect(selector).toHaveAttribute('data-provider', binding.provider)+ await selector.getByRole('button', { name: /^Model — / }).click()+ const menu = selector.getByRole('menu', { name: 'Select model', exact: true })+ await expect(menu).toBeVisible()+ const label = unsupported ? binding.unsupportedModelLabel : binding.modelLabel+ await menu+ .getByRole('menuitemradio', { name: new RegExp(`^${escapeRegex(label)}(?:\\s*default)?$`) })+ .click()+ await expect(menu).toHaveCount(0)+ await expect(selector).toHaveAttribute(+ 'data-model',+ unsupported ? binding.unsupportedModelId : binding.modelId+ )+}+async function startOwnedChat(page: Page, binding: ProviderBinding): Promise<void> {+ await test.step('open the exact owned Host from the visible Agents entry', async () => {+ // A snapshot chooses only the responsive navigation layout; assertions retry.+ const agents = page.getByTestId('nav-agents')+ if (!(await agents.isVisible())) {+ const settings = page.getByTestId('nav-settings-menu')+ await expect(settings).toBeVisible()+ if ((await settings.getAttribute('aria-expanded')) !== 'true') await settings.click()+ await expect(settings).toHaveAttribute('aria-expanded', 'true')+ }+ await expect(agents).toBeVisible()+ await agents.click()+ const actions = page.getByRole('button', {+ name: `More actions for ${binding.hostLabel}`,+ exact: true,+ })+ await expect(actions).toBeVisible({ timeout: 30_000 })+ await actions.click()+ await expect(actions).toHaveAttribute('aria-expanded', 'true')+ const menu = page+ .getByRole('menu')+ .filter({ has: page.getByRole('button', { name: 'New chat', exact: true }) })+ await expect(menu).toBeVisible()+ await menu.getByRole('button', { name: 'New chat', exact: true }).click()+ await expect(page.getByTestId('chat-input')).toBeVisible()+ await expect(page.locator('[data-chat-message-id]')).toHaveCount(0)+ await expect(page.getByTestId('model-selector-up')).toHaveAttribute(+ 'data-host-ref',+ binding.hostRef,+ { timeout: 30_000 }+ )+ await selectModel(page, binding)+ })+}+async function attachAndPreview(page: Page, files: Upload[]): Promise<void> {+ await test.step('attach through the visible file chooser and inspect every preview', async () => {+ await page.getByRole('button', { name: 'Add context', exact: true }).click()+ const menuItem = page.getByRole('menuitem', { name: 'Upload Files', exact: true })+ await expect(menuItem).toBeVisible()+ const chooserReady = page.waitForEvent('filechooser')+ await menuItem.click()+ await (await chooserReady).setFiles(files)+ for (const file of files) {+ const chip = page.getByRole('button', { name: file.name, exact: true })+ await expect(chip).toBeVisible()+ await chip.click()+ const preview = page.getByRole('dialog', { name: file.name, exact: true })+ await expect(preview).toBeVisible()+ await expect(preview.getByRole('img', { name: file.name, exact: true })).toBeVisible()+ await preview.getByRole('button', { name: 'Close image preview', exact: true }).click()+ await expect(preview).toHaveCount(0)+ }+ // DOM order is read-only evidence of the user-visible composer input order.+ const orderedNames = await page.locator('.composer-attachment-chip strong').allTextContents()+ expect(orderedNames).toEqual(files.map(file => file.name))+ })+}++async function observeCompletedTask(+ page: Page,+ binding: ProviderBinding,+ expected: RegExp+): Promise<string> {+ await expect(page.locator('[data-chat-message-id]')).toHaveCount(2)+ const ids = await page+ .locator('[data-chat-message-id]')+ .evaluateAll(elements => elements.map(element => element.getAttribute('data-chat-message-id')))+ let taskId: string | null = null+ // Reads occur only AFTER visible submit/result. They never create a chat,+ // select a model, authenticate, send, approve, or alter product state.+ await expect+ .poll(+ async () => {+ const observed = await page.evaluate(+ async ({ hostRef, messageIds }) => {+ const chats = await window.clerum.chat.list(hostRef)+ for (const chat of chats.slice(0, 20)) {+ const messages = await window.clerum.chat.loadMessages(hostRef, chat.id)+ const pair = messageIds.map(id => messages.find(message => message.id === id))+ const candidate = pair[0]?.task_id+ if (!candidate || pair[1]?.task_id !== candidate) continue+ const result = await window.clerum.rpc.getTaskResult(hostRef, candidate)+ return {+ taskId: candidate,+ status: result.status,+ success: result.success,+ response: result.response,+ }+ }+ return null+ },+ { hostRef: binding.hostRef, messageIds: ids }+ )+ if (+ !observed ||+ observed.status !== 'completed' ||+ observed.success !== true ||+ !expected.test(observed.response ?? '')+ )+ return false+ taskId = observed.taskId+ return true+ },+ { timeout: 30_000 }+ )+ .toBe(true)+ expect(taskId).toMatch(/\S+/)+ return taskId!+}+async function sendAndVerify(+ page: Page,+ binding: ProviderBinding,+ files: Upload[],+ codes: string[],+ testInfo: TestInfo,+ textOnly = false+): Promise<void> {+ await test.step('send visibly and correlate the settled result with one physical task and ordered wire digests', async () => {+ const receiptId = randomUUID()+ const prompt = textOnly+ ? `Reply with TEXT_RECEIPT:${receiptId} only. Receipt: ${receiptId}`+ : `Read the hexadecimal code in each attached image, in file order. Reply with codes only, one per line. Receipt: ${receiptId}`+ for (const code of codes) expect(prompt).not.toContain(code)+ const expectedOutput = textOnly ? `TEXT_RECEIPT:${receiptId}` : codes.join('\n')+ const expected = new RegExp(+ `^\\s*${escapeRegex(expectedOutput).replaceAll('\n', '\\s+')}\\s*$`,+ 'i'+ )+ const composer = page.getByTestId('chat-input')+ await composer.fill(prompt)+ const send = page.getByTestId('send-button')+ await expect(send).toBeEnabled()+ await send.click()+ await expect(composer).toHaveValue('')+ const thread = page.getByTestId('message-list')+ await expect(thread.getByText(prompt, { exact: true })).toBeVisible()+ for (const file of files)+ await expect(+ thread.locator('.message-attachment-label').filter({ hasText: file.name })+ ).toBeVisible()+ const answer = page.getByTestId('agent-response')+ await expect(answer).toHaveCount(1, { timeout: 180_000 })+ await expect(answer).toHaveText(expected, { timeout: 180_000 })+ await expect(answer).not.toHaveClass(/chat-bubble--error/)+ await expect(thread.getByTestId('progress-stepper')).toHaveCount(0)+ await expect(thread.locator('.chat-message--in-flight')).toHaveCount(0)+ await expect(send).toHaveAttribute('aria-label', 'Send message')+ await expect(page.getByRole('status', { name: /^Running on fallback:/ })).toHaveCount(0)+ const selector = page.getByTestId('model-selector-up')+ await expect(selector).toHaveAttribute('data-host-ref', binding.hostRef)+ await expect(selector).toHaveAttribute('data-provider', binding.provider)+ await expect(selector).toHaveAttribute('data-model', binding.modelId)+ const taskId = await observeCompletedTask(page, binding, expected)+ const orderedDigests = files.map(file => sha256(file.buffer))+ if (run.mode === 'fixture') {+ await expect+ .poll(() => readVendorAttempts(run, binding).filter(row => row.receiptId === receiptId), {+ timeout: 20_000,+ })+ .toHaveLength(1)+ const attempt = readVendorAttempts(run, binding).find(row => row.receiptId === receiptId)!+ expect(attempt.model).toBe(binding.modelId)+ expect(attempt.imageSha256).toEqual(orderedDigests)+ expect(attempt.mimeTypes).toEqual(files.map(file => file.mimeType))+ expect(attempt.responseKind).toBe(textOnly ? 'text' : 'pixels')+ expect(attempt.outputSha256).toBe(sha256(expectedOutput))+ for (const other of run.bindings.filter(item => item.provider !== binding.provider)) {+ expect(+ readVendorAttempts(run, other).filter(row => row.receiptId === receiptId)+ ).toHaveLength(0)+ }+ }+ await testInfo.attach('subscription-image-business-evidence', {+ contentType: 'application/json',+ body: Buffer.from(+ JSON.stringify({+ runId: run.runId,+ mode: run.mode,+ provider: binding.provider,+ hostRef: binding.hostRef,+ model: binding.modelId,+ receiptId,+ taskId,+ orderedImageSha256: orderedDigests,+ })+ ),+ })+ })+}++for (const binding of run.bindings) {+ test.describe(binding.provider, () => {+ for (const format of ['png', 'jpeg'] as const) {+ test(`${format} pixels reach the selected owned Host and model`, async ({+ appPage,+ }, testInfo) => {+ const input = image(format)+ const file = upload(input, format)+ await startOwnedChat(appPage, binding)+ await attachAndPreview(appPage, [file])+ await sendAndVerify(appPage, binding, [file], [input.code], testInfo)+ })+ }+ test('mixed PNG/JPEG preserve attachment and wire order', async ({ appPage }, testInfo) => {+ const images = [image('png'), image('jpeg')]+ const files = [upload(images[0]!, 'png'), upload(images[1]!, 'jpeg')]+ await startOwnedChat(appPage, binding)+ await attachAndPreview(appPage, files)+ await sendAndVerify(+ appPage,+ binding,+ files,+ images.map(input => input.code),+ testInfo+ )+ })+ test('near 16 MiB composer image carries real pixels', async ({ appPage }, testInfo) => {+ const input = image('png', 16 * MIB - 4096)+ const file = upload(input, 'png')+ await startOwnedChat(appPage, binding)+ await attachAndPreview(appPage, [file])+ await sendAndVerify(appPage, binding, [file], [input.code], testInfo)+ })+ test('twenty ordered images complete without a dropped or repeated code', async ({+ appPage,+ }, testInfo) => {+ const images = Array.from({ length: 20 }, (_, index) => image(index % 2 ? 'jpeg' : 'png'))+ const files = images.map((input, index) => upload(input, index % 2 ? 'jpeg' : 'png'))+ await startOwnedChat(appPage, binding)+ await attachAndPreview(appPage, files)+ await sendAndVerify(+ appPage,+ binding,+ files,+ images.map(input => input.code),+ testInfo+ )+ })+ test('over-budget refusal leaves no task or dispatch and permits a subsequent text turn', async ({+ appPage,+ }, testInfo) => {+ await startOwnedChat(appPage, binding)+ const baseline = run.mode === 'fixture' ? readVendorAttempts(run, binding).length : undefined+ const file = upload(image('png', 17 * MIB), 'png')+ await appPage.getByRole('button', { name: 'Add context', exact: true }).click()+ const chooserReady = appPage.waitForEvent('filechooser')+ await appPage.getByRole('menuitem', { name: 'Upload Files', exact: true }).click()+ await (await chooserReady).setFiles([file])+ await expect(appPage.getByRole('alert')).toContainText(+ `${file.name} is too large. Max size is 16 MiB.`+ )+ await expect(appPage.getByRole('button', { name: file.name, exact: true })).toHaveCount(0)+ await expect(appPage.locator('[data-chat-message-id]')).toHaveCount(0)+ if (run.mode === 'fixture') expect(readVendorAttempts(run, binding)).toHaveLength(baseline!)+ await sendAndVerify(appPage, binding, [], [], testInfo, true)+ })+ test('unsupported model blocks image send, then visible removal and primary selection recover', async ({+ appPage,+ }, testInfo) => {+ await startOwnedChat(appPage, binding)+ const input = image('png'),+ file = upload(input, 'png')+ await attachAndPreview(appPage, [file])+ const baseline = run.mode === 'fixture' ? readVendorAttempts(run, binding).length : undefined+ await selectModel(appPage, binding, true)+ await appPage.getByTestId('chat-input').fill('Read the attached image.')+ await expect(appPage.getByTestId('composer-image-capability-notice')).toBeVisible()+ await expect(appPage.getByTestId('send-button')).toBeDisabled()+ await expect(appPage.locator('[data-chat-message-id]')).toHaveCount(0)+ if (run.mode === 'fixture') expect(readVendorAttempts(run, binding)).toHaveLength(baseline!)+ await appPage.getByRole('button', { name: `Remove ${file.name}`, exact: true }).click()+ await expect(appPage.getByRole('button', { name: file.name, exact: true })).toHaveCount(0)+ await expect(appPage.getByTestId('composer-image-capability-notice')).toHaveCount(0)+ await selectModel(appPage, binding)+ await sendAndVerify(appPage, binding, [], [], testInfo, true)+ })+ })+}++if (run.mode === 'real') {+ test('G8 Grok reads pixels in a 9000 px PNG through the owned Host', async ({+ appPage,+ }, testInfo) => {+ const binding = run.bindings.find(item => item.provider === 'grok-subscription')!+ const input = challengeImageAt('png', 9000, 128, { requirePixels: true }),+ file = upload(input, 'png')+ await startOwnedChat(appPage, binding)+ await attachAndPreview(appPage, [file])+ await sendAndVerify(appPage, binding, [file], [input.code], testInfo)+ })+}diff --git a/desktop-app/test/e2e-playwright/subscriptionImageChallenge.ts b/desktop-app/test/e2e-playwright/subscriptionImageChallenge.tsnew file mode 100644index 000000000..e887a48e0--- /dev/null+++ b/desktop-app/test/e2e-playwright/subscriptionImageChallenge.ts@@ -0,0 +1,21 @@+// E2E_GUARDIAN_IPC_FLOW: test-only pixels used by Desktop IPC journeys and the external vendor decoder.+import { createRequire } from 'node:module'++const codec = createRequire(__filename)(+ '../../../scripts/e2e/fixtures/subscription-image-challenge.cjs'+) as {+ requirePixelRenderer: () => unknown+ tileChallengeImage: (+ format: 'png' | 'jpeg',+ options: { requirePixels: true }+ ) => {+ code: string+ bytes: Buffer+ width: number+ height: number+ }+ decodeTileChallenge: (bytes: Buffer) => Promise<string>+}+export const requirePixelRenderer = codec.requirePixelRenderer+export const tileChallengeImage = codec.tileChallengeImage+export const decodeTileChallenge = codec.decodeTileChallengediff --git a/desktop-app/test/e2e-playwright/subscriptionImageFixtures.ts b/desktop-app/test/e2e-playwright/subscriptionImageFixtures.tsnew file mode 100644index 000000000..a1cfaf3cc--- /dev/null+++ b/desktop-app/test/e2e-playwright/subscriptionImageFixtures.ts@@ -0,0 +1,288 @@+/**+ * E2E_GUARDIAN_IPC_FLOW: launches only after an independently inspected Linux+ * runner receipt matches actual OS, namespaces and mounts. No legacy reset,+ * seeding, API login, or IPC that advances the journey belongs in this fixture.+ * Main must inspect fresh HOME/keychain, bind mounts, namespace ownership,+ * no personal-home/DBus/SSH mounts, target relays, source and stack marker first.+ * A fresh userData directory or an env assertion cannot prove auth isolation.+ */+import {+ type ElectronApplication,+ type Page,+ test as base,+ _electron as electron,+ expect,+} from '@playwright/test'+import { execFileSync } from 'node:child_process'+import { createHash } from 'node:crypto'+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'+import { isDeepStrictEqual } from 'node:util'+import { requirePixelRenderer } from './subscriptionImageChallenge.js'+import {+ type ProviderBinding,+ type RunnerObservation,+ type SubscriptionImageRun,+ requireSubscriptionImageRun,+ verifyRunnerObservation,+} from './subscriptionImageRunContract.js'++export const subscriptionImageRun = requireSubscriptionImageRun()+const repoRoot = path.resolve(__dirname, '../../..')+const mainEntry = path.join(repoRoot, 'desktop-app/dist/main.js')+export const sha256 = (value: string | Buffer): string =>+ createHash('sha256').update(value).digest('hex')++function readPrivateJson(filename: string, maxBytes: number): unknown {+ if (fs.realpathSync(path.dirname(filename)) !== path.dirname(filename))+ throw new Error('Runner evidence parent must not be a symlink')+ const fd = fs.openSync(filename, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW)+ try {+ const stat = fs.fstatSync(fd)+ if (+ !stat.isFile() ||+ stat.nlink !== 1 ||+ stat.uid !== process.getuid?.() ||+ (stat.mode & 0o077) !== 0 ||+ stat.size > maxBytes+ ) {+ throw new Error('Runner evidence must be bounded, private and owned')+ }+ return JSON.parse(fs.readFileSync(fd, 'utf8'))+ } finally {+ fs.closeSync(fd)+ }+}+function observeRunner(): RunnerObservation {+ if (process.platform !== 'linux' || !process.getuid || !process.getgid)+ throw new Error('Inspected non-root Linux runner required before Electron')+ return {+ platform: process.platform,+ uid: process.getuid(),+ gid: process.getgid(),+ home: fs.realpathSync(os.userInfo().homedir),+ mountNamespace: fs.readlinkSync('/proc/self/ns/mnt'),+ pidNamespace: fs.readlinkSync('/proc/self/ns/pid'),+ userNamespace: fs.readlinkSync('/proc/self/ns/user'),+ mountInfoSha256: sha256(fs.readFileSync('/proc/self/mountinfo')),+ }+}+export function verifyPhysicalRunner(run: SubscriptionImageRun): void {+ const observed = observeRunner()+ const receipt = readPrivateJson(run.runnerReceipt, 64 * 1024) as {+ kind?: string+ runId?: string+ repoRoot?: string+ gitHead?: string+ profile?: string+ context?: string+ restUrl?: string+ rpcUrl?: string+ bindings?: ProviderBinding[]+ observation?: RunnerObservation+ }+ const gitHead = execFileSync('git', ['-C', repoRoot, 'rev-parse', 'HEAD'], {+ encoding: 'utf8',+ timeout: 5_000,+ }).trim()+ if (+ receipt.kind !== 'evenfire-subscription-image-runner-v1' ||+ receipt.runId !== run.runId ||+ receipt.repoRoot !== fs.realpathSync(repoRoot) ||+ receipt.gitHead !== gitHead ||+ receipt.profile !== run.profile ||+ receipt.context !== run.context ||+ receipt.restUrl !== run.restUrl ||+ receipt.rpcUrl !== run.rpcUrl ||+ !isDeepStrictEqual(receipt.bindings, run.bindings) ||+ !receipt.observation+ ) {+ throw new Error('Physical runner receipt does not bind this run/source/stack/targets')+ }+ verifyRunnerObservation(receipt.observation, observed, process.env)+ const root = fs.lstatSync(run.runRoot)+ if (+ !root.isDirectory() ||+ root.isSymbolicLink() ||+ root.uid !== observed.uid ||+ (root.mode & 0o077) !== 0 ||+ fs.realpathSync(run.runRoot) !== run.runRoot+ )+ throw new Error('Runner root must be private and physically owned')+ for (const name of [+ 'XDG_RUNTIME_DIR',+ 'XAUTHORITY',+ 'XDG_CONFIG_HOME',+ 'XDG_CACHE_HOME',+ 'XDG_DATA_HOME',+ ]) {+ const value = process.env[name]+ if (value && !(value.startsWith(`${observed.home}/`) || value.startsWith(`${run.runRoot}/`))) {+ throw new Error(`Runner ${name} must remain inside the inspected private home/run root`)+ }+ }+ if (Number(process.versions.node.split('.')[0]) !== 24 || !fs.existsSync(mainEntry))+ throw new Error('Node24 and actual built Desktop are prerequisites')+ requirePixelRenderer()+}+export type VendorAttempt = {+ sequence: number+ provider: string+ model: string+ receiptId: string+ imageSha256: string[]+ mimeTypes: string[]+ requestSha256: string+ responseKind: 'pixels' | 'text' | 'rejected'+ outputSha256?: string+}+export function readVendorAttempts(+ run: SubscriptionImageRun,+ binding: ProviderBinding+): VendorAttempt[] {+ if (run.mode !== 'fixture')+ throw new Error('External fixture evidence is not real-subscription G8 evidence')+ const evidencePath = run.evidencePaths?.[binding.provider]+ if (!evidencePath) throw new Error('Physical proxy evidence path is missing')+ const ledger = readPrivateJson(evidencePath, 4 * 1024 * 1024) as {+ kind?: string+ runId?: string+ attempts?: VendorAttempt[]+ }+ if (+ ledger.kind !== 'evenfire-subscription-image-vendor-v1' ||+ ledger.runId !== run.runId ||+ !Array.isArray(ledger.attempts) ||+ ledger.attempts.length > 256+ )+ throw new Error('External vendor ledger does not belong to this run')+ for (const [index, row] of ledger.attempts.entries()) {+ if (+ row.sequence !== index + 1 ||+ row.provider !== binding.provider ||+ typeof row.model !== 'string' ||+ !/^[a-f0-9-]{36}$/.test(row.receiptId) ||+ !Array.isArray(row.imageSha256) ||+ row.imageSha256.length > 20 ||+ row.imageSha256.some(value => !/^[a-f0-9]{64}$/.test(value)) ||+ !Array.isArray(row.mimeTypes) ||+ row.mimeTypes.length !== row.imageSha256.length ||+ !/^[a-f0-9]{64}$/.test(row.requestSha256) ||+ !['pixels', 'text', 'rejected'].includes(row.responseKind)+ ) {+ throw new Error('External vendor ledger has invalid bounded evidence')+ }+ }+ return ledger.attempts+}+type Fixtures = {+ electronApp: ElectronApplication+ appPage: Page+ subscriptionRun: SubscriptionImageRun+}+export const test = base.extend<Fixtures>({+ subscriptionRun: async ({}, use) => {+ await use(subscriptionImageRun)+ },+ electronApp: async ({ subscriptionRun: run }, use, testInfo) => {+ verifyPhysicalRunner(run)+ const launchRoot = fs.mkdtempSync(path.join(run.runRoot, 'desktop-'))+ fs.chmodSync(launchRoot, 0o700)+ const userData = path.join(launchRoot, 'user-data')+ fs.mkdirSync(userData, { mode: 0o700 })+ const runtimeConfig = path.join(launchRoot, 'runtime-config.json')+ const launchEnv: Record<string, string> = {}+ for (const name of [+ 'PATH',+ 'HOME',+ 'USER',+ 'LOGNAME',+ 'LANG',+ 'LC_ALL',+ 'DISPLAY',+ 'XDG_RUNTIME_DIR',+ 'XAUTHORITY',+ 'XDG_CONFIG_HOME',+ 'XDG_CACHE_HOME',+ 'XDG_DATA_HOME',+ 'TMPDIR',+ ]) {+ if (process.env[name]) launchEnv[name] = process.env[name]!+ }+ Object.assign(launchEnv, {+ EXTERNAL_REST_API_BASE_URL: run.restUrl,+ RPC_PROXY_BASE_URL: run.rpcUrl,+ EVENFIRE_DEV_ISOLATION: '1',+ EVENFIRE_DEV_ISOLATION_RUN_DIR: launchRoot,+ EVENFIRE_DEV_ISOLATION_TARGET: run.runId,+ EVENFIRE_DEV_ISOLATION_PR: '806',+ EVENFIRE_DEV_ISOLATION_REST_URL: run.restUrl,+ EVENFIRE_DEV_ISOLATION_RPC_URL: run.rpcUrl,+ EVENFIRE_DEV_ISOLATION_APP_PATH: path.dirname(mainEntry),+ CLERUM_DESKTOP_CONFIG_PATH: runtimeConfig,+ })+ const app = await electron.launch({+ args: [`--user-data-dir=${userData}`, mainEntry],+ env: launchEnv,+ timeout: 30_000,+ recordVideo: { dir: testInfo.outputPath('video'), size: { width: 1280, height: 720 } },+ })+ try {+ const actual = await app.evaluate(({ app: desktopApp }) => ({+ pid: process.pid,+ uid: process.getuid?.(),+ userData: desktopApp.getPath('userData'),+ appPath: desktopApp.getAppPath(),+ }))+ expect(actual.pid).toBe(app.process().pid)+ expect(actual.uid).toBe(process.getuid!())+ expect(fs.realpathSync(actual.userData)).toBe(fs.realpathSync(userData))+ expect(fs.realpathSync(actual.appPath)).toBe(fs.realpathSync(path.dirname(mainEntry)))+ await use(app)+ } finally {+ await app.close()+ }+ },+ appPage: async ({ electronApp, subscriptionRun: run }, use) => {+ const page = await electronApp.firstWindow()+ await page.waitForLoadState('domcontentloaded')+ const config = await page.evaluate(async () => {+ const state = await window.clerum.auth.getRuntimeConfigState()+ return {+ storagePath: state.storagePath,+ restUrl: state.currentConfig?.externalRestApiBaseUrl,+ rpcUrl: state.currentConfig?.rpcProxyBaseUrl,+ }+ })+ const actualUserData = await electronApp.evaluate(({ app: desktopApp }) =>+ desktopApp.getPath('userData')+ )+ expect(path.resolve(config.storagePath)).toBe(+ path.join(path.dirname(actualUserData), 'runtime-config.json')+ )+ expect(config.restUrl).toBe(run.restUrl)+ expect(config.rpcUrl).toBe(run.rpcUrl)+ const loginEmail = page.locator('#email-input')+ await expect(loginEmail).toBeVisible({ timeout: 30_000 })+ await expect(page.locator('#password-input')).toBeVisible()+ await loginEmail.fill(process.env.E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL!)+ await page.locator('#password-input').fill(process.env.E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD!)+ await page.getByRole('button', { name: 'Sign in', exact: true }).click()+ await expect(loginEmail).toHaveCount(0)+ await expect(page.getByTestId('nav-settings-menu')).toBeVisible({ timeout: 30_000 })+ try {+ await use(page)+ } finally {+ // End only the owned test session through UI; no shared session reset.+ if (!page.isClosed()) {+ const settings = page.getByTestId('nav-settings-menu')+ if ((await settings.getAttribute('aria-expanded')) !== 'true') await settings.click()+ await expect(settings).toHaveAttribute('aria-expanded', 'true')+ await page.getByTestId('logout-btn').click()+ await expect(page.locator('#email-input')).toBeVisible({ timeout: 20_000 })+ }+ }+ },+})+export { expect }diff --git a/desktop-app/test/e2e-playwright/subscriptionImageRunContract.ts b/desktop-app/test/e2e-playwright/subscriptionImageRunContract.tsnew file mode 100644index 000000000..e18ef6481--- /dev/null+++ b/desktop-app/test/e2e-playwright/subscriptionImageRunContract.ts@@ -0,0 +1,190 @@+// E2E_GUARDIAN_IPC_FLOW: pure run admission; no environment files, login, launch, or network at module load.+import path from 'node:path'++export type SubscriptionImageProvider = 'grok-subscription' | 'codex-subscription'+export type ProviderBinding = {+ provider: SubscriptionImageProvider+ hostRef: string+ hostLabel: string+ modelId: string+ modelLabel: string+ unsupportedModelId: string+ unsupportedModelLabel: string+}+export type SubscriptionImageRun = {+ mode: 'fixture' | 'real'+ runId: string+ runnerReceipt: string+ runRoot: string+ evidencePaths?: Partial<Record<SubscriptionImageProvider, string>>+ profile: string+ context: string+ restUrl: string+ rpcUrl: string+ bindings: ProviderBinding[]+}++function required(env: NodeJS.ProcessEnv, name: string): string {+ const value = env[name]?.trim()+ if (!value) throw new Error(`Subscription image lane requires explicit ${name}`)+ return value+}+function absolute(env: NodeJS.ProcessEnv, name: string): string {+ const value = required(env, name)+ if (!path.isAbsolute(value)) throw new Error(`${name} must be absolute`)+ return path.resolve(value)+}+function ownedUrl(env: NodeJS.ProcessEnv, name: string): string {+ const value = required(env, name)+ const url = new URL(value)+ if (+ url.protocol !== 'http:' ||+ !['127.0.0.1', '[::1]', 'localhost'].includes(url.hostname) ||+ !url.port ||+ url.username ||+ url.password ||+ url.search ||+ url.hash ||+ !['', '/'].includes(url.pathname) ||+ ['3000', '8090', '8091', '8094', '8098'].includes(url.port)+ ) {+ throw new Error(`${name} must bind an explicit owned loopback port without credentials`)+ }+ return url.origin+}++export function requireSubscriptionImageRun(+ env: NodeJS.ProcessEnv = process.env+): SubscriptionImageRun {+ if (env.E2E_SUBSCRIPTION_IMAGE_INPUT !== '1') {+ throw new Error('Subscription image lane requires E2E_SUBSCRIPTION_IMAGE_INPUT=1')+ }+ const mode = required(env, 'E2E_SUBSCRIPTION_IMAGE_MODE')+ if (mode !== 'fixture' && mode !== 'real')+ throw new Error('E2E_SUBSCRIPTION_IMAGE_MODE must be fixture or real')+ const approvals =+ mode === 'real'+ ? ['GROK_REAL_UPSTREAM_CONFIRM', 'CODEX_REAL_UPSTREAM_CONFIRM']+ : ['SUBSCRIPTION_IMAGE_FIXTURE_CONFIRM']+ for (const name of approvals)+ if (env[name] !== '1') throw new Error(`Subscription image lane requires ${name}=1`)+ const runId = required(env, 'E2E_SUBSCRIPTION_IMAGE_RUN_ID')+ if (!/^subscription-image-[a-f0-9]{12}$/.test(runId))+ throw new Error('E2E_SUBSCRIPTION_IMAGE_RUN_ID must identify this run')+ const runnerReceipt = absolute(env, 'SUBSCRIPTION_IMAGE_RUNNER_RECEIPT')+ const runRoot = absolute(env, 'SUBSCRIPTION_IMAGE_RUN_ROOT')+ const profile = required(env, 'MINIKUBE_PROFILE')+ const context = required(env, 'CONTROL_API_REAL_PG_CONTEXT')+ if (+ profile !== context ||+ !/^[a-z0-9][a-z0-9-]{0,62}$/.test(profile) ||+ profile === 'clerum-test' ||+ /(^|[-_])(prod|production)([-_]|$)/i.test(profile)+ ) {+ throw new Error(+ 'Subscription image lane requires the explicit owned development profile/context'+ )+ }+ const restUrl = ownedUrl(env, 'EXTERNAL_REST_API_BASE_URL')+ const rpcUrl = ownedUrl(env, 'RPC_PROXY_BASE_URL')+ if (restUrl === rpcUrl) throw new Error('REST and RPC bindings must differ')+ required(env, 'E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL')+ required(env, 'E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD')+ const bindings = (['GROK', 'CODEX'] as const).map(kind => ({+ provider: `${kind.toLowerCase()}-subscription` as SubscriptionImageProvider,+ hostRef: required(env, `E2E_${kind}_IMAGE_HOST_REF`),+ hostLabel: required(env, `E2E_${kind}_IMAGE_HOST_LABEL`),+ modelId: required(env, `E2E_${kind}_IMAGE_MODEL`),+ modelLabel: required(env, `E2E_${kind}_IMAGE_MODEL_LABEL`),+ unsupportedModelId: required(env, `E2E_${kind}_IMAGE_UNSUPPORTED_MODEL`),+ unsupportedModelLabel: required(env, `E2E_${kind}_IMAGE_UNSUPPORTED_MODEL_LABEL`),+ }))+ if (+ bindings[0]!.hostRef === bindings[1]!.hostRef ||+ bindings.some(binding => binding.modelId === binding.unsupportedModelId)+ ) {+ throw new Error('Provider and capability bindings must identify distinct owned targets')+ }+ const evidencePaths: Partial<Record<SubscriptionImageProvider, string>> = {}+ if (mode === 'fixture') {+ for (const [kind, binding] of (['GROK', 'CODEX'] as const).map(+ (kind, index) => [kind, bindings[index]!] as const+ )) {+ const evidencePath = absolute(env, `E2E_${kind}_IMAGE_EVIDENCE_PATH`)+ const relative = path.relative(runRoot, evidencePath)+ if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) {+ throw new Error(+ `E2E_${kind}_IMAGE_EVIDENCE_PATH must be inside SUBSCRIPTION_IMAGE_RUN_ROOT`+ )+ }+ evidencePaths[binding.provider] = evidencePath+ }+ if (new Set(Object.values(evidencePaths)).size !== 2)+ throw new Error('Each physical proxy requires its own vendor evidence file')+ }+ return {+ mode,+ runId,+ runnerReceipt,+ runRoot,+ evidencePaths,+ profile,+ context,+ restUrl,+ rpcUrl,+ bindings,+ }+}++export type RunnerObservation = {+ platform: string+ uid: number+ gid: number+ home: string+ mountNamespace: string+ pidNamespace: string+ userNamespace: string+ mountInfoSha256: string+}++/** The main runner inspects physical mounts/namespaces first and seals these observations in its receipt. */+export function verifyRunnerObservation(+ expected: RunnerObservation,+ actual: RunnerObservation,+ env: NodeJS.ProcessEnv+): void {+ if (+ actual.platform !== 'linux' ||+ !Number.isInteger(actual.uid) ||+ actual.uid <= 0 ||+ !Number.isInteger(actual.gid) ||+ actual.gid <= 0+ ) {+ throw new Error('Subscription image isolation requires an inspected non-root Linux runner')+ }+ for (const field of [+ 'platform',+ 'uid',+ 'gid',+ 'home',+ 'mountNamespace',+ 'pidNamespace',+ 'userNamespace',+ 'mountInfoSha256',+ ] as const) {+ if (expected[field] !== actual[field])+ throw new Error(`Physical runner isolation changed: ${field}`)+ }+ if (+ !/^mnt:\[\d+\]$/.test(actual.mountNamespace) ||+ !/^pid:\[\d+\]$/.test(actual.pidNamespace) ||+ !/^user:\[\d+\]$/.test(actual.userNamespace) ||+ !/^[a-f0-9]{64}$/.test(actual.mountInfoSha256)+ ) {+ throw new Error('Physical runner isolation observations are incomplete')+ }+ if (!path.isAbsolute(actual.home) || env.HOME !== actual.home)+ throw new Error('Runner HOME does not match the OS account')+ if (env.DBUS_SESSION_BUS_ADDRESS || env.SSH_AUTH_SOCK)+ throw new Error('Inherited DBus/SSH socket is forbidden in the isolated runner')+}diff --git a/desktop-app/test/subscriptionAdmissionGuard.test.ts b/desktop-app/test/subscriptionAdmissionGuard.test.tsnew file mode 100644index 000000000..74130d245--- /dev/null+++ b/desktop-app/test/subscriptionAdmissionGuard.test.ts@@ -0,0 +1,61 @@+import { describe, expect, it } from 'vitest'+import fs from 'node:fs'+import path from 'node:path'+import {+ isProtectedSubscriptionBusinessPath,+ requireSubscriptionAdmissionGuardEnv,+} from '../../tests/e2e/playwright/helpers/subscription-admission-guard'++describe('negative subscription admission guard contract', () => {+ it('observes actual protected subscription/model access while permitting the public auth probe', () => {+ for (const pathname of [+ '/api/v1/admin/llm/providers/codex-subscription/connections',+ '/api/v1/admin/llm/providers/grok-subscription/connections/unit/models',+ '/api/v1/admin/agents/unit/model',+ '/api/v1/admin/hosts/unit',+ '/api/v1/admin/llm-models',+ ])+ expect(isProtectedSubscriptionBusinessPath(pathname)).toBe(true)+ for (const pathname of [+ '/api/v1/admin/auth/me',+ '/secrets/llm/subscriptions',+ '/api/v1/health',+ ]) {+ expect(isProtectedSubscriptionBusinessPath(pathname)).toBe(false)+ }+ })+ it('refuses default/shared/remote or unapproved guard targets at config load', () => {+ expect(() => requireSubscriptionAdmissionGuardEnv({})).toThrow(+ /E2E_SUBSCRIPTION_ADMISSION_GUARDS/+ )+ const input = {+ E2E_SUBSCRIPTION_ADMISSION_GUARDS: '1',+ MINIKUBE_PROFILE: 'unit-owned',+ CONTROL_API_REAL_PG_CONTEXT: 'unit-owned',+ CONTROL_UI_URL: 'http://127.0.0.1:34000',+ E2E_SUBSCRIPTION_ADMISSION_OUTPUT_DIR: '/tmp/unit-guard-results',+ }+ expect(requireSubscriptionAdmissionGuardEnv(input).url).toBe(input.CONTROL_UI_URL)+ for (const patch of [+ { CONTROL_UI_URL: 'http://127.0.0.1:3000' },+ { CONTROL_UI_URL: 'https://fixture.invalid' },+ { CONTROL_API_REAL_PG_CONTEXT: 'another' },+ { E2E_SUBSCRIPTION_ADMISSION_OUTPUT_DIR: '' },+ ]) {+ expect(() => requireSubscriptionAdmissionGuardEnv({ ...input, ...patch })).toThrow()+ }+ })+ it('selects only the unauthenticated guards without the legacy setup or login preflight', () => {+ const config = fs.readFileSync(+ path.resolve(+ __dirname,+ '../../tests/e2e/playwright/playwright.subscription-admission.config.ts'+ ),+ 'utf8'+ )+ expect(config).toContain('grep: /unauthenticated/')+ expect(config).toContain("'control-ui/codex-subscription-admission.spec.ts'")+ expect(config).not.toMatch(/globalSetup|global-setup|visible-login/)+ expect(config).toContain('requireSubscriptionAdmissionGuardEnv')+ })+})diff --git a/desktop-app/test/subscriptionImageChallenge.test.ts b/desktop-app/test/subscriptionImageChallenge.test.tsnew file mode 100644index 000000000..7580fc0b6--- /dev/null+++ b/desktop-app/test/subscriptionImageChallenge.test.ts@@ -0,0 +1,65 @@+import { describe, expect, it } from 'vitest'+import { createRequire } from 'node:module'+import {+ decodeTileChallenge,+ requirePixelRenderer,+ tileChallengeImage,+} from './e2e-playwright/subscriptionImageChallenge.js'++const native = createRequire(new URL('../../mcp-host/package.json', import.meta.url))(+ '@napi-rs/canvas'+)++describe('subscription fixture pixel oracle', () => {+ it.each(['png', 'jpeg'] as const)(+ 'decodes the received %s pixels without an answer registry',+ async format => {+ requirePixelRenderer()+ const image = tileChallengeImage(format, { requirePixels: true })+ expect(image.code).toMatch(/^[0-9A-F]{16}$/)+ expect(image.bytes.includes(Buffer.from(image.code))).toBe(false)+ expect(await decodeTileChallenge(image.bytes)).toBe(image.code)+ const other = tileChallengeImage(format, { requirePixels: true })+ expect(other.code).not.toBe(image.code)+ expect(await decodeTileChallenge(other.bytes)).toBe(other.code)+ }+ )++ it('fails the original answer after changing an actual tile', async () => {+ const image = tileChallengeImage('png', { requirePixels: true })+ const canvas = native.createCanvas(512, 512)+ const context = canvas.getContext('2d')+ context.drawImage(await native.loadImage(image.bytes), 0, 0)+ const digit = image.code[0] === '0' ? '1' : '0'+ context.fillStyle = digit === '0' ? 'rgb(32,32,80)' : 'rgb(32,96,80)'+ context.fillRect(64, 64, 96, 96)+ const decoded = await decodeTileChallenge(canvas.toBuffer('image/png'))+ expect(decoded).toBe(digit + image.code.slice(1))+ expect(decoded).not.toBe(image.code)+ })++ it('rejects undecodable data and a real image without a challenge', async () => {+ await expect(decodeTileChallenge(Buffer.from([1, 2, 3]))).rejects.toThrow(/image|decode/i)+ const canvas = native.createCanvas(512, 512)+ const context = canvas.getContext('2d')+ context.fillStyle = 'white'+ context.fillRect(0, 0, 512, 512)+ await expect(decodeTileChallenge(canvas.toBuffer('image/png'))).rejects.toThrow(+ /marker|challenge/i+ )+ })++ it('makes removal and reordering observably different from the original visual result', async () => {+ const images = [+ tileChallengeImage('png', { requirePixels: true }),+ tileChallengeImage('jpeg', { requirePixels: true }),+ ]+ const expected = images.map(image => image.code).join('\n')+ expect(+ (+ await Promise.all([...images].reverse().map(image => decodeTileChallenge(image.bytes)))+ ).join('\n')+ ).not.toBe(expected)+ expect(await decodeTileChallenge(images[0]!.bytes)).not.toBe(expected)+ })+})diff --git a/desktop-app/test/subscriptionImageCollection.test.ts b/desktop-app/test/subscriptionImageCollection.test.tsnew file mode 100644index 000000000..e6c0d0cb1--- /dev/null+++ b/desktop-app/test/subscriptionImageCollection.test.ts@@ -0,0 +1,98 @@+import { afterEach, describe, expect, it, vi } from 'vitest'+import { spawnSync } from 'node:child_process'+import fs from 'node:fs'+import { createRequire } from 'node:module'+import os from 'node:os'+import path from 'node:path'++// Unit-only filesystem boundary: importing the general config cannot read any+// personal/canonical environment file. This is config coverage, not an E2E mock.+vi.mock('node:fs', async importOriginal => {+ const actual = await importOriginal<typeof import('node:fs')>()+ return {+ ...actual,+ default: {+ ...actual,+ readFileSync: () => {+ throw Object.assign(new Error('unit optional file absent'), { code: 'ENOENT' })+ },+ },+ }+})+afterEach(() => vi.unstubAllEnvs())+const realFs = createRequire(import.meta.url)('node:fs') as typeof fs+const desktopRoot = path.resolve(__dirname, '..')+const cli = createRequire(import.meta.url).resolve('@playwright/test/cli')++function collectionEnv(root: string): NodeJS.ProcessEnv {+ // Synthetic bindings only test collection; no runtime receipt exists and no+ // fixture activates. The actual runner must supply physically verified data.+ return {+ PATH: path.dirname(process.execPath),+ HOME: root,+ E2E_SUBSCRIPTION_IMAGE_INPUT: '1',+ E2E_SUBSCRIPTION_IMAGE_MODE: 'fixture',+ SUBSCRIPTION_IMAGE_FIXTURE_CONFIRM: '1',+ E2E_SUBSCRIPTION_IMAGE_RUN_ID: 'subscription-image-123456abcdef',+ SUBSCRIPTION_IMAGE_RUNNER_RECEIPT: path.join(root, 'intentionally-absent-receipt.json'),+ SUBSCRIPTION_IMAGE_RUN_ROOT: root,+ E2E_GROK_IMAGE_EVIDENCE_PATH: path.join(root, 'grok.json'),+ E2E_CODEX_IMAGE_EVIDENCE_PATH: path.join(root, 'codex.json'),+ MINIKUBE_PROFILE: 'unit-collection',+ CONTROL_API_REAL_PG_CONTEXT: 'unit-collection',+ EXTERNAL_REST_API_BASE_URL: 'http://127.0.0.1:34001',+ RPC_PROXY_BASE_URL: 'http://127.0.0.1:34002',+ E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL: '[email protected]',+ E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD: ['unit', 'collection'].join('-'),+ E2E_GROK_IMAGE_HOST_REF: 'unit-grok',+ E2E_GROK_IMAGE_HOST_LABEL: 'Unit Grok',+ E2E_GROK_IMAGE_MODEL: 'unit-grok-image',+ E2E_GROK_IMAGE_MODEL_LABEL: 'Unit Grok Image',+ E2E_GROK_IMAGE_UNSUPPORTED_MODEL: 'unit-grok-text',+ E2E_GROK_IMAGE_UNSUPPORTED_MODEL_LABEL: 'Unit Grok Text',+ E2E_CODEX_IMAGE_HOST_REF: 'unit-codex',+ E2E_CODEX_IMAGE_HOST_LABEL: 'Unit Codex',+ E2E_CODEX_IMAGE_MODEL: 'unit-codex-image',+ E2E_CODEX_IMAGE_MODEL_LABEL: 'Unit Codex Image',+ E2E_CODEX_IMAGE_UNSUPPORTED_MODEL: 'unit-codex-text',+ E2E_CODEX_IMAGE_UNSUPPORTED_MODEL_LABEL: 'Unit Codex Text',+ }+}+function list(env: NodeJS.ProcessEnv) {+ return spawnSync(+ process.execPath,+ [cli, 'test', '--config=test/e2e-playwright/playwright.subscription-image.config.ts', '--list'],+ { cwd: desktopRoot, env, encoding: 'utf8', timeout: 20_000, maxBuffer: 256 * 1024 }+ )+}++describe('subscription image configuration collection safety', () => {+ it('the actual general project config excludes the dedicated suite without reading environment files', async () => {+ vi.stubEnv('EVENFIRE_ENV_FILE_PRESENT', '0')+ const { default: config } = await import('./e2e-playwright/playwright.config.js')+ const project = config.projects?.find(project => project.name === 'default')+ expect(project?.testIgnore).toContain('**/subscription-image-input.spec.ts')+ })+ it('actual Playwright config rejects absent opt-ins before any fixture activation', () => {+ const result = list({ PATH: path.dirname(process.execPath) })+ expect(result.error).toBeUndefined()+ expect(result.status).toBe(1)+ expect(result.stdout + result.stderr).toContain('requires E2E_SUBSCRIPTION_IMAGE_INPUT=1')+ expect(result.stdout + result.stderr).not.toContain('Physical runner')+ })+ it('actual dedicated list selects all fourteen provider journeys without opening a nonexistent receipt or launching Electron', () => {+ const root = realFs.mkdtempSync(path.join(os.tmpdir(), 'subscription-image-collection-unit-'))+ try {+ const result = list(collectionEnv(root))+ expect(result.error).toBeUndefined()+ expect(result.status, result.stderr).toBe(0)+ expect(result.stdout).toContain('Total: 14 tests in 1 file')+ expect(result.stdout).toContain('grok-subscription')+ expect(result.stdout).toContain('codex-subscription')+ expect(result.stdout).not.toContain('codex-image-input.spec.ts')+ expect(realFs.existsSync(path.join(root, 'intentionally-absent-receipt.json'))).toBe(false)+ } finally {+ realFs.rmSync(root, { recursive: true, force: true })+ }+ })+})diff --git a/desktop-app/test/subscriptionImageRunContract.test.ts b/desktop-app/test/subscriptionImageRunContract.test.tsnew file mode 100644index 000000000..7f829ee7c--- /dev/null+++ b/desktop-app/test/subscriptionImageRunContract.test.ts@@ -0,0 +1,137 @@+import { describe, expect, it } from 'vitest'+import fs from 'node:fs'+import path from 'node:path'+import {+ requireSubscriptionImageRun,+ verifyRunnerObservation,+} from './e2e-playwright/subscriptionImageRunContract.js'++// These are unit-only bindings. They are never a runtime receipt or login identity.+function env(): NodeJS.ProcessEnv {+ return {+ E2E_SUBSCRIPTION_IMAGE_INPUT: '1',+ E2E_SUBSCRIPTION_IMAGE_MODE: 'fixture',+ SUBSCRIPTION_IMAGE_FIXTURE_CONFIRM: '1',+ E2E_SUBSCRIPTION_IMAGE_RUN_ID: 'subscription-image-123456abcdef',+ SUBSCRIPTION_IMAGE_RUNNER_RECEIPT: '/tmp/runner-proof.json',+ SUBSCRIPTION_IMAGE_RUN_ROOT: '/tmp/runner-owned',+ E2E_GROK_IMAGE_EVIDENCE_PATH: '/tmp/runner-owned/grok-vendor.json',+ E2E_CODEX_IMAGE_EVIDENCE_PATH: '/tmp/runner-owned/codex-vendor.json',+ MINIKUBE_PROFILE: 'unit-owned-profile',+ CONTROL_API_REAL_PG_CONTEXT: 'unit-owned-profile',+ EXTERNAL_REST_API_BASE_URL: 'http://127.0.0.1:34011',+ RPC_PROXY_BASE_URL: 'http://127.0.0.1:34012',+ E2E_SUBSCRIPTION_IMAGE_LOGIN_EMAIL: '[email protected]',+ E2E_SUBSCRIPTION_IMAGE_LOGIN_PASSWORD: ['unit', 'only'].join('-'),+ E2E_GROK_IMAGE_HOST_REF: 'unit-grok',+ E2E_GROK_IMAGE_HOST_LABEL: 'Unit Grok',+ E2E_GROK_IMAGE_MODEL: 'unit-grok-model',+ E2E_GROK_IMAGE_MODEL_LABEL: 'Unit Grok Model',+ E2E_GROK_IMAGE_UNSUPPORTED_MODEL: 'unit-grok-text',+ E2E_GROK_IMAGE_UNSUPPORTED_MODEL_LABEL: 'Unit Grok Text',+ E2E_CODEX_IMAGE_HOST_REF: 'unit-codex',+ E2E_CODEX_IMAGE_HOST_LABEL: 'Unit Codex',+ E2E_CODEX_IMAGE_MODEL: 'unit-codex-model',+ E2E_CODEX_IMAGE_MODEL_LABEL: 'Unit Codex Model',+ E2E_CODEX_IMAGE_UNSUPPORTED_MODEL: 'unit-codex-text',+ E2E_CODEX_IMAGE_UNSUPPORTED_MODEL_LABEL: 'Unit Codex Text',+ }+}++describe('subscription image load admission', () => {+ it('refuses missing opt-ins before considering any fixture or setup', () => {+ expect(() => requireSubscriptionImageRun({})).toThrow(/E2E_SUBSCRIPTION_IMAGE_INPUT/)+ for (const name of [+ 'E2E_SUBSCRIPTION_IMAGE_MODE',+ 'SUBSCRIPTION_IMAGE_FIXTURE_CONFIRM',+ 'SUBSCRIPTION_IMAGE_RUNNER_RECEIPT',+ ]) {+ const input = env()+ delete input[name]+ expect(() => requireSubscriptionImageRun(input)).toThrow(new RegExp(name))+ }+ })++ it('requires both real-provider authorizations without downgrading malformed mode', () => {+ const input: NodeJS.ProcessEnv = { ...env(), E2E_SUBSCRIPTION_IMAGE_MODE: 'real' }+ expect(() => requireSubscriptionImageRun(input)).toThrow(/GROK_REAL_UPSTREAM_CONFIRM/)+ input.GROK_REAL_UPSTREAM_CONFIRM = '1'+ expect(() => requireSubscriptionImageRun(input)).toThrow(/CODEX_REAL_UPSTREAM_CONFIRM/)+ input.CODEX_REAL_UPSTREAM_CONFIRM = '1'+ expect(requireSubscriptionImageRun(input).mode).toBe('real')+ expect(() =>+ requireSubscriptionImageRun({ ...env(), E2E_SUBSCRIPTION_IMAGE_MODE: 'invalid' })+ ).toThrow(/MODE/)+ })++ it('rejects unowned defaults, remote targets and ambiguous provider bindings', () => {+ for (const patch of [+ { EXTERNAL_REST_API_BASE_URL: 'http://127.0.0.1:8091' },+ { RPC_PROXY_BASE_URL: 'https://fixture.invalid:34123' },+ { CONTROL_API_REAL_PG_CONTEXT: 'another-profile' },+ { E2E_CODEX_IMAGE_HOST_REF: 'unit-grok' },+ { E2E_GROK_IMAGE_EVIDENCE_PATH: '/tmp/outside.json' },+ ])+ expect(() => requireSubscriptionImageRun({ ...env(), ...patch })).toThrow()+ })++ it('checks actual namespace, mount, OS identity and HOME observations instead of a boolean assertion', () => {+ const observed = {+ platform: 'linux',+ uid: 1000,+ gid: 1000,+ home: '/home/runner',+ mountNamespace: 'mnt:[123]',+ pidNamespace: 'pid:[234]',+ userNamespace: 'user:[345]',+ mountInfoSha256: 'a'.repeat(64),+ }+ expect(() =>+ verifyRunnerObservation(observed, { ...observed }, { HOME: observed.home })+ ).not.toThrow()+ for (const field of [+ 'uid',+ 'gid',+ 'home',+ 'mountNamespace',+ 'pidNamespace',+ 'userNamespace',+ 'mountInfoSha256',+ ] as const) {+ expect(() =>+ verifyRunnerObservation(+ observed,+ { ...observed, [field]: typeof observed[field] === 'number' ? 1001 : 'different' },+ { HOME: observed.home }+ )+ ).toThrow(/runner|isolation/i)+ }+ expect(() =>+ verifyRunnerObservation(observed, { ...observed, uid: 0 }, { HOME: observed.home })+ ).toThrow()+ expect(() =>+ verifyRunnerObservation(+ observed,+ { ...observed },+ { HOME: observed.home, DBUS_SESSION_BUS_ADDRESS: 'unix:path=/outside/bus' }+ )+ ).toThrow(/socket/i)+ expect(() => verifyRunnerObservation(observed, { ...observed }, { HOME: '/outside' })).toThrow(+ /HOME/+ )+ })++ it('keeps the dedicated suite out of general collection and independent of legacy setup', () => {+ const root = path.resolve(__dirname, 'e2e-playwright')+ expect(fs.readFileSync(path.join(root, 'playwright.config.ts'), 'utf8')).toContain(+ "'**/subscription-image-input.spec.ts'"+ )+ const dedicated = fs.readFileSync(+ path.join(root, 'playwright.subscription-image.config.ts'),+ 'utf8'+ )+ expect(dedicated).toContain('requireSubscriptionImageRun')+ expect(dedicated).not.toMatch(/global-setup|from ['"].*playwright\.config|\.env/)+ expect(dedicated).toContain('subscription-image-input.spec.ts')+ })+})diff --git a/scripts/e2e/fixtures/subscription-image-challenge.cjs b/scripts/e2e/fixtures/subscription-image-challenge.cjsnew file mode 100644index 000000000..5af923147--- /dev/null+++ b/scripts/e2e/fixtures/subscription-image-challenge.cjs@@ -0,0 +1,87 @@+// E2E_GUARDIAN_IPC_FLOW: test-only generation/collection for Electron IPC journeys; no renderer HTTP transition.+/** Test-only codec. Answers come from received RGBA cells, never names, metadata or a digest registry. */+const { randomBytes } = require('node:crypto')+const { createRequire } = require('node:module')+const path = require('node:path')++const hostRequire = createRequire(path.resolve(__dirname, '../../../mcp-host/package.json'))+const levels = [32, 96, 160, 224]+const palette = levels.flatMap(red => levels.map(green => [red, green, 80]))+const markers = [[240, 24, 240], [24, 240, 240], [240, 240, 24], [24, 24, 240]]++function requirePixelRenderer() {+ let native+ try { native = hostRequire('@napi-rs/canvas') } catch {+ throw new Error('Subscription image fixture requires native canvas pixels')+ }+ // Resolve and exercise the addon before any launch, including its image encoder.+ const canvas = native.createCanvas(2, 2)+ canvas.getContext('2d').fillRect(0, 0, 2, 2)+ if (!canvas.toBuffer('image/png').length || typeof native.loadImage !== 'function') {+ throw new Error('Subscription image fixture requires native pixel rendering and decoding')+ }+ return native+}++function tileChallengeImage(format, options) {+ if (options?.requirePixels !== true) throw new Error('Tile challenges require explicit native pixels')+ if (!['png', 'jpeg'].includes(format)) throw new Error('Unsupported challenge format')+ const { createCanvas } = requirePixelRenderer()+ const width = 512, height = 512+ const code = randomBytes(8).toString('hex').toUpperCase()+ const canvas = createCanvas(width, height)+ const context = canvas.getContext('2d')+ context.fillStyle = 'white'+ context.fillRect(0, 0, width, height)+ for (let index = 0; index < 16; index++) {+ context.fillStyle = `rgb(${palette[parseInt(code[index], 16)].join(',')})`+ context.fillRect(64 + (index % 4) * 96, 64 + Math.floor(index / 4) * 96, 96, 96)+ }+ for (let index = 0; index < 4; index++) {+ context.fillStyle = `rgb(${markers[index].join(',')})`+ const x = index % 2 ? 464 : 16+ const y = index >= 2 ? 464 : 16+ context.fillRect(x, y, 32, 32)+ }+ return { code, bytes: canvas.toBuffer(`image/${format}`), width, height }+}++function sample(context, x, y) {+ const data = context.getImageData(Math.floor(x) - 2, Math.floor(y) - 2, 5, 5).data+ const sums = [0, 0, 0]+ for (let offset = 0; offset < data.length; offset += 4) {+ if (data[offset + 3] < 250) throw new Error('Image challenge has transparent pixels')+ for (let component = 0; component < 3; component++) sums[component] += data[offset + component]+ }+ return sums.map(value => value / 25)+}+const distance = (left, right) => Math.max(...left.map((value, index) => Math.abs(value - right[index])))++async function decodeTileChallenge(bytes) {+ if (!Buffer.isBuffer(bytes) || !bytes.length || bytes.length > 20 * 1024 * 1024) {+ throw new Error('Image challenge decode byte bound exceeded')+ }+ const { createCanvas, loadImage } = requirePixelRenderer()+ let image+ try { image = await loadImage(bytes) } catch { throw new Error('Image challenge cannot decode received bytes') }+ if (image.width !== 512 || image.height !== 512) throw new Error('Image challenge geometry is unsupported')+ const canvas = createCanvas(image.width, image.height)+ const context = canvas.getContext('2d')+ context.drawImage(image, 0, 0)+ for (let index = 0; index < 4; index++) {+ const actual = sample(context, index % 2 ? 480 : 32, index >= 2 ? 480 : 32)+ if (distance(actual, markers[index]) > 24) throw new Error('Image challenge marker is missing')+ }+ let code = ''+ for (let index = 0; index < 16; index++) {+ const actual = sample(context, 112 + (index % 4) * 96, 112 + Math.floor(index / 4) * 96)+ const candidates = palette.map((color, digit) => ({ digit, distance: distance(actual, color) }))+ .filter(candidate => candidate.distance <= 24)+ if (candidates.length !== 1) throw new Error('Image challenge tile is undecodable')+ code += candidates[0].digit.toString(16).toUpperCase()+ }+ return code+}++// CommonJS is shared by Playwright's CommonJS transform and the ESM external peer.+module.exports = { requirePixelRenderer, tileChallengeImage, decodeTileChallenge }diff --git a/scripts/e2e/fixtures/subscription-image-provider.mjs b/scripts/e2e/fixtures/subscription-image-provider.mjsnew file mode 100644index 000000000..dcc6276e6--- /dev/null+++ b/scripts/e2e/fixtures/subscription-image-provider.mjs@@ -0,0 +1,142 @@+/**+ * Test-only external Grok/Codex Responses peers. Load with --import only in the+ * inspected derived proxy runtime; Desktop, IPC, RPC, Host, authorization and PG+ * remain real. No expected answers, image registry or production endpoint override.+ * E2E_GUARDIAN_IPC_FLOW: fixture observes the external end of the Desktop IPC journey.+ */+import { createHash } from 'node:crypto'+import { createRequire } from 'node:module'+import fs from 'node:fs'+import path from 'node:path'+import { decodeTileChallenge, requirePixelRenderer } from './subscription-image-challenge.cjs'++const require = createRequire(import.meta.url)+const grok = require('../../../packages/grok-provider-attempt-contract/index.cjs')+export const SUBSCRIPTION_VENDOR_URLS = {+ 'grok-subscription': { responses: grok.COMPLETIONS_ORIGIN, catalog: grok.CATALOG_ORIGIN },+ 'codex-subscription': {+ responses: 'https://chatgpt.com/backend-api/codex/responses',+ catalog: 'https://chatgpt.com/backend-api/codex/models?client_version=1.0.0',+ },+}+const sha256 = value => createHash('sha256').update(value).digest('hex')+const reject = code => new Response(JSON.stringify({ error: { code } }), { status: 422, headers: { 'content-type': 'application/json' } })++export function createSubscriptionImageVendor({ runId, bindings, acceptedProvider, maxAttempts = 256, record = () => {} }) {+ if (!/^subscription-image-[a-f0-9]{12}$/.test(runId) || !Array.isArray(bindings) || bindings.length !== 2 ||+ !Number.isSafeInteger(maxAttempts) || maxAttempts < 1 || maxAttempts > 1024) throw new Error('Invalid external vendor fixture binding')+ for (const provider of Object.keys(SUBSCRIPTION_VENDOR_URLS)) {+ const binding = bindings.find(item => item.provider === provider)+ if (!binding || !binding.modelId || !binding.unsupportedModelId || binding.modelId === binding.unsupportedModelId) {+ throw new Error('External vendor fixture requires distinct exact model bindings')+ }+ }+ requirePixelRenderer()+ const attempts = []+ const snapshot = () => ({ kind: 'evenfire-subscription-image-vendor-v1', runId, attempts: structuredClone(attempts) })+ async function respond(rawUrl, init = {}) {+ const provider = Object.keys(SUBSCRIPTION_VENDOR_URLS).find(name => Object.values(SUBSCRIPTION_VENDOR_URLS[name]).includes(rawUrl))+ if (!provider || (acceptedProvider && provider !== acceptedProvider)) throw new Error('Request is outside the exact external vendor boundary')+ const binding = bindings.find(item => item.provider === provider)+ if (rawUrl === SUBSCRIPTION_VENDOR_URLS[provider].catalog) {+ if ((init.method ?? 'GET') !== 'GET') throw new Error('Invalid external catalog method')+ // Synthetic catalogue identities are caller-bound; capability evidence is+ // still owned by the real Host/Control API projection, not this fixture.+ return Response.json({ models: [binding.modelId, binding.unsupportedModelId].map(model => ({ model })) })+ }+ if (init.method !== 'POST' || typeof init.body !== 'string' || Buffer.byteLength(init.body) > 36 * 1024 * 1024) {+ throw new Error('External fixture Responses body or method is invalid')+ }+ if (attempts.length >= maxAttempts) throw new Error('External fixture evidence bound exceeded')+ if (init.signal?.aborted) throw init.signal.reason+ const body = JSON.parse(init.body)+ if (!Array.isArray(body.input)) return reject('image_input_missing')+ const messages = body.input.filter(item => item && Array.isArray(item.content))+ const latest = messages.findLast(item => item.role === 'user')+ const prompt = latest?.content.filter(part => part.type === 'input_text').map(part => part.text).join('\n') ?? ''+ const receiptId = prompt.match(/Receipt: ([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/i)?.[1]+ if (!receiptId) return reject('image_receipt_missing')+ const parts = messages.flatMap(item => item.content).filter(part => part?.type === 'input_image')+ if (parts.length > 20) return reject('image_count_exceeded')+ const images = []+ let totalBytes = 0+ for (const part of parts) {+ const matched = typeof part.image_url === 'string' && part.image_url.match(/^data:(image\/(?:png|jpeg));base64,([A-Za-z0-9+/]+={0,2})$/)+ if (!matched) return reject('image_wire_invalid')+ const bytes = Buffer.from(matched[2], 'base64')+ totalBytes += bytes.length+ if (totalBytes > 20 * 1024 * 1024 || bytes.toString('base64') !== matched[2]) return reject('image_wire_invalid')+ images.push({ bytes, mimeType: matched[1] })+ }+ const row = { sequence: attempts.length + 1, provider, model: body.model, receiptId,+ imageSha256: images.map(image => sha256(image.bytes)), mimeTypes: images.map(image => image.mimeType),+ requestSha256: sha256(init.body), responseKind: 'rejected' }+ let output+ if (body.model !== binding.modelId || (body.model === binding.unsupportedModelId && images.length)) {+ attempts.push(row); record(snapshot()); return reject('image_model_unsupported')+ }+ try {+ output = images.length+ ? (await Promise.all(images.map(image => decodeTileChallenge(image.bytes)))).join('\n')+ : `TEXT_RECEIPT:${receiptId}`+ } catch {+ attempts.push(row); record(snapshot()); return reject('image_challenge_unreadable')+ }+ if (init.signal?.aborted) throw init.signal.reason+ row.responseKind = images.length ? 'pixels' : 'text'+ row.outputSha256 = sha256(output)+ attempts.push(row)+ record(snapshot())+ const events = [+ { type: 'response.output_text.delta', delta: output },+ { type: 'response.completed', response: { status: 'completed' } },+ ]+ return new Response(events.map(event => `event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`).join(''), {+ status: 200, headers: { 'content-type': 'text/event-stream' },+ })+ }+ return { respond, snapshot }+}++/** Explicit derived-runtime hook. The caller owns restoration/image/lease proof. */+export function installSubscriptionImageVendor(env = process.env) {+ if (env.NODE_ENV !== 'test' || env.EVENFIRE_SUBSCRIPTION_IMAGE_VENDOR_FIXTURE !== '1') {+ throw new Error('External vendor fixture requires an explicitly derived test runtime')+ }+ const acceptedProvider = env.SUBSCRIPTION_IMAGE_FIXTURE_PROVIDER+ if (!Object.hasOwn(SUBSCRIPTION_VENDOR_URLS, acceptedProvider ?? '')) throw new Error('External vendor fixture requires its physical proxy provider binding')+ const evidencePath = env.SUBSCRIPTION_IMAGE_EVIDENCE_PATH+ if (!evidencePath || !path.isAbsolute(evidencePath) || fs.existsSync(evidencePath)) {+ throw new Error('External vendor evidence requires a fresh absolute path')+ }+ const parent = fs.statSync(path.dirname(evidencePath))+ if (!parent.isDirectory() || parent.uid !== process.getuid?.() || (parent.mode & 0o077) !== 0) {+ throw new Error('External vendor evidence requires a private owned directory')+ }+ const bindings = ['GROK', 'CODEX'].map(kind => ({ provider: `${kind.toLowerCase()}-subscription`,+ modelId: env[`E2E_${kind}_IMAGE_MODEL`], unsupportedModelId: env[`E2E_${kind}_IMAGE_UNSUPPORTED_MODEL`] }))+ const vendor = createSubscriptionImageVendor({ runId: env.E2E_SUBSCRIPTION_IMAGE_RUN_ID, bindings, acceptedProvider,+ record: snapshot => {+ const temporary = `${evidencePath}.next`+ fs.writeFileSync(temporary, JSON.stringify(snapshot), { flag: 'wx', mode: 0o600 })+ fs.renameSync(temporary, evidencePath)+ } })+ fs.writeFileSync(evidencePath, JSON.stringify(vendor.snapshot()), { flag: 'wx', mode: 0o600 })+ const original = globalThis.fetch+ globalThis.fetch = async (input, init) => {+ const rawUrl = input instanceof Request ? input.url : String(input)+ if (Object.values(SUBSCRIPTION_VENDOR_URLS).some(urls => Object.values(urls).includes(rawUrl))) {+ return vendor.respond(rawUrl, init)+ }+ // Core requests are passed through unchanged. Other vendor paths fail closed+ // so this deterministic lane cannot accidentally call a real vendor route.+ const url = new URL(rawUrl)+ if (Object.values(SUBSCRIPTION_VENDOR_URLS).some(urls => new URL(urls.responses).hostname === url.hostname)) {+ throw new Error('Request is outside the exact external vendor boundary')+ }+ return original(input, init)+ }+ return () => { globalThis.fetch = original }+}++if (process.env.EVENFIRE_SUBSCRIPTION_IMAGE_VENDOR_FIXTURE === '1') installSubscriptionImageVendor()diff --git a/scripts/e2e/fixtures/subscription-image-provider.test.mjs b/scripts/e2e/fixtures/subscription-image-provider.test.mjsnew file mode 100644index 000000000..96dddc768--- /dev/null+++ b/scripts/e2e/fixtures/subscription-image-provider.test.mjs@@ -0,0 +1,71 @@+import assert from 'node:assert/strict'+import { randomUUID } from 'node:crypto'+import test from 'node:test'+import { createSubscriptionImageVendor, SUBSCRIPTION_VENDOR_URLS } from './subscription-image-provider.mjs'+import { tileChallengeImage } from './subscription-image-challenge.cjs'++const bindings = [+ { provider: 'grok-subscription', modelId: 'unit-grok-image', unsupportedModelId: 'unit-grok-text' },+ { provider: 'codex-subscription', modelId: 'unit-codex-image', unsupportedModelId: 'unit-codex-text' },+]+function request(images, receipt = randomUUID(), model = bindings[0].modelId) {+ return { method: 'POST', body: JSON.stringify({ model, input: [{ role: 'user', content: [+ { type: 'input_text', text: `Read each image in order. Receipt: ${receipt}` },+ ...images.map(image => ({ type: 'input_image', image_url: `data:image/${image.format};base64,${image.bytes.toString('base64')}`, detail: 'high' })),+ ] }] }) }+}+const image = format => ({ ...tileChallengeImage(format, { requirePixels: true }), format })++test('both subscription external peers answer from ordered received pixels and publish only bounded evidence', async () => {+ const vendor = createSubscriptionImageVendor({ runId: 'subscription-image-123456abcdef', bindings })+ const images = [image('png'), image('jpeg')]+ for (const binding of bindings) {+ const response = await vendor.respond(SUBSCRIPTION_VENDOR_URLS[binding.provider].responses, request(images, randomUUID(), binding.modelId))+ assert.equal(response.status, 200)+ const delta = (await response.text()).split('\n').filter(line => line.startsWith('data: ')).map(line => JSON.parse(line.slice(6))).find(event => event.type === 'response.output_text.delta')+ assert.equal(delta.delta, images.map(item => item.code).join('\n'))+ }+ const evidence = vendor.snapshot()+ assert.equal(evidence.attempts.length, 2)+ assert.equal(evidence.attempts[0].imageSha256.length, 2)+ assert.equal(evidence.attempts[0].responseKind, 'pixels')+ const serialized = JSON.stringify(evidence)+ for (const item of images) {+ assert(!serialized.includes(item.code))+ assert(!serialized.includes(item.bytes.toString('base64')))+ }+})++test('removing, replacing or reordering wire bytes cannot satisfy the original ordered oracle', async () => {+ const vendor = createSubscriptionImageVendor({ runId: 'subscription-image-123456abcdef', bindings })+ const images = [image('png'), image('jpeg')]+ const expected = images.map(item => item.code).join('\n')+ const output = async input => {+ const response = await vendor.respond(SUBSCRIPTION_VENDOR_URLS['grok-subscription'].responses, request(input))+ const stream = await response.text()+ const events = stream.split('\n').filter(line => line.startsWith('data: ')).map(line => JSON.parse(line.slice(6)))+ return events.find(event => event.type === 'response.output_text.delta')?.delta+ }+ assert.equal(await output(images), expected)+ assert.notEqual(await output([...images].reverse()), expected)+ assert.notEqual(await output(images.slice(0, 1)), expected)+ assert.notEqual(await output([]), expected)+ assert.notEqual(await output([image('png'), images[1]]), expected)+})++test('rejects no-code images, unsupported models and every non-vendor boundary', async () => {+ const vendor = createSubscriptionImageVendor({ runId: 'subscription-image-123456abcdef', bindings })+ const response = await vendor.respond(SUBSCRIPTION_VENDOR_URLS['grok-subscription'].responses, request([{ format: 'png', bytes: Buffer.from([1, 2, 3]) }]))+ assert.equal(response.status, 422)+ const unsupported = await vendor.respond(SUBSCRIPTION_VENDOR_URLS['grok-subscription'].responses, request([image('png')], randomUUID(), bindings[0].unsupportedModelId))+ assert.equal(unsupported.status, 422)+ for (const url of ['https://example.invalid/api/v1/mcp-host/llm-provider-attempts/authorize', 'https://fixture.invalid/responses', SUBSCRIPTION_VENDOR_URLS['grok-subscription'].responses + '?escape=1']) {+ await assert.rejects(() => vendor.respond(url, request([image('png')])), /external vendor boundary/)+ }+})++test('bounds retained attempts and request bodies rather than hiding missing evidence', async () => {+ const vendor = createSubscriptionImageVendor({ runId: 'subscription-image-123456abcdef', bindings, maxAttempts: 1 })+ await vendor.respond(SUBSCRIPTION_VENDOR_URLS['grok-subscription'].responses, request([]))+ await assert.rejects(() => vendor.respond(SUBSCRIPTION_VENDOR_URLS['grok-subscription'].responses, request([])), /evidence bound/)+})diff --git a/tests/e2e/playwright/control-ui/codex-subscription-admission.spec.ts b/tests/e2e/playwright/control-ui/codex-subscription-admission.spec.tsindex 0114e6dd4..6acac381d 100644--- a/tests/e2e/playwright/control-ui/codex-subscription-admission.spec.ts+++ b/tests/e2e/playwright/control-ui/codex-subscription-admission.spec.ts@@ -7,33 +7,60 @@* - LLM Models is no longer the ChatGPT assignment owner.*/import { expect, test } from '@playwright/test'-import { loginControlUiVisible } from '../helpers/visible-login'+import { observeProtectedSubscriptionBusinessAccess } from '../helpers/subscription-admission-guard'test.describe('Codex subscription admission', () => {- test('unauthenticated nested Subscriptions deep link is blocked by AuthGate', async ({- page,- }) => {- await page.goto('/secrets/llm/subscriptions')- await expect(page.getByLabel('Username or email')).toBeVisible({ timeout: 20_000 })- await expect(page.getByRole('button', { name: 'Add subscription' })).toHaveCount(0)- await expect(page.getByRole('columnheader', { name: 'Name' })).toHaveCount(0)- })-- test('unauthenticated legacy Subscription path is blocked by AuthGate', async ({ page }) => {- await page.goto('/secrets/subscription')- await expect(page.getByLabel('Username or email')).toBeVisible({ timeout: 20_000 })- await expect(page.getByRole('button', { name: 'Add subscription' })).toHaveCount(0)- })-- test('unauthenticated agent model deep link is blocked by AuthGate', async ({ page }) => {- await page.goto('/agents/e2e-codex-authoring/model')- await expect(page.getByLabel('Username or email')).toBeVisible({ timeout: 20_000 })- await expect(page.getByLabel('Credential', { exact: true })).toHaveCount(0)- await expect(page.getByRole('button', { name: 'Sign in with ChatGPT' })).toHaveCount(0)- })+ for (const guard of [+ {+ name: 'nested Subscriptions deep link',+ path: '/secrets/llm/subscriptions',+ next: '/secrets/llm/subscriptions',+ },+ {+ name: 'legacy Subscription deep link',+ path: '/secrets/subscription',+ next: '/secrets/llm/subscriptions',+ },+ {+ name: 'agent model deep link',+ path: '/agents/e2e-codex-authoring/model',+ next: '/agents/e2e-codex-authoring/model',+ },+ ]) {+ test(`unauthenticated ${guard.name} is blocked before protected business access`, async ({+ page,+ }) => {+ const attemptedBusiness = observeProtectedSubscriptionBusinessAccess(page)+ const authProbe = page.waitForResponse(+ response =>+ new URL(response.url()).pathname === '/api/v1/admin/auth/me' &&+ response.request().method() === 'GET'+ )+ // Negative deep-link guard: direct access is the behavior under test.+ await page.goto(guard.path)+ const authentication = await authProbe+ expect(authentication.status()).toBe(401)+ await expect(page).toHaveURL(+ url => url.pathname === '/login' && url.searchParams.get('next') === guard.next+ )+ await expect(page.getByLabel('Username or email')).toBeVisible()+ await expect(page.getByRole('button', { name: 'Sign in', exact: true })).toBeVisible()+ await expect(page.getByLabel('Main navigation')).toHaveCount(0)+ await expect(page.getByRole('button', { name: 'Add subscription' })).toHaveCount(0)+ await expect(page.getByRole('columnheader', { name: 'Name' })).toHaveCount(0)+ await expect(page.getByLabel('Credential', { exact: true })).toHaveCount(0)+ await expect(page.getByRole('button', { name: 'Sign in with ChatGPT' })).toHaveCount(0)+ // AuthGate has settled after its real 401 probe and visible login render.+ // Assert attempts, not only successful responses: even a denied protected+ // request would reveal a guard bypass in this unauthenticated context.+ expect(attemptedBusiness).toEqual([])+ })+ }test('LLM Models no longer owns Codex assignment', async ({ page }) => {+ // E2E_GUARDIAN_ENTRY_POINT: legitimate root entry for the visible login.await page.goto('/')+ const { loginControlUiVisible } = await import('../helpers/visible-login')await loginControlUiVisible(page)await test.step('sidebar LLM Models has no Codex subscription tab', async () => {@@ -43,6 +70,7 @@ test.describe('Codex subscription admission', () => {})await test.step('legacy provider URL does not expose Connect', async () => {+ // Negative legacy terminal-route guard: direct access is intentional.await page.goto('/llm-models/providers/codex-subscription')await expect(page.getByRole('button', { name: 'Sign in with ChatGPT' })).toHaveCount(0)await expect(page.getByTestId('codex-connection-status')).toHaveCount(0)diff --git a/tests/e2e/playwright/helpers/subscription-admission-guard.ts b/tests/e2e/playwright/helpers/subscription-admission-guard.tsnew file mode 100644index 000000000..40a2c1ce8--- /dev/null+++ b/tests/e2e/playwright/helpers/subscription-admission-guard.ts@@ -0,0 +1,61 @@+import type { Page } from '@playwright/test'+import path from 'node:path'++/** Observer only: negative guards own waitForResponse on the real auth probe. */+export function isProtectedSubscriptionBusinessPath(pathname: string): boolean {+ return /^\/api\/v1\/admin\/(?:llm\/providers\/(?:codex-subscription|grok-subscription)(?:\/|$)|(?:hosts|agents)(?:\/|$)|llm-models(?:\/|$))/.test(+ pathname+ )+}+export function observeProtectedSubscriptionBusinessAccess(page: Page): string[] {+ const attempted: string[] = []+ page.on('request', request => {+ const pathname = new URL(request.url()).pathname+ if (isProtectedSubscriptionBusinessPath(pathname))+ attempted.push(`${request.method()} ${pathname}`)+ })+ return attempted+}+export function requireSubscriptionAdmissionGuardEnv(env: NodeJS.ProcessEnv = process.env): {+ url: string+ context: string+ outputDir: string+} {+ if (env.E2E_SUBSCRIPTION_ADMISSION_GUARDS !== '1')+ throw new Error('Subscription admission guards require E2E_SUBSCRIPTION_ADMISSION_GUARDS=1')+ const context = env.CONTROL_API_REAL_PG_CONTEXT?.trim()+ if (+ !context ||+ !/^[a-z0-9][a-z0-9-]{0,62}$/.test(context) ||+ context !== env.MINIKUBE_PROFILE ||+ context === 'clerum-test' ||+ /(^|[-_])(prod|production)([-_]|$)/i.test(context)+ ) {+ throw new Error(+ 'Subscription admission guards require an explicit owned development profile/context'+ )+ }+ const raw = env.CONTROL_UI_URL?.trim() || env.CONTROL_UI_BASE_URL?.trim()+ if (!raw)+ throw new Error('Subscription admission guards require an explicit owned Control UI URL')+ const url = new URL(raw)+ if (+ url.protocol !== 'http:' ||+ !['127.0.0.1', '[::1]', 'localhost'].includes(url.hostname) ||+ !url.port ||+ url.port === '3000' ||+ url.username ||+ url.password ||+ url.search ||+ url.hash ||+ !['', '/'].includes(url.pathname)+ ) {+ throw new Error('Subscription admission guards require an owned loopback port')+ }+ const outputDir = env.E2E_SUBSCRIPTION_ADMISSION_OUTPUT_DIR?.trim()+ if (!outputDir || !path.isAbsolute(outputDir))+ throw new Error(+ 'Subscription admission guards require an explicit absolute E2E_SUBSCRIPTION_ADMISSION_OUTPUT_DIR'+ )+ return { url: url.origin, context, outputDir: path.resolve(outputDir) }+}diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.jsonindex d921d1cec..e49ae275f 100644--- a/tests/e2e/playwright/package-lock.json+++ b/tests/e2e/playwright/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-playwright-tests",- "version": "0.1.64",+ "version": "0.1.65","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-playwright-tests",- "version": "0.1.64",+ "version": "0.1.65","devDependencies": {"@playwright/test": "^1.50.0","@types/node": "^22.0.0",diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.jsonindex d7b65879c..63176346f 100644--- a/tests/e2e/playwright/package.json+++ b/tests/e2e/playwright/package.json@@ -1,6 +1,6 @@{"name": "clerum-playwright-tests",- "version": "0.1.64",+ "version": "0.1.65","private": true,"description": "Playwright E2E tests for Control UI and Desktop App","scripts": {diff --git a/tests/e2e/playwright/playwright.subscription-admission.config.ts b/tests/e2e/playwright/playwright.subscription-admission.config.tsnew file mode 100644index 000000000..3c9d2e58b--- /dev/null+++ b/tests/e2e/playwright/playwright.subscription-admission.config.ts@@ -0,0 +1,21 @@+// Selection-only config. The negative spec owns waitForResponse on the real unauthenticated auth probe.+import { defineConfig, devices } from '@playwright/test'+import { requireSubscriptionAdmissionGuardEnv } from './helpers/subscription-admission-guard'++// Pure admission before setup/browser/network; this lane has no global setup or login preflight.+const target = requireSubscriptionAdmissionGuardEnv()+export default defineConfig({+ testDir: '.',+ testMatch: 'control-ui/codex-subscription-admission.spec.ts',+ grep: /unauthenticated/,+ timeout: 45_000,+ expect: { timeout: 20_000 },+ retries: 0,+ workers: 1,+ fullyParallel: false,+ reporter: [['list']],+ outputDir: target.outputDir,+ metadata: { context: target.context, lane: 'subscription-admission-negative-guards' },+ projects: [{ name: 'control-ui', use: { ...devices['Desktop Chrome'], baseURL: target.url } }],+ use: { screenshot: 'only-on-failure', trace: 'retain-on-failure', video: 'retain-on-failure' },+})