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
refactor([pipeline-audio-phase-4c-2-4c-3-4d-2-local-oss]): share isPlacedOffset predicate
[._.]/ Adam Eivya7db186d05dc
diff --git a/server/services/pipeline/audioMux.js b/server/services/pipeline/audioMux.jsindex 78af20ef54..bd52520756 100644--- a/server/services/pipeline/audioMux.js+++ b/server/services/pipeline/audioMux.js@@ -69,13 +69,17 @@ export async function resolveMusicTrackPath(trackFilename) {* counts as a placed VO line", shared by the CD stitch and any future batch* export so the predicate can't drift across call sites.*/+// A line is "placed" only with a real numeric offset >= 0. `typeof === 'number'`+// (not Number(x)) so a null offset — the sanitizer's "not placed yet" sentinel —+// is excluded rather than coerced to 0 and stacked at the episode start+// (Number(null) === 0). Single source of the scalar test so the two call sites+// (selectPlacedVoLines, muxVoLines) can't drift on the placement rule.+const isPlacedOffset = (x) => typeof x === 'number' && Number.isFinite(x) && x >= 0;+export function selectPlacedVoLines(lines) {if (!Array.isArray(lines)) return [];- // `typeof === 'number'` (not Number(x)) so a null offset — the sanitizer's- // "not placed yet" sentinel — is excluded rather than coerced to 0 and- // stacked at the episode start (Number(null) === 0).return lines- .filter((l) => l?.audioFilename && typeof l.offsetSec === 'number' && Number.isFinite(l.offsetSec) && l.offsetSec >= 0)+ .filter((l) => l?.audioFilename && isPlacedOffset(l.offsetSec)).map((l) => ({ path: join(PATHS.audio, l.audioFilename), offsetSec: l.offsetSec }));}@@ -217,8 +221,7 @@ export async function muxVoLines(inputVideoPath, { voLines = [], musicPath = nulreturn { ok: false, reason: 'input video missing' };}const placed = (Array.isArray(voLines) ? voLines : []).filter((l) => (- // `typeof === 'number'` so a null offset isn't coerced to 0 (Number(null) === 0).- l?.path && existsSync(l.path) && typeof l.offsetSec === 'number' && Number.isFinite(l.offsetSec) && l.offsetSec >= 0+ l?.path && existsSync(l.path) && isPlacedOffset(l.offsetSec)));if (!placed.length) return { ok: false, reason: 'no placed VO lines' };// A missing music file is not fatal — drop to a VO-only mux rather than