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
renumber canon-reconcile migration 054→055 (054 taken by scrap-chunking on main)
[._.]/ Adam Eivy389841517574
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 956cfc6b09..3b964484cd 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -18,7 +18,7 @@## Added-- **[catalog-character-sheet-enrichment] Catalog and Universe Builder are now the same durable record, and the catalog's color palette / stats / aliases are editable inline.** Editing a character/place/object on the Catalog detail page and editing it on the Universe Builder canon surface used to write two parallel copies (the `catalog_ingredients` row and the embedded `universe.characters[]` entry) that silently drifted apart. They're now kept in lockstep by a bidirectional projection (`server/services/catalogCanonProjection.js`): a Catalog edit fans into every linked universe's embedded canon entry (best-effort, after the response), and a canon edit projects back into the catalog row synchronously inside `updateUniverse` so the embedded copy is a never-lagging cache of the one store of record. Conflicts resolve last-writer-wins on `updatedAt`; an in-flight re-entrancy guard breaks the catalog→canon→catalog loop so each side is written exactly once per edit. A one-time boot reconciliation (`reconcileCanonCatalog.js`, marker `data/catalog-canon-reconcile.applied.json`, registered as migration `054`) collapses any pre-existing divergence on first upgrade. Separately, the catalog character/place/object detail page now edits the enriched array fields inline — Aliases (string chips), Color Palette (`{ name, hex, role }` swatch rows with a native color picker), and Stats (`{ label, value }` rows) — instead of rendering them read-only; add-buttons disable at the storyBible caps (12 colors, 30 stats, 12 aliases). Bible-type payloads are now run through their storyBible sanitizer (`sanitizeCharacter`/`sanitizePlace`/`sanitizeObject`) on every catalog create/update so the array editors can't land malformed rows; idea/scene/concept and user-defined types are untouched. (Builds on the editable grouped sheet + reference-sheet panel + friendly-tag repair that shipped earlier as a slice.)+- **[catalog-character-sheet-enrichment] Catalog and Universe Builder are now the same durable record, and the catalog's color palette / stats / aliases are editable inline.** Editing a character/place/object on the Catalog detail page and editing it on the Universe Builder canon surface used to write two parallel copies (the `catalog_ingredients` row and the embedded `universe.characters[]` entry) that silently drifted apart. They're now kept in lockstep by a bidirectional projection (`server/services/catalogCanonProjection.js`): a Catalog edit fans into every linked universe's embedded canon entry (best-effort, after the response), and a canon edit projects back into the catalog row synchronously inside `updateUniverse` so the embedded copy is a never-lagging cache of the one store of record. Conflicts resolve last-writer-wins on `updatedAt`; an in-flight re-entrancy guard breaks the catalog→canon→catalog loop so each side is written exactly once per edit. A one-time boot reconciliation (`reconcileCanonCatalog.js`, marker `data/catalog-canon-reconcile.applied.json`, registered as migration `055`) collapses any pre-existing divergence on first upgrade. Separately, the catalog character/place/object detail page now edits the enriched array fields inline — Aliases (string chips), Color Palette (`{ name, hex, role }` swatch rows with a native color picker), and Stats (`{ label, value }` rows) — instead of rendering them read-only; add-buttons disable at the storyBible caps (12 colors, 30 stats, 12 aliases). Bible-type payloads are now run through their storyBible sanitizer (`sanitizeCharacter`/`sanitizePlace`/`sanitizeObject`) on every catalog create/update so the array editors can't land malformed rows; idea/scene/concept and user-defined types are untouched. (Builds on the editable grouped sheet + reference-sheet panel + friendly-tag repair that shipped earlier as a slice.)- **[catalog-user-defined-types] Define your own Catalog ingredient types in Settings → Catalog.** The catalog shipped six built-in types (character / place / object / idea / scene / concept); you can now add your own — wardrobe, vehicle, faction, magic-system, prompt-fragment, anything — without a code change. A new Settings → Catalog tab lists the built-ins read-only and lets you build custom types from a flat field list: each type is `{ id, label, primaryContentKey, fields: [{ key, label, kind: 'string' | 'longtext' | 'tags' | 'ref', maxLength? }] }`. User types persist in `data/settings.json` (`catalogUserTypes`) — not a new table — and merge into the active type registry at boot and on every save, so they show up immediately as filter chips, in the "New" dropdown, and as a fully editable detail page driven by a single generic field renderer (no per-type React file). A `ref` field links to another catalog ingredient via the existing picker; `tags` reuses the tag chip input. Validity is enforced at the app layer (the registry + a Zod refinement on the ingredient `type`), building on the already-dropped DB `CHECK`. User types federate: they ride a new additive `catalogTypes` block in the catalog sync envelope (LWW-merged into each peer's own settings slice, skipping built-in-id collisions), gated by `PORTOS_SCHEMA_VERSIONS.catalog` bumped to 8 — a peer on an older catalog schema rejects a forward-shaped push with a clean 412 rather than dropping the definitions and then choking on ingredients of an unknown type. Deleting a type that still has ingredients is refused unless you force it (the orphaned rows survive under a fallback editor). No DB migration — settings-only.diff --git a/scripts/migrations/054-reconcile-canon-catalog.js b/scripts/migrations/055-reconcile-canon-catalog.jssimilarity index 100%rename from scripts/migrations/054-reconcile-canon-catalog.jsrename to scripts/migrations/055-reconcile-canon-catalog.jsdiff --git a/scripts/migrations/054-reconcile-canon-catalog.test.js b/scripts/migrations/055-reconcile-canon-catalog.test.jssimilarity index 74%rename from scripts/migrations/054-reconcile-canon-catalog.test.jsrename to scripts/migrations/055-reconcile-canon-catalog.test.jsindex fbd822cf3d..4867fce414 100644--- a/scripts/migrations/054-reconcile-canon-catalog.test.js+++ b/scripts/migrations/055-reconcile-canon-catalog.test.js@@ -1,5 +1,5 @@/**- * Migration 054 is a REGISTRATION STUB — the actual canon↔catalog reconcile+ * Migration 055 is a REGISTRATION STUB — the actual canon↔catalog reconcile* runs at boot from server/scripts/reconcileCanonCatalog.js (which needs the* Postgres pool, unavailable to the file runner). This stub exists only so the* change lands in the migration ledger; its `up()` is a logging no-op. The test@@ -7,9 +7,9 @@*/import { describe, it, expect } from 'vitest';-import migration from './054-reconcile-canon-catalog.js';+import migration from './055-reconcile-canon-catalog.js';-describe('migration 054 — reconcile-canon-catalog (registration stub)', () => {+describe('migration 055 — reconcile-canon-catalog (registration stub)', () => {it('is a no-op that resolves without throwing', async () => {await expect(migration.up()).resolves.toBeUndefined();});diff --git a/server/scripts/reconcileCanonCatalog.js b/server/scripts/reconcileCanonCatalog.jsindex e8544cffad..846c365aa7 100644--- a/server/scripts/reconcileCanonCatalog.js+++ b/server/scripts/reconcileCanonCatalog.js@@ -23,7 +23,7 @@* already-converged rows is a no-op anyway (the LWW comparison finds them* equal-or-fresher and writes nothing material).*- * The corresponding `scripts/migrations/054-reconcile-canon-catalog.js` is a+ * The corresponding `scripts/migrations/055-reconcile-canon-catalog.js` is a* registration stub for the migration ledger — the actual repair runs here* (boot-time) because the `scripts/migrations/` runner executes before the DB* pool is up (same reason migrations 048–053 are boot-time + stubbed).