Skip to content

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

TypeScript

test(llm): cover visible image and admission recovery journeys

Alfredo Lopez7cf55fa7ca10
diff --git a/desktop-app/test/e2e-playwright/playwright.subscription-admission-recovery.config.ts b/desktop-app/test/e2e-playwright/playwright.subscription-admission-recovery.config.ts
new file mode 100644
index 000000000..a6d390017
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/playwright.subscription-admission-recovery.config.ts
@@ -0,0 +1,7 @@
+// E2E_GUARDIAN_IPC_FLOW: collection gates precede all setup; this suite has its own named report.
+import { remainingJourneyConfig } from './subscriptionRemainingJourneyConfig.js'
+
+export default remainingJourneyConfig(
+ 'admission-recovery',
+ 'subscription-admission-recovery.spec.ts'
+)
diff --git a/desktop-app/test/e2e-playwright/playwright.subscription-gfs-image.config.ts b/desktop-app/test/e2e-playwright/playwright.subscription-gfs-image.config.ts
new file mode 100644
index 000000000..98e908096
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/playwright.subscription-gfs-image.config.ts
@@ -0,0 +1,4 @@
+// E2E_GUARDIAN_IPC_FLOW: collection gates precede all setup; this suite has its own named report.
+import { remainingJourneyConfig } from './subscriptionRemainingJourneyConfig.js'
+
+export default remainingJourneyConfig('gfs-image', 'subscription-gfs-image.spec.ts')
diff --git a/desktop-app/test/e2e-playwright/playwright.subscription-tool-screenshot.config.ts b/desktop-app/test/e2e-playwright/playwright.subscription-tool-screenshot.config.ts
new file mode 100644
index 000000000..54bb2dce6
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/playwright.subscription-tool-screenshot.config.ts
@@ -0,0 +1,4 @@
+// E2E_GUARDIAN_IPC_FLOW: collection gates precede all setup; this suite has its own named report.
+import { remainingJourneyConfig } from './subscriptionRemainingJourneyConfig.js'
+
+export default remainingJourneyConfig('tool-screenshot', 'subscription-tool-screenshot.spec.ts')
diff --git a/desktop-app/test/e2e-playwright/subscription-admission-recovery.spec.ts b/desktop-app/test/e2e-playwright/subscription-admission-recovery.spec.ts
new file mode 100644
index 000000000..f8ffc5240
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/subscription-admission-recovery.spec.ts
@@ -0,0 +1,201 @@
+/**
+ * E2E_GUARDIAN_IPC_FLOW: visible login -> owned Host/model -> visible Send while
+ * the real authorizer owner is held -> visible terminal refusal -> actual owner
+ * drain -> visible new chat/text Send -> primary completion and durable tasks.
+ * The private companion prepares competing authorized incomplete bodies only.
+ * It never sends, authenticates, selects, or advances the Desktop business flow.
+ * Native inspector observations belong to the actual server instance and PID;
+ * unknown/missing ownership is a failure, never a synthetic counter or UI error.
+ */
+import { randomUUID } from 'node:crypto'
+import { openAdmissionPressure } from '../../../scripts/e2e/fixtures/subscription-image-admission-pressure.mjs'
+import {
+ expect,
+ readVendorAttempts,
+ subscriptionImageRun as run,
+ sha256,
+ test,
+} from './subscriptionImageFixtures.js'
+import { readRemainingFixture } from './subscriptionRemainingJourneyData.js'
+import {
+ assertPrimary,
+ observeDurableTurn,
+ openOwnedChat,
+ outputPattern,
+ settledVisibleAnswer,
+ submitVisibly,
+} from './subscriptionRemainingJourneyUi.js'
+import {
+ type AdmissionFixture,
+ type FixtureReceipt,
+ requireRemainingJourney,
+} from './subscriptionRemainingJourneysContract.js'
+
+const input = requireRemainingJourney('admission-recovery', run)
+let receipt: FixtureReceipt
+test.beforeAll(() => {
+ receipt = readRemainingFixture(input, run)
+})
+type OwnerObservation = {
+ pressureRunId: string
+ maxInFlight: number
+ owners: { baseline: number; held: number; drained: number }
+ counts: { sameRunAttempts: number; sameRunTickets: number; reservations: number }
+ pids: number[]
+ inspector: { pid: number; startTime: string }
+}
+
+function assertSameNativeOwner(
+ observation: OwnerObservation,
+ reference: OwnerObservation,
+ maxInFlight: number
+): void {
+ expect(observation.pressureRunId).toBe(reference.pressureRunId)
+ expect(observation.maxInFlight).toBe(maxInFlight)
+ expect(observation.inspector).toEqual(reference.inspector)
+ expect(observation.pids).toEqual(reference.pids)
+ expect(observation.pids).toContain(observation.inspector.pid)
+ expect(observation.owners.baseline).toBe(0)
+ expect(observation.counts).toEqual({ sameRunAttempts: 0, sameRunTickets: 0, reservations: 0 })
+}
+
+for (const binding of run.bindings) {
+ test(`${binding.provider} local admission refusal settles visibly and a subsequent text turn stays on primary`, async ({
+ appPage,
+ }, testInfo) => {
+ const fixture = receipt.fixtures[binding.provider] as AdmissionFixture
+ await openOwnedChat(appPage, binding)
+ const refusalReceiptId = randomUUID()
+ const refusalPrompt = `Reply with TEXT_RECEIPT:${refusalReceiptId} only. Receipt: ${refusalReceiptId}`
+ await appPage.getByTestId('chat-input').fill(refusalPrompt)
+ const pressure = await openAdmissionPressure({
+ receiptFile: fixture.pressure.receiptFile,
+ deadlineMs: 30_000,
+ })
+ let released = false
+ try {
+ const metadata = pressure.metadata
+ expect(metadata.profile).toBe(run.profile)
+ expect(metadata.context).toBe(run.context)
+ expect(metadata.sourceManifestSha256).toBe(receipt.sourceManifestSha256)
+ expect(metadata.podUid).toBe(fixture.controlApiPodUid)
+ expect(metadata.imageId).toBe(fixture.controlApiImageId)
+ expect(metadata.maxInFlight).toBe(fixture.maxInFlight)
+ expect(new Set(metadata.hostRefs)).toEqual(new Set(run.bindings.map(item => item.hostRef)))
+ const baseline = (await pressure.owners()) as OwnerObservation
+ expect(baseline.pressureRunId).toBe(metadata.pressureRunId)
+ assertSameNativeOwner(baseline, baseline, fixture.maxInFlight)
+ expect(baseline.owners).toEqual({ baseline: 0, held: 0, drained: 0 })
+ const held = (await pressure.hold({ maxInFlight: fixture.maxInFlight })) as OwnerObservation
+ assertSameNativeOwner(held, baseline, fixture.maxInFlight)
+ expect(held.owners.held).toBe(fixture.maxInFlight)
+ await test.step('send through Desktop and inspect the local refusal while actual owners remain held', async () => {
+ await submitVisibly(appPage, binding, refusalPrompt)
+ const response = appPage.getByTestId('agent-response')
+ await expect(response).toHaveCount(1, { timeout: 60_000 })
+ await expect(response).toHaveClass(/chat-bubble--error/)
+ await expect(response.locator('.error-bubble-label')).toContainText(/Connection Error/i)
+ await expect(response.locator('.error-bubble-message')).toContainText(
+ /authorize.*503|authorize_capacity_exceeded|admission.*full/i
+ )
+ await response.getByText('Details', { exact: true }).click()
+ await expect(response.locator('.error-bubble-details-text')).toBeVisible()
+ await expect(response.locator('.error-bubble-details-text')).toContainText(
+ /authorize.*503|authorize_capacity_exceeded|admission.*full/i
+ )
+ await expect(appPage.locator('.chat-message--in-flight')).toHaveCount(0)
+ await expect(appPage.getByTestId('send-button')).toHaveAttribute(
+ 'aria-label',
+ 'Send message'
+ )
+ await expect(appPage.getByTestId('chat-input')).toBeEnabled()
+ await assertPrimary(appPage, binding)
+ })
+ const stillHeld = (await pressure.owners()) as OwnerObservation
+ assertSameNativeOwner(stillHeld, baseline, fixture.maxInFlight)
+ expect(stillHeld.owners.held).toBe(fixture.maxInFlight)
+ const failed = await observeDurableTurn(appPage, binding, { status: 'failed' })
+ expect(failed.error).toMatchObject({
+ code: 'LLM_API_CALL_FAILED',
+ retryable: false,
+ provider: binding.provider,
+ })
+ expect(failed.toolSteps).toEqual([])
+ for (const target of run.bindings)
+ expect(
+ readVendorAttempts(run, target).filter(row => row.receiptId === refusalReceiptId)
+ ).toHaveLength(0)
+ const beforeRelease = (await pressure.owners()) as OwnerObservation
+ assertSameNativeOwner(beforeRelease, baseline, fixture.maxInFlight)
+ expect(beforeRelease.owners.held).toBe(fixture.maxInFlight)
+ const drained = (await pressure.release()) as OwnerObservation
+ released = true
+ assertSameNativeOwner(drained, baseline, fixture.maxInFlight)
+ expect(drained.owners.drained).toBe(0)
+ const afterRelease = (await pressure.owners()) as OwnerObservation
+ assertSameNativeOwner(afterRelease, baseline, fixture.maxInFlight)
+ expect(afterRelease.owners.drained).toBe(0)
+ await openOwnedChat(appPage, binding)
+ const recoveryReceiptId = randomUUID()
+ const recoveryPrompt = `Reply with TEXT_RECEIPT:${recoveryReceiptId} only. Receipt: ${recoveryReceiptId}`
+ await submitVisibly(appPage, binding, recoveryPrompt)
+ const expectedOutput = `TEXT_RECEIPT:${recoveryReceiptId}`
+ const expected = outputPattern([expectedOutput])
+ await settledVisibleAnswer(appPage, binding, expected)
+ const recovered = await observeDurableTurn(appPage, binding, {
+ status: 'completed',
+ response: expected,
+ })
+ expect(recovered.taskId).not.toBe(failed.taskId)
+ expect(recovered.chatId).not.toBe(failed.chatId)
+ expect(recovered.toolSteps).toEqual([])
+ await expect
+ .poll(
+ () => readVendorAttempts(run, binding).filter(row => row.receiptId === recoveryReceiptId),
+ { timeout: 20_000 }
+ )
+ .toHaveLength(1)
+ const wire = readVendorAttempts(run, binding).find(
+ row => row.receiptId === recoveryReceiptId
+ )!
+ expect(wire.model).toBe(binding.modelId)
+ expect(wire.responseKind).toBe('text')
+ expect(wire.imageSha256).toEqual([])
+ expect(wire.outputSha256).toBe(sha256(expectedOutput))
+ for (const other of run.bindings.filter(item => item.provider !== binding.provider)) {
+ expect(
+ readVendorAttempts(run, other).filter(row => row.receiptId === recoveryReceiptId)
+ ).toHaveLength(0)
+ }
+ await testInfo.attach('admission-refusal-and-primary-recovery', {
+ contentType: 'application/json',
+ body: Buffer.from(
+ JSON.stringify({
+ runId: run.runId,
+ provider: binding.provider,
+ hostRef: binding.hostRef,
+ model: binding.modelId,
+ failedTaskId: failed.taskId,
+ recoveredTaskId: recovered.taskId,
+ refusalReceiptId,
+ recoveryReceiptId,
+ controlApiPodUid: fixture.controlApiPodUid,
+ controlApiImageId: fixture.controlApiImageId,
+ nativeOwner: { baseline, held, stillHeld, beforeRelease, drained, afterRelease },
+ recoveryWire: {
+ sequence: wire.sequence,
+ requestSha256: wire.requestSha256,
+ outputSha256: wire.outputSha256,
+ },
+ })
+ ),
+ })
+ } finally {
+ try {
+ if (!released) await pressure.release()
+ } finally {
+ await pressure.close()
+ }
+ }
+ })
+}
diff --git a/desktop-app/test/e2e-playwright/subscription-gfs-image.spec.ts b/desktop-app/test/e2e-playwright/subscription-gfs-image.spec.ts
new file mode 100644
index 000000000..829097cb6
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/subscription-gfs-image.spec.ts
@@ -0,0 +1,251 @@
+/**
+ * E2E_GUARDIAN_IPC_FLOW: visible login -> Files -> actual preview tabs -> owned
+ * Host/model -> EvenDrive chooser -> attach refs -> Send -> real version-pinned
+ * gfs_read results -> ordered pixel answer -> one durable two-message task.
+ * Main seeds only two isolated QA files and grants. No business API writes,
+ * browser state mutation or injected core response advances this journey.
+ */
+import { randomUUID } from 'node:crypto'
+import { openResourcesNavItem } from './navigationHelpers.js'
+import { decodeTileChallenge } from './subscriptionImageChallenge.js'
+import { expect, subscriptionImageRun as run, sha256, test } from './subscriptionImageFixtures.js'
+import { preparedPixelCode, readRemainingFixture } from './subscriptionRemainingJourneyData.js'
+import {
+ assertPixelVendorEvidence,
+ observeDurableTurn,
+ openOwnedChat,
+ outputPattern,
+ settledVisibleAnswer,
+ showCompletedTools,
+ submitVisibly,
+} from './subscriptionRemainingJourneyUi.js'
+import {
+ type GfsFixture,
+ requireRemainingJourney,
+} from './subscriptionRemainingJourneysContract.js'
+
+const input = requireRemainingJourney('gfs-image', run)
+let fixtures: Record<string, GfsFixture>
+test.beforeAll(() => {
+ fixtures = readRemainingFixture(input, run).fixtures as Record<string, GfsFixture>
+})
+
+for (const binding of run.bindings) {
+ test(`${binding.provider} Files preview and attached GFS image preserve source and ordered pixels`, async ({
+ appPage,
+ }, testInfo) => {
+ const fixture = fixtures[binding.provider]!
+ const codes = await Promise.all(fixture.files.map(file => preparedPixelCode(run, file)))
+ expect(new Set(codes).size).toBe(2)
+ for (const code of codes) {
+ expect(
+ JSON.stringify(
+ fixture.files.map(({ name, drive, resourceId, version, gfsUri }) => ({
+ name,
+ drive,
+ resourceId,
+ version,
+ gfsUri,
+ }))
+ )
+ ).not.toContain(code)
+ }
+ await test.step('open both prepared images through Files and decode the visible preview', async () => {
+ for (const [index, file] of fixture.files.entries()) {
+ await openResourcesNavItem(appPage, 'nav-files')
+ const browser = appPage.getByRole('region', { name: 'EvenDrive browser', exact: true })
+ await expect(browser).toBeVisible()
+ const root = browser
+ .getByRole('navigation', { name: 'File location', exact: true })
+ .getByRole('button', { name: 'Shared with me', exact: true })
+ // A read-only snapshot chooses the current breadcrumb state; visible assertions retry.
+ if (await root.isEnabled()) await root.click()
+ for (const folder of fixture.folderNames) {
+ const entry = browser.getByRole('button', { name: `Open ${folder}`, exact: true })
+ await expect(entry).toBeVisible()
+ await entry.click()
+ await expect(
+ browser.getByRole('navigation', { name: 'File location', exact: true })
+ ).toContainText(folder)
+ }
+ const entry = browser.getByRole('button', { name: `Open ${file.name}`, exact: true })
+ await expect(entry).toBeVisible()
+ await entry.click()
+ await expect(
+ appPage.getByRole('heading', { name: file.name, level: 2, exact: true })
+ ).toBeVisible()
+ const preview = appPage.getByRole('img', { name: `Preview of ${file.name}`, exact: true })
+ await expect(preview).toBeVisible()
+ await expect
+ .poll(() =>
+ preview.evaluate(async element => {
+ const image = element as HTMLImageElement
+ try {
+ await image.decode()
+ return { width: image.naturalWidth, height: image.naturalHeight }
+ } catch {
+ return null
+ }
+ })
+ )
+ .toEqual({ width: file.width, height: file.height })
+ if (run.mode === 'fixture') {
+ // Read only the image already displayed by the real preview. This
+ // detects a stale/wrong source behind a correct filename and size.
+ const displayedPixels = await preview.evaluate(element => {
+ const image = element as HTMLImageElement
+ const canvas = document.createElement('canvas')
+ canvas.width = image.naturalWidth
+ canvas.height = image.naturalHeight
+ const context = canvas.getContext('2d')
+ if (!context) throw new Error('Visible preview pixels cannot be read')
+ context.drawImage(image, 0, 0)
+ return canvas.toDataURL('image/png').split(',')[1]!
+ })
+ expect(await decodeTileChallenge(Buffer.from(displayedPixels, 'base64'))).toBe(
+ codes[index]
+ )
+ }
+ }
+ })
+ await openOwnedChat(appPage, binding)
+ await test.step('choose the same GFS files visibly in their intended message order', async () => {
+ await appPage.getByRole('button', { name: 'Add context', exact: true }).click()
+ const evenDrive = appPage.getByRole('menuitem', { name: 'EvenDrive', exact: true })
+ await expect(evenDrive).toBeVisible()
+ await evenDrive.click()
+ const picker = appPage.getByRole('dialog', {
+ name: 'Choose files for this message',
+ exact: true,
+ })
+ await expect(picker).toBeVisible()
+ for (const folder of fixture.folderNames) {
+ const directory = picker
+ .getByRole('button')
+ .filter({
+ hasText: new RegExp(`^${folder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*Folder$`),
+ })
+ await expect(directory).toBeVisible()
+ await directory.click()
+ await expect(
+ picker.getByRole('navigation', { name: 'Global file path', exact: true })
+ ).toContainText(folder)
+ }
+ for (const file of fixture.files) {
+ const checkbox = picker.getByRole('checkbox', {
+ name: new RegExp(`^${file.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s`),
+ })
+ await expect(checkbox).toBeVisible()
+ await checkbox.check()
+ await expect(checkbox).toBeChecked()
+ }
+ await picker.getByRole('button', { name: 'Attach 2', exact: true }).click()
+ await expect(picker).toHaveCount(0)
+ for (const file of fixture.files)
+ await expect(
+ appPage.getByRole('button', { name: `Remove ${file.name}`, exact: true })
+ ).toBeVisible()
+ const labels = await appPage.locator('.composer-attachment-chip strong').allTextContents()
+ expect(labels).toEqual(fixture.files.map(file => file.name))
+ })
+ const receiptId = randomUUID()
+ const targets = fixture.files.map(({ drive, resourceId, version }) => ({
+ drive,
+ resourceId,
+ version,
+ }))
+ const prompt = [
+ 'Journey: gfs-image',
+ `GFS targets: ${JSON.stringify(targets)}`,
+ 'Use clerum__gfs_read for each attached image in this order, with the exact expectedVersion shown above.',
+ 'Read the hexadecimal challenge from the returned image pixels. Reply only with one code per line in file order.',
+ 'Do not infer pixels from file names or source metadata. Do not use OCR or other tools.',
+ `Receipt: ${receiptId}`,
+ ].join('\n')
+ for (const code of codes) expect(prompt).not.toContain(code)
+ await submitVisibly(appPage, binding, prompt)
+ for (const file of fixture.files)
+ await expect(
+ appPage.getByTestId('message-list').getByText(file.name, { exact: true })
+ ).toBeVisible()
+ const expected = outputPattern(codes)
+ await settledVisibleAnswer(appPage, binding, expected)
+ await showCompletedTools(appPage, ['gfs_read', 'gfs_read'])
+ const turn = await observeDurableTurn(appPage, binding, {
+ status: 'completed',
+ response: expected,
+ })
+ expect(turn.userAttachments).toEqual(
+ fixture.files.map(file => ({
+ id: `global-file:${file.drive}:${file.pickerResourceId}`,
+ type: 'global_file',
+ label: file.name,
+ }))
+ )
+ expect(turn.toolSteps).toEqual([
+ { toolName: 'clerum__gfs_read', state: 'completed' },
+ { toolName: 'clerum__gfs_read', state: 'completed' },
+ ])
+ await assertPixelVendorEvidence(
+ run,
+ binding,
+ receiptId,
+ {
+ journey: 'gfs-image',
+ stages: ['read', 'pixels'],
+ imageSha256: fixture.files.map(file => file.imageSha256),
+ mimeTypes: fixture.files.map(file => file.mimeType),
+ output: codes.join('\n'),
+ calls: fixture.files.map(file => ({
+ name: 'clerum__gfs_read',
+ argumentsSha256: sha256(
+ JSON.stringify({
+ drive: file.drive,
+ resourceId: file.resourceId,
+ expectedVersion: file.version,
+ })
+ ),
+ })),
+ sources: fixture.files.map(({ drive, resourceId, version, gfsUri }) => ({
+ kind: 'gfs',
+ drive,
+ resourceId,
+ version,
+ gfsUri,
+ })),
+ referencedFiles: fixture.files.map(({ drive, resourceId, version, sizeBytes }) => ({
+ referenceId: `gfs:${drive}:${resourceId}@v${version}`,
+ drive,
+ resourceId,
+ version,
+ availability: 'available',
+ byteLength: sizeBytes,
+ })),
+ },
+ turn,
+ testInfo
+ )
+ await testInfo.attach('gfs-image-source-identity', {
+ contentType: 'application/json',
+ body: Buffer.from(
+ JSON.stringify({
+ runId: run.runId,
+ hostRef: fixture.hostRef,
+ podUid: fixture.podUid,
+ imageId: fixture.imageId,
+ taskId: turn.taskId,
+ files: fixture.files.map(
+ ({ drive, resourceId, gfsUri, version, sizeBytes, imageSha256 }) => ({
+ drive,
+ resourceId,
+ gfsUri,
+ version,
+ sizeBytes,
+ imageSha256,
+ })
+ ),
+ })
+ ),
+ })
+ })
+}
diff --git a/desktop-app/test/e2e-playwright/subscription-tool-screenshot.spec.ts b/desktop-app/test/e2e-playwright/subscription-tool-screenshot.spec.ts
new file mode 100644
index 000000000..6d102262f
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/subscription-tool-screenshot.spec.ts
@@ -0,0 +1,122 @@
+/**
+ * E2E_GUARDIAN_IPC_FLOW: visible login -> owned Host/model -> Send -> real shell
+ * approval -> real Host X11 screenshot -> visible pixels -> one durable task.
+ * Main prepares only a QA image on the owned Host's display. The vendor fixture
+ * receives actual tool-result pixels, never the expected answer or source file.
+ * Screenshot pixels are a new frame: its wire digest need not equal the input PNG.
+ */
+import { randomUUID } from 'node:crypto'
+import { expect, subscriptionImageRun as run, sha256, test } from './subscriptionImageFixtures.js'
+import { preparedPixelCode, readRemainingFixture } from './subscriptionRemainingJourneyData.js'
+import {
+ assertPixelVendorEvidence,
+ observeDurableTurn,
+ observeVisibleApprovalTask,
+ openOwnedChat,
+ outputPattern,
+ settledVisibleAnswer,
+ showCompletedTools,
+ submitVisibly,
+} from './subscriptionRemainingJourneyUi.js'
+import {
+ type ScreenFixture,
+ requireRemainingJourney,
+} from './subscriptionRemainingJourneysContract.js'
+
+const input = requireRemainingJourney('tool-screenshot', run)
+let fixtures: Record<string, ScreenFixture>
+test.beforeAll(() => {
+ fixtures = readRemainingFixture(input, run).fixtures as Record<string, ScreenFixture>
+})
+
+for (const binding of run.bindings) {
+ test(`${binding.provider} real desktop screenshot tool yields pixel evidence after visible approval`, async ({
+ appPage,
+ }, testInfo) => {
+ const fixture = fixtures[binding.provider]!
+ const code = await preparedPixelCode(run, fixture)
+ const receiptId = randomUUID()
+ const prompt = [
+ 'Journey: tool-screenshot',
+ `Screen fixture: ${fixture.hostImagePath}`,
+ `Screenshot region: ${JSON.stringify(fixture.region)}`,
+ 'First use shell_exec to check that the prepared screen file exists with exactly this command:',
+ `test -r ${fixture.hostImagePath}`,
+ 'Wait for my visible approval. Then use desktop_screenshot once for that region of the actual desktop.',
+ 'Read the 64-bit hexadecimal challenge from its pixels. Reply with that code only.',
+ 'Do not use OCR, read the PNG with another tool, or infer the answer from the path.',
+ `Receipt: ${receiptId}`,
+ ].join('\n')
+ expect(prompt).not.toContain(code)
+ await openOwnedChat(appPage, binding)
+ await submitVisibly(appPage, binding, prompt)
+ let approvedTaskId: string | undefined
+ await test.step('inspect and grant the real shell approval in the visible task', async () => {
+ const approve = appPage.getByTestId('approval-approve-btn')
+ await expect(approve).toHaveCount(1, { timeout: 60_000 })
+ await expect(approve).toBeVisible()
+ const stepper = appPage.getByTestId('progress-stepper').filter({ has: approve })
+ await expect(stepper).toHaveClass(/status-suspended/)
+ await expect(stepper.getByRole('status')).toContainText(/shell.*requires approval/i)
+ approvedTaskId = await observeVisibleApprovalTask(appPage, binding)
+ await approve.click()
+ await expect(approve).toHaveCount(0)
+ await expect(
+ appPage.getByText(`Approved request for ${binding.hostRef}.`, { exact: true })
+ ).toBeVisible()
+ })
+ const expected = outputPattern([code])
+ await settledVisibleAnswer(appPage, binding, expected)
+ await showCompletedTools(appPage, ['shell_exec', 'desktop_screenshot'])
+ const turn = await observeDurableTurn(appPage, binding, {
+ status: 'completed',
+ response: expected,
+ })
+ expect(turn.taskId).toBe(approvedTaskId)
+ expect(turn.userAttachments).toEqual([])
+ expect(turn.toolSteps).toEqual([
+ { toolName: 'shell_exec', state: 'completed' },
+ { toolName: 'desktop_screenshot', state: 'completed' },
+ ])
+ await assertPixelVendorEvidence(
+ run,
+ binding,
+ receiptId,
+ {
+ journey: 'tool-screenshot',
+ stages: ['prepare', 'capture', 'pixels'],
+ mimeTypes: ['image/png'],
+ output: code,
+ calls: [
+ {
+ name: 'shell_exec',
+ argumentsSha256: sha256(
+ JSON.stringify({ command: `test -r ${fixture.hostImagePath}` })
+ ),
+ },
+ {
+ name: 'desktop_screenshot',
+ argumentsSha256: sha256(JSON.stringify({ region: fixture.region })),
+ },
+ ],
+ },
+ turn,
+ testInfo
+ )
+ await testInfo.attach('tool-screenshot-source-identity', {
+ contentType: 'application/json',
+ body: Buffer.from(
+ JSON.stringify({
+ runId: run.runId,
+ hostRef: fixture.hostRef,
+ podUid: fixture.podUid,
+ imageId: fixture.imageId,
+ preparedImageSha256: fixture.imageSha256,
+ captureRegion: fixture.region,
+ taskId: turn.taskId,
+ tool: 'desktop_screenshot',
+ })
+ ),
+ })
+ })
+}
diff --git a/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyConfig.ts b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyConfig.ts
new file mode 100644
index 000000000..5b63cc035
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyConfig.ts
@@ -0,0 +1,29 @@
+// E2E_GUARDIAN_IPC_FLOW: independent opt-in config, no legacy global setup or network action during collection.
+import { defineConfig } from '@playwright/test'
+import path from 'node:path'
+import { requireSubscriptionImageRun } from './subscriptionImageRunContract.js'
+import {
+ type RemainingJourneySuite,
+ requireRemainingJourney,
+} from './subscriptionRemainingJourneysContract.js'
+
+export function remainingJourneyConfig(suite: RemainingJourneySuite, specFile: string) {
+ const run = requireSubscriptionImageRun()
+ requireRemainingJourney(suite, run)
+ return defineConfig({
+ testDir: '.',
+ testMatch: `**/${specFile}`,
+ projects: [{ name: suite }],
+ timeout: 240_000,
+ expect: { timeout: 20_000 },
+ retries: 0,
+ workers: 1,
+ fullyParallel: false,
+ reporter: [['list']],
+ outputDir: path.join(run.runRoot, `playwright-${suite}-results`),
+ metadata: { mode: run.mode, runId: run.runId, profile: run.profile, suite },
+ // Automatic tracing would retain the real login password fill. Main may
+ // start an owned trace only after the visible login fixture has completed.
+ use: { screenshot: 'only-on-failure', trace: 'off', video: 'retain-on-failure' },
+ })
+}
diff --git a/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyData.ts b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyData.ts
new file mode 100644
index 000000000..e70999772
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyData.ts
@@ -0,0 +1,90 @@
+// E2E_GUARDIAN_IPC_FLOW: read-only fixture preparation evidence, never auth/chat/tool execution.
+import { createHash } from 'node:crypto'
+import fs from 'node:fs'
+import path from 'node:path'
+import { decodeTileChallenge, requirePixelRenderer } from './subscriptionImageChallenge.js'
+import type { SubscriptionImageRun } from './subscriptionImageRunContract.js'
+import {
+ type FixtureReceipt,
+ type JourneyInput,
+ validateRemainingFixture,
+} from './subscriptionRemainingJourneysContract.js'
+
+const digest = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex')
+
+function privateBytes(filename: string, maxBytes: number): Buffer {
+ if (fs.realpathSync(path.dirname(filename)) !== path.dirname(filename))
+ throw new Error('Fixture 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 & 0o777) !== 0o600 ||
+ stat.size < 1 ||
+ stat.size > maxBytes
+ ) {
+ throw new Error('Fixture data must be bounded, private and physically owned')
+ }
+ return fs.readFileSync(fd)
+ } finally {
+ fs.closeSync(fd)
+ }
+}
+
+export function readRemainingFixture(
+ input: JourneyInput,
+ run: SubscriptionImageRun
+): FixtureReceipt {
+ const sourcePath = path.resolve(__dirname, '../../../subscription-image-source.json')
+ const sourceManifestSha256 = digest(fs.readFileSync(sourcePath))
+ return validateRemainingFixture(
+ JSON.parse(privateBytes(input.fixtureReceiptPath, 64 * 1024).toString('utf8')),
+ input,
+ run,
+ sourceManifestSha256
+ )
+}
+
+/** Only the test decodes its prepared fixture bytes; no answer crosses to the vendor fixture. */
+export async function preparedPixelCode(
+ run: SubscriptionImageRun,
+ fixture: { fixtureImagePath: string; imageSha256: string; sizeBytes?: number }
+): Promise<string> {
+ const bytes = privateBytes(fixture.fixtureImagePath, 3 * 1024 * 1024)
+ if (
+ digest(bytes) !== fixture.imageSha256 ||
+ (fixture.sizeBytes !== undefined && bytes.length !== fixture.sizeBytes)
+ ) {
+ throw new Error('Prepared native image bytes changed before the journey')
+ }
+ const native = requirePixelRenderer() as {
+ loadImage: (bytes: Buffer) => Promise<{ width: number; height: number }>
+ }
+ const image = await native.loadImage(bytes)
+ if (image.width !== 512 || image.height !== 512)
+ throw new Error('Prepared challenge must have actual 512x512 decoded pixels')
+ if (run.mode === 'fixture') return decodeTileChallenge(bytes)
+ // G8 uses text rendered in actual pixels. Main seals its independently generated
+ // 64-bit challenge as a private sidecar, never a name, provider prompt or config.
+ const oracle = JSON.parse(
+ privateBytes(`${fixture.fixtureImagePath}.oracle.json`, 1024).toString('utf8')
+ ) as {
+ kind?: string
+ runId?: string
+ imageSha256?: string
+ code?: string
+ }
+ if (
+ oracle.kind !== 'evenfire-subscription-live-pixel-oracle-v1' ||
+ oracle.runId !== run.runId ||
+ oracle.imageSha256 !== fixture.imageSha256 ||
+ typeof oracle.code !== 'string' ||
+ !/^[A-F0-9]{16}$/.test(oracle.code)
+ ) {
+ throw new Error('G8 requires the independently rendered pixel oracle for this image and run')
+ }
+ return oracle.code
+}
diff --git a/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyUi.ts b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyUi.ts
new file mode 100644
index 000000000..5ac641a54
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneyUi.ts
@@ -0,0 +1,339 @@
+/** E2E_GUARDIAN_IPC_FLOW: all business transitions use visible Desktop controls; reads correlate only after the UI turn. */
+import type { Page, TestInfo } from '@playwright/test'
+import { openResourcesNavItem } from './navigationHelpers.js'
+import { expect, readVendorAttempts, sha256, test } from './subscriptionImageFixtures.js'
+import type { ProviderBinding, SubscriptionImageRun } from './subscriptionImageRunContract.js'
+
+export const escapePattern = (value: string): string => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+export const outputPattern = (codes: string[]): RegExp =>
+ new RegExp(`^\\s*${codes.map(escapePattern).join('\\s+')}\\s*$`, 'i')
+export function primarySelector(page: Page) {
+ return page.getByTestId('model-selector-up')
+}
+export async function assertPrimary(page: Page, binding: ProviderBinding): Promise<void> {
+ const selector = primarySelector(page)
+ 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)
+ await expect(page.getByRole('status', { name: /^Running on fallback:/ })).toHaveCount(0)
+}
+export async function openOwnedChat(page: Page, binding: ProviderBinding): Promise<void> {
+ await test.step('choose the owned Host and its primary model visibly', async () => {
+ await openResourcesNavItem(page, 'nav-agents')
+ 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)
+ const selector = primarySelector(page)
+ 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 models = selector.getByRole('menu', { name: 'Select model', exact: true })
+ await expect(models).toBeVisible()
+ await models
+ .getByRole('menuitemradio', {
+ name: new RegExp(`^${escapePattern(binding.modelLabel)}(?:\\s*default)?$`),
+ })
+ .click()
+ await expect(models).toHaveCount(0)
+ await assertPrimary(page, binding)
+ })
+}
+export async function submitVisibly(
+ page: Page,
+ binding: ProviderBinding,
+ prompt: string
+): Promise<void> {
+ 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('')
+ await expect(page.getByTestId('message-list').getByText(prompt, { exact: true })).toBeVisible()
+ await expect(page.locator('[data-chat-message-id]')).toHaveCount(2)
+ await expect(primarySelector(page)).toHaveAttribute('data-host-ref', binding.hostRef)
+}
+export async function settledVisibleAnswer(
+ page: Page,
+ binding: ProviderBinding,
+ expected: RegExp
+): Promise<void> {
+ const response = page.getByTestId('agent-response')
+ await expect(response).toHaveCount(1, { timeout: 180_000 })
+ await expect(response.locator('.message-block')).toHaveText(expected, { timeout: 180_000 })
+ await expect(response).not.toHaveClass(/chat-bubble--error/)
+ await expect(page.locator('.chat-message--in-flight')).toHaveCount(0)
+ await expect(page.getByTestId('send-button')).toHaveAttribute('aria-label', 'Send message')
+ await expect(page.getByTestId('approval-approve-btn')).toHaveCount(0)
+ await assertPrimary(page, binding)
+}
+
+export type DurableTurn = {
+ chatId: string
+ taskId: string
+ status: unknown
+ success: unknown
+ response: string
+ error: unknown
+ userAttachments: Array<{ id: string; type: string; label: string }>
+ toolSteps: Array<{ toolName: string; state: string }>
+ acceptedFileReferenceIds: unknown
+}
+export async function observeDurableTurn(
+ page: Page,
+ binding: ProviderBinding,
+ expected: { status: 'completed' | 'failed'; response?: RegExp }
+): Promise<DurableTurn> {
+ await expect(page.locator('[data-chat-message-id]')).toHaveCount(2)
+ const messageIds = await page
+ .locator('[data-chat-message-id]')
+ .evaluateAll(elements => elements.map(element => element.getAttribute('data-chat-message-id')))
+ let matched: DurableTurn | null = null
+ // Read-only IPC is permitted AFTER visible submit/terminal; it never advances business state.
+ await expect
+ .poll(
+ async () => {
+ const candidate = await page.evaluate(
+ async ({ hostRef, ids }) => {
+ for (const chat of (await window.clerum.chat.list(hostRef)).slice(0, 20)) {
+ const messages = await window.clerum.chat.loadMessages(hostRef, chat.id)
+ const pair = ids.map(id => messages.find(message => message.id === id))
+ const taskId = pair[0]?.task_id
+ if (
+ !taskId ||
+ pair[1]?.task_id !== taskId ||
+ pair[0]?.role !== 'user' ||
+ pair[1]?.role !== 'assistant'
+ )
+ continue
+ const result = await window.clerum.rpc.getTaskResult(hostRef, taskId)
+ return {
+ chatId: chat.id,
+ taskId,
+ status: result.status,
+ success: result.success,
+ response: result.response ?? '',
+ error: result.error,
+ userAttachments: (pair[0]?.attachments ?? []).map(({ id, type, label }) => ({
+ id,
+ type,
+ label,
+ })),
+ toolSteps: (pair[1]?.toolSteps ?? []).map(({ toolName, state }) => ({
+ toolName,
+ state,
+ })),
+ acceptedFileReferenceIds: result.acceptedFileReferenceIds,
+ }
+ }
+ return null
+ },
+ { hostRef: binding.hostRef, ids: messageIds }
+ )
+ if (
+ !candidate ||
+ candidate.status !== expected.status ||
+ (expected.status === 'completed' && candidate.success !== true) ||
+ (expected.status === 'failed' && candidate.success !== false) ||
+ (expected.response && !expected.response.test(candidate.response))
+ )
+ return false
+ matched = candidate
+ return true
+ },
+ { timeout: 30_000 }
+ )
+ .toBe(true)
+ if (!matched) throw new Error('Visible two-message turn has no correlated durable terminal task')
+ return matched
+}
+
+export async function showCompletedTools(page: Page, toolNames: string[]): Promise<void> {
+ const expand = page.getByTestId('progress-expand-btn')
+ await expect(expand).toHaveCount(1)
+ await expect(expand).toBeVisible()
+ if ((await expand.getAttribute('aria-expanded')) !== 'true') await expand.click()
+ await expect(expand).toHaveAttribute('aria-expanded', 'true')
+ const counts = new Map<string, number>()
+ for (const name of toolNames) counts.set(name, (counts.get(name) ?? 0) + 1)
+ for (const [name, count] of counts) {
+ const row = page.getByTestId(/^step-row-/).filter({ hasText: name })
+ await expect(row).toHaveCount(count)
+ for (const completed of await row.all()) {
+ await expect(completed).toBeVisible()
+ await expect(completed.locator('.state-completed')).not.toHaveCount(0)
+ }
+ }
+}
+
+export async function observeVisibleApprovalTask(
+ page: Page,
+ binding: ProviderBinding
+): Promise<string> {
+ 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
+ // This observes the task only after its real approval UI is visible.
+ await expect
+ .poll(
+ async () => {
+ const candidate = await page.evaluate(
+ async ({ hostRef, messageIds }) => {
+ for (const chat of (await window.clerum.chat.list(hostRef)).slice(0, 20)) {
+ const messages = await window.clerum.chat.loadMessages(hostRef, chat.id)
+ const user = messages.find(
+ message => message.role === 'user' && messageIds.includes(message.id)
+ )
+ if (!user?.task_id) continue
+ const result = await window.clerum.rpc.getTaskResult(hostRef, user.task_id)
+ return { taskId: user.task_id, status: result.status, approval: result.approval }
+ }
+ return null
+ },
+ { hostRef: binding.hostRef, messageIds: ids }
+ )
+ if (
+ !candidate ||
+ candidate.status !== 'waiting_approval' ||
+ candidate.approval?.taskId !== candidate.taskId ||
+ !candidate.approval.requestId
+ )
+ return false
+ taskId = candidate.taskId
+ return true
+ },
+ { timeout: 30_000 }
+ )
+ .toBe(true)
+ if (!taskId) throw new Error('Visible approval is not linked to an actual suspended task')
+ return taskId
+}
+
+export async function assertPixelVendorEvidence(
+ run: SubscriptionImageRun,
+ binding: ProviderBinding,
+ receiptId: string,
+ expected: {
+ journey: 'tool-screenshot' | 'gfs-image'
+ stages: string[]
+ imageSha256?: string[]
+ mimeTypes: string[]
+ output: string
+ calls: Array<{ name: string; argumentsSha256: string }>
+ sources?: unknown[]
+ referencedFiles?: unknown[]
+ },
+ turn: DurableTurn,
+ testInfo: TestInfo
+): Promise<void> {
+ if (run.mode === 'fixture') {
+ await expect
+ .poll(() => readVendorAttempts(run, binding).filter(row => row.receiptId === receiptId), {
+ timeout: 20_000,
+ })
+ .toHaveLength(expected.stages.length)
+ const attempts = readVendorAttempts(run, binding).filter(
+ row => row.receiptId === receiptId
+ ) as Array<
+ ReturnType<typeof readVendorAttempts>[number] & {
+ journey?: string
+ stage?: string
+ toolCalls?: Array<{ id: string; name: string; argumentsSha256: string }>
+ toolOutputs?: Array<{ id: string; outputSha256: string; resource?: unknown }>
+ referencedFiles?: unknown[]
+ }
+ >
+ expect(attempts.map(row => row.journey)).toEqual(expected.stages.map(() => expected.journey))
+ expect(attempts.map(row => row.stage)).toEqual(expected.stages)
+ expect(attempts.every(row => row.model === binding.modelId)).toBe(true)
+ if (expected.referencedFiles)
+ expect(attempts[0]?.referencedFiles).toEqual(expected.referencedFiles)
+ const calls = attempts.flatMap(row => row.toolCalls ?? [])
+ expect(calls.map(({ name, argumentsSha256 }) => ({ name, argumentsSha256 }))).toEqual(
+ expected.calls
+ )
+ expect(new Set(calls.map(row => row.id)).size).toBe(expected.calls.length)
+ const final = attempts[attempts.length - 1]!
+ expect(final.responseKind).toBe('pixels')
+ expect(final.outputSha256).toBe(sha256(expected.output))
+ expect(final.mimeTypes).toEqual(expected.mimeTypes)
+ expect(final.imageSha256).toHaveLength(expected.mimeTypes.length)
+ expect(final.toolOutputs?.map(row => row.id)).toEqual(calls.map(row => row.id))
+ if (expected.sources)
+ expect(final.toolOutputs?.map(row => row.resource)).toEqual(expected.sources)
+ if (expected.imageSha256) expect(final.imageSha256).toEqual(expected.imageSha256)
+ 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(`${expected.journey}-wire-evidence`, {
+ contentType: 'application/json',
+ body: Buffer.from(
+ JSON.stringify({
+ runId: run.runId,
+ mode: run.mode,
+ hostRef: binding.hostRef,
+ provider: binding.provider,
+ model: binding.modelId,
+ receiptId,
+ taskId: turn.taskId,
+ attempts: attempts.map(
+ ({
+ sequence,
+ requestSha256,
+ imageSha256,
+ mimeTypes,
+ responseKind,
+ outputSha256,
+ stage,
+ toolCalls,
+ toolOutputs,
+ referencedFiles,
+ }) => ({
+ sequence,
+ requestSha256,
+ imageSha256,
+ mimeTypes,
+ responseKind,
+ outputSha256,
+ stage,
+ toolCalls,
+ toolOutputs,
+ referencedFiles,
+ })
+ ),
+ })
+ ),
+ })
+ } else {
+ await testInfo.attach(`${expected.journey}-live-business-evidence`, {
+ contentType: 'application/json',
+ body: Buffer.from(
+ JSON.stringify({
+ runId: run.runId,
+ mode: run.mode,
+ hostRef: binding.hostRef,
+ provider: binding.provider,
+ model: binding.modelId,
+ receiptId,
+ taskId: turn.taskId,
+ outputSha256: sha256(expected.output),
+ toolSteps: turn.toolSteps,
+ })
+ ),
+ })
+ }
+}
diff --git a/desktop-app/test/e2e-playwright/subscriptionRemainingJourneysContract.ts b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneysContract.ts
new file mode 100644
index 000000000..ff8d7df85
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/subscriptionRemainingJourneysContract.ts
@@ -0,0 +1,260 @@
+// E2E_GUARDIAN_IPC_FLOW: pure collection admission and fixture shape validation; no launch, network or session access.
+import path from 'node:path'
+import type {
+ SubscriptionImageProvider,
+ SubscriptionImageRun,
+} from './subscriptionImageRunContract.js'
+
+export type RemainingJourneySuite = 'tool-screenshot' | 'gfs-image' | 'admission-recovery'
+export type JourneyInput = { suite: RemainingJourneySuite; fixtureReceiptPath: string }
+export type RuntimeIdentity = {
+ hostRef: string
+ podUid: string
+ imageId: string
+}
+export type ScreenFixture = RuntimeIdentity & {
+ hostImagePath: string
+ fixtureImagePath: string
+ imageSha256: string
+ region: { x: number; y: number; w: 512; h: 512 }
+}
+export type GfsFixtureFile = {
+ name: string
+ drive: string
+ // API listing retains its database UUID; the model/tool source uses compact rid.
+ pickerResourceId: string
+ resourceId: string
+ version: number
+ gfsUri: string
+ sizeBytes: number
+ mimeType: 'image/png' | 'image/jpeg'
+ fixtureImagePath: string
+ imageSha256: string
+ width: 512
+ height: 512
+}
+export type GfsFixture = RuntimeIdentity & {
+ // Actual visible directory names from Shared with me to the fixture folder.
+ folderNames: string[]
+ files: [GfsFixtureFile, GfsFixtureFile]
+}
+export type AdmissionFixture = RuntimeIdentity & {
+ controlApiPodUid: string
+ controlApiImageId: string
+ maxInFlight: number
+ readDeadlineMs: number
+ // The private relay client validates its own sealed metadata and physical
+ // socket ownership. This layer never invents a URL, JWT or IPC command.
+ pressure: { receiptFile: string }
+ // Main must prove a real eligible fallback exists before testing no-failover.
+ fallback: { provider: SubscriptionImageProvider; modelId: string }
+}
+export type FixtureReceipt = {
+ kind: 'evenfire-subscription-remaining-journey-fixture-v1'
+ runId: string
+ suite: RemainingJourneySuite
+ profile: string
+ context: string
+ sourceManifestSha256: string
+ preparedAt: string
+ fixtures: Partial<
+ Record<SubscriptionImageProvider, ScreenFixture | GfsFixture | AdmissionFixture>
+ >
+}
+
+const SHA256 = /^[a-f0-9]{64}$/
+const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i
+const IMAGE_ID =
+ /^(?:(?:docker-pullable|docker|containerd|cri-o):\/\/)?(?:[\w.:/-]+@)?sha256:[a-f0-9]{64}$/
+const SPECIFIC_OPT_IN = {
+ 'tool-screenshot': 'E2E_SUBSCRIPTION_TOOL_SCREENSHOT',
+ 'gfs-image': 'E2E_SUBSCRIPTION_GFS_IMAGE',
+ 'admission-recovery': 'E2E_SUBSCRIPTION_ADMISSION_RECOVERY',
+} as const
+
+function record(value: unknown, message: string): Record<string, unknown> {
+ if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error(message)
+ return value as Record<string, unknown>
+}
+function insideRunRoot(value: unknown, runRoot: string): value is string {
+ if (typeof value !== 'string' || !path.isAbsolute(value) || path.resolve(value) !== value)
+ return false
+ const relative = path.relative(runRoot, value)
+ return (
+ Boolean(relative) &&
+ relative !== '..' &&
+ !relative.startsWith(`..${path.sep}`) &&
+ !path.isAbsolute(relative)
+ )
+}
+function visibleName(value: unknown): value is string {
+ return (
+ typeof value === 'string' &&
+ value.length > 0 &&
+ value.length <= 128 &&
+ !/[\x00-\x1f/\\]/.test(value)
+ )
+}
+
+/** Config admission precedes fixture setup. Missing opt-ins never become skips. */
+export function requireRemainingJourney(
+ suite: RemainingJourneySuite,
+ run: SubscriptionImageRun,
+ env: NodeJS.ProcessEnv = process.env
+): JourneyInput {
+ if (env[SPECIFIC_OPT_IN[suite]] !== '1')
+ throw new Error(`${suite} requires ${SPECIFIC_OPT_IN[suite]}=1`)
+ if (suite === 'admission-recovery' && run.mode !== 'fixture')
+ throw new Error('admission-recovery is a fixture-only physical workload lane')
+ const fixtureReceiptPath = env.E2E_SUBSCRIPTION_REMAINING_FIXTURE_RECEIPT
+ if (!insideRunRoot(fixtureReceiptPath, run.runRoot))
+ throw new Error('Remaining journey fixture receipt must be inside the owned run root')
+ return { suite, fixtureReceiptPath }
+}
+
+/** Validate data preparation, never a substitute for the subsequently observed UI/tool/wire effects. */
+export function validateRemainingFixture(
+ value: unknown,
+ input: JourneyInput,
+ run: SubscriptionImageRun,
+ sourceManifestSha256: string
+): FixtureReceipt {
+ const receipt = record(value, 'Remaining journey fixture receipt is invalid')
+ if (
+ receipt.kind !== 'evenfire-subscription-remaining-journey-fixture-v1' ||
+ receipt.suite !== input.suite ||
+ receipt.runId !== run.runId ||
+ receipt.profile !== run.profile ||
+ receipt.context !== run.context ||
+ !SHA256.test(sourceManifestSha256) ||
+ receipt.sourceManifestSha256 !== sourceManifestSha256 ||
+ typeof receipt.preparedAt !== 'string' ||
+ !Number.isFinite(Date.parse(receipt.preparedAt))
+ ) {
+ throw new Error('Remaining journey fixture does not bind the admitted run/source/stack')
+ }
+ const fixtures = record(receipt.fixtures, 'Remaining journey fixtures are missing')
+ if (Object.keys(fixtures).length !== run.bindings.length)
+ throw new Error('Each provider needs one exact fixture binding')
+ for (const binding of run.bindings) {
+ const fixture = record(fixtures[binding.provider], `Missing actual ${binding.provider} fixture`)
+ if (
+ fixture.hostRef !== binding.hostRef ||
+ typeof fixture.podUid !== 'string' ||
+ !UUID.test(fixture.podUid) ||
+ typeof fixture.imageId !== 'string' ||
+ !IMAGE_ID.test(fixture.imageId)
+ ) {
+ throw new Error('Fixture Host/pod/image identity is incomplete')
+ }
+ if (input.suite === 'tool-screenshot') {
+ const region = record(fixture.region, 'Screen fixture region is missing')
+ if (
+ typeof fixture.hostImagePath !== 'string' ||
+ !/^\/tmp\/evenfire-qa-screen-[a-f0-9-]{36}\.png$/.test(fixture.hostImagePath) ||
+ !insideRunRoot(fixture.fixtureImagePath, run.runRoot) ||
+ typeof fixture.imageSha256 !== 'string' ||
+ !SHA256.test(fixture.imageSha256) ||
+ !Number.isSafeInteger(region.x) ||
+ Number(region.x) < 0 ||
+ !Number.isSafeInteger(region.y) ||
+ Number(region.y) < 0 ||
+ region.w !== 512 ||
+ region.h !== 512
+ )
+ throw new Error(
+ 'Screen fixture must identify actual prepared native pixels and exact capture region'
+ )
+ } else if (input.suite === 'gfs-image') {
+ if (
+ !Array.isArray(fixture.folderNames) ||
+ fixture.folderNames.length < 1 ||
+ fixture.folderNames.length > 8 ||
+ !fixture.folderNames.every(visibleName) ||
+ !Array.isArray(fixture.files) ||
+ fixture.files.length !== 2
+ ) {
+ throw new Error('GFS fixture needs a visible folder path and two independent files')
+ }
+ const ids = new Set<string>(),
+ names = new Set<string>(),
+ digests = new Set<string>()
+ for (const raw of fixture.files) {
+ const file = record(raw, 'GFS fixture file is invalid')
+ if (
+ !visibleName(file.name) ||
+ typeof file.drive !== 'string' ||
+ !/^[a-zA-Z0-9_-]{1,63}$/.test(file.drive) ||
+ typeof file.resourceId !== 'string' ||
+ !/^[a-f0-9]{32}$/.test(file.resourceId) ||
+ typeof file.pickerResourceId !== 'string' ||
+ !(/^[a-f0-9]{32}$/.test(file.pickerResourceId) || UUID.test(file.pickerResourceId)) ||
+ file.pickerResourceId.replaceAll('-', '').toLowerCase() !== file.resourceId ||
+ !Number.isSafeInteger(file.version) ||
+ Number(file.version) < 0 ||
+ file.gfsUri !== `gfs://${file.drive}/${file.resourceId}` ||
+ !Number.isSafeInteger(file.sizeBytes) ||
+ Number(file.sizeBytes) < 1 ||
+ Number(file.sizeBytes) > 3 * 1024 * 1024 ||
+ !['image/png', 'image/jpeg'].includes(String(file.mimeType)) ||
+ file.width !== 512 ||
+ file.height !== 512 ||
+ !insideRunRoot(file.fixtureImagePath, run.runRoot) ||
+ typeof file.imageSha256 !== 'string' ||
+ !SHA256.test(file.imageSha256)
+ ) {
+ throw new Error(
+ 'GFS fixture needs exact grantable source identity and within-budget native pixels'
+ )
+ }
+ ids.add(file.gfsUri)
+ names.add(file.name)
+ digests.add(file.imageSha256)
+ }
+ if (ids.size !== 2 || names.size !== 2 || digests.size !== 2)
+ throw new Error('GFS ordered challenge requires independent identities and pixels')
+ } else {
+ const fallback = record(
+ fixture.fallback,
+ 'Admission fixture requires an actual eligible fallback'
+ )
+ const other = run.bindings.find(candidate => candidate.provider !== binding.provider)
+ const pressure = record(
+ fixture.pressure,
+ 'Admission pressure requires sealed private relay metadata'
+ )
+ if (
+ typeof pressure.receiptFile !== 'string' ||
+ !path.isAbsolute(pressure.receiptFile) ||
+ path.resolve(pressure.receiptFile) !== pressure.receiptFile ||
+ path.dirname(pressure.receiptFile) !== '/runner-admission' ||
+ !/\.json$/.test(pressure.receiptFile) ||
+ /(?:^|[-_.])(?:env|token|secret|credential|wallet|cookie|password|private[-_]?key)(?:[-_.]|$)/i.test(
+ path.basename(pressure.receiptFile)
+ )
+ ) {
+ throw new Error(
+ 'Pressure receipt must identify sealed admission metadata, never private account/config files'
+ )
+ }
+ if (
+ typeof fixture.controlApiPodUid !== 'string' ||
+ !UUID.test(fixture.controlApiPodUid) ||
+ typeof fixture.controlApiImageId !== 'string' ||
+ !IMAGE_ID.test(fixture.controlApiImageId) ||
+ !Number.isSafeInteger(fixture.maxInFlight) ||
+ Number(fixture.maxInFlight) < 1 ||
+ !Number.isSafeInteger(fixture.readDeadlineMs) ||
+ Number(fixture.readDeadlineMs) < 1 ||
+ Number(fixture.readDeadlineMs) > 2_147_483_647 ||
+ fallback.provider !== other?.provider ||
+ fallback.modelId !== other?.modelId
+ ) {
+ throw new Error(
+ 'Admission fixture must bind real owned capacity and an eligible physical fallback'
+ )
+ }
+ }
+ }
+ return value as FixtureReceipt
+}
diff --git a/desktop-app/test/subscriptionRemainingJourneyData.test.ts b/desktop-app/test/subscriptionRemainingJourneyData.test.ts
new file mode 100644
index 000000000..1fac35d40
--- /dev/null
+++ b/desktop-app/test/subscriptionRemainingJourneyData.test.ts
@@ -0,0 +1,101 @@
+import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'
+import { createHash } from 'node:crypto'
+import fs from 'node:fs'
+import os from 'node:os'
+import path from 'node:path'
+import { tileChallengeImage } from './e2e-playwright/subscriptionImageChallenge.js'
+import type { SubscriptionImageRun } from './e2e-playwright/subscriptionImageRunContract.js'
+import { preparedPixelCode } from './e2e-playwright/subscriptionRemainingJourneyData.js'
+
+const digest = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex')
+let root: string
+beforeAll(() => {
+ root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'evenfire-remaining-pixels-unit-')))
+ fs.chmodSync(root, 0o700)
+})
+afterEach(() => {
+ for (const name of fs.readdirSync(root)) fs.unlinkSync(path.join(root, name))
+})
+afterAll(() => {
+ fs.rmdirSync(root)
+})
+// Only the codec/file-admission boundary is exercised here. No Host, account,
+// provider or E2E runtime is fabricated by these unit-only run coordinates.
+const run = { mode: 'fixture', runId: 'subscription-image-123456789abc' } as SubscriptionImageRun
+function image(format: 'png' | 'jpeg' = 'png') {
+ const visual = tileChallengeImage(format, { requirePixels: true })
+ const fixtureImagePath = path.join(root, `native.${format}`)
+ fs.writeFileSync(fixtureImagePath, visual.bytes, { mode: 0o600 })
+ return {
+ visual,
+ fixture: {
+ fixtureImagePath,
+ imageSha256: digest(visual.bytes),
+ sizeBytes: visual.bytes.length,
+ },
+ }
+}
+
+describe('remaining-journey prepared native pixel data', () => {
+ it.each(['png', 'jpeg'] as const)(
+ 'decodes the independently rendered %s pixels after private-file/digest checks',
+ async format => {
+ const { visual, fixture } = image(format)
+ expect(await preparedPixelCode(run, fixture)).toBe(visual.code)
+ }
+ )
+ it('refuses changed image bytes with an old preparation digest', async () => {
+ const { fixture } = image()
+ const changed = tileChallengeImage('png', { requirePixels: true })
+ fs.writeFileSync(fixture.fixtureImagePath, changed.bytes)
+ await expect(preparedPixelCode(run, fixture)).rejects.toThrow('changed')
+ })
+ it('refuses a GFS file with a different physical byte count', async () => {
+ const { fixture } = image()
+ await expect(
+ preparedPixelCode(run, { ...fixture, sizeBytes: fixture.sizeBytes + 1 })
+ ).rejects.toThrow('changed')
+ })
+ it('refuses non-private source files before interpreting their pixels', async () => {
+ const { fixture } = image()
+ fs.chmodSync(fixture.fixtureImagePath, 0o644)
+ await expect(preparedPixelCode(run, fixture)).rejects.toThrow('private')
+ })
+ it('refuses a symlink source instead of following it', async () => {
+ const { fixture } = image()
+ const link = path.join(root, 'alias.png')
+ fs.symlinkSync(fixture.fixtureImagePath, link)
+ await expect(preparedPixelCode(run, { ...fixture, fixtureImagePath: link })).rejects.toThrow()
+ })
+ it('refuses undecodable bytes even when a receipt contains their correct digest', async () => {
+ const fixtureImagePath = path.join(root, 'invalid.png')
+ const bytes = Buffer.from('shape-only data is not native image pixels')
+ fs.writeFileSync(fixtureImagePath, bytes, { mode: 0o600 })
+ await expect(
+ preparedPixelCode(run, { fixtureImagePath, imageSha256: digest(bytes) })
+ ).rejects.toThrow()
+ })
+ it('refuses a live oracle belonging to other pixels or another run', async () => {
+ const { visual, fixture } = image()
+ const oraclePath = `${fixture.fixtureImagePath}.oracle.json`
+ for (const patch of [
+ { runId: 'subscription-image-ffffffffffff' },
+ { imageSha256: 'b'.repeat(64) },
+ ]) {
+ fs.writeFileSync(
+ oraclePath,
+ JSON.stringify({
+ kind: 'evenfire-subscription-live-pixel-oracle-v1',
+ runId: run.runId,
+ imageSha256: fixture.imageSha256,
+ code: visual.code,
+ ...patch,
+ }),
+ { mode: 0o600 }
+ )
+ await expect(preparedPixelCode({ ...run, mode: 'real' }, fixture)).rejects.toThrow(
+ 'rendered pixel oracle'
+ )
+ }
+ })
+})
diff --git a/desktop-app/test/subscriptionRemainingJourneysContract.test.ts b/desktop-app/test/subscriptionRemainingJourneysContract.test.ts
new file mode 100644
index 000000000..27e77370e
--- /dev/null
+++ b/desktop-app/test/subscriptionRemainingJourneysContract.test.ts
@@ -0,0 +1,297 @@
+import { describe, expect, it } from 'vitest'
+import type { SubscriptionImageRun } from './e2e-playwright/subscriptionImageRunContract.js'
+import {
+ requireRemainingJourney,
+ validateRemainingFixture,
+} from './e2e-playwright/subscriptionRemainingJourneysContract.js'
+
+// These are shape-only identities. No runtime/session or provider is fabricated
+// by the unit fixture; physical ownership remains the independent runner gate.
+const digest = 'a'.repeat(64)
+const run: SubscriptionImageRun = {
+ mode: 'fixture',
+ runId: 'subscription-image-123456789abc',
+ runnerReceipt: '/private/tmp/unit-run/runner.json',
+ runRoot: '/private/tmp/unit-run',
+ profile: 'clerum-owned-unit-lane',
+ context: 'clerum-owned-unit-lane',
+ restUrl: 'http://127.0.0.1:43001',
+ rpcUrl: 'http://127.0.0.1:43002',
+ bindings: ['grok', 'codex'].map(kind => ({
+ provider: `${kind}-subscription` as 'grok-subscription' | 'codex-subscription',
+ hostRef: `qa-${kind}`,
+ hostLabel: `QA ${kind}`,
+ modelId: `${kind}-image`,
+ modelLabel: `${kind} Image`,
+ unsupportedModelId: `${kind}-text`,
+ unsupportedModelLabel: `${kind} Text`,
+ })),
+}
+const input = {
+ suite: 'tool-screenshot' as const,
+ fixtureReceiptPath: `${run.runRoot}/screens.json`,
+}
+const env = {
+ E2E_SUBSCRIPTION_TOOL_SCREENSHOT: '1',
+ E2E_SUBSCRIPTION_REMAINING_FIXTURE_RECEIPT: input.fixtureReceiptPath,
+}
+function receipt() {
+ return {
+ kind: 'evenfire-subscription-remaining-journey-fixture-v1',
+ suite: input.suite,
+ runId: run.runId,
+ profile: run.profile,
+ context: run.context,
+ sourceManifestSha256: digest,
+ preparedAt: '2026-10-02T00:00:00.000Z',
+ fixtures: Object.fromEntries(
+ run.bindings.map(binding => [
+ binding.provider,
+ {
+ hostRef: binding.hostRef,
+ podUid: '12345678-1234-4234-8234-123456789abc',
+ imageId: `sha256:${digest}`,
+ hostImagePath: '/tmp/evenfire-qa-screen-12345678-1234-4234-8234-123456789abc.png',
+ fixtureImagePath: `${run.runRoot}/${binding.provider}.png`,
+ imageSha256: digest,
+ region: { x: 0, y: 0, w: 512, h: 512 },
+ },
+ ])
+ ),
+ }
+}
+function gfsReceipt() {
+ return {
+ ...receipt(),
+ suite: 'gfs-image',
+ fixtures: Object.fromEntries(
+ run.bindings.map(binding => [
+ binding.provider,
+ {
+ hostRef: binding.hostRef,
+ podUid: '12345678-1234-4234-8234-123456789abc',
+ imageId: `sha256:${digest}`,
+ folderNames: ['owned-qa-folder'],
+ files: ['png', 'jpeg'].map((format, index) => ({
+ name: `qa-file-${index}.${format}`,
+ drive: 'main',
+ resourceId: (index ? 'b' : 'c').repeat(32),
+ pickerResourceId: `${(index ? 'b' : 'c').repeat(8)}-${(index ? 'b' : 'c').repeat(4)}-${(index ? 'b' : 'c').repeat(4)}-${(index ? 'b' : 'c').repeat(4)}-${(index ? 'b' : 'c').repeat(12)}`,
+ version: 4,
+ gfsUri: `gfs://main/${(index ? 'b' : 'c').repeat(32)}`,
+ sizeBytes: 2048,
+ mimeType: `image/${format}`,
+ fixtureImagePath: `${run.runRoot}/qa-${binding.provider}-${index}.${format}`,
+ imageSha256: (index ? 'b' : 'c').repeat(64),
+ width: 512,
+ height: 512,
+ })),
+ },
+ ])
+ ),
+ }
+}
+function admissionReceipt() {
+ return {
+ ...receipt(),
+ suite: 'admission-recovery',
+ fixtures: Object.fromEntries(
+ run.bindings.map(binding => [
+ binding.provider,
+ {
+ hostRef: binding.hostRef,
+ podUid: '12345678-1234-4234-8234-123456789abc',
+ imageId: `sha256:${digest}`,
+ controlApiPodUid: 'abcdefab-1234-4234-8234-123456789abc',
+ controlApiImageId: `sha256:${digest}`,
+ maxInFlight: 1,
+ readDeadlineMs: 10000,
+ // This suite tests only outer metadata admission. The physical pressure
+ // client must reject this unit-only record; it is never used to hold work.
+ pressure: { receiptFile: '/runner-admission/unit-pressure-metadata.json' },
+ fallback: {
+ provider: run.bindings.find(item => item.provider !== binding.provider)!.provider,
+ modelId: run.bindings.find(item => item.provider !== binding.provider)!.modelId,
+ },
+ },
+ ])
+ ),
+ }
+}
+
+describe('remaining subscription journeys collection and data-preparation gates', () => {
+ it('refuses each missing dedicated opt-in rather than producing skipped success', () => {
+ for (const suite of ['tool-screenshot', 'gfs-image', 'admission-recovery'] as const) {
+ expect(() => requireRemainingJourney(suite, run, {})).toThrow('requires')
+ }
+ })
+ it('rejects admission saturation in the real subscription mode', () => {
+ expect(() =>
+ requireRemainingJourney(
+ 'admission-recovery',
+ { ...run, mode: 'real' },
+ {
+ E2E_SUBSCRIPTION_ADMISSION_RECOVERY: '1',
+ E2E_SUBSCRIPTION_REMAINING_FIXTURE_RECEIPT: input.fixtureReceiptPath,
+ }
+ )
+ ).toThrow('fixture-only')
+ })
+ it.each([
+ '/private/tmp/elsewhere/screens.json',
+ '/private/tmp/unit-run/../foreign.json',
+ 'screens.json',
+ ])('refuses a fixture outside its physical run root: %s', fixtureReceiptPath => {
+ expect(() =>
+ requireRemainingJourney('tool-screenshot', run, {
+ ...env,
+ E2E_SUBSCRIPTION_REMAINING_FIXTURE_RECEIPT: fixtureReceiptPath,
+ })
+ ).toThrow('owned run root')
+ })
+ it('admits a dedicated suite without reading a receipt or running setup during collection', () => {
+ expect(requireRemainingJourney('tool-screenshot', run, env)).toEqual(input)
+ })
+ it('accepts exactly bound native-screen fixture metadata', () => {
+ const value = receipt()
+ expect(validateRemainingFixture(value, input, run, digest)).toBe(value)
+ })
+ it('refuses a different run, source, or stack', () => {
+ for (const patch of [
+ { runId: 'subscription-image-ffffffffffff' },
+ { sourceManifestSha256: 'b'.repeat(64) },
+ { profile: 'other-branch' },
+ { context: 'other-branch' },
+ ]) {
+ expect(() =>
+ validateRemainingFixture({ ...receipt(), ...patch }, input, run, digest)
+ ).toThrow('run/source/stack')
+ }
+ })
+ it('refuses a screenshot fixture for another actual Host', () => {
+ const value = receipt()
+ value.fixtures['grok-subscription']!.hostRef = 'different-host'
+ expect(() => validateRemainingFixture(value, input, run, digest)).toThrow('Host/pod/image')
+ })
+ it.each(['imageId', 'podUid'] as const)('refuses unverifiable runtime identity: %s', field => {
+ const value = receipt()
+ value.fixtures['grok-subscription']![field] = 'unknown'
+ expect(() => validateRemainingFixture(value, input, run, digest)).toThrow('Host/pod/image')
+ })
+ it.each([
+ `docker://sha256:${digest}`,
+ `containerd://sha256:${digest}`,
+ `docker-pullable://ghcr.io/evenfire/qa@sha256:${digest}`,
+ ])('preserves the actual Kubernetes image-id form: %s', imageId => {
+ const value = receipt()
+ value.fixtures['grok-subscription']!.imageId = imageId
+ expect(validateRemainingFixture(value, input, run, digest)).toBe(value)
+ })
+ it('refuses shell syntax in the prepared screen path', () => {
+ const value = receipt()
+ value.fixtures['grok-subscription']!.hostImagePath += '; command'
+ expect(() => validateRemainingFixture(value, input, run, digest)).toThrow('native pixels')
+ })
+ it('refuses geometry that cannot decode the actual challenge', () => {
+ const value = receipt()
+ value.fixtures['grok-subscription']!.region.w = 513
+ expect(() => validateRemainingFixture(value, input, run, digest)).toThrow('capture region')
+ })
+ it('rejects missing or extra provider bindings', () => {
+ const value = receipt()
+ delete value.fixtures['codex-subscription']
+ expect(() => validateRemainingFixture(value, input, run, digest)).toThrow(
+ 'exact fixture binding'
+ )
+ const extra = receipt()
+ extra.fixtures['other-provider'] = extra.fixtures['grok-subscription']!
+ expect(() => validateRemainingFixture(extra, input, run, digest)).toThrow(
+ 'exact fixture binding'
+ )
+ })
+ it('accepts independently named and version-pinned GFS fixture files', () => {
+ const value = gfsReceipt()
+ expect(validateRemainingFixture(value, { ...input, suite: 'gfs-image' }, run, digest)).toBe(
+ value
+ )
+ })
+ it('refuses a GFS URI for a different source', () => {
+ const value = gfsReceipt()
+ value.fixtures['grok-subscription']!.files[0]!.gfsUri = `gfs://main/${'d'.repeat(32)}`
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'gfs-image' }, run, digest)
+ ).toThrow('source identity')
+ })
+ it('refuses a picker UUID that refers to another compact model/tool rid', () => {
+ const value = gfsReceipt()
+ value.fixtures['grok-subscription']!.files[0]!.pickerResourceId =
+ '12345678-1234-4234-8234-123456789abc'
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'gfs-image' }, run, digest)
+ ).toThrow('source identity')
+ })
+ it.each(['resourceId', 'name', 'imageSha256'] as const)(
+ 'refuses repeated GFS identities or pixel content: %s',
+ field => {
+ const value = gfsReceipt()
+ value.fixtures['grok-subscription']!.files[1]![field] =
+ value.fixtures['grok-subscription']!.files[0]![field]
+ if (field === 'resourceId') {
+ value.fixtures['grok-subscription']!.files[1]!.gfsUri =
+ value.fixtures['grok-subscription']!.files[0]!.gfsUri
+ value.fixtures['grok-subscription']!.files[1]!.pickerResourceId =
+ value.fixtures['grok-subscription']!.files[0]!.pickerResourceId
+ }
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'gfs-image' }, run, digest)
+ ).toThrow('independent')
+ }
+ )
+ it('refuses an image that would exceed the actual GFS inline byte budget', () => {
+ const value = gfsReceipt()
+ value.fixtures['grok-subscription']!.files[0]!.sizeBytes = 3 * 1024 * 1024 + 1
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'gfs-image' }, run, digest)
+ ).toThrow('within-budget')
+ })
+ it('refuses an invalid pinned version or a non-visible folder path', () => {
+ const value = gfsReceipt()
+ value.fixtures['grok-subscription']!.files[0]!.version = -1
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'gfs-image' }, run, digest)
+ ).toThrow('source identity')
+ const path = gfsReceipt()
+ path.fixtures['grok-subscription']!.folderNames = ['folder/escape']
+ expect(() =>
+ validateRemainingFixture(path, { ...input, suite: 'gfs-image' }, run, digest)
+ ).toThrow('visible folder path')
+ })
+ it('requires an eligible fallback, so no-failover cannot pass with no alternate target', () => {
+ const value = admissionReceipt()
+ value.fixtures['grok-subscription']!.fallback.modelId = run.bindings[0]!.modelId
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'admission-recovery' }, run, digest)
+ ).toThrow('eligible physical fallback')
+ })
+ it('rejects pressure metadata with no actual control-api pod identity', () => {
+ const value = admissionReceipt()
+ value.fixtures['grok-subscription']!.controlApiPodUid = 'unknown'
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'admission-recovery' }, run, digest)
+ ).toThrow('owned capacity')
+ })
+ it('rejects pressure without sealed private relay metadata', () => {
+ const value = admissionReceipt()
+ ;(value.fixtures['grok-subscription'] as unknown as { pressure?: unknown }).pressure = undefined
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'admission-recovery' }, run, digest)
+ ).toThrow('private relay metadata')
+ })
+ it.each([0, -1, 1.5])('rejects an invalid physical owner count: %s', count => {
+ const value = admissionReceipt()
+ value.fixtures['grok-subscription']!.maxInFlight = count
+ expect(() =>
+ validateRemainingFixture(value, { ...input, suite: 'admission-recovery' }, run, digest)
+ ).toThrow('owned capacity')
+ })
+})