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
address review (codex): run wan/hunyuan refusal before kind branch; platform-scoped dup check
[._.]/ Adam Eivy88afe4f60c4a
diff --git a/server/lib/huggingfaceModel.js b/server/lib/huggingfaceModel.jsindex 9428f7257c..fcae384bf5 100644--- a/server/lib/huggingfaceModel.js+++ b/server/lib/huggingfaceModel.js@@ -255,6 +255,19 @@ export const classifyHfMediaModel = ({ repo, model, kind, runtime, runner } = {});}+ // Refuse a repo whose DETECTED runtime isn't addable (wan22 / hunyuan need a+ // BYO venv) UNCONDITIONALLY — before kind resolution and before any override.+ // The "a bad add can't wedge the picker" guarantee must hold even when the+ // caller forces `runtime: 'mlx_video'` on a Hunyuan repo OR `kind: 'image'`+ // (which would otherwise route it into the image branch and skip this check+ // entirely, persisting a Wan/Hunyuan repo as a bogus image model).+ if (detectedVideo && !ADDABLE_VIDEO_RUNTIMES.includes(detectedVideo.runtime)) {+ throw new ServerError(+ `HuggingFace repo "${repo}" targets the "${detectedVideo.runtime}" runtime, which needs a dedicated venv (${detectedVideo.installHint}) and can't be added self-service — set it up via the script, then edit data/media-models.json.`,+ { status: 422, code: 'HF_UNSUPPORTED_RUNTIME' },+ );+ }+// Resolve kind: explicit override wins, else detect.let resolvedKind = kind || null;if (!resolvedKind) {@@ -271,18 +284,6 @@ export const classifyHfMediaModel = ({ repo, model, kind, runtime, runner } = {}}if (resolvedKind === 'video') {- // Refuse a repo whose DETECTED runtime isn't addable (wan22 / hunyuan need- // a BYO venv) BEFORE honoring any override — the "a bad add can't wedge the- // picker" guarantee must hold even when the caller forces- // `runtime: 'mlx_video'` on a HunyuanVideo repo (the entry would register- // but the runtime couldn't load it). The override only picks between the- // *addable* runtimes; it can't launder a known-unsupported repo through.- if (detectedVideo && !ADDABLE_VIDEO_RUNTIMES.includes(detectedVideo.runtime)) {- throw new ServerError(- `HuggingFace repo "${repo}" targets the "${detectedVideo.runtime}" runtime, which needs a dedicated venv (${detectedVideo.installHint}) and can't be added self-service — set it up via the script, then edit data/media-models.json.`,- { status: 422, code: 'HF_UNSUPPORTED_RUNTIME' },- );- }// Explicit override wins (already allowlist-validated).if (runtime) return { kind: 'video', runtime, format: 'safetensors' };// Otherwise require a POSITIVELY-detected addable runtime. A repo that onlydiff --git a/server/lib/huggingfaceModel.test.js b/server/lib/huggingfaceModel.test.jsindex e07ffb2773..8839585f90 100644--- a/server/lib/huggingfaceModel.test.js+++ b/server/lib/huggingfaceModel.test.js@@ -65,6 +65,17 @@ describe('classifyHfMediaModel — strict refusal', () => {})).toThrow(/needs a dedicated venv/);});+ it('refuses a wan/hunyuan repo even when kind:image is forced (override cannot skip the video guard)', () => {+ // kind:'image' would route into the image branch and bypass the video-only+ // refusal — the guard must run unconditionally, before kind resolution.+ expect(() => classifyHfMediaModel({+ repo: 'Wan-AI/Wan2.2-T2V-A14B',+ model: hf({ files: ['model.safetensors'], tags: ['wan'] }),+ kind: 'image',+ runner: 'qwen',+ })).toThrow(/needs a dedicated venv/);+ });+it('refuses a LoRA adapter repo (belongs in the LoRA manager, not base models)', () => {// base_model in the card is the adapter signal.expect(() => classifyHfMediaModel({diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.jsindex 385b70e18f..afe386649c 100644--- a/server/lib/mediaModels.js+++ b/server/lib/mediaModels.js@@ -762,15 +762,20 @@ export const addUserModelEntry = (entry, { kind }) => {throw new ServerError(`Unknown model kind "${kind}" — expected "image" or "video".`, { status: 400, code: 'BAD_MODEL_KIND' });}const reg = loadMediaModels();- if (findModelLocation(reg, entry.id)) {+ const listKey = kind === 'video' ? (IS_WIN ? 'windows' : 'macos') : 'image';+ // Conflict-check only the TARGET list, not every list. A shared+ // media-models.json used across a macOS + Windows peer stores a video model+ // per-platform; the same repo must remain addable on the other platform's+ // list even though it already exists on the first — a global scan would+ // wrongly 409 and leave no self-service way to enable it there.+ const current = (listKey === 'image' ? reg.image : reg.video?.[listKey]) || [];+ if (current.some((m) => m?.id === entry.id)) {throw new ServerError(- `A model with id "${entry.id}" is already in the registry (repo already added?). Remove it first to re-add.`,+ `A model with id "${entry.id}" is already in the ${kind} registry for this platform (repo already added?). Remove it first to re-add.`,{ status: 409, code: 'MODEL_ALREADY_EXISTS' },);}- const listKey = kind === 'video' ? (IS_WIN ? 'windows' : 'macos') : 'image';- const current = listKey === 'image' ? reg.image : reg.video[listKey];- persistRegistry(withList(reg, listKey, [...(current || []), entry]));+ persistRegistry(withList(reg, listKey, [...current, entry]));console.log(`📝 Added user media model: ${entry.id} (${kind}) → ${entry.repo || '?'}`);return entry;};diff --git a/server/lib/mediaModels.test.js b/server/lib/mediaModels.test.jsindex 6b8accecb1..bc94658a8a 100644--- a/server/lib/mediaModels.test.js+++ b/server/lib/mediaModels.test.js@@ -790,6 +790,21 @@ describe('user model entry mutators (#2124)', () => {expect(() => addUserModelEntry(videoEntry, { kind: 'video' })).toThrow(/already/i);});+ it('conflict-checks only the target platform list, not every list', async () => {+ // A video id present ONLY on the OTHER platform's list must remain addable+ // on the current platform (shared media-models.json across macOS+Windows).+ const { loadMediaModels } = await import('./mediaModels.js');+ const reg = loadMediaModels();+ const currentKey = process.platform === 'win32' ? 'windows' : 'macos';+ const otherKey = currentKey === 'macos' ? 'windows' : 'macos';+ reg.video[otherKey] = [...(reg.video[otherKey] || []), { ...videoEntry }];+ writeFileSync(registryFile, JSON.stringify(reg, null, 2) + '\n');+ vi.resetModules();+ const m2 = await import('./mediaModels.js');+ expect(() => m2.addUserModelEntry({ ...videoEntry }, { kind: 'video' })).not.toThrow();+ expect(m2.getVideoModels().some((x) => x.id === videoEntry.id)).toBe(true);+ });+it('patches a user entry but refuses built-ins', async () => {const { addUserModelEntry, patchUserModelEntry, getImageModels } = await import('./mediaModels.js');addUserModelEntry(imageEntry, { kind: 'image' });