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: clamp maxDurationSec override to MAX_ANALYSIS_SEC (#8973)
[._.]/ Adam Eivy6092a4f1fb62
diff --git a/server/lib/beatGrid.js b/server/lib/beatGrid.jsindex 92d49cde59..26dc190e42 100644--- a/server/lib/beatGrid.js+++ b/server/lib/beatGrid.js@@ -374,7 +374,9 @@ export function __analyzeBeatGridPcm(samples, sampleRate, { hop = ONSET_HOP } =* @param {{ signal?: AbortSignal, maxDurationSec?: number }} [opts]* `maxDurationSec` overrides MAX_ANALYSIS_SEC — a test-only seam so the* truncation path can be exercised against a short fixture rather than a- * real multi-minute file; real callers should not pass it.+ * real multi-minute file; real callers should not pass it. Clamped to+ * MAX_ANALYSIS_SEC — it can only shrink the decode window, never grow it,+ * so it can't be used to defeat the memory bound.* @returns {Promise<{ samples: Float32Array, sampleRate: number } | null>}*/export async function decodeAudioToPcm(audioPath, { signal, maxDurationSec = MAX_ANALYSIS_SEC } = {}) {@@ -384,11 +386,15 @@ export async function decodeAudioToPcm(audioPath, { signal, maxDurationSec = MAXif (!ffmpeg) return null;if (signal?.aborted) return null;+ const boundedDurationSec = Number.isFinite(maxDurationSec) && maxDurationSec > 0+ ? Math.min(maxDurationSec, MAX_ANALYSIS_SEC)+ : MAX_ANALYSIS_SEC;+return new Promise((resolve) => {const args = ['-v', 'error','-i', audioPath,- '-t', String(maxDurationSec),+ '-t', String(boundedDurationSec),'-ac', '1','-ar', String(BEAT_GRID_SAMPLE_RATE),'-f', 'f32le',diff --git a/server/services/musicVideo/audioAnalysis.js b/server/services/musicVideo/audioAnalysis.jsindex bdeeb5eb03..a5395370cc 100644--- a/server/services/musicVideo/audioAnalysis.js+++ b/server/services/musicVideo/audioAnalysis.js@@ -166,7 +166,9 @@ function fftInPlace(real, imaginary, plan) {* @param {{ signal?: AbortSignal, maxDurationSec?: number }} [opts]* `maxDurationSec` overrides MAX_ANALYSIS_SEC — a test-only seam so the* truncation path can be exercised against a short fixture rather than a- * real multi-minute file; real callers should not pass it.+ * real multi-minute file; real callers should not pass it. Clamped to+ * MAX_ANALYSIS_SEC — it can only shrink the decode window, never grow it,+ * so it can't be used to defeat the memory bound.* @returns {Promise<{ samples: Float32Array, sampleRate: number } | null>}*/export async function decodeAudioToPcm(audioPath, { signal, maxDurationSec = MAX_ANALYSIS_SEC } = {}) {@@ -181,11 +183,15 @@ export async function decodeAudioToPcm(audioPath, { signal, maxDurationSec = MAX// the listener below would again attach to an already-aborted signal.if (signal?.aborted) return null;+ const boundedDurationSec = Number.isFinite(maxDurationSec) && maxDurationSec > 0+ ? Math.min(maxDurationSec, MAX_ANALYSIS_SEC)+ : MAX_ANALYSIS_SEC;+return new Promise((resolve) => {const args = ['-v', 'error','-i', audioPath,- '-t', String(maxDurationSec),+ '-t', String(boundedDurationSec),'-ac', '1','-ar', String(ANALYSIS_SAMPLE_RATE),'-f', 'f32le',