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
feat: gate MiniMax H3 LoRAs on a runtime capability probe instead of refusing them by rule (#3802)
[._.]/ Adam Eivy446ca0ae8f0e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 87a1dde3b3..99c1e70740 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -42,6 +42,8 @@- **Continuing a video carries its prompt forward.** Continuing or extending a clip we generated now prefills the Video Gen prompt (and negative prompt) with the one that produced the source, instead of dropping you into an empty box. This covers both entry points: the **Continue** action on a video card/lightbox, and picking a prior render in Extend mode. Text you typed yourself is never overwritten — only a blank box or a value an earlier pick filled — and a clip we didn't generate (an import, or a legacy render with no stored prompt) leaves the field alone rather than clearing it. The style preset is dropped along with the prefill, since history stores the already-composed prompt and re-applying a preset would prefix it twice.- **Subscription Usage cards now lay out in four quadrants.** The provider quota grid orders Claude, Antigravity, Codex, Grok — and because Codex and Grok typically report only a single weekly meter, they now share one grid cell stacked vertically instead of each stretching to a full-height card. Cards render at their natural height, so the Image Gen card floats into the fourth quadrant and the whole section fits above the fold on desktop.+- **Video LoRAs are no longer refused on MiniMax H3 by rule — they're gated on what the installed runner can actually do.** H3's DiT ships quantized, so an adapter can only be applied at render time from quantization metadata rather than fused into packed weights. PortOS previously rejected every H3 LoRA outright with LTX-shaped advice ("use an LTX-2.x model") that H3 users can't act on. A capability probe now asks the pinned checkout directly, and the answer flows through one path: the model payload, the Video Gen LoRA picker, the request gate, and the render argv. Until a capable build is pinned the rejection stands, but it names the real blocker and points at the runtime upgrade; the day one is pinned the picker opens with no code change. MiniMax H3 LoRAs also classify as their own video family on import, so they no longer land untagged or get mistaken for LTX adapters.+## Fixed- **The prompt-drift baseline caught up with the arc-resolve migration, un-reddening `main`.** Migration 254 shipped a new `pipeline-arc-resolve.md` and correctly recorded the prior default as an accepted-old hash, but the independent baseline in `scripts/setup-data-drift.test.js` still named the superseded hash as current — so the drift sweep disagreed with the migrations it mirrors and the suite failed on every commit after it landed. The baseline now carries the shipped hash and lists the previous one among the accepted-old set. The guard itself is unchanged and still fails when a migration ships a hash it doesn't export.diff --git a/client/src/hooks/useMusicVideoModelSettings.js b/client/src/hooks/useMusicVideoModelSettings.jsindex 9227eadab2..d2a9e6e1f0 100644--- a/client/src/hooks/useMusicVideoModelSettings.js+++ b/client/src/hooks/useMusicVideoModelSettings.js@@ -3,6 +3,7 @@ import toast from '../components/ui/Toast';import { updateMusicVideoProject } from '../services/apiMusicVideo.js';import { getVideoGenStatus, listLorasFull } from '../services/apiImageVideo.js';import useVideoModelTerms from './useVideoModelTerms.js';+import { loraFamilyOf, VIDEO_LORA_FAMILIES } from '../lib/runnerFamilies';const isLtx23 = (model) => !!model&& model.runtime === 'ltx2'@@ -67,7 +68,7 @@ export default function useMusicVideoModelSettings({ project, onProjectPatch } =const audioReactiveModels = models.filter(isLtx23);const audioReactiveLoras = loras.filter((lora) =>/audio-reactive/i.test(`${lora.filename} ${lora.name || ''}`)- && (lora.loraCompatKey || lora.runnerFamily) === 'ltx-video');+ && loraFamilyOf(lora) === VIDEO_LORA_FAMILIES.LTX_VIDEO);const detectedAudioReactiveLora = loras.find((lora) =>lora.filename === settings.audioReactiveLora)|| audioReactiveLoras.find((lora) =>diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.jsindex 70bb8419ea..63c87c2a62 100644--- a/client/src/hooks/useVideoGenForm.js+++ b/client/src/hooks/useVideoGenForm.js@@ -3,7 +3,7 @@ import { useSearchParams } from 'react-router';import toast from '../components/ui/Toast';import { extractLastFrame } from '../services/api';import { composeStyledPrompt } from '../lib/composeStyledPrompt';-import { videoLoraFamily, VIDEO_LORA_FAMILIES } from '../lib/runnerFamilies';+import { videoLoraFamily, isVideoLoraFamily, loraFamilyOf, VIDEO_LORA_FAMILIES } from '../lib/runnerFamilies';import { randomSeed } from '../lib/genUtils';import { VIDEO_RESOLUTIONS, snapAspectToImage } from '../lib/videoGenResolutions';import { clampImageEdge } from '../lib/imageGenResolutions';@@ -277,13 +277,17 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })// Wait for `models` to load before deciding (the LoRA library usually// loads first); the mode is still the default 'text', with which every// ltx2 model is compatible, so the modelId-validation effect won't undo- // this. A non-ltx2 LoRA needs no switch (the image picker tolerates it).- const isVideoLora = (match.loraCompatKey || match.runnerFamily) === VIDEO_LORA_FAMILIES.LTX_VIDEO;+ // this. A non-video LoRA needs no switch (the image picker tolerates it).+ // Family-agnostic on BOTH sides: an incoming H3 LoRA must be recognized as+ // video (else the Test handoff from /media/loras lands in the no-op+ // branch), and the model it switches to must be one whose family matches,+ // not an ltx2 model that would reject it.+ const incomingFamily = loraFamilyOf(match);const cur = models.find((m) => m.id === modelId);- if (isVideoLora && !videoLoraFamily(cur)) {+ if (isVideoLoraFamily(incomingFamily) && videoLoraFamily(cur) !== incomingFamily) {if (!models.length) return; // re-runs when models loads (in deps)- const ltx2Model = models.find((m) => m.runtime === 'ltx2');- if (ltx2Model) setModelId(ltx2Model.id);+ const compatible = models.find((m) => videoLoraFamily(m) === incomingFamily);+ if (compatible) setModelId(compatible.id);}setSelectedLoras((prev) => prev.find((s) => s.filename === fromUrl) ? prev : [...prev, {filename: match.filename,@@ -401,31 +405,42 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })// Video LoRAs always carry an explicit `ltx-video` family (HF import sets it),// so an exact-match filter here is the correct strict mode.const videoLoras = useMemo(- () => (loraFamily- ? availableLoras.filter((l) => (l.loraCompatKey || l.runnerFamily) === loraFamily)- : []),+ () => (loraFamily ? availableLoras.filter((l) => loraFamilyOf(l) === loraFamily) : []),[availableLoras, loraFamily],);- // Installed LTX-video LoRAs regardless of the selected model's runtime. When- // the user picks an LTX-2.x model whose runtime can't fuse LoRAs (a quantized- // mlx_video model — loraFamily is null), the picker is correctly hidden, but- // silently doing so reads as a bug. Use this to explain *why* the LoRA is- // unavailable and point at the models that CAN run it. The `/ltx-?2/i` scope- // matches the server's LTX-2.x capability family (see isMlxVideoLtxLoraCapable)- // so the hint never fires for a non-LTX-2.x model where the advice wouldn't apply.- const installedVideoLoras = useMemo(- () => availableLoras.filter(- (l) => (l.loraCompatKey || l.runnerFamily) === VIDEO_LORA_FAMILIES.LTX_VIDEO,- ),- [availableLoras],- );- // Gated on the quantized-mlx_video case specifically (runtime mlx_video +- // loraFamily null = a quantized LTX-2.x model) so the hint copy's "quantized- // runtime isn't supported yet" wording always matches what triggered it.- const showLtxLoraUnsupportedHint = !loraFamily && installedVideoLoras.length > 0- && currentModel?.runtime === 'mlx_video'- && /ltx-?2/i.test(`${currentModel?.id || ''} ${currentModel?.repo || ''} ${currentModel?.name || ''}`);+ // Installed video LoRAs bucketed by family, regardless of the selected model.+ // One pass instead of one filter per family, and the source for the+ // "why is the picker gone" hint below.+ const installedVideoLorasByFamily = useMemo(() => {+ const buckets = new Map();+ for (const l of availableLoras) {+ const family = loraFamilyOf(l);+ if (!isVideoLoraFamily(family)) continue;+ buckets.set(family, (buckets.get(family) || 0) + 1);+ }+ return buckets;+ }, [availableLoras]);++ // When the picker is hidden but the user HAS a LoRA of the family the selected+ // model's runtime would use, silently hiding it reads as a bug — say why, and+ // say the right why. The two cases need different advice, so the hint carries+ // its own copy: a quantized mlx_video LTX-2.x model is fixed by switching+ // models, while H3 is blocked by its pinned runner and switching models is+ // wrong advice. `null` when there is nothing useful to explain.+ const loraUnavailableHint = useMemo(() => {+ if (loraFamily) return null;+ const ltxCount = installedVideoLorasByFamily.get(VIDEO_LORA_FAMILIES.LTX_VIDEO) || 0;+ // Scoped to LTX-2.x mlx_video (see isMlxVideoLtxLoraCapable) so the copy's+ // "quantized runtime" wording always matches what triggered it.+ if (ltxCount > 0 && currentModel?.runtime === 'mlx_video'+ && /ltx-?2/i.test(`${currentModel?.id || ''} ${currentModel?.repo || ''} ${currentModel?.name || ''}`)) {+ return { count: ltxCount, kind: 'ltx' };+ }+ const h3Count = installedVideoLorasByFamily.get(VIDEO_LORA_FAMILIES.MINIMAX_H3) || 0;+ if (h3Count > 0 && currentModel?.runtime === 'minimax_h3') return { count: h3Count, kind: 'minimax_h3' };+ return null;+ }, [loraFamily, installedVideoLorasByFamily, currentModel]);// Multi-keyframe availability + validation. Keyframes are an ltx2-runtime// primitive (the route 400s with KEYFRAMES_REQUIRE_LTX2 otherwise), so the@@ -1188,7 +1203,7 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })stylePreset, setStylePreset,// ModelmodelId, handleModelChange, currentModel, visibleModels,- loraFamily, videoLoras, installedVideoLoras, showLtxLoraUnsupportedHint,+ loraFamily, videoLoras, loraUnavailableHint,selectedLoras, setSelectedLoras,// Sampler / outputwidth, height, handleResolutionChange,diff --git a/client/src/lib/runnerFamilies.js b/client/src/lib/runnerFamilies.jsindex aecbd40f89..6fd55e1a49 100644--- a/client/src/lib/runnerFamilies.js+++ b/client/src/lib/runnerFamilies.js@@ -17,6 +17,7 @@ export const RUNNER_FAMILIES = Object.freeze({// LoRAs are imported from HuggingFace. Mirror of server/lib/runners.js.export const VIDEO_LORA_FAMILIES = Object.freeze({LTX_VIDEO: 'ltx-video',+ MINIMAX_H3: 'minimax-h3',});// Predicate: is this LoRA family a video family (vs. an image RUNNER_FAMILIES@@ -26,6 +27,13 @@ export const VIDEO_LORA_FAMILIES = Object.freeze({const VIDEO_LORA_FAMILY_SET = new Set(Object.values(VIDEO_LORA_FAMILIES));export const isVideoLoraFamily = (family) => VIDEO_LORA_FAMILY_SET.has(family);+// The family an INSTALLED LoRA belongs to. `loraCompatKey` is the refined key+// (e.g. flux2-9b) written by the importer; `runnerFamily` is the coarse legacy+// field a pre-sidecar install may be the only thing carrying. One helper so the+// `||` fallback can't drift between the pickers, the family filters, and the+// deep-link handoff. Mirror of server/lib/runners.js#loraFamilyOf.+export const loraFamilyOf = (lora) => lora?.loraCompatKey || lora?.runnerFamily || null;+// A LoRA-quantization marker (`q4` / `q8`) in a model's id/repo/name. Leading// boundary + trailing non-digit lookahead catches delimited (`-q4`, `q8_0`) and// suffixed (`q4bit`) forms while not matching `q40`. Mirror of server/lib/runners.js.@@ -46,12 +54,17 @@ export const isMlxVideoLtxLoraCapable = (model) => {// Map a video model (carries `runtime`, not `runner`) to its LoRA family. Both// the dgrauet `ltx2` runtime and non-quantized LTX-2.x `mlx_video` models fuse-// user LoRAs; everything else returns null so the VideoGen picker hides itself.+// user LoRAs. `minimax_h3` can take them only when the *installed* runner can+// apply them to the quantized DiT at runtime — a property of the pinned+// checkout that the client can't derive, so the server decorates each model+// with `runtimeLoraCapable` and this reads it off the payload. Everything else+// returns null so the VideoGen picker hides itself.// Mirror of server/lib/runners.js#videoLoraFamily.-export const videoLoraFamily = (model) =>- (model?.runtime === 'ltx2' || isMlxVideoLtxLoraCapable(model))- ? VIDEO_LORA_FAMILIES.LTX_VIDEO- : null;+export const videoLoraFamily = (model) => {+ if (model?.runtime === 'ltx2' || isMlxVideoLtxLoraCapable(model)) return VIDEO_LORA_FAMILIES.LTX_VIDEO;+ if (model?.runtime === 'minimax_h3' && model?.runtimeLoraCapable === true) return VIDEO_LORA_FAMILIES.MINIMAX_H3;+ return null;+};// FLUX.2 Klein ships in two sizes with different transformer hidden dims (4B =// 3072, 9B = 4096), so a LoRA trained for one can't load on the other. Thediff --git a/client/src/lib/runnerFamilies.test.js b/client/src/lib/runnerFamilies.test.jsindex 7dd6841c7d..c732b4d139 100644--- a/client/src/lib/runnerFamilies.test.js+++ b/client/src/lib/runnerFamilies.test.js@@ -1,5 +1,8 @@import { describe, it, expect } from 'vitest';-import { RUNNER_FAMILIES, flux2VariantFromModel, loraCompatKey, composeCompatKey } from './runnerFamilies';+import {+ RUNNER_FAMILIES, VIDEO_LORA_FAMILIES, flux2VariantFromModel, isVideoLoraFamily,+ loraCompatKey, composeCompatKey, loraFamilyOf, videoLoraFamily,+} from './runnerFamilies';// This is the client mirror of server/lib/runners.js. The server suite greps// this file for the helper *names*; these tests pin their *behavior* so the@@ -32,4 +35,29 @@ describe('runnerFamilies mirror', () => {expect(composeCompatKey('mflux', '4b')).toBe('mflux');expect(composeCompatKey(null, null)).toBe(null);});++ // The picker is driven entirely by this function, so a mirror drift here+ // shows the user a LoRA control the server would then 400 on.+ it('videoLoraFamily gates minimax_h3 on the server-decorated runtime capability', () => {+ expect(videoLoraFamily({ runtime: 'ltx2' })).toBe(VIDEO_LORA_FAMILIES.LTX_VIDEO);+ expect(videoLoraFamily({ runtime: 'minimax_h3', runtimeLoraCapable: true })).toBe(VIDEO_LORA_FAMILIES.MINIMAX_H3);+ expect(videoLoraFamily({ runtime: 'minimax_h3', runtimeLoraCapable: false })).toBe(null);+ // undecorated payload (server older than this client) must fail closed+ expect(videoLoraFamily({ runtime: 'minimax_h3' })).toBe(null);+ expect(videoLoraFamily({ runtime: 'wan22', runtimeLoraCapable: true })).toBe(null);+ });++ it('loraFamilyOf prefers the refined compat key over the legacy coarse field', () => {+ expect(loraFamilyOf({ loraCompatKey: 'flux2-9b', runnerFamily: 'flux2' })).toBe('flux2-9b');+ expect(loraFamilyOf({ runnerFamily: 'ltx-video' })).toBe('ltx-video');+ expect(loraFamilyOf({})).toBe(null);+ expect(loraFamilyOf(null)).toBe(null);+ });++ it('treats both video families as video, so an H3 LoRA deep-links to Video Gen', () => {+ expect(isVideoLoraFamily(VIDEO_LORA_FAMILIES.MINIMAX_H3)).toBe(true);+ expect(isVideoLoraFamily(VIDEO_LORA_FAMILIES.LTX_VIDEO)).toBe(true);+ expect(isVideoLoraFamily(RUNNER_FAMILIES.FLUX2)).toBe(false);+ expect(isVideoLoraFamily(null)).toBe(false);+ });});diff --git a/client/src/pages/Loras.jsx b/client/src/pages/Loras.jsxindex cafd02e2c8..99e8035fce 100644--- a/client/src/pages/Loras.jsx+++ b/client/src/pages/Loras.jsx@@ -40,6 +40,7 @@ const RUNNER_LABEL = {[RUNNER_FAMILIES.HIDREAM]: 'HiDream',[RUNNER_FAMILIES.QWEN]: 'Qwen',[VIDEO_LORA_FAMILIES.LTX_VIDEO]: 'LTX-Video',+ [VIDEO_LORA_FAMILIES.MINIMAX_H3]: 'MiniMax H3',};const RUNNER_BADGE_CLASS = {[RUNNER_FAMILIES.MFLUX]: 'bg-port-accent/20 text-port-accent border-port-accent/30',@@ -49,6 +50,7 @@ const RUNNER_BADGE_CLASS = {[RUNNER_FAMILIES.HIDREAM]: 'bg-rose-600/20 text-rose-300 border-rose-500/30',[RUNNER_FAMILIES.QWEN]: 'bg-sky-600/20 text-sky-300 border-sky-500/30',[VIDEO_LORA_FAMILIES.LTX_VIDEO]: 'bg-fuchsia-600/20 text-fuchsia-300 border-fuchsia-500/30',+ [VIDEO_LORA_FAMILIES.MINIMAX_H3]: 'bg-teal-600/20 text-teal-300 border-teal-500/30',};// Image/Video filter applied to BOTH the suggestion panel and the installed@@ -1089,9 +1091,9 @@ function LoraCard({ lora, onDelete, deleting, deleteConfirm }) {const civitai = lora.civitai;// The gen pages read ?lora=<filename> as a preselect hint via query string;// keeps the manager → gen handoff URL-driven (deep-linkable). Video-family- // LoRAs (ltx-video) deep-link to Video Gen — routing them to Image Gen would- // preselect an LTX adapter into an incompatible image render.- const isVideoLora = family === VIDEO_LORA_FAMILIES.LTX_VIDEO;+ // LoRAs (ltx-video, minimax-h3) deep-link to Video Gen — routing them to Image+ // Gen would preselect a video adapter into an incompatible image render.+ const isVideoLora = isVideoLoraFamily(family);const testHref = `${isVideoLora ? '/media/video' : '/media/image'}?lora=${encodeURIComponent(lora.filename)}`;// The confirm pair also stays mounted while the delete is in flight (the hook// disarms the moment it fires), so the spinner replaces the row rather thandiff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 73fe1f1955..dc3d74c154 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -145,7 +145,7 @@ export default function VideoGen() {mode, handleModeChange,prompt, setPrompt, negativePrompt, setNegativePrompt, stylePreset, setStylePreset,modelId, handleModelChange, currentModel, visibleModels,- loraFamily, videoLoras, installedVideoLoras, showLtxLoraUnsupportedHint,+ loraFamily, videoLoras, loraUnavailableHint,selectedLoras, setSelectedLoras,width, height, handleResolutionChange,numFrames, setNumFrames, fps, setFps, chunks, setChunks,@@ -1073,9 +1073,13 @@ export default function VideoGen() {{/* LTX model that can't fuse LoRAs (quantized mlx_video — q4/q8) withcompatible LoRAs on disk: explain the absence instead of hidingsilently, and point at the models that CAN run them. */}- {showLtxLoraUnsupportedHint && (+ {loraUnavailableHint && (<div className="col-span-2 sm:col-span-3 rounded-lg border border-port-warning/40 bg-port-warning/10 px-3 py-2 text-xs text-port-warning leading-snug">- You have {installedVideoLoras.length} LTX video LoRA{installedVideoLoras.length === 1 ? '' : 's'} installed, but <strong className="font-semibold">{currentModel?.name}</strong> can't fuse LoRAs (its quantized <code>mlx_video</code> runtime isn't supported yet). Switch to the <strong className="font-semibold">LTX-2.3 Unified Beta</strong> (bf16) or an <strong className="font-semibold">LTX-2.3 dgrauet (Q4/Q8)</strong> model to use them.+ {loraUnavailableHint.kind === 'ltx' ? (+ <>You have {loraUnavailableHint.count} LTX video LoRA{loraUnavailableHint.count === 1 ? '' : 's'} installed, but <strong className="font-semibold">{currentModel?.name}</strong> can't fuse LoRAs (its quantized <code>mlx_video</code> runtime isn't supported yet). Switch to the <strong className="font-semibold">LTX-2.3 Unified Beta</strong> (bf16) or an <strong className="font-semibold">LTX-2.3 dgrauet (Q4/Q8)</strong> model to use them.</>+ ) : (+ <>You have {loraUnavailableHint.count} MiniMax H3 LoRA{loraUnavailableHint.count === 1 ? '' : 's'} installed, but the installed H3 runtime can't apply them — its DiT is quantized, so LoRAs need a runner that applies them at render time from quantization metadata. Upgrade the <strong className="font-semibold">MiniMax H3</strong> runtime from the model setup panel once a build that supports it is pinned.</>+ )}</div>)}diff --git a/scripts/generate_minimax_h3.py b/scripts/generate_minimax_h3.pyindex ff43dd4fb8..b913f60588 100644--- a/scripts/generate_minimax_h3.py+++ b/scripts/generate_minimax_h3.py@@ -55,6 +55,10 @@ def parse_args() -> argparse.Namespace:help="keyframe conditioning image (repeatable, max 2)")parser.add_argument("--anchor", action="append", default=[], choices=["first", "last"],help="latent anchor for each --image, in the same order")+ parser.add_argument("--lora", action="append", default=[],+ help="user LoRA safetensors applied at runtime (repeatable)")+ parser.add_argument("--lora-scale", action="append", type=float, default=[],+ help="strength for each --lora, in the same order")parser.add_argument("--output", required=True)return parser.parse_args()@@ -205,6 +209,14 @@ def validate_args(args: argparse.Namespace) -> None:# anchor would silently overwrite one keyframe's position with another's.if len(set(args.anchor)) != len(args.anchor):raise SystemExit(f"MiniMax H3 anchors must be distinct; got {args.anchor}.")+ if len(args.lora_scale) != len(args.lora):+ raise SystemExit(+ f"MiniMax H3 needs one --lora-scale per --lora; got {len(args.lora)} LoRAs "+ f"and {len(args.lora_scale)} scales."+ )+ for path in args.lora:+ if not Path(path).is_file():+ raise SystemExit(f"LoRA file is missing: {path}")def load_keyframes(paths: list[str]) -> list:@@ -287,6 +299,21 @@ def main() -> int:load_vision=bool(images),)+ # Runtime LoRA application — never a fuse. The DiT is quantized, so the+ # applicator has to take each layer's logical dims from the quantization+ # metadata (packed-uint32 storage shapes match no LoRA) and add the deltas+ # during the forward pass. PortOS only ever passes --lora when its capability+ # probe has already confirmed this module exists, so an ImportError here is a+ # real contract violation and should surface, not be swallowed.+ if args.lora:+ print("STAGE:apply-loras", file=sys.stderr, flush=True)+ from minimax_h3_mlx.lora import apply_loras++ apply_loras(+ pipe.transformer,+ [{"path": p, "scale": s} for p, s in zip(args.lora, args.lora_scale)],+ )+print("STAGE:inference", file=sys.stderr, flush=True)progress = ProgressWriter()with heartbeat("minimax-h3-inference"), redirect_stdout(progress):diff --git a/scripts/generate_minimax_h3.test.js b/scripts/generate_minimax_h3.test.jsindex 5f6efd16e1..ed6642914e 100644--- a/scripts/generate_minimax_h3.test.js+++ b/scripts/generate_minimax_h3.test.js@@ -73,7 +73,7 @@ describe('generate_minimax_h3.py', () => {it('rejects zero dimensions at the execution boundary', () => {const output = runPython(`${importRunner}\n${['from types import SimpleNamespace',- 'args = SimpleNamespace(fps=24, width=0, height=320, num_frames=124, steps=8, image=[], anchor=[])',+ 'args = SimpleNamespace(fps=24, width=0, height=320, num_frames=124, steps=8, lora=[], lora_scale=[], image=[], anchor=[])','try:',' runner.validate_args(args)','except SystemExit as exc:',@@ -92,7 +92,7 @@ describe('generate_minimax_h3.py', () => {])('rejects mismatched keyframe anchors (%j / %j)', (images, anchors, pattern) => {const output = runPython(`${importRunner}\n${['from types import SimpleNamespace',- `args = SimpleNamespace(fps=24, width=512, height=320, num_frames=124, steps=8, image=${JSON.stringify(images)}, anchor=${JSON.stringify(anchors)})`,+ `args = SimpleNamespace(fps=24, width=512, height=320, num_frames=124, steps=8, lora=[], lora_scale=[], image=${JSON.stringify(images)}, anchor=${JSON.stringify(anchors)})`,'try:',' runner.validate_args(args)','except SystemExit as exc:',@@ -106,13 +106,33 @@ describe('generate_minimax_h3.py', () => {it('accepts a paired first/last keyframe request', () => {const output = runPython(`${importRunner}\n${['from types import SimpleNamespace',- 'args = SimpleNamespace(fps=24, width=512, height=320, num_frames=124, steps=8, image=["a.png", "b.png"], anchor=["first", "last"])',+ 'args = SimpleNamespace(fps=24, width=512, height=320, num_frames=124, steps=8, lora=[], lora_scale=[], image=["a.png", "b.png"], anchor=["first", "last"])','runner.validate_args(args)','print("ok")',].join('\n')}`);expect(output.trim()).toBe('ok');});+ // An unpaired --lora/--lora-scale would apply the wrong strength (or none) to+ // an adapter, and a missing file would only surface after the ~83 GB load.+ it.each([+ [['a.safetensors'], [], /one --lora-scale per --lora/i],+ [['a.safetensors', 'b.safetensors'], [0.8], /one --lora-scale per --lora/i],+ [['/nonexistent/a.safetensors'], [0.8], /LoRA file is missing/i],+ ])('rejects mismatched or missing LoRA arguments (%j / %j)', (loras, scales, pattern) => {+ const output = runPython(`${importRunner}\n${[+ 'from types import SimpleNamespace',+ `args = SimpleNamespace(fps=24, width=512, height=320, num_frames=124, steps=8, image=[], anchor=[], lora=${JSON.stringify(loras)}, lora_scale=${JSON.stringify(scales)})`,+ 'try:',+ ' runner.validate_args(args)',+ 'except SystemExit as exc:',+ ' print(str(exc))',+ 'else:',+ ' raise SystemExit("bad LoRA args were accepted")',+ ].join('\n')}`);+ expect(output).toMatch(pattern);+ });+// Reading the keyframes happens before the ~83 GB load, so a bad path costs// a second rather than an hour. Both branches asserted here run WITHOUT// Pillow — CI's bare python3 has no PIL, and blocking `import PIL` on themdiff --git a/scripts/minimax_h3_lora_probe.py b/scripts/minimax_h3_lora_probe.pynew file mode 100644index 0000000000..d38409882f--- /dev/null+++ b/scripts/minimax_h3_lora_probe.py@@ -0,0 +1,48 @@+#!/usr/bin/env python3+"""Probe whether a pinned MiniMax H3 checkout can apply LoRAs at runtime.++H3's shipped DiT is quantized, so a LoRA can only be applied the way the+reference implementation does it: read each target layer's *logical* dimensions+from the quantization metadata (the packed-uint32 storage shapes never match a+LoRA's) and add the deltas during the forward pass, never fusing them into the+quantized weights.++PortOS does not implement that applicator — it consumes one. The contract is a+`minimax_h3_mlx.lora` module exposing a callable `apply_loras(transformer,+loras)`, where `loras` is a list of `{"path": str, "scale": float}` mappings.+Exit 0 means the installed checkout satisfies the contract and PortOS may offer+LoRAs on this runtime; any non-zero exit means it does not, and the render path+keeps rejecting them with a precise reason.++Kept separate from minimax_h3_runtime_probe.py so a runtime that is perfectly+healthy for plain renders is never marked unready just because it predates the+LoRA applicator.+"""++from __future__ import annotations++import importlib+import sys+from pathlib import Path++from _runner_common import register_source_namespace+++def main() -> int:+ if len(sys.argv) != 2:+ raise SystemExit("usage: minimax_h3_lora_probe.py <runtime-dir>")+ runtime_dir = Path(sys.argv[1]).resolve()+ package_dir = runtime_dir / "minimax_h3_mlx"+ if not (package_dir / "pipeline.py").is_file():+ raise RuntimeError(f"MiniMax H3 runtime source is missing under {runtime_dir}.")+ register_source_namespace("minimax_h3_mlx", package_dir)+ lora = importlib.import_module("minimax_h3_mlx.lora")+ if not callable(getattr(lora, "apply_loras", None)):+ raise RuntimeError(+ "minimax_h3_mlx.lora does not expose a callable apply_loras(transformer, loras)."+ )+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/server/lib/huggingfaceLora.js b/server/lib/huggingfaceLora.jsindex 60111a829c..bc4bff7d3f 100644--- a/server/lib/huggingfaceLora.js+++ b/server/lib/huggingfaceLora.js@@ -183,15 +183,26 @@ export const modelClassificationBlob = ({ repo, model } = {}) => {export const LTX_VIDEO_RE = /\bltx[\s._-]?v?(?:ideo)?\b|\bltx[\s._-]?2/;export const looksLikeLtxVideo = (blob) => LTX_VIDEO_RE.test(blob) || /ltxvideo/.test(blob);+// `minimax h3` / `minimax-h3` / `MiniMaxAI/MiniMax-H3` all collapse to H3.+// Requires the `minimax` maker token so a bare "h3" (a common version suffix)+// can't mis-tag an unrelated adapter into a family whose runtime would reject+// its key layout at render time.+export const MINIMAX_H3_RE = /\bminimax[\s._-]?h[\s._-]?3\b/;+export const looksLikeMiniMaxH3 = (blob) => MINIMAX_H3_RE.test(blob);+// Detect the PortOS video-LoRA family for an HF repo. LTX-2 / LTX-Video LoRAs-// (fal, Lightricks) map to the `ltx-video` family — the only video family with-// a working runtime today. Looks at the repo id, HF tags, and the card's-// `base_model`. Returns a VIDEO_LORA_FAMILIES value or null (unrecognized →-// the installer surfaces a clear error rather than mis-tagging it).+// (fal, Lightricks) map to `ltx-video`; MiniMax H3 LoRAs map to `minimax-h3`,+// which only renders once the installed H3 runtime proves it can apply LoRAs to+// its quantized DiT (see services/videoGen/runtimes.js). Looks at the repo id,+// HF tags, and the card's `base_model`. Returns a VIDEO_LORA_FAMILIES value or+// null (unrecognized → the installer surfaces a clear error rather than+// mis-tagging it).export const detectVideoLoraFamily = ({ repo, model } = {}) => {- if (looksLikeLtxVideo(modelClassificationBlob({ repo, model }))) {- return VIDEO_LORA_FAMILIES.LTX_VIDEO;- }+ const blob = modelClassificationBlob({ repo, model });+ // H3 first: an H3 adapter card can name LTX among comparison models, and the+ // LTX pattern is the looser of the two.+ if (looksLikeMiniMaxH3(blob)) return VIDEO_LORA_FAMILIES.MINIMAX_H3;+ if (looksLikeLtxVideo(blob)) return VIDEO_LORA_FAMILIES.LTX_VIDEO;return null;};diff --git a/server/lib/huggingfaceLora.test.js b/server/lib/huggingfaceLora.test.jsindex 15e4b75a32..6ad6c746d0 100644--- a/server/lib/huggingfaceLora.test.js+++ b/server/lib/huggingfaceLora.test.js@@ -103,6 +103,23 @@ describe('detectVideoLoraFamily', () => {expect(detectVideoLoraFamily({ repo: 'someone/cool-lora', model: { cardData: { base_model: 'Lightricks/LTX-Video' } } })).toBe(VIDEO_LORA_FAMILIES.LTX_VIDEO);});+ it('classifies MiniMax H3 repos as minimax-h3', () => {+ expect(detectVideoLoraFamily({ repo: 'someone/minimax-h3-character-lora' })).toBe(VIDEO_LORA_FAMILIES.MINIMAX_H3);+ expect(detectVideoLoraFamily({ repo: 'someone/opaque', model: { cardData: { base_model: 'MiniMaxAI/MiniMax-H3' } } }))+ .toBe(VIDEO_LORA_FAMILIES.MINIMAX_H3);+ expect(detectVideoLoraFamily({ repo: 'someone/opaque', model: { tags: ['minimax h3', 'lora'] } }))+ .toBe(VIDEO_LORA_FAMILIES.MINIMAX_H3);+ });+ it('needs the minimax maker token — a bare "h3" version suffix must not mis-tag', () => {+ expect(detectVideoLoraFamily({ repo: 'someone/style-h3' })).toBe(null);+ expect(detectVideoLoraFamily({ repo: 'someone/h3-anime-lora', model: { tags: ['sdxl'] } })).toBe(null);+ });+ it('prefers H3 over LTX when an H3 card also name-drops LTX', () => {+ expect(detectVideoLoraFamily({+ repo: 'someone/minimax-h3-lora',+ model: { cardData: { base_model: 'MiniMaxAI/MiniMax-H3' }, tags: ['ltx-video'] },+ })).toBe(VIDEO_LORA_FAMILIES.MINIMAX_H3);+ });it('returns null for unrelated repos (e.g. an image SDXL LoRA)', () => {expect(detectVideoLoraFamily({ repo: 'someone/sdxl-anime-lora', model: { tags: ['sdxl'] } })).toBe(null);});diff --git a/server/lib/runners.js b/server/lib/runners.jsindex a84d7e4b4e..6bfa2d463c 100644--- a/server/lib/runners.js+++ b/server/lib/runners.js@@ -36,6 +36,7 @@ export const RUNNER_FAMILIES = Object.freeze({// `ltx-video` video model without any change there.export const VIDEO_LORA_FAMILIES = Object.freeze({LTX_VIDEO: 'ltx-video',+ MINIMAX_H3: 'minimax-h3',});// Predicate: is this LoRA family a video family (vs. an image RUNNER_FAMILIES@@ -46,6 +47,13 @@ export const VIDEO_LORA_FAMILIES = Object.freeze({const VIDEO_LORA_FAMILY_SET = new Set(Object.values(VIDEO_LORA_FAMILIES));export const isVideoLoraFamily = (family) => VIDEO_LORA_FAMILY_SET.has(family);+// The family an INSTALLED LoRA belongs to. `loraCompatKey` is the refined key+// (e.g. flux2-9b) written by the importer; `runnerFamily` is the coarse legacy+// field a pre-sidecar install may be the only thing carrying. One helper so the+// `||` fallback can't drift between the pickers, the family filters, and the+// deep-link handoff. Mirrored to client/src/lib/runnerFamilies.js.+export const loraFamilyOf = (lora) => lora?.loraCompatKey || lora?.runnerFamily || null;+// A LoRA-quantization marker (`q4` / `q8`) in a model's id/repo/name. Anchored// on a leading boundary (so it doesn't match inside `seq4uence`) and a trailing// non-digit lookahead, which catches both delimited (`-q4`, `q8_0`) AND suffixed@@ -77,12 +85,20 @@ export const isMlxVideoLtxLoraCapable = (model) => {// - notapalindrome's `mlx_video` on a non-quantized LTX-2.x model — fused// offline into the transformer weights (see isMlxVideoLtxLoraCapable +// scripts/generate_av_lora.py).+// - `minimax_h3`, but ONLY when the installed runner can apply LoRAs to the+// quantized DiT at runtime. That is a property of the pinned checkout, not+// of the model entry, so it can't be derived here: listVideoModels()+// decorates each model with `runtimeLoraCapable` from the probe in+// services/videoGen/runtimes.js and this reads it off the payload (the same+// shape as `lastFrameAnchored`). An undecorated model therefore reads as+// "not capable" — the gate fails closed.// The wan22 / hunyuan runtimes (and quantized mlx_video models) have no LoRA// path, so they return null ("no LoRA support") and the VideoGen picker hides.-export const videoLoraFamily = (model) =>- (model?.runtime === 'ltx2' || isMlxVideoLtxLoraCapable(model))- ? VIDEO_LORA_FAMILIES.LTX_VIDEO- : null;+export const videoLoraFamily = (model) => {+ if (model?.runtime === 'ltx2' || isMlxVideoLtxLoraCapable(model)) return VIDEO_LORA_FAMILIES.LTX_VIDEO;+ if (model?.runtime === 'minimax_h3' && model?.runtimeLoraCapable === true) return VIDEO_LORA_FAMILIES.MINIMAX_H3;+ return null;+};// Convenience predicate helpers — match the semantics of the existing// `isFlux2()` / `isZImage()` / `isErnie()` exports in `mediaModels.js`diff --git a/server/lib/runners.test.js b/server/lib/runners.test.jsindex 5230cb5017..8b52956d09 100644--- a/server/lib/runners.test.js+++ b/server/lib/runners.test.js@@ -3,7 +3,7 @@ import { readFileSync } from 'fs';import { dirname, join } from 'path';import { fileURLToPath } from 'url';-import { RUNNER_FAMILIES, VIDEO_LORA_FAMILIES, videoLoraFamily, isMlxVideoLtxLoraCapable, isMflux, isFlux2, isZImage, isErnie, isHiDream, isQwen, flux2VariantFromModel, loraCompatKey, composeCompatKey } from './runners.js';+import { RUNNER_FAMILIES, VIDEO_LORA_FAMILIES, videoLoraFamily, isMlxVideoLtxLoraCapable, loraFamilyOf, isMflux, isFlux2, isZImage, isErnie, isHiDream, isQwen, flux2VariantFromModel, loraCompatKey, composeCompatKey } from './runners.js';const __dirname_self = dirname(fileURLToPath(import.meta.url));const CLIENT_MIRROR_PATH = join(__dirname_self, '..', '..', 'client', 'src', 'lib', 'runnerFamilies.js');@@ -50,11 +50,27 @@ describe('RUNNER_FAMILIES', () => {});describe('VIDEO_LORA_FAMILIES / videoLoraFamily', () => {- it('exports the canonical ltx-video family id, frozen', () => {+ it('exports the canonical video family ids, frozen', () => {expect(VIDEO_LORA_FAMILIES.LTX_VIDEO).toBe('ltx-video');+ expect(VIDEO_LORA_FAMILIES.MINIMAX_H3).toBe('minimax-h3');expect(Object.isFrozen(VIDEO_LORA_FAMILIES)).toBe(true);});+ // H3's quantized DiT can only take LoRAs if the INSTALLED runner applies them+ // at runtime, which no model field can express — listVideoModels() decorates+ // the probe result as `runtimeLoraCapable` and this reads it. Anything short of+ // a literal `true` must read as not capable so the gate fails closed.+ it('maps minimax_h3 to a family only when the runtime probe proved it capable', () => {+ expect(videoLoraFamily({ runtime: 'minimax_h3', runtimeLoraCapable: true })).toBe('minimax-h3');+ expect(videoLoraFamily({ runtime: 'minimax_h3', runtimeLoraCapable: false })).toBe(null);+ // undecorated payload (older peer, unprobed cache) → closed+ expect(videoLoraFamily({ runtime: 'minimax_h3' })).toBe(null);+ // truthy-but-not-true must not open the gate+ expect(videoLoraFamily({ runtime: 'minimax_h3', runtimeLoraCapable: 'yes' })).toBe(null);+ // the flag alone never grants a family to a runtime with no LoRA path+ expect(videoLoraFamily({ runtime: 'wan22', runtimeLoraCapable: true })).toBe(null);+ });+it('maps the ltx2 runtime + non-quantized LTX-2.x mlx_video models to a LoRA family', () => {expect(videoLoraFamily({ runtime: 'ltx2' })).toBe('ltx-video');// bare mlx_video (no LTX-2.x identity) stays null@@ -91,6 +107,14 @@ describe('VIDEO_LORA_FAMILIES / videoLoraFamily', () => {expect(isMlxVideoLtxLoraCapable(null)).toBe(false);});+ it('loraFamilyOf prefers the refined compat key over the legacy coarse field', () => {+ expect(loraFamilyOf({ loraCompatKey: 'flux2-9b', runnerFamily: 'flux2' })).toBe('flux2-9b');+ // pre-sidecar install: only the coarse field survives+ expect(loraFamilyOf({ runnerFamily: 'ltx-video' })).toBe('ltx-video');+ expect(loraFamilyOf({})).toBe(null);+ expect(loraFamilyOf(null)).toBe(null);+ });+it('composeCompatKey leaves the ltx-video family bare (no variant)', () => {expect(composeCompatKey('ltx-video', null)).toBe('ltx-video');expect(composeCompatKey('ltx-video', '9b')).toBe('ltx-video');@@ -99,8 +123,11 @@ describe('VIDEO_LORA_FAMILIES / videoLoraFamily', () => {it('client mirror carries the video family + helpers', () => {const text = readFileSync(CLIENT_MIRROR_PATH, 'utf-8');expect(text).toMatch(/LTX_VIDEO:\s*'ltx-video'/);+ expect(text).toMatch(/MINIMAX_H3:\s*'minimax-h3'/);+ expect(text).toMatch(/runtimeLoraCapable === true/);expect(text).toMatch(/export const videoLoraFamily/);expect(text).toMatch(/export const isMlxVideoLtxLoraCapable/);+ expect(text).toMatch(/export const loraFamilyOf/);});});diff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex c8f467cb7e..22d23cf4c6 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -34,6 +34,7 @@ import {isByovRuntimeReady,isByovRuntimeCurrent,invalidateByovReadyCache,+ invalidateByovLoraCapabilityCache,invalidateRuntimeFingerprintCache,resolveRuntimeFingerprint,loadHistory,@@ -492,6 +493,7 @@ router.get('/setup/runtime-install', asyncHandler(async (req, res) => {// a stale "true" from before a deliberate cleanup. Same for the cached// runtime fingerprint — a reinstall can bump ltx/mlx/torch versions.invalidateByovReadyCache(info.id);+ invalidateByovLoraCapabilityCache(info.id);invalidateRuntimeFingerprintCache(info.id);const scriptPath = join(PATHS.root, 'scripts', 'setup-image-video.sh');diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.jsindex d8ea372f4b..50a6ab9ce5 100644--- a/server/routes/videoGen.test.js+++ b/server/routes/videoGen.test.js@@ -29,6 +29,17 @@ vi.mock('child_process', async (importOriginal) => ({spawn: installProcess.spawn,}));+// The enqueue gate resolves the runtime's LoRA capability for real (it is+// imported straight from the leaf so a mocked service can't fake it), which+// would spawn a venv python — and the suite's shared spawn mock reports every+// child as a clean exit, i.e. "capable". Pin the verdict explicitly so each+// test states the capability it is exercising.+const loraCapability = vi.hoisted(() => ({ capable: false }));+vi.mock('../services/videoGen/runtimes.js', async (importOriginal) => ({+ ...(await importOriginal()),+ resolveByovRuntimeLoraCapable: vi.fn(async (runtime) => runtime === 'minimax_h3' && loraCapability.capable),+}));+vi.mock('../services/settings.js', () => ({getSettings: vi.fn(async () => ({ imageGen: { local: { pythonPath: '/usr/bin/python3' } } })),updateSettingsWith: vi.fn(async (mutate) => mutate({ imageGen: { local: { pythonPath: '/usr/bin/python3' } } })),@@ -97,6 +108,7 @@ vi.mock('../services/videoGen/local.js', () => ({isByovRuntimeReady: vi.fn(async () => false),isByovRuntimeCurrent: vi.fn(async () => false),invalidateByovReadyCache: vi.fn(),+ invalidateByovLoraCapabilityCache: vi.fn(),invalidateRuntimeFingerprintCache: vi.fn(),// /status now surfaces a runtime block (host chip/os + per-runtime versions).// Mock returns a fixed shape so the status test can assert it's wired through.@@ -254,6 +266,7 @@ describe('isAudioMime', () => {describe('videoGen routes', () => {let app;beforeEach(() => {+ loraCapability.capable = false;app = express();app.use(express.json());app.use('/api/video-gen', videoGenRoutes);@@ -803,6 +816,55 @@ describe('videoGen routes', () => {expect(r.body.code).toBe('LORAS_REQUIRE_LTX2');});+ // H3 CAN take LoRAs — it's the pinned runner that can't apply them to the+ // quantized DiT. "Use an LTX-2.x model" would be wrong advice, so the+ // rejection carries its own code and reason.+ it('rejects LoRAs on an H3 model whose runtime has no applicator, with an H3-specific code', async () => {+ videoGenService.listVideoModels.mockReturnValueOnce([+ { id: 'minimax_h3_8bit', name: 'MiniMax H3', runtime: 'minimax_h3', defaultFrames: 141, frameOptions: [141], fpsOptions: [24], runtimeLoraCapable: false },+ ]);+ const r = await request(app).post('/api/video-gen/').send({+ prompt: 'clip',+ modelId: 'minimax_h3_8bit',+ loraFilenames: ['a.safetensors'],+ });+ expect(r.status).toBe(400);+ expect(r.body.code).toBe('MINIMAX_H3_LORA_UNSUPPORTED');+ });++ // The decoration is a SYNC cache read, so a capable install still reports+ // `runtimeLoraCapable: false` until the probe lands. The gate must resolve+ // it rather than trust that snapshot — otherwise the first LoRA render after+ // boot is refused and only succeeds on a retry.+ it('resolves the probe rather than trusting a cold decoration on the model payload', async () => {+ loraCapability.capable = true;+ videoGenService.listVideoModels.mockReturnValueOnce([+ { id: 'minimax_h3_8bit', name: 'MiniMax H3', runtime: 'minimax_h3', defaultFrames: 141, frameOptions: [141], fpsOptions: [24], runtimeLoraCapable: false },+ ]);+ const r = await request(app).post('/api/video-gen/').send({+ prompt: 'clip',+ modelId: 'minimax_h3_8bit',+ loraFilenames: ['a.safetensors'],+ });+ expect(r.status).toBe(200);+ });++ it('accepts LoRAs on an H3 model once the runtime probe proved it capable', async () => {+ loraCapability.capable = true;+ videoGenService.listVideoModels.mockReturnValueOnce([+ { id: 'minimax_h3_8bit', name: 'MiniMax H3', runtime: 'minimax_h3', defaultFrames: 141, frameOptions: [141], fpsOptions: [24], runtimeLoraCapable: true },+ ]);+ const r = await request(app).post('/api/video-gen/').send({+ prompt: 'clip',+ modelId: 'minimax_h3_8bit',+ loraFilenames: ['a.safetensors'],+ });+ expect(r.status).toBe(200);+ expect(mediaJobQueue.enqueueJob).toHaveBeenCalledWith(expect.objectContaining({+ params: expect.objectContaining({ loras: [{ filename: 'a.safetensors', scale: 1.0 }] }),+ }));+ });+it('strips path-traversal segments from sourceImageFile via basename + prefix-check', async () => {const r = await request(app).post('/api/video-gen/').send({prompt: 'a cat',diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.jsindex 39ef22f7c1..1d4ec61ce9 100644--- a/server/services/videoGen/local.js+++ b/server/services/videoGen/local.js@@ -40,7 +40,7 @@ import { inspectModelCache, findCachedRepoFile } from '../../lib/hfCache.js';import { safeChildProcessEnv } from '../../lib/processEnv.js';import { makeVideoGenLineHandler, finalizeGeneratedVideo, isWatchdogSuccess, describeSignalDeath, describeRenderConditioning, RENDER_INPUTS_VERSION } from './generateVideoHelpers.js';import { assertSafeLoraFilename, getLoraKeyLayout } from '../loras.js';-import { isMlxVideoLtxLoraCapable } from '../../lib/runners.js';+import { videoLoraFamily } from '../../lib/runners.js';import {isVideoModelTermsAccepted, acceptedVideoModelTerms, videoModelTermsGateId, videoModelTermsError,} from '../../lib/videoDisclosure.js';@@ -63,6 +63,9 @@ import {HUNYUAN_REPO_DIR,BYOV_RUNTIME_INFO,BYOV_VIDEO_RUNTIMES,+ byovRuntimeLoraCapable,+ resolveByovRuntimeLoraCapable,+ videoLoraUnsupportedError,modelAnchorsLastFrame,assertByovRuntimeInstalled,invalidateByovReadyCache,@@ -151,14 +154,24 @@ export const VIDEO_MODELS = Object.fromEntries(getVideoModels().map((m) => [m.id// Resolve a model by id from the LIVE registry (getVideoModels reads the// hot-reloadable cache), falling back to the boot snapshot. This is what the// render path uses so a runtime-added model resolves without a server restart.+// Attach the runtime capabilities a model entry can't express on its own:+// whether an FFLF last frame is a real anchor, and whether the *installed* BYOV+// runner can apply user LoRAs (H3's DiT is quantized, so that depends on the+// pinned checkout — see runtimes.js `loraProbeArgs`). Both are declared in+// runtimes.js and surfaced here so the Video Gen form and videoLoraFamily() read+// them off the model instead of keeping their own lists. Applied by BOTH model+// resolvers, so the render path and the API payload can never disagree about+// what a model supports.+const decorateVideoModel = (m) => (m ? {+ ...m,+ lastFrameAnchored: modelAnchorsLastFrame(m),+ runtimeLoraCapable: byovRuntimeLoraCapable(m.runtime),+} : m);+export const resolveVideoModel = (modelId) =>- getVideoModels().find((m) => m.id === modelId) || VIDEO_MODELS[modelId] || null;+ decorateVideoModel(getVideoModels().find((m) => m.id === modelId) || VIDEO_MODELS[modelId] || null);-// Decorated with the one runtime capability the client can't derive: whether an-// FFLF last frame is a real anchor. Declared in runtimes.js, surfaced here so-// the Video Gen form reads it off the model instead of keeping its own list.-export const listVideoModels = () => getVideoModels()- .map((m) => ({ ...m, lastFrameAnchored: modelAnchorsLastFrame(m) }));+export const listVideoModels = () => getVideoModels().map(decorateVideoModel);export const defaultVideoModelId = () => getDefaultVideoModelId();@@ -618,7 +631,7 @@ const buildWan22Args = ({ model, wanModelPath, wanRequiredWeights, prompt, negat// Build args for PipeNetwork's pinned MiniMax H3 MLX port. The helper resolves// only exact, already-cached HF revisions; every network download remains an// explicit Video Gen UI action guarded by the model's terms acknowledgement.-const buildMiniMaxH3Args = ({ model, prompt, negativePrompt, width, height, numFrames, fps, steps, seed, sourceImagePath, lastImagePath, keyframes, extendFromVideoPath, audioFilePath, audioStartSec, icReferencePaths, mode, tiling, disableAudio, outputPath }) => {+const buildMiniMaxH3Args = ({ model, prompt, negativePrompt, width, height, numFrames, fps, steps, seed, sourceImagePath, lastImagePath, keyframes, extendFromVideoPath, audioFilePath, audioStartSec, icReferencePaths, mode, tiling, disableAudio, outputPath, loras }) => {assertByovRuntimeInstalled('minimax_h3');assertRenderModeContract({model,@@ -697,6 +710,11 @@ const buildMiniMaxH3Args = ({ model, prompt, negativePrompt, width, height, numF// the canvas as the geometry anchor, so a first-frame image must lead.if (sourceImagePath) args.push('--image', sourceImagePath, '--anchor', 'first');if (lastImagePath) args.push('--image', lastImagePath, '--anchor', 'last');+ // Runtime (never fused) application — each --lora needs its own --lora-scale,+ // in the same order, mirroring the --image/--anchor pairing above. buildArgs+ // has already rejected LoRAs unless the probe proved this checkout can apply+ // them to the quantized DiT (see runtimes.js `loraProbeArgs`).+ for (const l of loras ?? []) args.push('--lora', l.path, '--lora-scale', String(l.strength));return { bin: MINIMAX_H3_VENV_PYTHON, args };};@@ -756,26 +774,29 @@ const buildArgs = ({ pythonPath, modelId, model, wanModelPath, wanRequiredWeight);}const hasLoras = Array.isArray(loras) && loras.length > 0;- // Defense-in-depth: LoRAs fuse only on ltx2 (handled above) or a non-quantized- // LTX-2.x mlx_video model (the wrapper below), and the wrapper path is- // macOS/mlx-only. The route already rejects other runtimes, but a non-route- // caller (test, queue replay) — or a Windows install with a hand-edited/synced- // mlx_video LTX-2.x entry — could reach here. Fail clearly rather than fall+ // Defense-in-depth: LoRAs run only where videoLoraFamily() says they can —+ // ltx2 (handled above), a non-quantized LTX-2.x mlx_video model (the wrapper+ // below), or a minimax_h3 checkout whose probe proved a quant-aware+ // applicator. All of those macOS/mlx-only. The route already rejects the rest,+ // but a non-route caller (test, queue replay) — or a Windows install with a+ // hand-edited/synced entry — could reach here. Fail clearly rather than fall// through to the IS_WIN generate_win.py branch below, which would silently drop// the LoRAs and produce a base render the user thinks is LoRA-styled.- if (hasLoras && (!isMlxVideoLtxLoraCapable(model) || IS_WIN)) {- throw new ServerError(- IS_WIN- ? `LoRA fusion runs through the macOS-only mlx_video path; model "${modelId}" can't fuse LoRAs on Windows.`- : `LoRAs aren't supported on this model. Model "${modelId}" runs on "${model.runtime || 'mlx_video'}".`,- { status: 400, code: 'LORAS_REQUIRE_LTX2' },- );+ // The same predicate the enqueue gate uses, off the same decorated model, so+ // the two can't disagree — and the reason text comes from one factory.+ if (hasLoras && (!videoLoraFamily(model) || IS_WIN)) {+ throw IS_WIN+ ? new ServerError(+ `LoRA fusion runs through the macOS-only mlx_video path; model "${modelId}" can't fuse LoRAs on Windows.`,+ { status: 400, code: 'LORAS_REQUIRE_LTX2' },+ )+ : videoLoraUnsupportedError(model, modelId);}if (model.runtime === 'wan22') {return buildWan22Args({ model, wanModelPath, wanRequiredWeights, prompt, negativePrompt, width, height, numFrames, fps, steps, guidance, seed, sourceImagePath, mode, outputPath });}if (model.runtime === 'minimax_h3') {- return buildMiniMaxH3Args({ model, prompt, negativePrompt, width, height, numFrames, fps, steps, seed, sourceImagePath, lastImagePath, keyframes, extendFromVideoPath, audioFilePath, audioStartSec, icReferencePaths, mode, tiling, disableAudio, outputPath });+ return buildMiniMaxH3Args({ model, prompt, negativePrompt, width, height, numFrames, fps, steps, seed, sourceImagePath, lastImagePath, keyframes, extendFromVideoPath, audioFilePath, audioStartSec, icReferencePaths, mode, tiling, disableAudio, outputPath, loras });}if (model.runtime === 'hunyuan') {return buildHunyuanArgs({ model, prompt, negativePrompt, width, height, numFrames, steps, guidance, seed, outputPath });@@ -981,6 +1002,10 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m// rejects LoRAs on non-ltx2 runtimes (the route also guards), so this is a// no-op there.const resolvedLoras = await resolveVideoLoras(loras);+ // Resolve the runtime's LoRA capability BEFORE buildArgs, which reads it+ // synchronously. Without this the render would hit a cold cache and reject a+ // LoRA the installed runner can actually apply (the sync read fails closed).+ if (resolvedLoras.length) await resolveByovRuntimeLoraCapable(model.runtime);// IC-LoRA remix: resolve the per-mode weight before any GPU work. A cached// weight resolves to the exact file inside the HF snapshot; an un-cached onediff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.jsindex a15cdf9faf..6619b7df52 100644--- a/server/services/videoGen/local.test.js+++ b/server/services/videoGen/local.test.js@@ -170,6 +170,17 @@ vi.mock('fs', () => ({statSync: vi.fn(() => ({ size: 1000 })),}));+// Whether the installed MiniMax H3 checkout can apply LoRAs to its quantized+// DiT. Really a spawned python probe; stubbed here so the render-path tests+// drive both verdicts without the shared child_process mock (which resolves+// every spawn successfully) silently reporting "capable".+const h3LoraState = vi.hoisted(() => ({ capable: false }));+vi.mock('./runtimes.js', async (importOriginal) => ({+ ...await importOriginal(),+ byovRuntimeLoraCapable: vi.fn((runtime) => runtime === 'minimax_h3' && h3LoraState.capable),+ resolveByovRuntimeLoraCapable: vi.fn(async (runtime) => runtime === 'minimax_h3' && h3LoraState.capable),+}));+// LoRA key-layout gate (resolveVideoLoras). `null` = undetermined, which is// the permissive default so the pre-existing LoRA-threading tests below still// reach the spawn path; the gate's own tests set a layout explicitly.@@ -2156,6 +2167,75 @@ describe('generateVideo — MiniMax H3 MLX contract', () => {});});+// H3's DiT is quantized, so LoRAs ride along only if the installed runner+// applies them at render time from quantization metadata. That is a property of+// the pinned checkout, so the verdict comes from a probe — and the render path+// must honor it in both directions rather than blanket-rejecting the runtime.+describe('MiniMax H3 user LoRAs', () => {+ const h3Render = (jobId) => generateVideo({+ jobId,+ modelId: 'minimax_h3_8bit',+ prompt: 'a fox watches the rain',+ width: 512, height: 320, numFrames: 141, fps: 24, mode: 'text',+ loras: [{ filename: 'fox.safetensors', scale: 0.8 }],+ });++ afterEach(() => { h3LoraState.capable = false; });++ it('rejects LoRAs with an H3-specific reason when the runner has no applicator', async () => {+ h3LoraState.capable = false;+ await expect(h3Render('h3-lora-blocked')).rejects.toMatchObject({+ code: 'MINIMAX_H3_LORA_UNSUPPORTED',+ status: 400,+ });+ });++ it('forwards each LoRA as a paired --lora/--lora-scale once the runner proves capable', async () => {+ h3LoraState.capable = true;+ const { spawnDetached } = await import('../../lib/detachedSpawn.js');+ const spawnMock = vi.mocked(spawnDetached);+ spawnMock.mockClear();++ await generateVideo({+ jobId: 'h3-lora-ok',+ modelId: 'minimax_h3_8bit',+ prompt: 'a fox watches the rain',+ width: 512, height: 320, numFrames: 141, fps: 24, mode: 'text',+ loras: [{ filename: 'fox.safetensors', scale: 0.8 }, { filename: 'rain.safetensors', scale: 0.5 }],+ });++ const [, args] = spawnMock.mock.calls.find(([, a]) => (+ Array.isArray(a) && a.some((arg) => String(arg).endsWith('/generate_minimax_h3.py'))+ ));+ expect(args.flatMap((arg, i) => (+ arg === '--lora' ? [[args[i + 1], args[i + 2] === '--lora-scale' ? args[i + 3] : 'UNPAIRED']] : []+ ))).toEqual([+ [expect.stringContaining('fox.safetensors'), '0.8'],+ [expect.stringContaining('rain.safetensors'), '0.5'],+ ]);+ });++ it('emits no LoRA argv on a plain H3 render', async () => {+ h3LoraState.capable = true;+ const { spawnDetached } = await import('../../lib/detachedSpawn.js');+ const spawnMock = vi.mocked(spawnDetached);+ spawnMock.mockClear();++ await generateVideo({+ jobId: 'h3-no-lora',+ modelId: 'minimax_h3_8bit',+ prompt: 'a fox watches the rain',+ width: 512, height: 320, numFrames: 141, fps: 24, mode: 'text',+ });++ const [, args] = spawnMock.mock.calls.find(([, a]) => (+ Array.isArray(a) && a.some((arg) => String(arg).endsWith('/generate_minimax_h3.py'))+ ));+ expect(args).not.toContain('--lora');+ expect(args).not.toContain('--lora-scale');+ });+});+describe('runtime fingerprint (/status)', () => {it('hostRuntimeFingerprint reports chip/os/platform/arch/node', async () => {const { hostRuntimeFingerprint } = await import('./local.js');diff --git a/server/services/videoGen/prepareParams.js b/server/services/videoGen/prepareParams.jsindex 4b43f24c7f..eb207933aa 100644--- a/server/services/videoGen/prepareParams.js+++ b/server/services/videoGen/prepareParams.js@@ -54,6 +54,7 @@ import {// Straight from the leaf, not through local.js: the suites that exercise this// module mock local.js wholesale, and a mocked rule table would assert nothing.import { videoModeContractError, videoChainUnsupportedError } from './modeContract.js';+import { resolveByovRuntimeLoraCapable, videoLoraUnsupportedError } from './runtimes.js';/*** Best-effort unlink of every multipart temp file the parser wrote before the@@ -792,15 +793,23 @@ async function resolvePreparedParams({// Video LoRAs fuse on two runtimes: dgrauet's `ltx2` (via the pipeline's// _pending_loras hook, see scripts/generate_ltx2.py) and non-quantized// LTX-2.x `mlx_video` models (merged offline by scripts/generate_av_lora.py).+ // `minimax_h3` applies them at runtime, but only if the installed checkout+ // implements a quant-aware applicator — listVideoModels() decorates that+ // probe result as `runtimeLoraCapable`, which videoLoraFamily() reads.// videoLoraFamily() returns null for everything else (wan22 / hunyuan /// quantized mlx_video) — reject up-front so a bad modelId can't enqueue a// doomed job that only fails in the worker.- if (loras && effectiveModel && !videoLoraFamily(effectiveModel)) {- await cleanupStaged();- throw new ServerError(- `LoRAs aren't supported on this model. Model "${effectiveModelId}" runs on "${effectiveModel.runtime || 'mlx_video'}" — use an LTX-2.x model (dgrauet ltx2, or the bf16 Unified Beta).`,- { status: 400, code: 'LORAS_REQUIRE_LTX2' },- );+ if (loras && effectiveModel) {+ // `runtimeLoraCapable` was decorated from a SYNC cache read, which is false+ // on a cold cache. Resolve the probe before rejecting, or the first LoRA+ // render after boot on a capable install would be refused and only heal on+ // retry. Re-derive the flag from the settled verdict rather than trusting+ // the snapshot the model list was built from.+ const runtimeLoraCapable = await resolveByovRuntimeLoraCapable(effectiveModel.runtime);+ if (!videoLoraFamily({ ...effectiveModel, runtimeLoraCapable })) {+ await cleanupStaged();+ throw videoLoraUnsupportedError(effectiveModel, effectiveModelId);+ }}// a2v and the IC remix modes both anchor a single render (audio track /diff --git a/server/services/videoGen/runtimes.js b/server/services/videoGen/runtimes.jsindex 6779b3a73d..4c4e6c083d 100644--- a/server/services/videoGen/runtimes.js+++ b/server/services/videoGen/runtimes.js@@ -16,6 +16,7 @@ import { homedir, cpus, type as osType, release as osRelease } from 'os';import { PATHS } from '../../lib/fileUtils.js';import { ServerError } from '../../lib/errorHandler.js';import { safeChildProcessEnv } from '../../lib/processEnv.js';+import { createSingleFlight } from '../../lib/singleFlight.js';// Path to the dgrauet/ltx-2-mlx venv populated by `INSTALL_LTX2=1// scripts/setup-image-video.sh`. Used when a model entry has@@ -37,6 +38,7 @@ export const WAN22_EXPECTED_REVISION = '2452f0c12edcc8886eebf15772205ce9c417a618export const MINIMAX_H3_VENV_PYTHON = join(homedir(), '.portos', 'minimax-h3-mlx', '.venv', 'bin', 'python3');export const MINIMAX_H3_HELPER_SCRIPT = join(PATHS.root, 'scripts', 'generate_minimax_h3.py');export const MINIMAX_H3_RUNTIME_PROBE_SCRIPT = join(PATHS.root, 'scripts', 'minimax_h3_runtime_probe.py');+export const MINIMAX_H3_LORA_PROBE_SCRIPT = join(PATHS.root, 'scripts', 'minimax_h3_lora_probe.py');export const MINIMAX_H3_REPO_DIR = join(homedir(), '.portos', 'minimax-h3-mlx');export const MINIMAX_H3_EXPECTED_REVISION = 'fcd9e9b79a1d6018d91ac477c0968de1fa067e49';@@ -84,6 +86,17 @@ export const BYOV_RUNTIME_INFO = Object.freeze({// registers only the source package namespace; it never prepends the whole// checkout, where an untracked root module could shadow a locked venv dep.probeArgs: [MINIMAX_H3_RUNTIME_PROBE_SCRIPT, MINIMAX_H3_REPO_DIR],+ // Separate, OPTIONAL capability probe: can this checkout apply LoRAs to the+ // quantized DiT at runtime? H3's shipped weights are 8-bit, so a LoRA can+ // only ride along if the runner reads logical layer dims from the+ // quantization metadata and adds deltas in the forward pass (fusing into+ // packed-uint32 weights is not possible). The pinned revision has no LoRA+ // code at all, so this probe fails today and LoRAs stay rejected with a+ // precise reason — advancing the pin to a revision that satisfies the+ // contract (see scripts/minimax_h3_lora_probe.py) opens the gate with no+ // code change here. Absence of this key means "runtime can never take+ // LoRAs", which is the correct answer for wan22 / hunyuan.+ loraProbeArgs: [MINIMAX_H3_LORA_PROBE_SCRIPT, MINIMAX_H3_REPO_DIR],fingerprintPackages: ['mlx', 'mlx-metal', 'mlx-vlm', 'transformers', 'huggingface-hub'],},hunyuan: {@@ -171,8 +184,16 @@ export async function isByovRuntimeReady(runtimeId) {// earlier successful probe.if (info.expectedRevision && !await isByovRuntimeCurrent(runtimeId)) return false;if (readyCache.get(runtimeId) === true) return true;- const probeOk = await new Promise((resolve) => {- const child = spawn(info.venvPython, info.probeArgs || ['-c', info.importProbe], {+ const probeOk = await runVenvProbe(info.venvPython, info.probeArgs || ['-c', info.importProbe]);+ if (probeOk) readyCache.set(runtimeId, true);+ return probeOk;+}++// Spawn one exit-code-only probe in a BYOV venv. Bounded (30s SIGKILL) so a+// wedged import can't pin a request open; any spawn/exit failure is `false`.+function runVenvProbe(venvPython, args) {+ return new Promise((resolve) => {+ const child = spawn(venvPython, args, {env: safeChildProcessEnv(),stdio: ['ignore', 'ignore', 'ignore'],});@@ -180,8 +201,73 @@ export async function isByovRuntimeReady(runtimeId) {child.on('close', (code) => { clearTimeout(timer); resolve(code === 0); });child.on('error', () => { clearTimeout(timer); resolve(false); });});- if (probeOk) readyCache.set(runtimeId, true);- return probeOk;+}++// Probed LoRA-capability verdicts per runtime. Booleans only — a missing entry+// is "never probed", which is deliberately NOT the same as a probed `false`:+// the sync accessor below must tell "we don't know yet" from "we asked and this+// runner can't". Both outcomes are cached once resolved (a checkout can't grow a+// LoRA applicator without a reinstall, and the install route invalidates); the+// concurrent-probe coalescing lives in the single-flight, not in this Map.+const loraCapabilityCache = new Map();+const loraProbeFlight = createSingleFlight();+export function invalidateByovLoraCapabilityCache(runtimeId) {+ if (runtimeId) loraCapabilityCache.delete(runtimeId); else loraCapabilityCache.clear();+}++// Authoritative (async) answer: may this runtime take user LoRAs? Runtimes with+// no `loraProbeArgs` can never take them. An installed-but-unprobed runtime runs+// the probe once; the result is cached for the life of the process. An+// uninstalled runtime is NOT cached, matching isByovRuntimeReady's policy that+// negatives stay re-checkable so a finished install reflects immediately.+export async function resolveByovRuntimeLoraCapable(runtimeId) {+ const info = BYOV_RUNTIME_INFO[runtimeId];+ if (!info?.loraProbeArgs) return false;+ const cached = loraCapabilityCache.get(runtimeId);+ if (cached !== undefined) return cached;+ if (!existsSync(info.venvPython)) return false;+ return loraProbeFlight.run(runtimeId, async () => {+ const capable = await runVenvProbe(info.venvPython, info.loraProbeArgs);+ loraCapabilityCache.set(runtimeId, capable);+ return capable;+ });+}++// Sync read of the same fact, for the sync paths that decorate model payloads+// (decorateVideoModel in local.js). Only a probed verdict counts — an unprobed+// runtime reads as "not capable", so the gate fails CLOSED and the UI never+// offers a LoRA control the render would then refuse. Warms the cache in the+// background so the next read reflects the truth; every path that REJECTS on+// this awaits resolveByovRuntimeLoraCapable() first, so it never decides on a+// cold read.+export function byovRuntimeLoraCapable(runtimeId) {+ const cached = loraCapabilityCache.get(runtimeId);+ if (cached !== undefined) return cached;+ // Skip the warm when the venv isn't there: resolve would return an uncached+ // `false` anyway, so this would allocate a promise per call, forever.+ const info = BYOV_RUNTIME_INFO[runtimeId];+ if (info?.loraProbeArgs && existsSync(info.venvPython)) {+ resolveByovRuntimeLoraCapable(runtimeId).catch(() => {});+ }+ return false;+}++// Single user-facing reason a video model can't take LoRAs. Lives here, beside+// the capability data it reads, so the enqueue gate (prepareParams) and the+// render gate (local.js buildArgs) can't drift into telling the user two+// different stories — and so a future probe-gated runtime adds one branch, not+// two more copies of a paragraph.+export function videoLoraUnsupportedError(model, modelId) {+ if (model?.runtime === 'minimax_h3') {+ return new ServerError(+ `The installed MiniMax H3 runtime cannot apply LoRAs. Model "${modelId}" has a quantized DiT, so LoRAs need a runner that applies them at render time from quantization metadata — the pinned checkout has no such applicator. Upgrade the H3 runtime from Video Gen once a build that supports it is pinned.`,+ { status: 400, code: 'MINIMAX_H3_LORA_UNSUPPORTED' },+ );+ }+ return new ServerError(+ `LoRAs aren't supported on this model. Model "${modelId}" runs on "${model?.runtime || 'mlx_video'}" — use an LTX-2.x model (dgrauet ltx2, or the bf16 Unified Beta).`,+ { status: 400, code: 'LORAS_REQUIRE_LTX2' },+ );}// Resolve a checkout's exact revision without trusting a mutable tag/branch.diff --git a/server/services/videoGen/runtimes.test.js b/server/services/videoGen/runtimes.test.jsindex 054625997c..18360b8f4b 100644--- a/server/services/videoGen/runtimes.test.js+++ b/server/services/videoGen/runtimes.test.js@@ -16,7 +16,9 @@ vi.mock('child_process', async (importOriginal) => ({}));import {- invalidateByovReadyCache, isByovRuntimeReady, isPinnedSourceStatusClean, modelAnchorsLastFrame,+ byovRuntimeLoraCapable, invalidateByovLoraCapabilityCache, invalidateByovReadyCache,+ isByovRuntimeReady, isPinnedSourceStatusClean, modelAnchorsLastFrame,+ resolveByovRuntimeLoraCapable,} from './runtimes.js';const REVISION = 'fcd9e9b79a1d6018d91ac477c0968de1fa067e49';@@ -32,8 +34,17 @@ const statusChild = (stdout) => {return child;};+// Exit-code-only probe child (no stdout), for the LoRA capability probe.+const exitChild = (code) => {+ const child = new EventEmitter();+ child.kill = vi.fn();+ queueMicrotask(() => child.emit('close', code));+ return child;+};+beforeEach(() => {invalidateByovReadyCache();+ invalidateByovLoraCapabilityCache();runtimeMocks.existsSync.mockReset().mockReturnValue(true);runtimeMocks.spawn.mockReset();});@@ -71,6 +82,66 @@ describe('isByovRuntimeReady', () => {});});+// H3's DiT is quantized, so whether a LoRA can ride along is a property of the+// installed checkout, not the model entry — hence a probe rather than a+// hardcoded predicate. The gate must fail CLOSED until that probe has answered.+describe('MiniMax H3 LoRA capability', () => {+ it('reports capable when the runner exposes a quant-aware applicator', async () => {+ runtimeMocks.spawn.mockImplementationOnce(() => exitChild(0));+ await expect(resolveByovRuntimeLoraCapable('minimax_h3')).resolves.toBe(true);+ expect(byovRuntimeLoraCapable('minimax_h3')).toBe(true);+ });++ it('reports not capable when the pinned checkout has no LoRA applicator', async () => {+ runtimeMocks.spawn.mockImplementationOnce(() => exitChild(1));+ await expect(resolveByovRuntimeLoraCapable('minimax_h3')).resolves.toBe(false);+ expect(byovRuntimeLoraCapable('minimax_h3')).toBe(false);+ });++ it('caches both outcomes so the probe runs once per process', async () => {+ runtimeMocks.spawn.mockImplementationOnce(() => exitChild(0));+ await resolveByovRuntimeLoraCapable('minimax_h3');+ await resolveByovRuntimeLoraCapable('minimax_h3');+ expect(runtimeMocks.spawn).toHaveBeenCalledTimes(1);+ });++ it('shares one in-flight probe across concurrent callers', async () => {+ runtimeMocks.spawn.mockImplementationOnce(() => exitChild(0));+ const [a, b] = await Promise.all([+ resolveByovRuntimeLoraCapable('minimax_h3'),+ resolveByovRuntimeLoraCapable('minimax_h3'),+ ]);+ expect([a, b]).toEqual([true, true]);+ expect(runtimeMocks.spawn).toHaveBeenCalledTimes(1);+ });++ it('does not cache a verdict for an uninstalled runtime', async () => {+ runtimeMocks.existsSync.mockReturnValue(false);+ await expect(resolveByovRuntimeLoraCapable('minimax_h3')).resolves.toBe(false);+ expect(runtimeMocks.spawn).not.toHaveBeenCalled();++ runtimeMocks.existsSync.mockReturnValue(true);+ runtimeMocks.spawn.mockImplementationOnce(() => exitChild(0));+ await expect(resolveByovRuntimeLoraCapable('minimax_h3')).resolves.toBe(true);+ });++ it('reads as not capable while the probe is still in flight, and warms the cache', async () => {+ runtimeMocks.spawn.mockImplementationOnce(() => exitChild(0));+ // Cold read: unknown must NOT be mistaken for a probed `true`.+ expect(byovRuntimeLoraCapable('minimax_h3')).toBe(false);+ // ...but it kicked off the probe, so the next read reflects the truth.+ await resolveByovRuntimeLoraCapable('minimax_h3');+ expect(byovRuntimeLoraCapable('minimax_h3')).toBe(true);+ expect(runtimeMocks.spawn).toHaveBeenCalledTimes(1);+ });++ it.each(['ltx2', 'wan22', 'hunyuan'])('never probes %s, which has no LoRA runtime path', async (runtime) => {+ await expect(resolveByovRuntimeLoraCapable(runtime)).resolves.toBe(false);+ expect(byovRuntimeLoraCapable(runtime)).toBe(false);+ expect(runtimeMocks.spawn).not.toHaveBeenCalled();+ });+});+// One declaration feeds three consumers: buildArgs (which forwards the last// frame), the last-image resize in local.js, and the client's advisory note via// the `lastFrameAnchored` field listVideoModels() decorates onto each model.