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
docs: changelog entry for shared-helper reuse (#2526)
Adam Eivybdcef6073daf
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 365456f579..c91ac983dd 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -18,6 +18,7 @@## Changed+- **[issue-2526] Reuse shared helpers instead of local reimplementations (DRY).** Swapped duplicated one-off implementations for their existing `server/lib` counterparts: `sleep` (`youtubeSync.js`, `pipeline/seriesAutopilot.js`) and `pathExists` (`localLlm.js`) now import from `fileUtils.js`; `database.js`'s inline color-only `stripAnsi` uses the shared `ansiStrip.js` (full ANSI/control stripper); `systemHealth.js`'s byte formatter and `huggingFaceCatalog.js`'s (via a thin wrapper that preserves its `null`-on-unknown-size fallback contract) now delegate to `fileUtils.formatBytes`; and the two hand-rolled SSE header blocks now use the canonical `SSE_HEADERS` — `ask.js` keeps its extra `no-transform` directive on top of the shared set, and `mediaJobQueue`'s terminal-event path gains the previously-missing `X-Accel-Buffering: no` so it matches the live-stream path.- **[issue-2521] Validate the remaining ad-hoc route bodies with Zod `validateRequest`.** The ports (`/check`, `/allocate`), database (`switch`/`start`/`stop`/`destroy`/`export`), brain digest/review run, telegram (`method`/`config`/`test`/`forward-types`), and AI-toolkit provider (`POST`/`PUT`/`PUT active`) routes parsed `req.body` with hand-rolled `Array.isArray`/`includes` checks. Each now has a named Zod schema (PortOS schemas in `lib/validation.js`, brain schema in `brainValidation.js`, provider schemas in `aiToolkit/validation.js`) wired through `validateRequest`, so invalid bodies return a consistent `400 VALIDATION_ERROR` with per-field `context.details` instead of ad-hoc messages. Port numbers are range-checked (and `count` coercion no longer silently accepts booleans/arrays), backend/target values are enum-checked, and provider create/update reuse the canonical `providerSchema` (`.partial()` on update). As part of wiring `PUT /api/providers/active`, the toolkit providers map is now null-prototyped on load so a crafted id (`__proto__`, `constructor`, `toString`) can no longer resolve an inherited `Object.prototype` member as an existing provider and be persisted as the active one.- **[issue-2525] Extract shared `migrationMarker` helpers using `atomicWrite`.** Eleven boot-time migration/repair/reconcile scripts under `server/scripts/` each hand-rolled `markerExists`/`readMarker`/`writeMarker` on top of `readFile(...).catch(() => null)` and a non-atomic `writeFile(JSON.stringify(...))`, so a crash mid-write could leave a truncated marker a later boot misreads as "not applied." The three helpers now live once in `server/lib/migrationMarker.js` (anchored under `PATHS.data`, built on the existing `tryReadFile`/`atomicWrite`/`safeJSONParse`), are barrel- and README-cataloged, and carry their own unit test. Marker filenames, gate semantics, and payloads are unchanged; the write path is now atomic (temp file + rename).- **[issue-2522] Deep-link Tribe tabs and fix form label associations.** The Tribe page's active section (Circle / Map / Care Queue / Focus) lived in local `useState`, so a section couldn't be shared, bookmarked, or survive a reload. It now reads from a `?tab=` URL search param (default `circle` omitted for a clean `/tribe`) with a valid-tab fallback for stale/unknown values — matching the PromptManager convention. Separately, the `StylePresetPicker` style-preset `<label>` and the Loops "Interval" `<label>` had no `htmlFor`/`id` pairing; both now associate with their control via a `useId()`-generated id so click-to-focus and screen readers work.