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([extract-cover-render-handler-factory]): remove from PLAN.md and log to changelog
[._.]/ Adam Eivy7dfc83fda5aa
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 48f1118190..bc35ea57e3 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Changed+- **[extract-cover-render-handler-factory] Four cover-render route handlers collapsed into one config-driven factory.** The volume front/back + comic-issue front/back cover-render routes in `server/routes/pipeline.js` were 95% identical — differing only in { Zod schema, slot field (`cover` vs `backCover`), script body field (`coverScript` vs `backCoverScript`), optional precheck (issue routes ran `getIssue` for an early 404), enqueue fn (`enqueueVolumeCover` / `enqueueVolumeBackCover` / `enqueueComicCover` / `enqueueComicBackCover`), write fn (`seriesSvc.updateSeasonOnSeries` vs `issuesSvc.updateStageWithLatest`), and response shape (`{ season, series }` vs `{ cover|backCover, issue, stage }`) }. Extracted `makeCoverRenderHandler({ schema, slotField, scriptField, prepare, enqueue, applyWrite, buildResponse })` factory + a pure `buildCoverPatchFn` helper that owns the shared `compute` closure — same `typeof body[scriptField] === 'string'` script-gate semantics (absent preserves, empty-string clears) on all four routes, just defined once. Two named helpers (`updateVolumeSeason`, `updateComicPagesStage`) capture the per-record write signature so the route definitions only declare what's actually different. Net ~80 LOC → ~25 LOC across the four routes; 85/85 pipeline route tests pass (preserves the script-gate invariants pinned by `[med-pipeline-server-routes-pipeline-js-1416-1452]`); 6150/6150 server tests pass.+- **[med-sharing-server-services-sharing-version-js] Sharing importer salvages pre-B.4 series-side canon instead of dropping it.** Cross-peer share-bucket imports from a pre-B.4 install previously lost any `series.{characters, settings|places, objects}` arrays silently — `sanitizeSeries` (post-B.4) strips those fields on insert, and the importer fed records straight into `insertSeriesWithId`. The B.4 schema teardown intentionally moved canon onto the linked universe, so the recovery shape was the existing `migrateSeriesCanon` CLI helper; the gap was that nothing ran it for peer-authored records. `server/services/pipeline/migrateSeriesCanon.js` now exposes a per-record helper `applyLegacySeriesCanonToUniverse(series, { dryRun, log })` (extracted from the CLI batch's loop body) that folds legacy canon into the linked or freshly-created universe with the same `SERIES_EXTRACT` + `autoLock` + `sourceSeriesId` provenance the live extract path uses. `server/services/sharing/importer.js` calls this helper for every incoming series record carrying a non-empty `characters / settings / places / objects` array — between the universes merge loop and the series merge loop, so the universe (existing or newly minted for orphan series) holds the canon by the time `sanitizeSeries` runs. The pre-022 `settings[]` wire name is coalesced onto `places[]` inside the helper so peers shipping either rename-era survive. Two new integration tests in `services/sharing/integration.test.js` lock in the linked-universe and orphan-universe paths; 5904 server tests pass. `SHARING_SCHEMA_VERSION` is intentionally NOT bumped — the version bump would only help if paired with a hard refusal, and salvaging the data is the kinder outcome.- **[med-pipeline-server-routes-pipeline-js-1416-1452] Cover render routes no longer overwrite `script` when the body omits it.** The four cover render handlers in `server/routes/pipeline.js` (issue front, issue back, volume front, volume back) previously wrote `script: result.coverScript || ''` (or `result.backCoverScript || ''`) on every render, where `result.<script>` is the *resolved* value from the service (body override OR persisted record fallback). That collapsed two distinct cases — "body omitted the field" and "body explicitly cleared it to empty string" — into the same overwrite, and races against blur-save (PATCH `stages.comicPages.cover.script`) because the render path's resolved value can be stale by the time `updateStageWithLatest` / `updateSeasonOnSeries` writes. Switched all four routes to gate the `script` write on `typeof body.<scriptField> === 'string'` — absent leaves the persisted script untouched, empty string is honored as an intentional clear, present text writes through. Added the missing `enqueueComicBackCover` / `enqueueVolumeCover` / `enqueueVolumeBackCover` mocks to `pipeline.test.js` (only the front-cover mock existed before) and added 5 new tests covering absent-preserves / empty-clears semantics across all four routes. 85/85 pipeline route tests pass; 6089/6089 server tests pass.diff --git a/PLAN.md b/PLAN.mdindex c6363ef50e..9d09896882 100644--- a/PLAN.md+++ b/PLAN.md@@ -12,7 +12,9 @@ _Nothing currently parked — pick the next item from the Backlog._### Code quality / dedup (from `/simplify` passes)-- [ ] [extract-cover-render-handler-factory] **Collapse the four cover-render route handlers into one factory.** `server/routes/pipeline.js` has four sibling cover-render routes (`/series/:id/seasons/:seasonId/cover/render`, `/back-cover/render`, `/issues/:id/stages/comicPages/cover/render`, `/back-cover/render`) whose bodies are 95% identical — they differ only in { schema, enqueue fn, slot field (`cover` vs `backCover`), service-write helper (`updateSeasonOnSeries` vs `updateStageWithLatest`), script field name (`coverScript` vs `backCoverScript`), and response shape }. `makeCoverRenderSchema` already factored the schema (line ~376); a parallel `makeCoverRenderHandler({ schema, enqueueFn, slotField, writeFn, scriptField, responseShape })` factory would fold ~80 LOC into ~25. Surfaced by /simplify on `[med-pipeline-server-routes-pipeline-js-1416-1452]`; deferred to keep that PR scoped to the script-write bugfix.+- [ ] [drop-redundant-getissue-precheck-comic-cover-render] **[LOW][EFF]** Drop the `prepare: (req) => issuesSvc.getIssue(req.params.id)` precheck from the two comic-issue cover-render routes (`server/routes/pipeline.js:1518` + `:1532`). The follow-up `enqueueComicCover` / `enqueueComicBackCover` already calls `loadBibleContext(issueId)` (`server/services/pipeline/visualStages.js:401`), whose first step at `loadBibleContext`:141 is the same `getIssue(issueId)` — same `ERR_NOT_FOUND` → 404 mapping fires from there. The precheck is a duplicate `data/issues.json` read on every render request, and the inline comment's "before we spend the bible-context load" rationale is misleading because `loadBibleContext`'s first step IS that `getIssue`. Removing it also lets us drop the `prepare` knob from `makeCoverRenderHandler` if no other future caller needs it. Surfaced by /simplify during `[extract-cover-render-handler-factory]`; deferred to keep that PR a pure behavior-preserving refactor.++- [ ] [cover-render-factory-target-binding] **[LOW][CODE]** Collapse `makeCoverRenderHandler`'s 7-field config into a "target binding" object so volume / comic dispatch is one symbol per route. Today `applyWrite` + `buildResponse` are independently passed and a comic config could nonsensically mix `applyWrite: updateVolumeSeason` with `buildResponse: buildVolumeCoverResponse`. A `volumeTarget` / `comicTarget` binding (`{ update, buildResponse }`) makes invalid combos unrepresentable and shrinks the four route configs to `{ schema, slotField, scriptField, target }`. Also: promote `'cover' | 'backCover'` to a `COVER_TARGETS` enum in `server/services/pipeline/owners.js` and derive `scriptField` from it so the parallel `scriptField` field can drop entirely. Surfaced by /simplify during `[extract-cover-render-handler-factory]`; deferred because there are only two bindings (volume / comic) and no third caller is in sight, so today's parameter shape is fine — pick this up when a fifth cover-render variant appears.### v2.1.0 pre-release review residue (deferred from main→release multi-agent review, 2026-05-16)