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
close the same cold LoRA-verdict read on the A1111 video-models endpoint
[._.]/ Adam Eivy40f97225d2dd
diff --git a/server/routes/sdapi.js b/server/routes/sdapi.jsindex bf76bab3d5..7518cb7ef8 100644--- a/server/routes/sdapi.js+++ b/server/routes/sdapi.js@@ -25,7 +25,7 @@ import { getSettings } from '../services/settings.js';import { generateImage, getMode, getActiveJob, IMAGE_GEN_MODE, CLOUD_IMAGE_GEN_MODES } from '../services/imageGen/index.js';import { local as localImage } from '../services/imageGen/index.js';import { createImageGenWaiter } from '../services/imageGenWaiter.js';-import { listVideoModels, defaultVideoModelId } from '../services/videoGen/local.js';+import { listVideoModels, defaultVideoModelId, warmByovLoraCapabilities } from '../services/videoGen/local.js';const router = Router();@@ -101,9 +101,15 @@ router.get('/samplers', (_req, res) => {// LTX models surfaced as a PortOS extension — clients that know about us can// list video options without hitting a separate endpoint.-router.get('/portos/video-models', (_req, res) => {+// Warmed for the same reason the Video Gen model routes are: each entry's+// `runtimeLoraCapable` is stamped from a sync accessor that reads an unprobed+// runtime as "not capable" (see warmByovLoraCapabilities in+// services/videoGen/runtimes.js). An external client has even less recourse+// than our own — it has no second surface to reconcile against.+router.get('/portos/video-models', asyncHandler(async (_req, res) => {+ await warmByovLoraCapabilities();res.json({ models: listVideoModels(), defaultModel: defaultVideoModelId() });-});+}));// Live progress — A1111 clients poll this every ~500ms while a generation is// running. The dispatcher's getActiveJob() surfaces the current generationdiff --git a/server/routes/sdapi.test.js b/server/routes/sdapi.test.jsindex 969d339431..8a50fca226 100644--- a/server/routes/sdapi.test.js+++ b/server/routes/sdapi.test.js@@ -26,6 +26,7 @@ vi.mock('../services/imageGenEvents.js', async () => {vi.mock('../services/videoGen/local.js', () => ({listVideoModels: vi.fn(() => []),defaultVideoModelId: vi.fn(() => 'ltx_video'),+ warmByovLoraCapabilities: vi.fn(async () => {}),}));vi.mock('../lib/fileUtils.js', () => ({@@ -37,6 +38,7 @@ import { getSettings } from '../services/settings.js';import * as imageGen from '../services/imageGen/index.js';import { imageGenEvents as realEmitter } from '../services/imageGenEvents.js';import { tryReadFile } from '../lib/fileUtils.js';+import * as videoGenService from '../services/videoGen/local.js';import sdapiRoutes from './sdapi.js';const enabled = () => getSettings.mockResolvedValue({ imageGen: { expose: { a1111: true } } });@@ -90,6 +92,30 @@ describe('sdapi routes — A1111-compatible surface', () => {});});+ describe('GET /portos/video-models', () => {+ // Every entry's `runtimeLoraCapable` is stamped from a sync accessor that+ // reads an unprobed runtime as "not capable" (see warmByovLoraCapabilities+ // in services/videoGen/runtimes.js). This surface has no second endpoint an+ // external client could reconcile against, so the list must not be built+ // until the warm has settled.+ it('builds the model list only after the LoRA warm has settled', async () => {+ enabled();+ let probed = false;+ videoGenService.warmByovLoraCapabilities.mockImplementationOnce(async () => {+ await new Promise((resolve) => { setImmediate(resolve); });+ probed = true;+ });+ videoGenService.listVideoModels.mockImplementationOnce(() => [{+ id: 'minimax_h3_8bit', runtime: 'minimax_h3', runtimeLoraCapable: probed,+ }]);++ const r = await request(app).get('/sdapi/v1/portos/video-models');+ expect(r.status).toBe(200);+ expect(r.body.models[0].runtimeLoraCapable).toBe(true);+ expect(r.body.defaultModel).toBe('ltx_video');+ });+ });+describe('GET /progress', () => {it('returns idle payload when no active job', async () => {enabled();diff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex 1d0354c0fd..aaba170327 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -93,15 +93,12 @@ import { isDisplaySleepEnabled } from '../services/videoGen/displayPower.js';const router = Router();const hardwareAwareVideoModels = async () => {- // Warm the LoRA-capability verdicts BEFORE decorating: listVideoModels()- // stamps each entry's `runtimeLoraCapable` from the sync accessor, which- // reads an unprobed runtime as "not capable". Serving that unprobed default- // is what made an install whose H3 runtime passes the probe show "this H3- // runtime did not pass PortOS's quantization-aware LoRA probe" until the page- // was reloaded — the client fetches this list once, so the background warm- // never reached it. Concurrent with the hardware probe (both cache for the- // process) so the first call after a restart is the only one that pays, and- // pays nothing extra in wall time.+ // Warm BEFORE decorating: listVideoModels() stamps each entry's+ // `runtimeLoraCapable` from a sync accessor that reads an unprobed runtime as+ // "not capable", and shipping that default is a bug the client cannot recover+ // from — see warmByovLoraCapabilities in services/videoGen/runtimes.js.+ // Joined to the hardware probe this function already awaits for the same+ // reason; both cache for the process, so only the first call pays.const [capabilities] = await Promise.all([detectSystemCapabilities(), warmByovLoraCapabilities()]);return {capabilities,diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.jsindex f2aad9cbf5..614d95554b 100644--- a/server/routes/videoGen.test.js+++ b/server/routes/videoGen.test.js@@ -649,18 +649,19 @@ describe('videoGen routes', () => {expect(checkPackages).not.toHaveBeenCalled();});- // Each model's `runtimeLoraCapable` is stamped from a SYNC accessor that- // reads a not-yet-probed runtime as "not capable" — the gate fails closed.- // That default is indistinguishable from a probed `false` once it is in the- // payload, and the client fetches this list ONCE: an install whose H3- // runtime passes the probe was told "this H3 runtime did not pass PortOS's- // quantization-aware LoRA probe" for the life of the page, because the- // background warm corrected the server and nothing corrected the client.- it('reports the probed LoRA verdict, not the pre-probe fail-closed default', async () => {+ // The payload's `runtimeLoraCapable` is only as good as the probe having+ // ANSWERED first — the reason is on warmByovLoraCapabilities in+ // services/videoGen/runtimes.js. Calling the warm is not enough: the list+ // must be built after it SETTLES, so the warm here resolves on a later tick+ // and a route that fired it without awaiting reads `probed` as false.+ it('builds the model list only after the LoRA warm has settled', async () => {let probed = false;- runtimeProbes.warmByovLoraCapabilities.mockImplementationOnce(async () => { probed = true; });+ runtimeProbes.warmByovLoraCapabilities.mockImplementationOnce(async () => {+ await new Promise((resolve) => { setImmediate(resolve); });+ probed = true;+ });// Stands in for decorateVideoModel, which stamps the sync read at the- // moment the list is built — so this is `false` unless the warm ran first.+ // moment the list is built.videoGenService.listVideoModels.mockImplementationOnce(() => [{id: 'minimax_h3_8bit', name: 'MiniMax H3 MLX 8-bit', runtime: 'minimax_h3',supportedModes: ['text'], runtimeLoraCapable: probed,diff --git a/server/services/videoGen/runtimes.js b/server/services/videoGen/runtimes.jsindex 999f6dae8f..26dea5e2b4 100644--- a/server/services/videoGen/runtimes.js+++ b/server/services/videoGen/runtimes.js@@ -563,17 +563,20 @@ export function byovRuntimeLoraCapable(runtimeId) {// the life of the page on an install where the probe passes.//// Cheap enough to await on a request path: the probe is a bare MLX import with-// no model load (tens of ms), and BOTH verdicts cache for the life of the-// process — so this is one spawn per server start, not the per-request python-// probe that /model-context exists to avoid. An uninstalled runtime spawns-// nothing; resolve short-circuits on the missing venv.+// no model load (tens of ms), and an INSTALLED runtime's verdict caches either+// way for the life of the process — so this is one spawn per server start, not+// the per-request python probe that /model-context exists to avoid. Its worst+// case is runVenvProbe's 30s SIGKILL ceiling, paid once by whichever request+// warms a wedged interpreter. Runtimes that declare no `loraProbeArgs`, and+// installed-but-absent venvs, are answered without a child at all — resolve+// short-circuits on both before it reaches the probe.export async function warmByovLoraCapabilities() {+ // No `loraProbeArgs` filter here: resolve owns that predicate and returns+ // early on it, so re-encoding the gate would only give it a second home.+ // `.catch` because this runs on a request path where a future throw must not+ // take the whole model-list response down with it — the values are discarded.await Promise.all(Object.keys(BYOV_RUNTIME_INFO)- .filter((runtimeId) => BYOV_RUNTIME_INFO[runtimeId].loraProbeArgs)- // resolve never rejects today (runVenvProbe resolves every outcome), but- // this runs on a request path where a future throw must not take the whole- // model-list response down with it.- .map((runtimeId) => resolveByovRuntimeLoraCapable(runtimeId).catch(() => false)));+ .map((runtimeId) => resolveByovRuntimeLoraCapable(runtimeId).catch(() => {})));}// Single user-facing reason a video model can't take LoRAs. Lives here, besidediff --git a/server/services/videoGen/runtimes.test.js b/server/services/videoGen/runtimes.test.jsindex 8497a26f76..59fa58ac48 100644--- a/server/services/videoGen/runtimes.test.js+++ b/server/services/videoGen/runtimes.test.js@@ -284,14 +284,12 @@ describe('MiniMax H3 LoRA capability', () => {});// What the model-list route awaits so its payload never ships the cold read- // above as if it were a probed verdict.- it('makes the sync accessor authoritative, probing only the LoRA-gated runtimes', async () => {+ // above as if it were a probed verdict. The route's own suite doubles this+ // function, so its fan-out over the runtime table is only checked here.+ it('makes the sync accessor authoritative once it resolves', async () => {runtimeMocks.spawn.mockImplementationOnce(() => exitChild(0));await warmByovLoraCapabilities();expect(byovRuntimeLoraCapable('minimax_h3')).toBe(true);- // One spawn, not one per BYOV runtime: everything else declares no- // loraProbeArgs, which resolve answers without a child.- expect(runtimeMocks.spawn).toHaveBeenCalledTimes(1);});it.each(['ltx2', 'ltx25', 'wan22'])('never probes %s, which has no LoRA runtime path', async (runtime) => {