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 (ollama): fail-safe memory gate on non-finite budget + harden vm_stat parse
[._.]/ Adam Eivy9e8b423f9f05
diff --git a/server/services/loraTraining/index.js b/server/services/loraTraining/index.jsindex aa8e8c6a48..254de1584b 100644--- a/server/services/loraTraining/index.js+++ b/server/services/loraTraining/index.js@@ -386,7 +386,9 @@ export async function runTraining({ jobId, runId, pythonPath = null, resumeCheckconsole.log(`🧹 training [${shortId(jobId)}] freed ${memReport.unloaded.length} resident model(s): ${memReport.unloaded.join(', ')}`);}console.log(`🧮 training [${shortId(jobId)}] memory budget ${memReport.budgetGb.toFixed(0)} GB free of ${memReport.totalGb.toFixed(0)} GB total`);- if (memReport.budgetGb < TRAINING_MIN_HEADROOM_GB) {+ if (!Number.isFinite(memReport.budgetGb) || memReport.budgetGb < TRAINING_MIN_HEADROOM_GB) {+ // Fail safe: a non-finite budget (should never happen — both inputs are+ // finite) must REFUSE the run, not slip past `NaN < x` (always false).return failBeforeSpawn(`Not enough free memory to train safely — ${memReport.budgetGb.toFixed(1)} GB available, need ≥ ${TRAINING_MIN_HEADROOM_GB} GB. Stop other model servers or close apps and retry.`);}diff --git a/server/services/loraTraining/memoryPrep.js b/server/services/loraTraining/memoryPrep.jsindex bdc86e2506..f7951bdc0e 100644--- a/server/services/loraTraining/memoryPrep.js+++ b/server/services/loraTraining/memoryPrep.js@@ -30,10 +30,14 @@ const GB = 2 ** 30;// larger variants are protected by the budget-derived quantize/low_ram tiers.export const TRAINING_MIN_HEADROOM_GB = 24;+// Loopback hosts, plus `0.0.0.0` — a backend URL of `0.0.0.0` targets the local+// machine (the all-interfaces bind, which clients reach via loopback), so it is+// "local" for the purpose of deciding whether an unload frees local memory.const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1']);/**- * True only when `url` points at this machine's loopback interface. Unloading a+ * True only when `url` points at this machine (loopback, or the `0.0.0.0`+ * local-bind sentinel). Unloading a* model frees memory on the box the backend RUNS on, not the box that issued* the request — and PortOS supports pointing `OLLAMA_URL` / `LM_STUDIO_URL` at a* remote LAN peer (a common federated-machines setup). Evicting a *remote*@@ -85,7 +89,7 @@ export async function unloadResidentModels() {}const parsePageSize = (out) => {- const m = out.match(/page size of (\d+) bytes/);+ const m = out.match(/page size of (\d+) bytes/i); // case-insensitive for robustnessreturn m ? Number(m[1]) : 4096;};