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: harden CoS improvement-check rescheduling + VO-line path-traversal guard
Adam Eivybf59c957c0d7
diff --git a/PLAN.md b/PLAN.mdindex b75d921f71..257d5c9561 100644--- a/PLAN.md+++ b/PLAN.md@@ -27,4 +27,9 @@ the tracker until one is promoted to a real, claimable issue.- **Bump `react-router-dom` for the pre-existing HIGH advisory** (tracked in #883) — `client/package.json` pins `[email protected]`; `npm audit` flags react-router 7.0.0–7.14.2 (HIGH: CSRF/XSS/open-redirect/turbo-stream RCE, GHSA-h5cw-625j-3rxh et al.). Fix is an in-major bump to `7.16.0+`. Left out of issue-880 (scoped to the react-three/React-19 coupling) to keep that PR focused; not introduced by it. Bump and re-run the full client suite (router is app-wide).- **Workflow tab Phase 2** — drag-and-drop ordering of stages, custom user-defined stages, per-app workflow overrides.- **Inspiration & Mood Board Canvas** — dedicated mood-board surface for collecting visual + textual references that feed into Universe Builder, Writers Room, and Creative Director (distinct from raw Media History). Items can be pinned from any media surface; canvas surfaces ref images when starting a new universe / scene / treatment. Documented as a Secondary Goal in GOALS.md but had no tracking.+- **Clamp negative success-duration on learning reset** — `resetTaskTypeLearning` in `server/services/taskLearning/metrics.js` (~line 188) subtracts a task type's `successDurationMs`/`successMaxDurationMs` from the totals guarded only by `if (data.totals.successDurationMs)`, without clamping the result to ≥0 (the tier-subtraction block just below it DOES clamp). A hand-edited/older store where totals drifted below a single type's accumulated value goes negative and `calculateDurationETA` then yields a negative `avgDurationMs`. Self-heals via `recalculateDurationStats`; add `Math.max(0, …)` for parity. (Deferred from v2.15.0 release review — NIT.)+- **NaN guard in `computeGoalVelocity`** — `server/services/identity/goals.js` (~line 104) does date arithmetic (`new Date(entry.date) - new Date(...)`) and string-compares `entry.date` without guarding malformed dates; a bad `progressHistory.date` yields `NaN`/mis-ordering. Low-risk (self-authored data) but a `Number.isNaN(daysDiff)` early return would harden it. (Deferred from v2.15.0 release review — NIT.)+- **Verify goal-organization apex round-trip** — `organizeGoals` instructs the LLM to return `apexGoal` (`suggestedTitle`/`suggestedDescription` for a NEW apex) and `suggestedSubApex`, and references a `__new_apex__` sentinel, but `applyGoalOrganization` (`server/services/identity/goals.js` ~line 713) only reparents/retypes existing goals — any goal with `suggestedParentId === '__new_apex__'` fails the `goalMap.has()` check and is silently skipped, and no apex/sub-apex is created. Confirm the apex creation is handled elsewhere in the route, or this is prompt/behavior drift to close. (Deferred from v2.15.0 release review — NIT.)+- **Single-source the `audioMode` default** — `server/services/creativeDirector/stitchRunner.js` (~line 150) inlines `issue.stages?.audio?.audioMode || 'per-clip'`, a third copy of the fallback already centralized in `sanitizeAudioMode` (`issues.js`) and `AudioStage.jsx`. Functionally fine (record is sanitized on read) but route it through `sanitizeAudioMode` so the default has one source of truth. (Deferred from v2.15.0 release review — NIT.)+- **Finite-gain guard in audio mux builders** — `muxMusicBed`/cue builders in `server/services/pipeline/audioMux.js` call `Number(musicGain).toFixed(3)` without a finite check; a non-numeric gain would put `"NaN"` in the ffmpeg filter and abort the graph. Not currently reachable (all callers pass clamped/frozen gains) but these are exported "pure, unit-tested" builders — add a `Number.isFinite` fallback to `DEFAULT_MUSIC_GAIN`. (Deferred from v2.15.0 release review — NIT.)- **Generative regen path for SynthID defeat (image cleaner) — research/backlog, hardware-gated.** Current `cleanImageBuffer` (`server/lib/imageClean.js`) only strips the C2PA `caBX` chunk + runs `median(3).sharpen()` — SynthID survives by design. The only honest defeat path is to round-trip pixels through a generative model: short-step img2img (low step count + low–moderate denoise, ~0.35–0.5) on a local FLUX runner so composition holds but the per-pixel watermark signal is overwritten by fresh sampling. **Scope narrowed (2026-05-20):** post-hoc, history-only — a second button next to "Clean (aggressive)" on the image-settings/lightbox modal; never auto-applied, never wired into the active gen flow. Each run is ~5–15s on local mflux and GPU/unified-memory heavy; wants its own queue lane. Sidecar records `regenerated: true, regenSteps: N, regenStrength: 0.4, regenModelId: 'flux-v1'` so lineage stays honest. **Hardware-gated** — the 128GB unified-memory machine is now online, so this can be pulled in when the user wants to play with it. UX caveat: this is the only honest watermark-defeat path; the existing C2PA-strip-and-denoise will always be a no-op against SynthID.diff --git a/server/services/cosJobScheduler.js b/server/services/cosJobScheduler.jsindex 7f39994375..9e3caf37fc 100644--- a/server/services/cosJobScheduler.js+++ b/server/services/cosJobScheduler.js@@ -329,20 +329,23 @@ export async function scheduleNextImprovementCheck() {delayMs: Math.max(delayMs, 1000),handler: async () => {if (!isDaemonRunning()) return;- const paused = (await loadState()).paused || false;- if (paused) {+ // This is a 'once' event — the eventScheduler does NOT auto-reschedule it,+ // so the handler must re-arm itself. Re-arm in `finally` so a throw in the+ // body (loadState / getCosTasks / queueEligibleImprovementTasks) can't+ // permanently halt the improvement cadence until a process restart.+ try {+ const paused = (await loadState()).paused || false;+ if (paused) return;++ const state = await loadState();+ if (state.config.idleReviewEnabled) {+ const cosTaskData = await getCosTasks();+ await queueEligibleImprovementTasks(state, cosTaskData);+ cosEvents.emit('cos:dequeue-requested');+ }+ } finally {await scheduleNextImprovementCheck();- return;}-- const state = await loadState();- if (state.config.idleReviewEnabled) {- const cosTaskData = await getCosTasks();- await queueEligibleImprovementTasks(state, cosTaskData);- cosEvents.emit('cos:dequeue-requested');- }-- await scheduleNextImprovementCheck();},metadata: { description }});diff --git a/server/services/pipeline/audioMux.js b/server/services/pipeline/audioMux.jsindex 583547018d..82f1905b49 100644--- a/server/services/pipeline/audioMux.js+++ b/server/services/pipeline/audioMux.js@@ -80,9 +80,18 @@ const isPlacedOffset = (x) => typeof x === 'number' && Number.isFinite(x) && x >export function selectPlacedVoLines(lines) {if (!Array.isArray(lines)) return [];- return lines- .filter((l) => l?.audioFilename && isPlacedOffset(l.offsetSec))- .map((l) => ({ path: join(PATHS.audio, l.audioFilename), offsetSec: l.offsetSec }));+ const out = [];+ for (const l of lines) {+ if (!l?.audioFilename || !isPlacedOffset(l.offsetSec)) continue;+ // Validate the filename is a safe basename under PATHS.audio before building+ // an ffmpeg input path — VO line state can arrive from a synced peer, so a+ // traversal/absolute filename must be dropped rather than handed to ffmpeg+ // (mirrors the selectPlacedCues guard below).+ const path = safeUnder(PATHS.audio, l.audioFilename);+ if (!path) continue;+ out.push({ path, offsetSec: l.offsetSec });+ }+ return out;}/**diff --git a/server/services/pipeline/audioMux.test.js b/server/services/pipeline/audioMux.test.jsindex 50f8433e7a..a139bcee82 100644--- a/server/services/pipeline/audioMux.test.js+++ b/server/services/pipeline/audioMux.test.js@@ -209,6 +209,17 @@ describe('selectPlacedVoLines', () => {expect(selectPlacedVoLines(undefined)).toEqual([]);expect(selectPlacedVoLines([])).toEqual([]);});+ it('drops traversal/absolute filenames from stale or peer-synced state', () => {+ // VO line state can arrive from a synced peer; a traversal/absolute+ // audioFilename must be dropped rather than handed to ffmpeg (parity with+ // the selectPlacedCues guard).+ const out = selectPlacedVoLines([+ { audioFilename: '../../etc/passwd', offsetSec: 1 }, // dropped — escapes PATHS.audio+ { audioFilename: '/etc/passwd', offsetSec: 2 }, // dropped — absolute+ { audioFilename: 'safe.wav', offsetSec: 3 }, // kept+ ]);+ expect(out).toEqual([{ path: expect.stringMatching(/safe\.wav$/), offsetSec: 3 }]);+ });});describe('buildVoMuxArgs', () => {