Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: make the LoRA effect timeout cache actually readable, and kill a wedged probe (#4872)
[._.]/ Adam Eivyca0e2509b403
diff --git a/server/lib/loraEffect.test.js b/server/lib/loraEffect.test.jsindex 5ff8d4c7a9..a3cd62af00 100644--- a/server/lib/loraEffect.test.js+++ b/server/lib/loraEffect.test.js@@ -131,6 +131,28 @@ describe('readCachedLoraEffectReport', () => {expect(readCachedLoraEffectReport(cached, {})).toBeNull();});+ it('round-trips a report that carries the current probe version', () => {+ // The read side of the cache, exercised end-to-end: whatever a writer+ // stamps must come back out. A report stamped with the WRONG version is+ // written and then never readable, which is a silently-dead cache rather+ // than an error — see the constructor in services/loraEffectProbe.js.+ const built = normalizeLoraEffectReport({+ probeVersion: LORA_EFFECT_PROBE_VERSION, status: 'unmeasurable', reason: 'ran out of budget',+ });+ const stored = normalizeLoraEffectReport(built, { sizeBytes: 4096, mtimeMs: 111, measuredAt: 'x' });+ expect(readCachedLoraEffectReport(stored, { sizeBytes: 4096, mtimeMs: 111 }))+ .toMatchObject({ status: 'unmeasurable', reason: 'ran out of budget' });+ });++ it('keeps an unstamped sidecar payload untrusted', () => {+ // An absent version means "written by something that didn't stamp it" — a+ // legacy or hand-edited sidecar. It must NOT be inferred as current.+ const unstamped = normalizeLoraEffectReport(+ { ...okPayload, probeVersion: undefined }, { sizeBytes: 4096, mtimeMs: 111 },+ );+ expect(readCachedLoraEffectReport(unstamped, { sizeBytes: 4096, mtimeMs: 111 })).toBeNull();+ });+it('returns null for a missing sidecar field rather than a hollow report', () => {expect(readCachedLoraEffectReport(undefined, onDisk)).toBeNull();});diff --git a/server/lib/pythonSetup.js b/server/lib/pythonSetup.jsindex c26a43a909..c9604b38f9 100644--- a/server/lib/pythonSetup.js+++ b/server/lib/pythonSetup.js@@ -538,9 +538,13 @@ export const HF_HUB_PYTHON_RESOLVERS = Object.freeze([// The LTX-2.x video venvs are deliberately NOT here — their paths are owned by// services/videoGen/runtimes.js, and lib/ must not import from services/. The// probe prepends them itself; this list is everything pythonSetup can see.+// NOTE the mflux entry resolves the venv PATH directly rather than going through+// `resolveMfluxPython`: that resolver answers "which interpreter can run+// mflux-train", so it returns null on an mflux install without the trainer+// package — an interpreter that has numpy and would have measured fine.export const NUMPY_PYTHON_RESOLVERS = Object.freeze([resolveFlux2Python,- resolveMfluxPython,+ () => MFLUX_VENV_DEFAULT,...HF_HUB_PYTHON_RESOLVERS,]);diff --git a/server/services/loraEffectProbe.js b/server/services/loraEffectProbe.jsindex 47c9beb68d..a71b703b11 100644--- a/server/services/loraEffectProbe.js+++ b/server/services/loraEffectProbe.js@@ -37,7 +37,9 @@ import { ServerError } from '../lib/errorHandler.js';import { createSingleFlight } from '../lib/singleFlight.js';import { runSidecarProcess, parseSidecarResult } from '../lib/sidecarProcess.js';import { withAbortTimeout } from '../lib/abortTimeout.js';+import { killWithEscalation } from '../lib/killWithEscalation.js';import {+ LORA_EFFECT_PROBE_VERSION,LORA_EFFECT_STATUSES,normalizeLoraEffectReport,readCachedLoraEffectReport,@@ -89,7 +91,19 @@ const probeInterpreterCandidates = async () => {return installedCandidates([await detectPython()]);};+const timeoutReport = () => unmeasurable(+ `the effect probe ran out of its ${PROBE_TIMEOUT_MS / 1000}s budget reading this adapter`,+);++// Stamped with the CURRENT probe version because we are BUILDING this report,+// not reading one: a locally-constructed verdict is current by definition.+// Without the stamp it normalizes to version 0, and caching a timeout becomes a+// silent no-op — the freshness check rejects its own freshly-written value, so+// the stall the cache exists to prevent repeats before every render. The shared+// normalizer deliberately does NOT infer this: an absent version in a SIDECAR+// means "written by something that didn't stamp it", which stays untrusted.const unmeasurable = (reason) => normalizeLoraEffectReport({+ probeVersion: LORA_EFFECT_PROBE_VERSION,status: LORA_EFFECT_STATUSES.UNMEASURABLE,reason,});@@ -112,12 +126,25 @@ const runProbeOnce = async (bin, filePath, budgetMs) => {// a diagnostic. withAbortTimeout owns the timer lifecycle and clears it on// both settle paths.let result;+ // runSidecarProcess's abort handler only SIGTERMs. A python child blocked in+ // an uninterruptible read (a network or iCloud-backed volume — exactly the+ // storage that makes this time out) never reaches its signal handler, so the+ // promise would never settle and the render would wait past its own timeout,+ // forever. Hold the handle and escalate to SIGKILL, as every other+ // runSidecarProcess caller does.+ let child = null;try {- result = await withAbortTimeout(budgetMs, (signal) => runSidecarProcess({- bin,- args: [LORA_EFFECT_PROBE_SCRIPT, filePath],- signal,- }));+ result = await withAbortTimeout(budgetMs, (signal) => {+ signal.addEventListener('abort', () => {+ if (child) killWithEscalation(child, { label: 'LoRA effect probe', stillRunning: () => true });+ }, { once: true });+ return runSidecarProcess({+ bin,+ args: [LORA_EFFECT_PROBE_SCRIPT, filePath],+ signal,+ onProcess: (proc) => { child = proc; },+ });+ });} catch (err) {return { report: unmeasurable(`the effect probe could not be started (${err?.message || err})`) };}@@ -131,10 +158,7 @@ const runProbeOnce = async (bin, filePath, budgetMs) => {const report = parsed ? normalizeLoraEffectReport(parsed) : null;if (report) return { report };if (result.canceled) {- return {- report: unmeasurable(`the effect probe ran out of its ${PROBE_TIMEOUT_MS / 1000}s budget reading this adapter`),- timedOut: true,- };+ return { report: timeoutReport(), timedOut: true };}return { report: unmeasurable(`the effect probe produced no result (${result.reason || 'no output'})`) };};@@ -157,13 +181,20 @@ const measureLoraEffect = async (filename, filePath, { sizeBytes, mtimeMs }) =>for (const bin of candidates) {const remaining = deadline - Date.now();if (remaining <= 0) { timedOut = true; break; }- ({ report: last, timedOut = false } = await runProbeOnce(bin, filePath, remaining));+ const attempt = await runProbeOnce(bin, filePath, remaining);+ last = attempt.report;+ timedOut = attempt.timedOut === true;// Only an unmeasurable verdict is worth another interpreter; every other// status is a real answer about the file and identical on any Python. A// timeout stops the walk outright — see runProbeOnce.if (timedOut || last.status !== LORA_EFFECT_STATUSES.UNMEASURABLE) break;}- if (last === null) last = unmeasurable(`the effect probe ran out of its ${PROBE_TIMEOUT_MS / 1000}s budget reading this adapter`);+ // The budget can also run out BETWEEN candidates, leaving `last` holding the+ // previous interpreter's verdict — very possibly "numpy is not installed",+ // which is about this machine and must never be cached. Rebuild the report+ // from the timeout so what gets stored describes what actually happened.+ if (timedOut) last = timeoutReport();+ if (last === null) last = timeoutReport();if (last.status === LORA_EFFECT_STATUSES.UNMEASURABLE) {console.log(`⚠️ LoRA effect probe unavailable for ${filename}: ${last.reason || 'unknown'}`);// A timeout is cached, unlike every other unmeasurable verdict. The othersdiff --git a/server/services/loraEffectProbe.test.js b/server/services/loraEffectProbe.test.jsindex dfe115b19e..345b3ca4f3 100644--- a/server/services/loraEffectProbe.test.js+++ b/server/services/loraEffectProbe.test.js@@ -212,15 +212,42 @@ describe('probeLoraEffect — never fatal, never a false verdict', () => {expect(report.status).toBe('unmeasurable');});- it('CACHES a timeout, so a pathologically slow adapter stalls one render and not every one', async () => {+ it('CACHES a timeout so the next render READS IT BACK instead of stalling again', async () => {// Unlike the other unmeasurable verdicts (which describe this machine's// Python and may fix themselves the moment a venv installs), a timeout// describes what reading THIS file costs on THIS storage — exactly what the// size+mtime key already scopes.+ //+ // Asserting the WRITE alone is vacuous: a report stamped with the wrong+ // probe version is written and then never read back, which is exactly how+ // this regressed once. Feed the stored value back through the cache.state.responses = [{ ok: false, canceled: true, reason: 'cancelled (SIGTERM)', stdout: '' }];await probeLoraEffect('style.safetensors');expect(state.patched).toHaveLength(1);- expect(state.patched[0].patch.effectReport).toMatchObject({ status: 'unmeasurable', sizeBytes: 4096 });+ const stored = state.patched[0].patch.effectReport;+ expect(stored).toMatchObject({ status: 'unmeasurable', sizeBytes: 4096 });++ state.sidecar = { effectReport: stored };+ state.runs = [];+ state.responses = [{ ok: true, stdout: resultLine(OK_PAYLOAD) }];+ const second = await probeLoraEffect('style.safetensors');+ expect(state.runs).toHaveLength(0);+ expect(second.status).toBe('unmeasurable');+ });++ it('never caches the previous candidate\'s verdict when the budget runs out between them', async () => {+ // The walk can end on budget exhaustion with `last` still holding a+ // machine-specific "numpy is not installed" — freezing that into the+ // sidecar would keep reporting unmeasurable long after the user installs a+ // runtime, because its probe version IS current.+ state.responses = [+ { ok: false, reason: 'exit 3', stdout: resultLine({ probeVersion: 1, status: 'unmeasurable', reason: 'numpy is not installed in this interpreter' }) },+ { ok: false, reason: 'exit 3', stdout: resultLine({ probeVersion: 1, status: 'unmeasurable', reason: 'numpy is not installed in this interpreter' }) },+ { ok: false, reason: 'exit 3', stdout: resultLine({ probeVersion: 1, status: 'unmeasurable', reason: 'numpy is not installed in this interpreter' }) },+ ];+ const report = await probeLoraEffect('style.safetensors');+ expect(report.reason).toMatch(/numpy/i);+ expect(state.patched).toHaveLength(0);});it('does NOT cache an unmeasurable that is only about this machine', async () => {