Skip to content

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

Merge remote-tracking branch 'origin/main' into claim/issue-2616

Adam Eivyfa2a1921c934
diff --cc .changelog/NEXT.md
index bd9f26fb89,05a98914be..d1370b7323
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -85,4 -87,4 +87,5 @@@
- **[issue-2548] Replace the vacuous agentLifecycle spawn/completion replica tests with imports of real guard helpers.** `agentLifecycle.test.js` re-implemented production logic — local `unfixedSpawn`/`fixedSpawn` copies of the `spawningTasks` dedup flow and a `runCompletion`/`makeCompletionHarness` copy of the completion try/finally — and never imported `spawnAgentForTask`/`handleAgentCompletion`, so they stayed green when production regressed. The two concurrency contracts those replicas modelled are now extracted into `server/services/agentGuards.js`: `withSpawnDedupGuard(spawningTasks, taskId, fn)` (acquire-before-first-await, hold across the whole spawn body incl. the runner-enqueue handoff, release in `finally`, `SPAWN_DEDUP_SKIP` on a concurrent duplicate) and `withMapEntryCleanup(map, key, fn)` (delete the `runnerAgents` entry in `finally` even when a completion step throws). `spawnAgentForTask` now wraps `runAgentSpawn` in the former (dropping six inline `spawningTasks.delete` sites), and `handleAgentCompletion` wraps its body in the latter — so the tests drive the exact code production runs. The late-delete race that spawned a second agent for the same task id is now a behavioral test against the real guard, not a hand-copied one; the remaining source-scan tests were trimmed to non-negotiable orderings (the handedOff pre-spawn/post-handoff split, the #1563 claim/register ordering, the #989 marker release, the #2243 runner env merge) plus two wiring guards that pin the delegation. `cos.test.js` already drove the real `createDequeueCapacity`/`isMissionTierEligible`/`isIdleTierEligible` exports after #2530, so it was left as-is. New `agentGuards.test.js` unit-tests both helpers in isolation.
- **[issue-2554] Align CoS chrome and scrollbar colors with port design tokens.** The Chief of Staff panel chrome hardcoded `bg-slate-900/60`, `hover:bg-slate-800/80`, the `from-slate-900/80 to-slate-900/40` gradients, and `text-slate-400` — a `slate` surface that ignored the active theme. Those now map to `bg-port-card`/`hover:bg-port-border`/`text-port-text-muted` (the collapse button's `text-gray-500 hover:text-white` also became `text-port-text-muted hover:text-port-text` so its icon stays legible in light themes), so the panel restyles with the selected theme. The global `::-webkit-scrollbar-thumb` (and its `:hover`) dropped their hardcoded `#3a3a3a`/`#4a4a4a` for the opaque, theme-derived `rgb(var(--port-text-muted))` and `rgb(var(--port-text))` — colors that stay high-contrast against the already-tokenized `rgb(var(--port-card))` track in both dark and light themes (an alpha-over-track blend would wash out on light cards, so the opaque muted-text token is used). The unread-count badges in `Layout.jsx` (four sites) and `NotificationDropdown.jsx` swapped `bg-yellow-500 text-black` for `bg-port-warning text-port-on-warning`; the Dashboard server-health glow's `shadow-[0_0_8px_#22c55e]`/`#ef4444` now reference `rgb(var(--port-success))`/`rgb(var(--port-error))`. The Ambient full-screen idle display is intentionally left on its fixed deep-black `bg-[#050505]` (with `text-white` content) — it is a theme-independent ambient/OLED surface, and making the backdrop theme-following would strand its non-tokenized white clock and translucent panels invisibly on light themes. Visual-only token swaps — no logic or layout change; the retokenized surfaces now follow the active theme instead of a fixed palette.
+- **[issue-2616] Add type-level consecutive-failure backoff with auto-park + notification; count unparseable agent output as failure.** The agent engine had no failure memory at the task-*type* level, so a permanently-broken scheduled type (or one whose instances all fail) re-queued on schedule forever — burning provider quota with no backoff, auto-disable, or notification (`failureCount` lived only in per-instance metadata; ROTATION types had no cadence gate at all, returning `shouldRun: true` unconditionally). A new per-type failure ledger now lives on the schedule execution record (`consecutiveFailures`/`lastFailureAt`/`lastErrorCategory`, per app + global) — persisted alongside `lastRun`, so it survives restarts as per-install runtime state (additive, backward-compatible, never synced). `shouldRunTask` applies an escalating failure cooldown (`2^n × base`, capped at a day) to *all* cadence types including ROTATION, so a failing type slows down instead of re-queuing every tick; after 5 consecutive failures the type auto-parks (indefinitely, for every cadence type) and fires a user-facing `AGENT_WARNING` notification naming the type, app, and last error category. A success resets the counter and lifts the park; a manual "Run now" or a config change (`updateTaskInterval`) clears the ledger to unpark. Separately, an LLM run that exits 0 but whose `.agent-done` output is unparseable — previously recorded as a benign completed success, invisible to any failure accounting — now feeds a failure signal into the ledger via the pure `resolveTypeFailureSignal` (an `unparseable-response` hook reason, or a thrown output hook, counts as a failure regardless of exit code; benign hook reasons like `no-proposal`/`duplicate` defer to the exit code). The existing per-instance retry ladder (`MAX_TASK_RETRIES`/`MAX_TOTAL_SPAWNS`) is unchanged. New unit tests cover the backoff math, ledger increment/reset/auto-park/notify/unpark, the ROTATION cooldown/park gates, and the unparseable-as-failure decision.
+ - **[issue-2535] Paginate the creative-catalog + media list endpoints with the shared `paginateArray` helper.** The primary index `GET`s for creativeDirector (`/`), storyBuilder (`/`), universeBuilder (`/`), moodBoard (`/`), videoTimeline (`/projects`), and loras (`/`) returned unbounded arrays. Each now opts into pagination the moment a client sends `limit`/`offset`, mirroring the `brainCrud` precedent: `isPaginationRequested(req.query)` gates a bounded `{ items, total, limit, offset }` envelope (via the existing `paginateArray` in `server/lib/validation.js`, `defaultLimit: 50`, `maxLimit: 500`), while a request with no pagination params still returns the full array byte-for-byte — so every current client (none of which pass those params to these routes) is unaffected and no client change is required. New route tests assert both the default array and the paginated envelope for each domain (moodBoard gains its first route test). Refs #2535 — CoS tasks (the `?full=1` default-paginated slice) already shipped; privacy vault/orgs/changes/brokers and digital-twin documents remain.