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
address review: include canon arrays in manual save payload
[._.]/ Adam Eivyf460f9028484
diff --git a/client/src/pages/UniverseBuilder.jsx b/client/src/pages/UniverseBuilder.jsxindex 06506295f2..fa958c035a 100644--- a/client/src/pages/UniverseBuilder.jsx+++ b/client/src/pages/UniverseBuilder.jsx@@ -35,6 +35,7 @@ import OriginBadge from '../components/sharing/OriginBadge';import UniverseCanonSection from '../components/universe/UniverseCanonSection';import { deriveAvailableBackends, IMAGE_GEN_MODE } from '../lib/imageGenBackends';import { PIPELINE_IMAGE_DEFAULTS, readPipelineImageSettings } from '../lib/pipelineImageDefaults';+import { normalizeSlugline } from '../lib/scenePrompt';const CATEGORY_LABELS = {landscapes: 'Landscapes',@@ -77,20 +78,28 @@ const mergeVariations = (existing, fresh) => {// AND slugline (for settings) so an expand that re-emits "Foundry City" or// "INT. FOUNDRY CITY — DAY" can't create a phantom duplicate. Mirrors the// server-side dedupe in backfillCanonFromCategories (storyBible#normalizeBibleName).+//+// Sluglines use `normalizeSlugline` (same identity rule the rest of the app+// uses — `server/lib/scenePrompt.js` + `client/src/lib/scenePrompt.js` ++// `storyBible.js` MERGE_CONFIG.setting.keyFields). Without this, sluglines+// that differ only in dash style or punctuation ("INT. FOUNDRY CITY — DAY"+// vs "INT FOUNDRY CITY - DAY") would land as two separate place-canon+// entries even though every downstream lookup treats them as one.const mergeCanonByName = (existing, fresh) => {// Empty/missing fresh — return `existing` unchanged (preserve reference so// a no-op expand doesn't trigger downstream identity-comparing effects).if (!fresh?.length) return existing || [];const norm = (s) => (typeof s === 'string' ? s.trim().toLowerCase() : '');+ const normSlug = (s) => (typeof s === 'string' ? normalizeSlugline(s) : '');const seen = new Set();for (const e of existing || []) {if (e?.name) seen.add(norm(e.name));- if (e?.slugline) seen.add(norm(e.slugline));+ if (e?.slugline) seen.add(normSlug(e.slugline));}const merged = [...(existing || [])];for (const e of fresh) {const nameKey = norm(e?.name);- const sluglineKey = norm(e?.slugline);+ const sluglineKey = normSlug(e?.slugline);if ((nameKey && seen.has(nameKey)) || (sluglineKey && seen.has(sluglineKey))) continue;if (nameKey) seen.add(nameKey);if (sluglineKey) seen.add(sluglineKey);@@ -419,6 +428,14 @@ export default function UniverseBuilder() {styleNotes: draft.styleNotes || '',categories: draft.categories,compositeSheets: draft.compositeSheets || [],+ // Canon arrays must be included on the manual Save/Create path too —+ // a brand-new world that took the "review then Save" toast path would+ // otherwise drop every expanded canon entry on first create, since+ // only the auto-save branch (which only runs for already-saved worlds)+ // forwards them. See review-resolved Copilot finding on PRRT_kwDOQx8jQ86CpLRw.+ characters: draft.characters || [],+ settings: draft.settings || [],+ objects: draft.objects || [],influences: ensureInfluences(draft.influences),locked: draft.locked || {},llm: draft.llm || {},diff --git a/scripts/migrations/019-arc-verify-resolve-canon-context.js b/scripts/migrations/019-arc-resolve-volume-verify-canon-context.jssimilarity index 92%rename from scripts/migrations/019-arc-verify-resolve-canon-context.jsrename to scripts/migrations/019-arc-resolve-volume-verify-canon-context.jsindex 028968aae5..dee06f973c 100644--- a/scripts/migrations/019-arc-verify-resolve-canon-context.js+++ b/scripts/migrations/019-arc-resolve-volume-verify-canon-context.js@@ -1,7 +1,12 @@/**- * Add `{{worldCanonText}}` context block to arc-verify + arc-resolve prompt- * templates so the LLM sees named universe canon (characters/places/objects)- * alongside the existing exploratory `worldCategoriesText`.+ * Add `{{worldCanonText}}` context block to the arc-resolve and+ * volume-verify prompt templates so the LLM sees named universe canon+ * (characters/places/objects) alongside the existing exploratory+ * `worldCategoriesText`.+ *+ * Updates (per ACCEPTED_OLD_MD5 below):+ * - data/prompts/stages/pipeline-arc-resolve.md+ * - data/prompts/stages/pipeline-volume-verify.md** Why:* Phase A retired the default `characters` category; characters now live indiff --git a/server/services/universeBuilderExpand.js b/server/services/universeBuilderExpand.jsindex fb5aa0d8db..e2f1aff0a0 100644--- a/server/services/universeBuilderExpand.js+++ b/server/services/universeBuilderExpand.js@@ -224,7 +224,14 @@ const normalizeCategories = (raw) => {let variations = [];if (Array.isArray(node)) variations = node;else if (Array.isArray(node?.variations)) variations = node.variations;+ // Forward the LLM-returned `kind` (if present) so sanitizeCategory can+ // honor it. Without this passthrough, every custom bucket falls back to+ // the WORLD_CATEGORY_DEFAULT_KINDS map (or `other`), and "kind"-tagged+ // buckets like `factions: { kind: 'characters' }` silently land under the+ // wrong canon trunk in the UI despite the prompt contract advertising it.+ const rawKind = node && typeof node === 'object' && !Array.isArray(node) ? node.kind : undefined;out[key] = {+ ...(rawKind !== undefined ? { kind: rawKind } : {}),// Clamp to the same per-category cap the route schema enforces (50)// so a runaway LLM response can't bloat /expand output.variations: variationsdiff --git a/server/services/universeBuilderExpand.test.js b/server/services/universeBuilderExpand.test.jsindex 8575bb87b7..b405938eaa 100644--- a/server/services/universeBuilderExpand.test.js+++ b/server/services/universeBuilderExpand.test.js@@ -225,6 +225,26 @@ describe("universeBuilderExpand.normalizeCategories", () => {const out = normalizeCategories({ factions: "not an object" });expect(out.factions).toMatchObject({ variations: [] });});++ it("forwards LLM-returned `kind` so custom buckets land under the right trunk", () => {+ // The expansion prompt asks the LLM to tag each category with a `kind`.+ // Without explicit passthrough in the normalizer, that tag is discarded+ // and every custom bucket falls back to the default-map / `other` —+ // breaking the contract that `factions: { kind: 'characters' }` lands+ // under the characters canon trunk in the UI.+ const out = normalizeCategories({+ factions: {+ kind: "characters",+ variations: [{ label: "Wake Jackals", prompt: "scavenger raiders" }],+ },+ gear: {+ kind: "objects",+ variations: [{ label: "Bone hook", prompt: "carved bone hook" }],+ },+ });+ expect(out.factions.kind).toBe("characters");+ expect(out.gear.kind).toBe("objects");+ });});describe("universeBuilderExpand.normalizeCompositeSheets", () => {