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: skip unreadable queue snapshots during hold migration (#6282)
[._.]/ Adam Eivy8c1acf991072
diff --git a/docs/STORAGE.md b/docs/STORAGE.mdindex d4082fdc7a..852286d294 100644--- a/docs/STORAGE.md+++ b/docs/STORAGE.md@@ -107,7 +107,7 @@ PostgreSQL is a **required** install/runtime dependency (see [Backup & Restore](**Examples.**- Upload staging — `data/uploads/*`. Ephemeral; do not put in DB except as job references.-- Media job queue — runtime queue state can stay file-backed short term, but **job history and artifact lineage are `db-primary`** and should move to the DB. Local video failure holds live in the existing `data/media-jobs.json` envelope as `videoHolds`, beside unchanged `jobs`. They are machine-local dispatch state, never federated and never sent in capability/status payloads to peers; the local queue API exposes them only on retained jobs. Three matching terminal causes hold one catalog model/runtime until explicit resume. Migration 343 adds an empty hold list to legacy envelopes without changing jobs; fresh installs use the empty seed. The envelope retains its existing filesystem backup coverage, with no new store, search index, sync cursor, or tombstone.+- Media job queue — runtime queue state can stay file-backed short term, but **job history and artifact lineage are `db-primary`** and should move to the DB. Local video failure holds live in the existing `data/media-jobs.json` envelope as `videoHolds`, beside unchanged `jobs`. They are machine-local dispatch state, never federated and never sent in capability/status payloads to peers; the local queue API exposes them on retained jobs and through `GET /api/media-jobs/holds`, so status and resume remain available when no retained jobs remain. Three matching terminal causes hold one catalog model/runtime until explicit resume. Migration 344 adds an empty hold list to legacy envelopes without changing jobs; fresh installs use the empty seed. The envelope retains its existing filesystem backup coverage, with no new store, search index, sync cursor, or tombstone.- Browser CDP profile / downloads — `data/browser-profile/`, `data/browser-downloads/` — cache, non-overridable backup excludes.- Brain parity audit results — `data/brain_parity_reports.json` (`server/services/brainParity.js`, #4519). The last record-level brain-parity report per peer, keyed by peer `instanceId` (the same key `data/instances_sync_cursors.json` uses). `ephemeral-file` because it is a point-in-time *observation* about two installs, fully regenerable by re-running the audit, and stale the moment either side syncs — the durable state it describes lives in the brain stores. **Intentionally machine-local — never federated**: it is this install's view of a peer, and each peer computes its own. No sync cursor, no tombstone, no migration (an absent file reads as "nothing audited yet"). Per-type record lists are capped at 25 ids with a `truncated` flag so a badly diverged install can't grow the file without bound.- CoS event ledgers — ordinary diagnostics use `data/cos/run-events.jsonl` + `run-events.1.jsonl`; persistent-mind trajectory uses the separate `mind-events.jsonl` + `mind-events.1.jsonl` pair (`server/services/agentRunEventLog.js`, #4540, #5082). Both are append-only, machine-local `ephemeral-file` replay aids with no federation cursor, tombstone, or `PORTOS_SCHEMA_VERSIONS` entry. The durable ordinary run record remains `data/runs/{id}/metadata.json`; mind rollups remain in their own bounded cache. Ordinary generations rotate at 5000 events and additionally expire after 30 days. Mind generations rotate at 10000 events without an age cutoff so a stopped mind keeps its unsummarized window, while high-volume mind chatter cannot evict ordinary run diagnostics. Migration 301 moves existing `mind.*` lines out of the shared files and stamps predecessor sequence provenance used to distinguish a legitimate timestamp jump from lost retained events. Payloads are redacted at append time, and both bounded pairs are backed up with the rest of `data/cos/`.diff --git a/scripts/migrations/343-local-video-queue-holds.js b/scripts/migrations/343-local-video-queue-holds.jsdeleted file mode 100644index a86730816d..0000000000--- a/scripts/migrations/343-local-video-queue-holds.js+++ /dev/null@@ -1,20 +0,0 @@-/** Add local runtime holds without changing or re-enqueueing any stored job. */-import { readFile } from 'fs/promises';-import { join } from 'path';-import { writeJsonAtomic } from './_lib.js';--export default {- async up({ rootDir }) {- const file = join(rootDir, 'data', 'media-jobs.json');- const raw = await readFile(file, 'utf8').catch((error) => {- if (error.code === 'ENOENT') return null;- throw error;- });- if (raw === null) return { updated: 0 };- const envelope = JSON.parse(raw);- if (!envelope || !Array.isArray(envelope.jobs)) throw new Error('Invalid media jobs envelope');- if (Object.hasOwn(envelope, 'videoHolds')) return { updated: 0 };- await writeJsonAtomic(file, { ...envelope, videoHolds: [] });- return { updated: 1 };- },-};diff --git a/scripts/migrations/344-local-video-queue-holds.js b/scripts/migrations/344-local-video-queue-holds.jsnew file mode 100644index 0000000000..9ae4ab92e5--- /dev/null+++ b/scripts/migrations/344-local-video-queue-holds.js@@ -0,0 +1,19 @@+/** Add local runtime holds without changing or re-enqueueing any stored job. */+import { join } from 'path';+import { writeJsonAtomic } from './_lib.js';+import { readJSONFileStrict } from '../../server/lib/fileUtils.js';++export default {+ async up({ rootDir }) {+ const file = join(rootDir, 'data', 'media-jobs.json');+ const { ok, value: envelope } = await readJSONFileStrict(file, null, { logError: false });+ if (ok && envelope === null) return { updated: 0 };+ if (!ok || !Array.isArray(envelope?.jobs)) {+ console.warn('⚠️ data/media-jobs.json: unreadable or invalid queue snapshot; skipping hold migration and preserving the file');+ return { updated: 0 };+ }+ if (Object.hasOwn(envelope, 'videoHolds')) return { updated: 0 };+ await writeJsonAtomic(file, { ...envelope, videoHolds: [] });+ return { updated: 1 };+ },+};diff --git a/scripts/migrations/343-local-video-queue-holds.test.js b/scripts/migrations/344-local-video-queue-holds.test.jssimilarity index 65%rename from scripts/migrations/343-local-video-queue-holds.test.jsrename to scripts/migrations/344-local-video-queue-holds.test.jsindex 370f9f0fd4..a9dda9d373 100644--- a/scripts/migrations/343-local-video-queue-holds.test.js+++ b/scripts/migrations/344-local-video-queue-holds.test.js@@ -1,8 +1,8 @@import { afterEach, expect, it } from 'vitest';-import { mkdtemp, mkdir, readFile, rm, writeFile } from 'fs/promises';+import { mkdtemp, mkdir, readFile, rm, stat, writeFile } from 'fs/promises';import { tmpdir } from 'os';import { join } from 'path';-import migration from './343-local-video-queue-holds.js';+import migration from './344-local-video-queue-holds.js';let rootDir;afterEach(async () => { if (rootDir) await rm(rootDir, { recursive: true, force: true }); });it('adds an empty hold list while preserving ordered jobs, unknown fields and existing holds', async () => {@@ -18,7 +18,14 @@ it('adds an empty hold list while preserving ordered jobs, unknown fields and exawait writeFile(file, JSON.stringify(current));expect(await migration.up({ rootDir })).toEqual({ updated: 0 });expect(JSON.parse(await readFile(file, 'utf8'))).toEqual(current);- await writeFile(file, '{invalid');- await expect(migration.up({ rootDir })).rejects.toThrow();- expect(await readFile(file, 'utf8')).toBe('{invalid');+ for (const invalid of ['{invalid', '{}']) {+ await writeFile(file, invalid);+ expect(await migration.up({ rootDir })).toEqual({ updated: 0 });+ expect(await readFile(file, 'utf8')).toBe(invalid);+ }+ // A directory is a portable non-ENOENT read failure, without chmod/root assumptions.+ await rm(file);+ await mkdir(file);+ expect(await migration.up({ rootDir })).toEqual({ updated: 0 });+ expect((await stat(file)).isDirectory()).toBe(true);});