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

address review: preserve migrateSeriesCanon recovery path post-B.4

[._.]/ Adam Eivyae10bc00a283
diff --git a/server/routes/pipeline.js b/server/routes/pipeline.js
index 59dcf8aeca..51bc02d943 100644
--- a/server/routes/pipeline.js
+++ b/server/routes/pipeline.js
@@ -623,9 +623,10 @@ router.patch('/issues/:id/stages/audio/lines/:lineIdx', asyncHandler(async (req,
}));
// Render one VO line. Voice resolution priority:
-// 1. line.voiceIdOverride (explicit per-line override)
-// 2. character.voiceId (series character binding)
-// 3. (none → uses the configured default voice via synthesize())
+// 1. body.voiceId (per-request override)
+// 2. line.voiceIdOverride (per-line override saved on the issue)
+// 3. character.voiceId (linked-universe canon binding via getSeriesCanon)
+// 4. (none → uses the configured default voice via synthesize())
const lineRenderSchema = z.object({ voiceId: z.string().trim().max(200).optional() });
router.post('/issues/:id/stages/audio/lines/:lineIdx/render', asyncHandler(async (req, res) => {
const lineIdx = Number(req.params.lineIdx);
diff --git a/server/services/pipeline/migrateSeriesCanon.js b/server/services/pipeline/migrateSeriesCanon.js
index 08ca074bc2..03425ed43b 100644
--- a/server/services/pipeline/migrateSeriesCanon.js
+++ b/server/services/pipeline/migrateSeriesCanon.js
@@ -1,17 +1,28 @@
-// One-shot migration: copy series.{characters,settings,objects} into the
-// linked universe so Phase B readers (which prefer universe canon) have data
-// to read. Idempotent — re-running merges by name without creating dupes.
+// One-shot migration: copy legacy series.{characters,settings,objects} into
+// the linked universe so Phase B readers (which only consult universe canon)
+// have data to read. Idempotent — re-running merges by name without dupes.
//
// Runs on demand via CLI: `node server/services/pipeline/migrateSeriesCanon.js`
// or programmatically from server boot if we ever auto-migrate.
//
-// Does NOT clear the series's arrays. They stay as a fallback (and as the
-// edit surface for the existing per-series UI) until Phase B.2 drops them.
+// Phase B.4 note: `sanitizeSeries` no longer round-trips the legacy canon
+// fields, so calling `listSeries()` here would silently produce empty arrays
+// and the migration would no-op for any install that hadn't already migrated.
+// This script intentionally reads the raw `pipeline-series.json` instead, so
+// the recovery path stays viable until the user runs it. Once migrated, the
+// next series-side write will rewrite the JSON without the legacy fields.
-import { listSeries, updateSeries } from './series.js';
+import { join } from 'path';
+import { updateSeries } from './series.js';
+import { PATHS, readJSONFile } from '../../lib/fileUtils.js';
import { getUniverse, createUniverse, updateUniverse } from '../universeBuilder.js';
import { mergeExtractedBible, BIBLE_FIELD } from '../../lib/storyBible.js';
+// Raw read of pipeline-series.json (bypasses sanitizeSeries, which post-B.4
+// strips the legacy canon fields the migration needs to see).
+const readRawSeriesState = () =>
+ readJSONFile(join(PATHS.data, 'pipeline-series.json'), { series: [] }, { logError: false });
+
// Reverse of BIBLE_FIELD — maps the persisted field name (`characters`) back
// to its BIBLE_KIND value (`character`) so the migration can call
// mergeExtractedBible per field. Sourcing this from BIBLE_FIELD keeps one
@@ -22,7 +33,8 @@ const KIND_BY_FIELD = Object.freeze(
);
export async function migrateSeriesCanon({ dryRun = false, log = console.log } = {}) {
- const series = await listSeries();
+ const { series: rawSeries } = await readRawSeriesState();
+ const series = Array.isArray(rawSeries) ? rawSeries : [];
const summary = { seriesScanned: 0, seriesMigrated: 0, universesCreated: 0, perKind: { characters: 0, settings: 0, objects: 0 } };
for (const s of series) {