Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(media): preserve supplied and requested reference provenance
[._.]/ Adam Eivyfed33d6a7fc7
diff --git a/server/services/federatedMedia/remoteExecutor.js b/server/services/federatedMedia/remoteExecutor.jsindex 034c944721..d880e61210 100644--- a/server/services/federatedMedia/remoteExecutor.js+++ b/server/services/federatedMedia/remoteExecutor.js@@ -492,6 +492,8 @@ export function createRemoteMediaExecutor({peerId: state.peerId,request,remoteJob: completed,+ // Local-only evidence for the consumer sidecar; never part of the wire request.+ inputAssets: marker.inputAssets,// Wall-clock render timing (#5878). Measured from THIS install's// ingestion of the job — submission, the peer's own queue wait and// render, download, verification — because that whole span is what thediff --git a/server/services/imageGen/agy.js b/server/services/imageGen/agy.jsindex c19a2db36f..44a2c78c91 100644--- a/server/services/imageGen/agy.js+++ b/server/services/imageGen/agy.js@@ -16,7 +16,7 @@ import { maintenance } from '../../lib/maintenanceAdmission.js';import { spawn } from '../../lib/childProcess.js';import { mkdir, open, stat } from 'fs/promises';import { randomUUID } from 'crypto';-import { isAbsolute, join, resolve as pathResolve, sep } from 'path';+import { basename, isAbsolute, join, resolve as pathResolve, sep } from 'path';import { tmpdir } from 'os';import sharp from 'sharp';import {@@ -341,6 +341,9 @@ export async function generateImage({// renders on Antigravity's fixed server-side backend — record it so// provenance names the model that actually produced the pixels (#3231).imageModel: AGY_IMAGEGEN_IMAGE_MODEL,+ inputProvenance: 'provider-inputs',+ initImageFilename: inputImages.initPath ? basename(inputImages.initPath) : null,+ referenceImageFilenames: inputImages.referencePaths.map(path => basename(path)),...(visualConditioning ? { visualConditioning } : {}),...sentRecord,createdAt: new Date().toISOString(),diff --git a/server/services/imageGen/agy.test.js b/server/services/imageGen/agy.test.jsindex 5c14631536..c46dbedc9d 100644--- a/server/services/imageGen/agy.test.js+++ b/server/services/imageGen/agy.test.js@@ -286,7 +286,12 @@ describe('agy image provider', () => {it('imports only a signature-verified directed PNG into the gallery', async () => {const completed = vi.fn();imageGenEvents.on('completed', completed);- const job = await agy.generateImage({ prompt: 'a fox' });+ await mkdir(FAKE_IMAGES_DIR, { recursive: true });+ for (const name of ['source.png', 'ref-a.png', 'ref-b.png', 'overflow.png']) await writeFile(join(FAKE_IMAGES_DIR, name), 'fake');+ const job = await agy.generateImage({+ prompt: 'a fox', initImagePath: join(FAKE_IMAGES_DIR, 'source.png'),+ referenceImagePaths: ['missing.png', 'ref-a.png', 'ref-b.png', 'overflow.png'],+ });const png = Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),Buffer.from('fakepngbody'),@@ -310,6 +315,9 @@ describe('agy image provider', () => {// Provenance records the FIXED server-side image model, distinct from the// agent/session model that drove the CLI (#3231).expect(sidecar.imageModel).toBe('imagen-3.0-generate-002');+ expect(sidecar.initImageFilename).toBe('source.png');+ expect(sidecar.inputProvenance).toBe('provider-inputs');+ expect(sidecar.referenceImageFilenames).toEqual(['ref-a.png', 'ref-b.png']);});// agy is a coding agent: when generate_image is quota-exhausted it can stilldiff --git a/server/services/imageGen/fal.js b/server/services/imageGen/fal.jsindex 6f01078b7e..2c59a07e23 100644--- a/server/services/imageGen/fal.js+++ b/server/services/imageGen/fal.js@@ -30,7 +30,7 @@ import { withBackupAssetPublication } from '../../lib/backupSnapshotBoundary.js'import { randomUUID } from 'crypto';import { readFile } from 'fs/promises';-import { join } from 'path';+import { basename, join } from 'path';import sharp from 'sharp';import { atomicWrite, detectImageFormat, ensureDir, PATHS, unlinkGuarded } from '../../lib/fileUtils.js';import { ServerError } from '../../lib/errorHandler.js';@@ -275,6 +275,9 @@ export async function generateImage({// user chose — a gallery reader should not have to re-derive either.model: endpointId,modelFamily: family.id,+ inputProvenance: 'provider-inputs',+ initImageFilename: inputImages.initPath ? basename(inputImages.initPath) : null,+ referenceImageFilenames: inputImages.referencePaths.map(path => basename(path)),...(inputImages.paths.length ? { inputImageCount: inputImages.paths.length } : {}),...(visualConditioning ? { visualConditioning } : {}),...sentRecord,diff --git a/server/services/imageGen/fal.test.js b/server/services/imageGen/fal.test.jsindex bd239bc918..4583cbf23e 100644--- a/server/services/imageGen/fal.test.js+++ b/server/services/imageGen/fal.test.js@@ -162,7 +162,9 @@ describe('imageGen/fal — generateImage', () => {expect(body.prompt).toContain('visual references for style, characters, and subject matter');expect(body).not.toHaveProperty('num_images');const sidecar = JSON.parse(await readFile(join(FAKE_IMAGES_DIR, `${job.jobId}.metadata.json`), 'utf8'));- expect(sidecar).toMatchObject({ model: 'fal-ai/flux-2-pro/edit', inputImageCount: 9 });+ expect(sidecar.inputProvenance).toBe('provider-inputs');+ expect(sidecar).toMatchObject({ model: 'fal-ai/flux-2-pro/edit', inputImageCount: 9,+ initImageFilename: null, referenceImageFilenames: refs.slice(0, 9) });});it('defaults to Nano Banana Pro and switches to its /edit endpoint when an init image is attached', async () => {diff --git a/server/services/imageGen/grok.js b/server/services/imageGen/grok.jsindex 6bebcc5814..b75f2973c8 100644--- a/server/services/imageGen/grok.js+++ b/server/services/imageGen/grok.js@@ -33,7 +33,7 @@ import { maintenance } from '../../lib/maintenanceAdmission.js';import { spawn } from '../../lib/childProcess.js';import { mkdir, open, stat } from 'fs/promises';-import { isAbsolute, join, resolve as pathResolve, sep } from 'path';+import { basename, isAbsolute, join, resolve as pathResolve, sep } from 'path';import { tmpdir } from 'os';import { randomUUID } from 'crypto';import { atomicWrite, copyFileGuarded, detectImageFormat, ensureDir, PATHS, rmGuarded, sleep, unlinkGuarded } from '../../lib/fileUtils.js';@@ -291,6 +291,9 @@ export async function generateImage({id: jobId, prompt: prompt.trim(), negativePrompt: negativePrompt || '',width: width ? Number(width) : null, height: height ? Number(height) : null,filename, mode: IMAGE_GEN_MODE.GROK,+ inputProvenance: 'provider-inputs',+ initImageFilename: inputImages.initPath ? basename(inputImages.initPath) : null,+ referenceImageFilenames: inputImages.referencePaths.map(path => basename(path)),...(visualConditioning ? { visualConditioning } : {}),...sentRecord,...(effectiveRatio ? { aspectRatio: effectiveRatio } : {}),diff --git a/server/services/imageGen/grok.test.js b/server/services/imageGen/grok.test.jsindex e9ce67738e..0d3c42a67f 100644--- a/server/services/imageGen/grok.test.js+++ b/server/services/imageGen/grok.test.js@@ -295,7 +295,12 @@ describe('grok provider — directed-path harvest', () => {const completedListener = vi.fn();imageGenEvents.on('completed', completedListener);- const job = await grok.generateImage({ prompt: 'a fox' });+ await mkdir(FAKE_IMAGES_DIR, { recursive: true });+ for (const name of ['source.png', 'ref-a.png', 'ref-b.png', 'overflow.png']) await writeFile(join(FAKE_IMAGES_DIR, name), 'fake');+ const job = await grok.generateImage({+ prompt: 'a fox', initImagePath: join(FAKE_IMAGES_DIR, 'source.png'),+ referenceImagePaths: ['missing.png', 'ref-a.png', 'ref-b.png'],+ });// Grok "writes" the directed staging file before the child exits. The// harvest signature-sniffs the bytes, so the fixture needs a real PNG// magic header.@@ -333,6 +338,9 @@ describe('grok provider — directed-path harvest', () => {// timing flake.const meta = JSON.parse(await readFile(sidecar, 'utf8'));expect(meta.renderMs).toBeGreaterThanOrEqual(0);+ expect(meta.initImageFilename).toBe('source.png');+ expect(meta.inputProvenance).toBe('provider-inputs');+ expect(meta.referenceImageFilenames).toEqual(['ref-a.png', 'ref-b.png']);expect(Date.parse(meta.renderStartedAt)).toBeLessThanOrEqual(Date.parse(meta.renderCompletedAt));expect(Date.parse(meta.renderCompletedAt) - Date.parse(meta.renderStartedAt)).toBe(meta.renderMs);});diff --git a/server/services/imageGen/local.js b/server/services/imageGen/local.jsindex f29d9d273a..e168303cc3 100644--- a/server/services/imageGen/local.js+++ b/server/services/imageGen/local.js@@ -40,7 +40,6 @@ import { safeChildProcessOptions } from '../../lib/processEnv.js';import { IMAGE_GEN_MODE, LOCAL_IMAGEGEN_DEFAULT_MODEL } from './modes.js';import { parseByteProgress, formatDownloadMessage, bufferChildExit } from '../videoGen/generateVideoHelpers.js';-const IS_WIN = process.platform === 'win32';import { getImageModels, isFlux2, isErnie, isHiDream, isQwen } from '../../lib/mediaModels.js';import { hardwareUnavailableReason, isHardwareCompatible } from '../../lib/systemCapabilities.js';@@ -90,7 +89,7 @@ export const cancel = () => {return true;};-export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, height, steps, guidance, seed, quantize, outputPath, loraPaths = [], loraScales = [], stepwiseDir, initImagePath, initImageStrength, referenceImagePaths = [], referenceImageStrengths = [] }) => {+export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, height, steps, guidance, seed, quantize, outputPath, loraPaths = [], loraScales = [], stepwiseDir, initImagePath, initImageStrength, referenceImagePaths = [], referenceImageStrengths = [], platform = process.platform }) => {const modelId = model?.id;if (usesDiffusersRunner(model)) {const runnerLabel = isErnie(model) ? 'ERNIE' : isHiDream(model) ? 'HiDream' : isQwen(model) ? 'Qwen' : 'Z-Image';@@ -151,7 +150,10 @@ export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, heif (model.textEncoderRepo) args.push('--text-encoder-repo', String(model.textEncoderRepo));if (model.textEncoderClass) args.push('--text-encoder-class', String(model.textEncoderClass));if (model.tokenizerClass) args.push('--tokenizer-class', String(model.tokenizerClass));- return { bin: torchPython, args };+ return { bin: torchPython, args, providerInputs: {+ initImagePath: initImagePath || null,+ referenceImagePaths: model.pipelineClass === 'QwenImage21Pipeline' ? referenceImagePaths : [],+ } };}if (isFlux2(model)) {if (!model.repo) {@@ -265,16 +267,17 @@ export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, heif (stepwiseDir) args.push('--stepwise-image-output-dir', stepwiseDir);if (loraPaths?.length) args.push('--lora-paths', ...loraPaths);if (loraScales?.length) args.push('--lora-scales', ...loraScales.map(String));- return { bin: flux2Python, args };+ return { bin: flux2Python, args, providerInputs: { initImagePath: initImagePath || null, referenceImagePaths: refImagePaths } };}- if (IS_WIN) {+ if (platform === 'win32') {// imagine_win.py does not implement i2i — silently drop the init-image// args here so the request still produces a normal txt2img result rather// than failing argparse with "unrecognized arguments".const scriptPath = join(PATHS.root, 'scripts', 'imagine_win.py');return {bin: pythonPath,+ providerInputs: { initImagePath: null, referenceImagePaths: [] },args: [scriptPath, '--model', modelId, '--prompt', prompt, '--height', String(height), '--width', String(width), '--steps', String(steps), '--seed', String(seed), '--quantize', String(quantize), '--output', outputPath, '--metadata',...(guidance > 0 ? ['--guidance', String(guidance)] : []),...(negativePrompt ? ['--negative-prompt', negativePrompt] : []),@@ -295,7 +298,7 @@ export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, he// stream the latest frame back to the client as `currentImage` for the// live-preview area.if (stepwiseDir) args.push('--stepwise-image-output-dir', stepwiseDir);- return { bin, args };+ return { bin, args, providerInputs: { initImagePath: initImagePath || null, referenceImagePaths: [] } };};// Clamp 0..1 with a finite-fallback — Math.max/min preserve NaN, so a@@ -738,7 +741,7 @@ export async function generateImage({ pythonPath, prompt = '', negativePrompt =maintenance.markCurrentUnsettled();console.error(`❌ Image generation scratch cleanup [${jobId.slice(0, 8)}]: ${err.message}`);});- let bin, args;+ let bin, args, providerInputs;let proc;let claimHandedOff = false;let takeEarlyExit = null;@@ -746,7 +749,34 @@ export async function generateImage({ pythonPath, prompt = '', negativePrompt =try {// `renderPrompt` — the user's prompt plus any LoRA activation tokens it was// missing (#4665). Identical to `prompt` when nothing was woven.- ({ bin, args } = buildArgs({ pythonPath, model, prompt: renderPrompt, negativePrompt, width: Number(width), height: Number(height), steps: actualSteps, guidance: actualGuidance, seed: actualSeed, quantize, outputPath, loraPaths: validLoras, loraScales, stepwiseDir, initImagePath: validInitImagePath, initImageStrength: validInitImageStrength, referenceImagePaths: validReferenceImagePaths, referenceImageStrengths: validReferenceImageStrengths }));+ ({ bin, args, providerInputs } = buildArgs({ pythonPath, model, prompt: renderPrompt, negativePrompt, width: Number(width), height: Number(height), steps: actualSteps, guidance: actualGuidance, seed: actualSeed, quantize, outputPath, loraPaths: validLoras, loraScales, stepwiseDir, initImagePath: validInitImagePath, initImageStrength: validInitImageStrength, referenceImagePaths: validReferenceImagePaths, referenceImageStrengths: validReferenceImageStrengths }));+ // Record only inputs the selected runner actually receives. Unsupported+ // references and Windows mflux init images remain explicit request evidence.+ const requestedInputs = [+ ...(meta.initImageFilename ? [{ role: 'initImage', filename: meta.initImageFilename }] : []),+ ...meta.referenceImageFilenames.map(filename => ({ role: 'referenceImages', filename })),+ ];+ const omittedInputs = [+ ...(validInitImagePath && !providerInputs.initImagePath ? [{ role: 'initImage', filename: meta.initImageFilename }] : []),+ ...validReferenceImagePaths.filter(path => !providerInputs.referenceImagePaths.includes(path))+ .map(path => ({ role: 'referenceImages', filename: basename(path) })),+ ];+ if (omittedInputs.length) {+ meta.requestedInputImages = requestedInputs;+ meta.omittedInputImages = omittedInputs.map(input => ({ ...input, reason: 'unsupported-render-path' }));+ }+ meta.inputProvenance = 'provider-inputs';+ meta.referenceImageFilenames = providerInputs.referenceImagePaths.map(path => basename(path));+ meta.referenceImageStrengths = validReferenceImageStrengths.filter((_, index) => providerInputs.referenceImagePaths.includes(validReferenceImagePaths[index]));+ if (!providerInputs.initImagePath) {+ meta.initImageFilename = null;+ meta.initImageStrength = null;+ for (const key of ['cleanedFrom', 'regenerated', 'regenMethod', 'regenStrength', 'regenSteps', 'regenModelId']) {+ delete meta[key];+ delete job[key];+ }+ }+ Object.assign(job, meta);heavyClaim = await claimHeavyLocalJob({ kind: 'local image generation', id: jobId });if (!heavyClaim.ok) {throw new ServerError(heavyClaim.message, { status: 409, code: 'HEAVY_LOCAL_JOB_BUSY', context: { holder: heavyClaim.holder } });@@ -767,7 +797,7 @@ export async function generateImage({ pythonPath, prompt = '', negativePrompt =throw new ServerError('Canceled before the render started', { status: 409, code: 'IMAGE_GEN_CANCELED' });}- console.log(`🎨 Generating image [${jobId.slice(0, 8)}] local: ${modelId} ${width}x${height} steps=${actualSteps} references=${validReferenceImagePaths.length}`);+ console.log(`🎨 Generating image [${jobId.slice(0, 8)}] local: ${modelId} ${width}x${height} steps=${actualSteps} references=${meta.referenceImageFilenames.length}`);imageGenEvents.emit('started', { generationId: jobId, totalSteps: actualSteps });startedEmitted = true;activeJob = { ...meta, generationId: jobId, totalSteps: actualSteps, step: 0, progress: 0, currentImage: null, mode: IMAGE_GEN_MODE.LOCAL };diff --git a/server/services/imageGen/local.test.js b/server/services/imageGen/local.test.jsindex cd3c4ba483..278cf6be30 100644--- a/server/services/imageGen/local.test.js+++ b/server/services/imageGen/local.test.js@@ -480,6 +480,16 @@ describe('imageGen local.buildArgs flux2 dispatch', () => {expect(args[args.indexOf('--image-strength') + 1]).toBe('0.25');});+ it('reports no supplied images for the Windows runner that omits image arguments', () => {+ const { args, providerInputs } = buildArgs({ ...baseInput, platform: 'win32',+ model: { id: 'dev', steps: 20, guidance: 3.5 },+ initImagePath: '/example/source.png', referenceImagePaths: ['/example/ref.png'],+ });+ expect(args).not.toContain('--image-path');+ expect(args).not.toContain('--reference-images');+ expect(providerInputs).toEqual({ initImagePath: null, referenceImagePaths: [] });+ });+it.skipIf(process.platform === 'win32')('falls back to mflux dispatch for non-flux2 models on macOS', () => {// No flux2 mock needed — the branch shouldn't be taken at all.mockResolveFlux2Python.mockReturnValue(null);@@ -1305,6 +1315,37 @@ describe('local render terminal dispatch — SSE/lifecycle decoupling (#8915)',});+it('persists omitted reference evidence when the LoRA runner drops inputs', async () => {+ mockResolveFlux2Python.mockReturnValue('/fake/venv-flux2/bin/python3');+ mockIsFlux2VenvHealthy.mockResolvedValue(true);+ const child = new EventEmitter();+ child.stdout = new EventEmitter();+ child.stderr = new EventEmitter();+ mockSpawn.mockReturnValue(child);+ const priorLoras = PATHS.loras;+ PATHS.loras = join(tmpRegistryDir, 'loras');+ mkdirSync(PATHS.loras, { recursive: true });+ writeFileSync(join(PATHS.loras, 'example.safetensors'), 'example');+ writeFileSync(join(PATHS.images, 'reference.png'), 'example');+ const { imageGenEvents } = await import('../imageGenEvents.js');+ try {+ const job = await generateImage({ modelId: 'flux2-klein-9b', prompt: '--reference-images',+ loraFilenames: ['example.safetensors'], referenceImagePaths: ['reference.png'] });+ expect(mockSpawn.mock.calls.at(-1)[1]).toContain('--reference-images');+ expect(mockSpawn.mock.calls.at(-1)[1]).not.toContain(join(PATHS.images, 'reference.png'));+ writeFileSync(join(PATHS.images, job.filename), 'synthetic output');+ const completed = new Promise(resolve => imageGenEvents.once('completed', resolve));+ child.emit('close', 0);+ await completed;+ const meta = JSON.parse(readFileSync(join(PATHS.images, `${job.jobId}.metadata.json`), 'utf8'));+ expect(meta.inputProvenance).toBe('provider-inputs');+ expect(meta.referenceImageFilenames).toEqual([]);+ expect(meta.referenceImageStrengths).toEqual([]);+ expect(meta.requestedInputImages).toEqual([{ role: 'referenceImages', filename: 'reference.png' }]);+ expect(meta.omittedInputImages).toEqual([{ role: 'referenceImages', filename: 'reference.png', reason: 'unsupported-render-path' }]);+ } finally { PATHS.loras = priorLoras; }+});+it('drains a snapshot through local upscale and the sidecar naming the delivered dimensions', async () => {mockResolveFlux2Python.mockReturnValue('/fake/venv-flux2/bin/python3');mockIsFlux2VenvHealthy.mockResolvedValue(true);diff --git a/server/services/imageGen/remote.js b/server/services/imageGen/remote.jsindex 474a2c7dad..8f4b0d4da1 100644--- a/server/services/imageGen/remote.js+++ b/server/services/imageGen/remote.js@@ -14,7 +14,7 @@ import { publishImageFiles } from './publication.js';* sidecar would land on disk and never appear in the gallery.*/-import { join } from 'node:path';+import { basename, join } from 'node:path';import { z } from 'zod';import { PATHS, atomicWrite } from '../../lib/fileUtils.js';import { renderTimingFields } from '../../lib/renderTiming.js';@@ -69,7 +69,7 @@ const executor = createRemoteMediaExecutor({// gallery, the media index, and the provider-side result guard all agree.resolveDestination: ({ jobId }) => ({ dir: PATHS.images, filename: `${jobId}.png` }),publishResult: (work, { path, dir, jobId }) => withBackupAssetPublication(() => publishImageFiles([path, join(dir, `${jobId}.metadata.json`)], work)),- async finalize({ jobId, dir, filename, request, remoteJob, peerId, renderStartedAtMs }) {+ async finalize({ jobId, dir, filename, request, remoteJob, peerId, renderStartedAtMs, inputAssets }) {// Honest sidecar: only fields this render actually had. Seed is the// requested one (wire-v1 results carry no rendered seed), so a render that// did not pin one records null rather than inventing a number the peer@@ -92,6 +92,10 @@ const executor = createRemoteMediaExecutor({steps: request.steps ?? null,guidance: request.guidance ?? null,filename,+ ...(Array.isArray(inputAssets) ? {+ // The wire confirms submission, not which inputs the provider applied.+ requestedInputImages: inputAssets.map(asset => ({ role: asset.role, filename: basename(asset.path) })),+ } : {}),federatedPeerId: peerId,federatedJobId: remoteJob.id,createdAt,diff --git a/server/services/imageGen/remote.test.js b/server/services/imageGen/remote.test.jsindex d281290bd3..04785c4ab9 100644--- a/server/services/imageGen/remote.test.js+++ b/server/services/imageGen/remote.test.js@@ -145,7 +145,7 @@ afterEach(() => {describe('federated image consumer adapter', () => {it('imports a verified PNG and writes the gallery sidecar the local renderer would have', async () => {- const png = Buffer.from('\x89PNG-example-bytes');+ const png = Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), Buffer.from('example-bytes')]);const digest = sha256(png);const metadata = {available: true,@@ -158,6 +158,11 @@ describe('federated image consumer adapter', () => {durationSec: null,};transport.fetch.mockImplementation(async (url, options) => {+ if (url.includes('/assets/')) return jsonResponse({ code: 'MEDIA_PROVIDER_ASSET_NOT_FOUND' }, 404);+ if (url.endsWith('/assets') && options.method === 'POST') return jsonResponse({+ wireVersion: 1, assetId: federatedMediaAssetId('consumer-instance', digest), sha256: digest,+ sizeBytes: png.length, mimeType: 'image/png', expiresAt: '2099-08-22T18:00:00.000Z',+ }, 201);if (url.endsWith('/jobs') && options.method === 'POST') return jsonResponse(providerJob('queued'), 202);if (url.endsWith(`/jobs/${REMOTE_JOB_ID}`)) return jsonResponse(providerJob('completed', { result: metadata }));if (url.endsWith(`/jobs/${REMOTE_JOB_ID}/result`)) {@@ -173,7 +178,12 @@ describe('federated image consumer adapter', () => {});const terminal = captureTerminal(LOCAL_JOB_ID);- await generateImage(params());+ const base = params();+ writeFileSync(join(tempImageDir, 'reference.png'), png);+ await generateImage({ ...base, remoteMedia: { ...base.remoteMedia, inputAssets: [+ { role: 'initImage', path: join(tempImageDir, 'reference.png') },+ { role: 'referenceImages', path: join(tempImageDir, 'reference.png') },+ ] } });const outcome = await terminal;expect(outcome).toMatchObject({@@ -202,6 +212,10 @@ describe('federated image consumer adapter', () => {filename: `${LOCAL_JOB_ID}.png`,federatedPeerId: PEER_ID,federatedJobId: REMOTE_JOB_ID,+ requestedInputImages: [+ { role: 'initImage', filename: 'reference.png' },+ { role: 'referenceImages', filename: 'reference.png' },+ ],});// Render timing (#5878) — for a federated render the span this install can// honestly report is its OWN: submission, the peer's queue wait and render,@@ -221,7 +235,10 @@ describe('federated image consumer adapter', () => {width: 512,height: 512,seed: 42,+ initImage: { assetId: federatedMediaAssetId('consumer-instance', digest) },+ referenceImages: [{ assetId: federatedMediaAssetId('consumer-instance', digest) }],});+ expect(submission[1].body).not.toContain(tempImageDir);expect(submission[1].headers['Idempotency-Key']).toBe(LOCAL_JOB_ID);});diff --git a/server/services/mediaJobQueue/sanitizeJob.js b/server/services/mediaJobQueue/sanitizeJob.jsindex d1ba2d1a7d..edf54f75e3 100644--- a/server/services/mediaJobQueue/sanitizeJob.js+++ b/server/services/mediaJobQueue/sanitizeJob.js@@ -50,6 +50,23 @@ const executionProvenance = (value) => {};};+// A history row must retain usable reference evidence without exposing worker paths.+// Missing old inputs mean unknown provenance, not a confirmed text-only render.+const referenceInputs = (params, routed) => {+ const inputs = routed+ ? (Array.isArray(params?.remoteMedia?.inputAssets) ? params.remoteMedia.inputAssets : [])+ : [+ ...(params?.initImagePath ? [{ role: 'initImage', path: params.initImagePath }] : []),+ ...(Array.isArray(params?.referenceImagePaths) ? params.referenceImagePaths.map(path => ({ role: 'referenceImages', path })) : []),+ ];+ return inputs.flatMap(input => {+ if (!['initImage', 'referenceImages'].includes(input?.role) || typeof input?.path !== 'string') return [];+ const filename = input.path.split(/[\\/]/).pop();+ if (!filename || !/^[^\x00-\x1f?#]+\.(?:png|jpe?g|webp|gif)$/i.test(filename)) return [];+ return [{ role: input.role, filename }];+ });+};+export function sanitizeJob(job) {if (!job) return job;if (job.durabilityPending) {@@ -89,7 +106,9 @@ export function sanitizeJob(job) {if (remotePrompt) safeParams.prompt = remotePrompt;if (typeof remoteModelId === 'string' && remoteModelId) safeParams.modelId = remoteModelId;}+ const requestedInputImages = job.kind === 'image' ? referenceInputs(job.params, routed) : [];return {+ ...(requestedInputImages.length ? { requestedInputImages } : {}),id: job.id,kind: job.kind,// Where this job renders. Job metadata, not a render input, so it rides ondiff --git a/server/services/mediaJobQueue/sanitizeJob.test.js b/server/services/mediaJobQueue/sanitizeJob.test.jsindex 8bf645364e..56143ee5db 100644--- a/server/services/mediaJobQueue/sanitizeJob.test.js+++ b/server/services/mediaJobQueue/sanitizeJob.test.js@@ -2,6 +2,27 @@ import { describe, expect, it } from 'vitest';import { sanitizeJob } from './sanitizeJob.js';describe('sanitizeJob', () => {+ it('exposes requested reference filenames without leaking local paths or inferring missing history', () => {+ const params = { initImagePath: '/private/gallery/source.png', referenceImagePaths: [+ 'C:\\private\\refs\\character.png', '/private/refs/character.png', null, '/private/secret.txt',+ ] };+ const local = sanitizeJob({ kind: 'image', params });+ expect(local.requestedInputImages).toEqual([+ { role: 'initImage', filename: 'source.png' },+ { role: 'referenceImages', filename: 'character.png' },+ { role: 'referenceImages', filename: 'character.png' },+ ]);+ expect(local.params).not.toHaveProperty('initImagePath');+ expect(local.params).not.toHaveProperty('referenceImagePaths');+ expect(sanitizeJob({ kind: 'image', params: {} })).not.toHaveProperty('requestedInputImages');+ const remote = sanitizeJob({ kind: 'image', params: { remoteMedia: {+ wireVersion: 1, peerId: 'example-peer', request: { kind: 'image' },+ inputAssets: [{ role: 'referenceImages', path: '/private/gallery/reference.webp' }],+ } } });+ expect(remote.requestedInputImages).toEqual([{ role: 'referenceImages', filename: 'reference.webp' }]);+ expect(JSON.stringify(remote)).not.toContain('/private');+ });+it('projects cancellation only while the job is still active', () => {const projectCancellation = (status) => sanitizeJob({id: 'job-cancel-example',