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
fix: backfill legacy canon descriptions
[._.]/ Adam Eivy8ff35bffb5bd
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 2cf1cbc4af..f6704d44fc 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -14,6 +14,7 @@- **Foundation judges now inspect the character designs they score.** Completed render fields were previously collapsed to the word `ready` in the judge context, so a harsh judge could only see that a value existed and then reasonably report that no anatomy, silhouette, palette, or visual grammar was available for comparison. The bounded context now carries the actual distinguishing details while still excluding unrelated universe assets.- **Series Autopilot can pause without killing productive work.** The live control used to offer only Stop, which terminates the active provider run even when a long foundation judgment is doing useful work. **Pause safely** now records a graceful request, lets the active step and any provisional repair-verification transaction settle, then persists a resumable manual pause; **Stop now** remains available as the immediate emergency control.- **Canon readiness now repairs manuscript-supported blanks before blocking art.** Autopilot's pre-render gate could identify a drawn character, place, or object with no description, but it immediately paused even though the Nouns workflow already had a safe fill-blanks-only service. The gate now runs that strict prose-grounded backfill for each affected issue, rechecks shared canon, and pauses only for locked nouns or visual facts the manuscript genuinely never established—never inventing unsupported design to force a pass.+- **Legacy canon prompts can be promoted into their missing description fields.** Universe expansion and promotion historically persisted image-ready `prompt` text while leaving the canonical `physicalDescription`/`description` blank, so the Cast/Places/Objects tabs and readiness gate disagreed with the renderer. A deterministic fill-blanks-only API now copies that already-authored text without an LLM call, preserving locks, IDs, kinds, prompts, and every existing asset.- **Arc verification can now repair the per-character milestones it judges.** The verifier already read canonical per-character arcs, but its resolver could only edit the series arc, volumes, and issue synopses, so a contradiction in a character transition was impossible to close and repeated retries rewrote unrelated records instead. Finding-keyed character-arc patches now preserve character and transition IDs, merge only named fields, participate in regression rollback, and migrate existing prompt installations to the sparse contract.diff --git a/server/routes/universeBuilder/canon.js b/server/routes/universeBuilder/canon.jsindex 85804e0675..1e546f11ea 100644--- a/server/routes/universeBuilder/canon.js+++ b/server/routes/universeBuilder/canon.js@@ -68,6 +68,15 @@ router.post('/:id/characters/differentiate-cast', asyncHandler(async (req, res)res.json(result);}));+// Deterministic migration for legacy canon entries whose image-ready `prompt`+// was persisted but whose canonical description field was left blank. This is+// fill-blanks-only, respects locks, and makes no LLM call.+router.post('/:id/canon/backfill-descriptions', asyncHandler(async (req, res) => {+ const result = await canonSvc.backfillCanonDescriptionsFromPrompts(req.params.id)+ .catch((err) => { throw mapServiceError(err); });+ res.json(result);+}));+// Cross-reference: per-canon-entry usage across the universe's linked series.// Read-only aggregation; no LLM calls, no writes. Surfaces which series + how// many issues each character / place / object appears in, so the user candiff --git a/server/services/universeCanon.js b/server/services/universeCanon.jsindex e996b7826b..0b030f03b6 100644--- a/server/services/universeCanon.js+++ b/server/services/universeCanon.js@@ -239,6 +239,56 @@ const hasDescription = (kind, entry) => {return !!((entry.description || '').trim());};+/**+ * Promote an existing image prompt into the canonical description field when+ * that field is blank. Older Universe Builder expansion/promotion paths wrote+ * rich `prompt` text but left `physicalDescription`/`description` empty, which+ * made the same entry renderable from one screen and "not ready" from another.+ *+ * This is deliberately deterministic and fill-blanks-only: no provider call,+ * no invented details, no kind changes, and no mutation of locked entries.+ */+export async function backfillCanonDescriptionsFromPrompts(universeId) {+ const report = {+ filled: 0,+ byKind: Object.fromEntries(BIBLE_KINDS.map((kind) => [kind, 0])),+ alreadyDescribed: 0,+ missingPrompt: 0,+ skippedLocked: 0,+ };+ const updated = await updateUniverse(universeId, (universe) => {+ const patch = {};+ for (const kind of BIBLE_KINDS) {+ const field = BIBLE_FIELD[kind];+ const list = Array.isArray(universe[field]) ? universe[field] : [];+ let touched = false;+ const next = list.map((entry) => {+ if (hasDescription(kind, entry)) {+ report.alreadyDescribed += 1;+ return entry;+ }+ if (entry.locked === true) {+ report.skippedLocked += 1;+ return entry;+ }+ const prompt = typeof entry.prompt === 'string' ? entry.prompt.trim() : '';+ if (!prompt) {+ report.missingPrompt += 1;+ return entry;+ }+ touched = true;+ report.filled += 1;+ report.byKind[kind] += 1;+ return { ...entry, [DESC_FIELD[kind]]: prompt.slice(0, DESC_LIMIT[kind]) };+ });+ if (touched) patch[field] = next;+ }+ return Object.keys(patch).length ? patch : null;+ });+ console.log(`📝 Universe canon prompt backfill — universe=${shortId(universeId)} filled=${report.filled} character=${report.byKind.character} place=${report.byKind.place} object=${report.byKind.object} locked=${report.skippedLocked}`);+ return { universe: updated, report };+}+/*** Backfill descriptions for canon nouns that have none, using ONLY what the* prose establishes. Unlike `extractCanonFromProse` (which is allowed to inventdiff --git a/server/services/universeCanon.test.js b/server/services/universeCanon.test.jsindex 46596685c8..1e2d88a4a6 100644--- a/server/services/universeCanon.test.js+++ b/server/services/universeCanon.test.js@@ -536,6 +536,52 @@ describe('universeCanon — describeCanonFromProse (strictly prose-grounded)', (});});+describe('universeCanon — backfillCanonDescriptionsFromPrompts', () => {+ it('copies existing prompts into blank per-kind description fields without an LLM call', async () => {+ const created = await svc.createUniverse({ name: 'U', starterPrompt: 'x', stylePrompt: 'y' });+ const seeded = await svc.updateUniverse(created.id, {+ characters: [{ name: 'Courier', prompt: 'patched yellow pressure coat', physicalDescription: '', locked: false }],+ places: [{ name: 'The Vault', prompt: 'a dim concrete room', description: '', locked: false }],+ objects: [{ name: 'Compass', prompt: 'brass compass with a cracked face', description: '', locked: false }],+ });++ const result = await canonSvc.backfillCanonDescriptionsFromPrompts(seeded.id);++ expect(result.report).toMatchObject({+ filled: 3,+ byKind: { character: 1, place: 1, object: 1 },+ alreadyDescribed: 0,+ missingPrompt: 0,+ skippedLocked: 0,+ });+ expect(result.universe.characters[0].physicalDescription).toContain('yellow pressure coat');+ expect(result.universe.places[0].description).toBe('a dim concrete room');+ expect(result.universe.objects[0].description).toContain('brass compass');+ expect(runStagedLLMMock).not.toHaveBeenCalled();+ });++ it('preserves authored descriptions and skips locked or promptless blanks', async () => {+ const created = await svc.createUniverse({ name: 'U', starterPrompt: 'x', stylePrompt: 'y' });+ const seeded = await svc.updateUniverse(created.id, {+ characters: [{ name: 'Done', prompt: 'replacement', physicalDescription: 'authored look', locked: false }],+ places: [{ name: 'Locked', prompt: 'available prompt', description: '', locked: true }],+ objects: [{ name: 'Unknown', prompt: '', description: '', locked: false }],+ });++ const result = await canonSvc.backfillCanonDescriptionsFromPrompts(seeded.id);++ expect(result.report).toMatchObject({+ filled: 0,+ alreadyDescribed: 1,+ missingPrompt: 1,+ skippedLocked: 1,+ });+ expect(result.universe.characters[0].physicalDescription).toBe('authored look');+ expect(result.universe.places[0].description).toBe('');+ expect(result.universe.objects[0].description).toBe('');+ });+});+describe('universeCanon — summarizeDescribeGaps', () => {it('maps the report into a persistable marker', () => {const m = canonSvc.summarizeDescribeGaps({