Skip to content

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

fix: build the H3 and Apple video migrations from the in-code registry (#8443)

[._.]/ Adam Eivy86a124d2dd71
diff --git a/scripts/migrations/242-minimax-h3-mlx-model.js b/scripts/migrations/242-minimax-h3-mlx-model.js
index aee2f23373..ae3ac22b05 100644
--- a/scripts/migrations/242-minimax-h3-mlx-model.js
+++ b/scripts/migrations/242-minimax-h3-mlx-model.js
@@ -1,6 +1,6 @@
/**
* Add the never-before-shipped MiniMax H3 MLX profile to existing macOS
- * registries. Fresh installs receive it from data.reference/media-models.json.
+ * registries. Fresh installs seed it from DEFAULT_REGISTRY on first load.
*
* Registries that predate `_shippedDefaults` need a migration: their normal
* bootstrap deliberately treats every current default id as already shipped
@@ -10,9 +10,9 @@
*/
import { readFile } from 'fs/promises';
-import { dirname, join } from 'path';
-import { fileURLToPath } from 'url';
+import { join } from 'path';
import { atomicWrite } from '../../server/lib/fileUtils.js';
+import { getShippedMediaRegistry } from '../../server/lib/mediaModels.js';
import {
VIDEO_BUCKET_CUDA,
VIDEO_BUCKET_MLX,
@@ -21,10 +21,6 @@ import {
const REL_PATH = 'data/media-models.json';
const H3_ID = 'minimax_h3_8bit';
-const REFERENCE_PATH = join(
- dirname(fileURLToPath(import.meta.url)),
- '..', '..', 'data.reference', 'media-models.json',
-);
// The built-in video model ids as of the release that introduced this
// migration (commit ffac284f9), used for the `_shippedDefaults` bootstrap union
@@ -74,23 +70,7 @@ export default {
const mlxEntries = readVideoBucket(config?.video, VIDEO_BUCKET_MLX);
if (!Array.isArray(mlxEntries)) return;
- // Load the H3 model definition. The seed file may not exist on fresh installs
- // (it's no longer committed), so gracefully skip if it's missing — the model
- // will be added by seedIfMissing() when the server boots and loads
- // DEFAULT_REGISTRY. Existing installs have it either in their registry already
- // or will pick it up here from the reference copy.
- const seedRaw = await readFile(REFERENCE_PATH, 'utf-8').catch((err) => {
- if (err.code === 'ENOENT') return null;
- throw err;
- });
- if (seedRaw === null) {
- // Seed file missing and mlx entries exist → old install with existing models.
- // Skip this migration; the model is new in this release and will be added by
- // a later update if needed. A fresh install will get the model from
- // DEFAULT_REGISTRY on first boot via seedIfMissing().
- return;
- }
- const reference = parseJson(seedRaw, 'data.reference/media-models.json');
+ const reference = getShippedMediaRegistry();
const referenceMlx = readVideoBucket(reference?.video, VIDEO_BUCKET_MLX);
const h3 = (Array.isArray(referenceMlx) ? referenceMlx : []).find((entry) => entry?.id === H3_ID);
if (!h3) throw new Error(`Cannot migrate ${REL_PATH}: shipped ${H3_ID} reference is missing`);
diff --git a/scripts/migrations/244-minimax-h3-image-to-video.test.js b/scripts/migrations/244-minimax-h3-image-to-video.test.js
index 2bfe25a890..d40dc34222 100644
--- a/scripts/migrations/244-minimax-h3-image-to-video.test.js
+++ b/scripts/migrations/244-minimax-h3-image-to-video.test.js
@@ -4,10 +4,8 @@ import { tmpdir } from 'os';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import migration from './244-minimax-h3-image-to-video.js';
+import { getShippedMediaRegistry } from '../../server/lib/mediaModels.js';
-const REFERENCE_PATH = join(
- dirname(fileURLToPath(import.meta.url)), '..', '..', 'data.reference', 'media-models.json',
-);
const H3_ID = 'minimax_h3_8bit';
const writeJson = (path, value) => writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
@@ -70,12 +68,12 @@ describe('migration 244 — MiniMax H3 image-to-video', () => {
// live seed would let a later seed edit retroactively change what 244 does),
// so pin it here — otherwise fresh installs and migrated installs could end
// up downloading different files with nothing failing.
- it('migrates to exactly what data.reference ships today', async () => {
+ it('migrates to exactly what the shipped registry carries today', async () => {
writeJson(path, registryWith(shippedH3()));
await migration.up({ rootDir });
const migrated = h3In(readJson(path));
- const seeded = JSON.parse(readFileSync(REFERENCE_PATH, 'utf-8'))
+ const seeded = getShippedMediaRegistry()
.video.mlx.find((entry) => entry.id === H3_ID);
expect(migrated.supportedModes).toEqual(seeded.supportedModes);
expect(migrated.requiredWeights[0].files.filter((f) => f.startsWith('FL2VA/processor/')))
@@ -132,7 +130,7 @@ describe('migration 244 — MiniMax H3 image-to-video', () => {
expect(readJson(path)).toEqual(before);
});
- it('skips a missing registry file (fresh install seeds from data.reference)', async () => {
+ it('skips a missing registry file (fresh install seeds from DEFAULT_REGISTRY)', async () => {
await expect(migration.up({ rootDir })).resolves.toBeUndefined();
});
diff --git a/scripts/migrations/247-retire-ltx2-unified.test.js b/scripts/migrations/247-retire-ltx2-unified.test.js
index 9d75cfd04a..94a93c937d 100644
--- a/scripts/migrations/247-retire-ltx2-unified.test.js
+++ b/scripts/migrations/247-retire-ltx2-unified.test.js
@@ -3,10 +3,9 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync, mkdirSync } from 'fs'
import { tmpdir } from 'os';
import { join } from 'path';
import { repoRoot } from './_testHelpers.js';
-import { RETIRED_VIDEO_MODELS } from '../../server/lib/mediaModels.js';
+import { RETIRED_VIDEO_MODELS, getShippedMediaRegistry } from '../../server/lib/mediaModels.js';
import migration, { RETIRED_ID, SHIPPED_REPO, REPLACEMENT_ID } from './247-retire-ltx2-unified.js';
-const REFERENCE_PATH = join(repoRoot, 'data.reference', 'media-models.json');
const writeJson = (path, value) => writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));
@@ -64,8 +63,8 @@ describe('migration 247 — retire LTX-2 Unified', () => {
// The migration exists to bring persisted registries in line with the seed a
// fresh install gets. If the seed ever re-gained the entry the two paths would
// silently diverge, so assert the seed agrees the model is gone.
- it('matches data.reference, which no longer ships the entry', () => {
- const seeded = JSON.parse(readFileSync(REFERENCE_PATH, 'utf-8'));
+ it('matches the shipped registry, which no longer ships the entry', () => {
+ const seeded = getShippedMediaRegistry();
expect(seeded.video.mlx.some((entry) => entry.id === RETIRED_ID)).toBe(false);
expect(seeded.video.mlx.some((entry) => entry.id === REPLACEMENT_ID)).toBe(true);
});
@@ -137,7 +136,7 @@ describe('migration 247 — retire LTX-2 Unified', () => {
expect(readJson(path)).toEqual(before);
});
- it('skips a missing registry file (fresh install seeds from data.reference)', async () => {
+ it('skips a missing registry file (fresh install seeds from DEFAULT_REGISTRY)', async () => {
await expect(migration.up({ rootDir })).resolves.toBeUndefined();
});
diff --git a/scripts/migrations/267-minimax-h3-native-output-controls.test.js b/scripts/migrations/267-minimax-h3-native-output-controls.test.js
index e6a79a37c9..9442ecfc52 100644
--- a/scripts/migrations/267-minimax-h3-native-output-controls.test.js
+++ b/scripts/migrations/267-minimax-h3-native-output-controls.test.js
@@ -4,11 +4,9 @@ import { tmpdir } from 'os';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import migration from './267-minimax-h3-native-output-controls.js';
+import { getShippedMediaRegistry } from '../../server/lib/mediaModels.js';
const H3_ID = 'minimax_h3_8bit';
-const REFERENCE_PATH = join(
- dirname(fileURLToPath(import.meta.url)), '..', '..', 'data.reference', 'media-models.json',
-);
const OLD_FRAMES = [124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362];
const h3 = () => ({
id: H3_ID,
@@ -55,7 +53,7 @@ describe('migration 267 — MiniMax H3 native output controls', () => {
{ label: '768x1024 (3:4 H3 native)', w: 768, h: 1024 },
{ label: '768x1344 (9:16 H3 native)', w: 768, h: 1344 },
]);
- const seeded = JSON.parse(readFileSync(REFERENCE_PATH, 'utf-8'))
+ const seeded = getShippedMediaRegistry()
.video.mlx.find((entry) => entry.id === H3_ID);
expect({
defaultFrames: migrated.defaultFrames,
diff --git a/scripts/migrations/268-minimax-h3-cuda-model.js b/scripts/migrations/268-minimax-h3-cuda-model.js
index abf8752cd0..730ec6df02 100644
--- a/scripts/migrations/268-minimax-h3-cuda-model.js
+++ b/scripts/migrations/268-minimax-h3-cuda-model.js
@@ -1,6 +1,6 @@
/**
* Add the never-before-shipped MiniMax H3 CUDA profile to existing CUDA-bucket
- * registries. Fresh installs receive it from data.reference/media-models.json.
+ * registries. Fresh installs seed it from DEFAULT_REGISTRY on first load.
*
* Same reason migration 242 exists for the MLX profile: a registry whose
* `_shippedDefaults.video.cuda` snapshot (pre-#4142: `.windows`) predates this
@@ -16,17 +16,13 @@
*/
import { readFile } from 'fs/promises';
-import { dirname, join } from 'path';
-import { fileURLToPath } from 'url';
+import { join } from 'path';
import { atomicWrite } from '../../server/lib/fileUtils.js';
+import { getShippedMediaRegistry } from '../../server/lib/mediaModels.js';
import { VIDEO_BUCKET_CUDA, readVideoBucket } from '../../server/lib/mediaModelBuckets.js';
const REL_PATH = 'data/media-models.json';
const CUDA_ID = 'minimax_h3_cuda';
-const REFERENCE_PATH = join(
- dirname(fileURLToPath(import.meta.url)),
- '..', '..', 'data.reference', 'media-models.json',
-);
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -53,23 +49,7 @@ export default {
const cudaEntries = readVideoBucket(config?.video, VIDEO_BUCKET_CUDA);
if (!Array.isArray(cudaEntries)) return;
- // Load the CUDA H3 model definition. The seed file may not exist on fresh installs
- // (it's no longer committed), so gracefully skip if it's missing — the model
- // will be added by seedIfMissing() when the server boots and loads
- // DEFAULT_REGISTRY. Existing installs have it either in their registry already
- // or will pick it up here from the reference copy.
- const seedRaw = await readFile(REFERENCE_PATH, 'utf-8').catch((err) => {
- if (err.code === 'ENOENT') return null;
- throw err;
- });
- if (seedRaw === null) {
- // Seed file missing and cuda entries exist → old install with existing models.
- // Skip this migration; the model is new in this release and will be added by
- // a later update if needed. A fresh install will get the model from
- // DEFAULT_REGISTRY on first boot via seedIfMissing().
- return;
- }
- const reference = parseJson(seedRaw, 'data.reference/media-models.json');
+ const reference = getShippedMediaRegistry();
const referenceCuda = readVideoBucket(reference?.video, VIDEO_BUCKET_CUDA);
const cuda = (Array.isArray(referenceCuda) ? referenceCuda : []).find((entry) => entry?.id === CUDA_ID);
if (!cuda) throw new Error(`Cannot migrate ${REL_PATH}: shipped ${CUDA_ID} reference is missing`);
diff --git a/scripts/migrations/315-retire-hunyuan-video.test.js b/scripts/migrations/315-retire-hunyuan-video.test.js
index 7878ace44b..86393243bb 100644
--- a/scripts/migrations/315-retire-hunyuan-video.test.js
+++ b/scripts/migrations/315-retire-hunyuan-video.test.js
@@ -3,10 +3,9 @@ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs'
import { tmpdir } from 'os';
import { join } from 'path';
import { repoRoot } from './_testHelpers.js';
-import { RETIRED_VIDEO_MODELS } from '../../server/lib/mediaModels.js';
+import { RETIRED_VIDEO_MODELS, getShippedMediaRegistry } from '../../server/lib/mediaModels.js';
import migration, { REPLACEMENT_ID, RETIRED_ID, SHIPPED_REPO } from './315-retire-hunyuan-video.js';
-const REFERENCE_PATH = join(repoRoot, 'data.reference', 'media-models.json');
const writeJson = (path, value) => writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));
@@ -55,7 +54,7 @@ describe('migration 315 — retire legacy HunyuanVideo', () => {
});
it('matches the fresh-install catalog', () => {
- const seeded = JSON.parse(readFileSync(REFERENCE_PATH, 'utf-8'));
+ const seeded = getShippedMediaRegistry();
expect(seeded.video.mlx.some((entry) => entry.id === RETIRED_ID)).toBe(false);
expect(seeded.video.mlx.some((entry) => entry.id === REPLACEMENT_ID)).toBe(true);
});
diff --git a/scripts/migrations/398-apple-video-model-options.js b/scripts/migrations/398-apple-video-model-options.js
index 4056d6b7e8..32bf2ccb9b 100644
--- a/scripts/migrations/398-apple-video-model-options.js
+++ b/scripts/migrations/398-apple-video-model-options.js
@@ -4,6 +4,7 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { atomicWrite } from '../../server/lib/fileUtils.js';
+import { getShippedMediaRegistry } from '../../server/lib/mediaModels.js';
const NEW_IDS = ['fasth3_v2_int8', 'fasth3_v2_int6', 'minimax_h3_6bit', 'minimax_h3_4bit'];
@@ -19,7 +20,7 @@ export default {
const key = Array.isArray(registry.video?.mlx) ? 'mlx'
: Array.isArray(registry.video?.macos) ? 'macos' : null;
if (!key) return;
- const seed = JSON.parse(await readFile(join(rootDir, 'data.reference/media-models.json'), 'utf8'));
+ const seed = getShippedMediaRegistry();
const defaults = seed.video.mlx;
const entries = registry.video[key];
const recorded = registry._shippedDefaults?.video?.mlx ?? registry._shippedDefaults?.video?.macos;
diff --git a/scripts/migrations/398-apple-video-model-options.test.js b/scripts/migrations/398-apple-video-model-options.test.js
index 2f23e12c5d..85c4bbd423 100644
--- a/scripts/migrations/398-apple-video-model-options.test.js
+++ b/scripts/migrations/398-apple-video-model-options.test.js
@@ -1,5 +1,5 @@
import { beforeEach, afterEach, it, expect } from 'vitest';
-import { mkdtemp, mkdir, readFile, writeFile, copyFile, rm } from 'node:fs/promises';
+import { mkdtemp, mkdir, readFile, writeFile, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import migration from './398-apple-video-model-options.js';
@@ -9,8 +9,6 @@ let path;
beforeEach(async () => {
rootDir = await mkdtemp(join(tmpdir(), 'video-options-upgrade-'));
await mkdir(join(rootDir, 'data'));
- await mkdir(join(rootDir, 'data.reference'));
- await copyFile(new URL('../../data.reference/media-models.json', import.meta.url), join(rootDir, 'data.reference/media-models.json'));
path = join(rootDir, 'data/media-models.json');
});
afterEach(async () => { await rm(rootDir, { recursive: true, force: true }); });
diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.js
index 73d1f314aa..c03cb327e7 100644
--- a/server/lib/mediaModels.js
+++ b/server/lib/mediaModels.js
@@ -515,8 +515,7 @@ const DEFAULT_REGISTRY = {
video: {
// `applyVideoDisclosures` attaches the shipped provenance/licensing block
// (lib/videoDisclosure.js) to each entry, so the seed written on a fresh
- // install, the in-memory defaults, and data.reference/media-models.json all
- // carry the same disclosure without repeating it inline here.
+ // install and the in-memory defaults carry the same disclosure without repeating it inline here.
// `applyVideoFinishProfiles` attaches the shipped draft → delivery
// `finishModelId` edges (lib/videoFinishProfiles.js) the same way, so the
// Finish relationship is declared in one place instead of inline here.
@@ -1172,6 +1171,10 @@ const ensureDir = (file) => {
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
};
+// The shipped default registry, cloned so a caller (a migration adding a new
+// shipped row to an existing install) can never mutate the in-memory defaults.
+export const getShippedMediaRegistry = () => structuredClone(DEFAULT_REGISTRY);
+
const seedIfMissing = () => {
if (existsSync(REGISTRY_FILE)) return;
ensureDir(REGISTRY_FILE);
diff --git a/server/lib/mediaModels.test.js b/server/lib/mediaModels.test.js
index 364b69387c..d837d60f26 100644
--- a/server/lib/mediaModels.test.js
+++ b/server/lib/mediaModels.test.js
@@ -4,9 +4,9 @@ import { tmpdir, homedir } from 'os';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { pinPlatform } from './testHelper.js';
+import { getShippedMediaRegistry } from './mediaModels.js';
const __dirname_self = dirname(fileURLToPath(import.meta.url));
-const SAMPLE_REGISTRY_PATH = join(__dirname_self, '..', '..', 'data.reference', 'media-models.json');
let tmpDir;
let registryFile;
@@ -67,24 +67,15 @@ describe('media model registry freshly loaded', () => {
expect(upgraded.image.find((m) => m.id === 'qwen-image')).toEqual(legacy);
});
- it('loads DEFAULT_REGISTRY correctly with expected defaults', async () => {
+ it('seeds a fresh install with exactly the shipped default registry', async () => {
const { loadMediaModels } = await import('./mediaModels.js');
- const registry = loadMediaModels();
- // Verify the fresh-seeded registry has the key defaults that distinguish
- // this release from older snapshots. This replaces the old equality test
- // against a committed seed file.
- expect(registry.video.defaultMlx).toBe('fastmetal_5b_qad');
- expect(registry.video.mlx.some((entry) => entry.id === registry.video.defaultMlx)).toBe(true);
- expect(registry.image.some((entry) => entry.id === registry.selectedTextEncoder)).toBe(false);
- // Spot-check a few complex entries exist and have expected fields
- const ltx23 = registry.video.mlx.find((m) => m.id === 'ltx23_unified');
- expect(ltx23).toBeDefined();
- expect(ltx23.disclosure).toBeDefined();
- expect(ltx23.speedProfiles).toBeDefined();
- // Fresh registries should have _shippedDefaults populated
- expect(registry._shippedDefaults).toBeDefined();
- expect(Array.isArray(registry._shippedDefaults.video.mlx)).toBe(true);
- expect(Array.isArray(registry._shippedDefaults.video.cuda)).toBe(true);
+ expect(existsSync(registryFile)).toBe(false);
+ const live = loadMediaModels();
+ // Load persists the runtime-only _shippedDefaults ledger beside the seed.
+ const { _shippedDefaults: _ledger, ...seeded } = JSON.parse(readFileSync(registryFile, 'utf-8'));
+ expect(seeded).toEqual(getShippedMediaRegistry());
+ const { _shippedDefaults: _omit, ...liveSeed } = live;
+ expect(liveSeed).toEqual(seeded);
});
});
@@ -851,7 +842,7 @@ describe('mediaModels registry', () => {
// _shippedDefaults claims every current built-in so appendNewlyShippedEntries
// adds nothing — these cases are about what the load REMOVES, and an
// "everything else is new" fixture would bury it under a dozen appends.
- const shippedMlxIds = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'))
+ const shippedMlxIds = getShippedMediaRegistry()
.video.mlx.map((e) => e.id).concat(RETIRED_ID);
const writeRegistry = (mlx, defaultMlx = 'ltx23_distilled_q4') => writeFileSync(
@@ -935,7 +926,7 @@ describe('mediaModels registry', () => {
// persist the cached object wholesale later in the same boot.
describe('MiniMax H3 output-control upgrade', () => {
const OLD_FRAMES = [124, 141, 158, 175, 192, 209, 226, 243, 260, 277, 294, 311, 328, 345, 362];
- const shippedMlxIds = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'))
+ const shippedMlxIds = getShippedMediaRegistry()
.video.mlx.map((entry) => entry.id);
const legacyH3 = (extra = {}) => ({
id: 'minimax_h3_8bit',
@@ -1553,7 +1544,7 @@ describe('video bucket selection is an MLX/CUDA axis, not an OS one', () => {
// installs that upgrade on their own schedule.
// _shippedDefaults claims every current built-in so appendNewlyShippedEntries
// adds nothing and each bucket holds exactly the one probe entry.
- const seed = JSON.parse(readFileSync(SAMPLE_REGISTRY_PATH, 'utf-8'));
+ const seed = getShippedMediaRegistry();
const shippedMlx = [...seed.video.mlx.map((m) => m.id), MLX_ONLY.id];
const shippedCuda = [...seed.video.cuda.map((m) => m.id), CUDA_ONLY.id];
const shippedImage = seed.image.map((m) => m.id);