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-1838

[._.]/ Adam Eivy7a6b1c16ccfa
diff --cc .changelog/NEXT.md
index fcf73bd8b0,e76201df9c..729b0093fe
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -26,7 -35,12 +35,13 @@@
## Internal
+ - **[issue-1860] De-flaked the `peerSync` reciprocal-sync tests** — the positive `reciprocates a full-sync peer on peer:online` test waited for an async event handler with a hard `setTimeout(r, 30)` before asserting `enqueueReciprocalSync` was called, so a loaded CI runner whose handler chain exceeded 30ms produced a spurious failure (surfaced during the v2.24.0 release CI-flake gate). It now polls with `vi.waitFor`. The sibling negative test (`does NOT reciprocate a non-full-sync peer`) replaced its fixed-sleep + `not.toHaveBeenCalled()` — which could false-pass if the absent call were merely slow — with a deterministic full-sync "barrier" peer emitted after the subject: once the barrier's reciprocal call lands, the subject's handler has provably reached and skipped its own fullSync check. Test-only. (#1860)
+
+ - Updated the bundled slashdo submodule to v3.20.0, pulling the latest `/do:*` slash commands and shared libraries.
+
+ - **[issue-1836] Moved socket-handler orchestration into services** — the `standardize:start` and `app:deploy` Socket.IO handlers (`server/services/socket.js`) implemented their multi-step flows inline in the socket layer, where they couldn't be unit-tested or reused from an HTTP route. The PM2 standardization flow (analyze → git backup → apply) is now `pm2Standardizer.runStandardizeFlow()` and the deploy flow (resolve app → check deploy script → run) is now `appDeployer.runDeployFlow()`; each takes progress callbacks and returns a terminal outcome, so the socket handler is a thin adapter. Both are covered by new unit tests. Behavior-preserving. (#1836)
+
+- **Extracted a shared helper for the copy-paste stage-seed migrations** — 44 first-shipment "seed a new pipeline stage" migrations under `scripts/migrations/` (e.g. `130-editorial-character-consistency-stage.js`) were near-identical: only the stage key differed while ~65 lines of read-reference → no-clobber-copy → merge-stage-config were verbatim copies, each with its own copy-paste test. They now collapse to a 3-line `export default makeSeedMigration(stageKey)` call from a new `scripts/migrations/_seedStageHelpers.js` (companion to the existing `_lib.js`/`_testHelpers.js`; the runner skips `_`-prefixed files). The helper reproduces the migrations' on-disk effects exactly — fresh-seed, idempotent no-clobber of a customized `.md`/config, and missing-reference no-throw; `filename` defaults to `${stageKey}.md` (the universal convention, overridable for a divergent template), and no `down()` is emitted because the runner (`run-migrations.js`) only ever calls `up()` and tracks applied migrations by filename. Boot-log copy is incidental and now uniformly keyed on `stageKey`. Net −2,500 lines; all 757 `scripts/` tests pass unchanged, and the new `_seedStageHelpers.test.js` covers the helper directly. (#1838)
- **Replaced aiToolkit runner monkey-patching with declared extension points** — `server/index.js` previously reached into the toolkit runner's private surface, overwriting `executeCliRun`/`executeTuiRun` and re-wrapping `stopRun`/`isRunActive`/`deleteRun` to consult an ad-hoc `_portosActiveRuns` map, plus inlining a 34-line update-marker IIFE in bootstrap. The toolkit runner (`server/lib/aiToolkit/runner.js`) now exposes `setCliRunner()`/`setTuiRunner()` and an external-run registry (`registerExternalRun`/`unregisterExternalRun`/`hasExternalRun`) that its own `stopRun`/`isRunActive`/`deleteRun` consult first — so the host registers its CLI/TUI runners through a documented contract instead of mutating private props, and adding a new lifecycle method no longer requires a matching monkey-patch. `server/services/runner.js` tracks its child processes via the registry, and the update-marker read/validate/record/cleanup lifecycle moved into a unit-tested `processUpdateMarker()` in `server/services/updateChecker.js`. Behavior-preserving; the aiToolkit override contract (`server/lib/aiToolkit/CLAUDE.md`) is updated to match. (#1834)
- **Decomposed two remaining large files: `server/routes/meatspace.js` + `server/services/videoGen/local.js`** — the 1,069-line `meatspace.js` router (14 health sub-domains, each backed by its own service import) is split one concern per file (`meatspaceCoreRoutes.js` overview/config/birth-date/death-clock/LEV, `meatspaceAlcoholRoutes.js`, `meatspaceNicotineRoutes.js`, `meatspaceHealthRoutes.js` blood/body/BP/workouts/epigenetic/eyes, `meatspacePostRoutes.js` POST drills + training + memory builder, `meatspaceCalendarRoutes.js` life calendar/activities/events, `meatspaceExportRoutes.js` MortalLoom export), assembled by a thin `meatspace.js` barrel that mounts each under `/api/meatspace` — the same pattern `routes/cos.js`/`routes/brain.js` use; the split is wiring-only (the 70-route surface is byte-identical, verified). The 1,805-line `videoGen/local.js` had its BYOV runtime management (venv/helper-script path constants, `BYOV_RUNTIME_INFO`, install/ready/fingerprint probes) extracted to `videoGen/runtimes.js` and its render-history I/O (`loadHistory`/`saveHistory`) to `videoGen/history.js`; `local.js` keeps generation + post-processing and re-exports the extracted surface so every existing deep import (`from '../videoGen/local.js'`) keeps resolving unchanged (all 30 prior exports preserved, verified). (#1833)
- **Decomposed `server/routes/brain.js` (1,149-line router covering 13 sub-domains)** — the monolithic Brain router that mixed capture/inbox, four entity CRUD collections + memories, digest/review, settings/summary, links + buckets, graph, federation sync, and the daily log is now split one concern per file (`brainCapture.js`, `brainCrud.js`, `brainDigest.js`, `brainSettings.js`, `brainLinks.js`, `brainGraph.js`, `brainSync.js`, `brainDailyLog.js`), assembled by a thin `brain.js` barrel that mounts each sub-router under `/api/brain` — the same pattern `routes/cos.js` already uses. The split is wiring-only: route paths, ordering (literal-before-`:id` routes stay within their owning sub-router), validation, and the barrel's default export are unchanged, so `server/index.js` and the existing `brain.test.js` (105 tests) pass without edits. (#1832)