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

docs([issue-2909]): log issue #2909 to changelog

[._.]/ Adam Eivy88c6ecd431e8
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5fbe1f2626..3d376cf440 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -77,7 +77,8 @@
- **[issue-2837] Break the agent-lifecycle circular-dependency cluster** — `finalizeAgent`/`releaseAgentLane` (plus the success-criteria + output-hook helpers) move to `server/services/agentFinalization.js`, the summary extractors to `agentSummaryExtraction.js`, runner recovery to `agentRunnerSync.js`, and the runner output batchers to `agentRunnerOutputBatchers.js`. With those leaves in place the two static cycles (`agentLifecycle` ↔ `agentCliSpawning`, `agentLifecycle` ↔ `agentTuiSpawning`) are gone, and three `await import()` cycle-dodges — `handleOrphanedTask`, the spawner's init-time lifecycle/management lookups, and `flushRunnerOutputBatcher` — become plain static imports. `agentLifecycle.js` still re-exports every moved symbol, so no import path changes for callers. New `agentImportCycles.test.js` re-derives the static import graph and fails if a cycle is reintroduced.
- **[issue-2844] Drop the `@dnd-kit/utilities` dependency** — the package was pulled in only for `CSS.Transform.toString()` at three drag-and-drop sites (influence chips, CoS sortable tasks, video timeline blocks). A ~10-line owned helper, `dndTransformToCss` in `client/src/lib/dndTransform.js`, replaces it with byte-identical output (rounded `translate3d` + verbatim `scaleX`/`scaleY`, `undefined` for a null transform), and the direct dependency is removed from `client/package.json` and its lockfile. It remains in the tree only as a transitive peer of `@dnd-kit/core`/`sortable`, which stay.
- **[issue-2846] Add a client `sleep(ms)` helper and rebuild `useLocalStorageBool` on `safeStorage`** — `client/src/utils/sleep.js` mirrors the server helper and replaces the three duplicated inline delays (`lazyWithReload`'s retry backoff, `staleChunkReload`'s purge race timeout, `voiceClient`'s decoder-tick wait). `useLocalStorageBool`/`useLocalStoragePersisted` now delegate their four hand-rolled `try/catch` storage helpers to `client/src/lib/safeStorage.js`, which gains a `safeWriteJsonStorage` that guards `JSON.stringify` alongside `setItem`. The JSON read keeps a private sentinel so a stored `null` still runs the caller's `parse` migration instead of collapsing into "missing".
-- **[issue-2899] Fold the Creative Director / Music Video / Sprites `selectBackend()` dispatchers into `pgFileFacade`** — Creative Director, Music Video, and Sprites each memoized their own copy of the same file-vs-Postgres selector (already drifted: differing error text, differing test-mode predicate). A new `createRecordStoreBackendSelector({ label, loadFileBackend, loadDbBackend, requireDbMessage?, isTestMode?, onDbReady? })` in `server/lib/pgFileFacade.js` wraps the existing `createPgFileFacade`/`resolvePgBackend` backbone for stores whose backends are whole modules rather than built objects, so the escape-hatch posture, the health-check → `ensureSchema` → one-time-migration bring-up, and the selection memoization live in one place. Public store surfaces are unchanged (`getProjectsBackendName()` still reports `'file'`/`'postgres'`), each store keeps its own requirement message, and Sprites keeps its stronger `isTestRunner()` test-mode signal via the new `isTestMode` hook — no gating semantics were weakened. The selector also exposes a `reset()` test seam matching the `_reset<X>Backend()` exports on the artists/tracks/albums/authors stores, which still hand-roll the same dispatcher and are tracked separately.
+- **[issue-2899] Fold the Creative Director / Music Video / Sprites `selectBackend()` dispatchers into `pgFileFacade`** — Creative Director, Music Video, and Sprites each memoized their own copy of the same file-vs-Postgres selector (already drifted: differing error text, differing test-mode predicate). A new `createRecordStoreBackendSelector({ label, loadFileBackend, loadDbBackend, requireDbMessage?, isTestMode?, onDbReady? })` in `server/lib/pgFileFacade.js` wraps the existing `createPgFileFacade`/`resolvePgBackend` backbone for stores whose backends are whole modules rather than built objects, so the escape-hatch posture, the health-check → `ensureSchema` → one-time-migration bring-up, and the selection memoization live in one place. Public store surfaces are unchanged (`getProjectsBackendName()` still reports `'file'`/`'postgres'`), each store keeps its own requirement message, and Sprites keeps its stronger `isTestRunner()` test-mode signal via the new `isTestMode` hook — no gating semantics were weakened. The selector also exposes a `reset()` test seam matching the `_reset<X>Backend()` exports on the artists/tracks/albums/authors stores, which are folded in by #2909 below.
+- **[issue-2909] Fold the artists/tracks/albums/authors `selectBackend()` dispatchers into `pgFileFacade`** — the four music/author record stores were the last holdouts still hand-rolling the same memoized file-vs-Postgres selector that #2899 centralized as `createRecordStoreBackendSelector`; each now delegates to it, so the escape-hatch predicate, the health-check → `ensureSchema()` bring-up, and the selection memoization live in exactly one place. Public surfaces are unchanged — `get<X>BackendName()` still reports `'file'`/`'postgres'`, `_reset<X>Backend()` still clears the memo (now via the selector's `reset()` seam), each store keeps its requirement message char-for-char, and all four keep their existing `NODE_ENV==='test'` test-mode predicate. One behavioral improvement falls out of the shared backbone: the selection *promise* is memoized rather than only the result, so two concurrent first calls can no longer both import the Postgres module.
- **[issue-2842] Barrel-split `checkInfra`, `layeredIntelligence`, and `seriesAutopilot` by sub-domain** — the three remaining ~2.6k-line multi-domain server files each become a thin re-exporting barrel over a new same-named directory, mirroring the `arcPlanner.js` split (#1152). `server/lib/editorial/checkInfra.js` → `checkInfra/{externals,taxonomy,revealForeshadowing,craftStages,voiceCanon,structureStages,povAndNames,canonScaffolding,llmRunner,readability,rosterCast,sceneAnalysis,proseDensity,comic}.js`; `server/services/layeredIntelligence.js` → `layeredIntelligence/{constants,config,dedup,proposal,outcomes,awareness,gates,prompt,runCli,sources,semanticDedup,forgeFiler,jiraFiler,planFiler}.js`; `server/services/pipeline/seriesAutopilot.js` → `seriesAutopilot/{state,config,convergence,stepResolver,session,childRuns,editorialSteps,visualSteps,revisionSteps,dispatch,dryRun,orchestrator}.js`. No caller changes — every existing deep import still resolves through the barrel, and `seriesAutopilot`'s `__testing` bundle is reassembled from the split modules. Three new `*Barrel.test.js` suites pin the contract (every module export reachable through the barrel as the same object, no cross-module symbol collisions). The largest resulting module is 439 lines, down from 2,635.
- **[issue-2841] Convert long positional parameter lists to options objects** — `appendIntervalOccurrences` (8 args) and its sibling `appendCronOccurrences` in `server/services/workflow.js`, `scaffoldVite` (7 args) and the equally-long `scaffoldPortOS` in `server/routes/`, and `createAgentRun` (6 args) in `server/services/agentRunTracking.js` now take a single destructured options object, matching the codebase's dominant convention and removing the "which of these five interchangeable numbers goes where" hazard at each call site. All call sites updated; `scaffold.test.js` gains two regression tests pinning the named-options dispatch shape. Behavior-preserving.
- **[issue-2890] Take the held-back `undici` 8 bump** — the failing `safeUrlFetch` pin test turned out not to be about `connect.lookup` at all (undici 8's connector still honors it, so the DNS-rebinding IP pin is expressed exactly as before). undici 8 dropped v7's implicit wrapping of the legacy `onConnect`/`onHeaders`/`onComplete` request-handler shape, so a bare undici-8 `Agent` handed to the *built-in* `fetch` of any Node that still bundles undici 7 (22/24/25, including the 24.x CI matrix) throws `InvalidArgumentError: invalid onRequestStart method` — and because `fetchGuarded` swallows network errors to null, every guarded fetch would have silently returned null rather than falling back to an unpinned connect. The new exported `buildPinnedDispatcher()` wraps the pinned `Agent` in undici 8's documented `Dispatcher1Wrapper`, which both the legacy and the v8 handler contracts accept, so one build works across Node 22→26. The end-to-end pin proof now runs through that production factory instead of a hand-rolled `new Agent(...)`, so it also guards the runtime-compat half.