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
withhold a federated render's duration on a post-restart reconcile
[._.]/ Adam Eivy7ba362da2b8d
diff --git a/server/services/federatedMedia/remoteExecutor.js b/server/services/federatedMedia/remoteExecutor.jsindex baa2fcc2db..519a269309 100644--- a/server/services/federatedMedia/remoteExecutor.js+++ b/server/services/federatedMedia/remoteExecutor.js@@ -516,8 +516,16 @@ export function createRemoteMediaExecutor({requestController: null,wake: null,// The instant the media-job queue handed this job to us; `finalize` turns- // it into the record's render-timing fields.- renderStartedAtMs: Date.now(),+ // it into the record's render-timing fields (#5878).+ //+ // NOT stamped on a reconcile. That path re-enters `run()` after a restart+ // for a job that was already submitted — `Date.now()` here would measure+ // only the post-restart download-and-verify tail, so a 20-minute render+ // interrupted by a `pm2 restart` would land claiming it took 8 seconds.+ // The pre-restart instant is not recoverable (it lived in this in-memory+ // state, not on the persisted marker), so report the honest unknown:+ // `renderTimingFields(null)` yields `{}` and the card shows no duration.+ renderStartedAtMs: marker.data.reconcile === true ? null : Date.now(),};activeJobs.set(params.jobId, state);try {diff --git a/server/services/imageGen/remote.test.js b/server/services/imageGen/remote.test.jsindex 9bedf5069e..ae88c1be49 100644--- a/server/services/imageGen/remote.test.js+++ b/server/services/imageGen/remote.test.js@@ -200,6 +200,13 @@ describe('federated image consumer adapter', () => {federatedPeerId: PEER_ID,federatedJobId: REMOTE_JOB_ID,});+ // 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,+ // download, verification. The peer's internal render time never crosses the+ // wire (a status payload would breach the privacy boundary), so this is the+ // measurement, not a stand-in for one.+ expect(sidecar.renderMs).toBeGreaterThanOrEqual(0);+ expect(Date.parse(sidecar.renderCompletedAt) - Date.parse(sidecar.renderStartedAt)).toBe(sidecar.renderMs);const submission = transport.fetch.mock.calls.find(([url, options]) => url.endsWith('/jobs') && options.method === 'POST');@@ -449,3 +456,56 @@ describe('standing-route tailnet boundary survives the enqueue', () => {expect(outcome.event.error).toMatch(/no longer a Tailscale host/i);});});++// #5878. A reconcile re-enters the executor after a restart for a job the peer+// was ALREADY rendering, so the in-memory instant this install would stamp now+// covers only the download-and-verify tail. Reporting that as the render time+// would tell the user a 20-minute federated render took a few seconds — worse+// than saying nothing, which is what the absent-`renderMs` sentinel means.+describe('a reconciled federated render reports no duration rather than a wrong one', () => {+ it('omits every timing field when the marker is a post-restart reconcile', async () => {+ const png = Buffer.from('\x89PNG-reconciled');+ const digest = sha256(png);+ transport.fetch.mockImplementation(async (url, options) => {+ if (url.endsWith('/jobs') && options.method === 'POST') return jsonResponse(providerJob('queued'), 202);+ if (url.endsWith(`/jobs/${REMOTE_JOB_ID}`)) {+ return jsonResponse(providerJob('completed', {+ result: {+ available: true,+ mimeType: 'image/png',+ sizeBytes: png.length,+ sha256: digest,+ downloadUrl: `/api/federation/media/v1/jobs/${REMOTE_JOB_ID}/result`,+ engine: 'local',+ modelId: 'dev',+ durationSec: null,+ },+ }));+ }+ if (url.endsWith(`/jobs/${REMOTE_JOB_ID}/result`)) {+ return new Response(png, {+ headers: {+ 'Content-Length': String(png.length),+ 'Content-Type': 'image/png',+ 'X-Content-SHA256': digest,+ },+ });+ }+ throw new Error(`Unexpected test URL: ${url}`);+ });++ const base = params();+ const terminal = captureTerminal(LOCAL_JOB_ID);+ await generateImage({ ...base, remoteMedia: { ...base.remoteMedia, reconcile: true } });+ expect((await terminal).type).toBe('completed');++ const sidecar = JSON.parse(readFileSync(join(tempImageDir, `${LOCAL_JOB_ID}.metadata.json`), 'utf8'));+ // Absent, not zero — `videoGen/eta.js` and the gallery card both read+ // absence as "unknown", while a 0 would read as an instant render.+ expect('renderMs' in sidecar).toBe(false);+ expect('renderStartedAt' in sidecar).toBe(false);+ expect('renderCompletedAt' in sidecar).toBe(false);+ // The record still lands — only the duration is withheld.+ expect(sidecar.federatedJobId).toBe(REMOTE_JOB_ID);+ });+});diff --git a/server/services/videoGen/upscaleVideo.js b/server/services/videoGen/upscaleVideo.jsindex 4e5c9e7ccb..d1033f9fd2 100644--- a/server/services/videoGen/upscaleVideo.js+++ b/server/services/videoGen/upscaleVideo.js@@ -8,7 +8,7 @@ import { PATHS, UUID_RE } from '../../lib/fileUtils.js';import { ServerError } from '../../lib/errorHandler.js';import { safeUnder, generateThumbnail, upscaleVideo2x } from '../../lib/ffmpeg.js';import { loadHistory, mutateVideoHistory } from './history.js';-import { renderTimingFields } from '../../lib/renderTiming.js';+import { omitRenderTiming, renderTimingFields } from '../../lib/renderTiming.js';const UPLOADED_HISTORY_ID_RE = /^upload-[a-f0-9]{8}$/i;@@ -43,15 +43,13 @@ export async function upscaleHistoryItem(historyId) {const newId = randomUUID();const newFilename = `${newId}.mp4`;const newPath = join(PATHS.videos, newFilename);+ // Wall-clock timing (#5878) for the pass the user actually waits through. An+ // upscale gets its own gallery card, so the ffmpeg pass is a real cost worth+ // reporting rather than leaving blank.+ const renderStartedAtMs = Date.now();// Copy first, then upscale-in-place — keeps the upscaler's atomic-rename// contract intact and means a mid-process kill leaves the source clip// untouched.- // Wall-clock timing (#5878) for the pass the user actually waits through.- // The entry below is built by spreading the SOURCE row, so without this it- // would inherit — and display — the original render's duration for work it- // never did. Overriding is the fix rather than stripping: an upscale produces- // its own gallery card, and the ffmpeg pass is a real cost worth reporting.- const renderStartedAtMs = Date.now();await copyFile(sourcePath, newPath);console.log(`🔍 Upscaling video [${historyId.slice(0, 8)} → ${newId.slice(0, 8)}]: 2×`);const result = await upscaleVideo2x(newPath);@@ -64,7 +62,11 @@ export async function upscaleHistoryItem(historyId) {// tag with `upscaledFrom: <id>` + a reusable suffix on the prompt so the// gallery row reads as "<original prompt> (2×)".const newEntry = {- ...item,+ // Strip before the spread rather than relying on the override below to win:+ // `renderTimingFields` reports `{}` when it can't measure the span, and an+ // override that contributes no keys would silently leave the SOURCE render's+ // duration on a row that only ran an ffmpeg pass.+ ...omitRenderTiming(item),id: newId,filename: newFilename,width: (Number(item.width) || 0) * 2,@@ -76,8 +78,6 @@ export async function upscaleHistoryItem(historyId) {// Drop hidden so the upscaled version surfaces in the visible gallery// even when the source clip was hidden.hidden: false,- // AFTER the `...item` spread above so this pass's own timing replaces the- // source render's inherited fields....renderTimingFields(renderStartedAtMs),};// Serialized append (re-reads inside the mutator) so a concurrent