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: keep universe and commission fields when an older peer's edit wins sync (#8414)
[._.]/ Adam Eivy521969eeed8c
diff --git a/server/lib/storyBible.js b/server/lib/storyBible.jsindex bd545b0790..7a09a4dd8d 100644--- a/server/lib/storyBible.js+++ b/server/lib/storyBible.js@@ -437,46 +437,77 @@ export function characterIdentityPackReadiness(character) {};}-// Additive character fields an older peer's sanitizer cannot represent, keyed+// Additive bible-entry fields an older peer's sanitizer cannot represent, keyed// by the `universes` wire version that introduced each one. A sender AT or// ABOVE that version omitting the field means the author cleared it; a sender// BELOW it omitted the field only because its code has no slot for it.const ADDITIVE_CHARACTER_FIELD_VERSIONS = Object.freeze({+ // v6 — structured character-to-character links (#1287).+ relationshipLinks: 6,// v10 — portable production canon (#5378).voiceCanon: 10,identityPack: 10,// v11 — optional structured psychology profile (#6414).psychology: 11,});+const ADDITIVE_OBJECT_FIELD_VERSIONS = Object.freeze({+ // v7 — structured object↔character attachments (#1288).+ attachments: 7,+});++// "The sender carried nothing here." Covers both absent-when-empty fields+// (voiceCanon, psychology) and always-present list fields a behind sender's+// sanitizer defaults to `[]` (relationshipLinks, attachments).+export function isLegacyAbsentValue(value) {+ return value === undefined || value === null || value === false || value === ''+ || (Array.isArray(value) && value.length === 0);+}/**- * Preserve additive character fields when an older peer wins LWW with a- * character shape that could not represent them. Each field is restored ONLY+ * Restore, onto each remote entry, the local entry's value for every additive+ * field the sender's version could not represent. Each field is restored ONLY* from a sender behind the version that introduced it — a version-aware* sender's omission is an intentional clear and must pass through unchanged.+ * Entries pair by id; a remote entry with no local counterpart is untouched.*/-export function preserveLegacyCharacterFields(remoteCharacters, localCharacters, senderUniversesVersion) {+function preserveLegacyEntryFields(remoteEntries, localEntries, fieldVersions, senderUniversesVersion) {const sender = Number(senderUniversesVersion) || 0;- const unrepresentable = Object.entries(ADDITIVE_CHARACTER_FIELD_VERSIONS)+ const unrepresentable = Object.entries(fieldVersions).filter(([, since]) => sender < since).map(([field]) => field);if (unrepresentable.length === 0- || !Array.isArray(remoteCharacters)- || !Array.isArray(localCharacters)) return remoteCharacters;+ || !Array.isArray(remoteEntries)+ || !Array.isArray(localEntries)) return remoteEntries;const localById = new Map(- localCharacters.filter((character) => character?.id).map((character) => [character.id, character]),+ localEntries.filter((entry) => entry?.id).map((entry) => [entry.id, entry]),);- return remoteCharacters.map((character) => {- const localCharacter = localById.get(character?.id);- if (!localCharacter) return character;+ return remoteEntries.map((entry) => {+ const localEntry = localById.get(entry?.id);+ if (!localEntry) return entry;const restored = {};for (const field of unrepresentable) {- if (!character?.[field] && localCharacter[field]) restored[field] = localCharacter[field];+ if (isLegacyAbsentValue(entry?.[field]) && !isLegacyAbsentValue(localEntry[field])) {+ restored[field] = localEntry[field];+ }}- return Object.keys(restored).length ? { ...character, ...restored } : character;+ return Object.keys(restored).length ? { ...entry, ...restored } : entry;});}+/** Preserve additive character fields when an older peer wins LWW. */+export function preserveLegacyCharacterFields(remoteCharacters, localCharacters, senderUniversesVersion) {+ return preserveLegacyEntryFields(+ remoteCharacters, localCharacters, ADDITIVE_CHARACTER_FIELD_VERSIONS, senderUniversesVersion,+ );+}++/** Preserve additive object fields when an older peer wins LWW. */+export function preserveLegacyObjectFields(remoteObjects, localObjects, senderUniversesVersion) {+ return preserveLegacyEntryFields(+ remoteObjects, localObjects, ADDITIVE_OBJECT_FIELD_VERSIONS, senderUniversesVersion,+ );+}+// The legacy 'standard' variant lives in `character.referenceSheetImageRef`;// every other variant lives in `character.referenceSheets[<id>]`. Exported so// every reader/writer of either slot uses the same constant — the alternativediff --git a/server/services/creativeCommissions/store.js b/server/services/creativeCommissions/store.jsindex 4573246ea5..cfd938f9e2 100644--- a/server/services/creativeCommissions/store.js+++ b/server/services/creativeCommissions/store.js@@ -351,6 +351,38 @@ function preserveLocalCommissionFields(remote, local) {return out;}+// Federated generation keys introduced by `creativeCommissions` v3 (#3135) —+// the per-commission render-backend pin. A v2 sender's sanitizer keeps only the+// generation keys it knows, so its record ALWAYS carries the default here.+const COMMISSION_BACKEND_PIN_KEYS = ['imageMode', 'videoMode', 'imageModelId', 'videoModelId'];++/**+ * Carry the local brief's additive federated fields onto a winning remote from a+ * sender too old to represent them (#8414). The version gate only rejects AHEAD+ * senders, so a behind sender's brief reaches this LWW merge with those fields+ * already sanitized away — its omission means "no slot", not "cleared". A sender+ * at or above the introducing version passes through untouched, so a real clear+ * still applies. A missing/unparseable sender version counts as 0.+ */+function preserveLegacyCommissionFields(remote, local, senderVersion) {+ const sender = Number(senderVersion) || 0;+ let out = remote;+ if (sender < 3 && remote.generation && local.generation) {+ // Only the keys BOTH shapes carry: a sender that also switched the output+ // type has no slot for the old type's pin, and the new type never had one.+ const pins = {};+ for (const key of COMMISSION_BACKEND_PIN_KEYS) {+ if (key in remote.generation && key in local.generation) pins[key] = local.generation[key];+ }+ if (Object.keys(pins).length) out = { ...out, generation: { ...out.generation, ...pins } };+ }+ // v4 — Digital Twin musicTaste config (#4347), persisted only when set.+ if (sender < 4 && !out.brief?.musicTaste && local.brief?.musicTaste) {+ out = { ...out, brief: { ...out.brief, musicTaste: local.brief.musicTaste } };+ }+ return out;+}+/*** LWW merge decision for one incoming commission (mirrors mergeWorkRecord): the* remote is sanitized here (drop-on-floor → null); a missing local INSERTS the@@ -358,8 +390,10 @@ function preserveLocalCommissionFields(remote, local) {* on the receiver until the user opts in; else the newer BRIEF clock wins, and the* receiver's machine-local schedule/runs/assignment/enabled/feedback carry forward* (they never travel), so a peer's brief edit can't arm or reset this machine.+ * `senderSchemaVersions` lets a behind sender's win keep the additive brief+ * fields its version cannot represent (see preserveLegacyCommissionFields).*/-export function mergeCommissionRecord(local, remoteRaw) {+export function mergeCommissionRecord(local, remoteRaw, { senderSchemaVersions = null } = {}) {const remote = sanitizeCommissionForSync(remoteRaw);if (!remote) return { next: null, inserted: false, remoteWins: false, changed: false };if (!local) {@@ -370,7 +404,12 @@ export function mergeCommissionRecord(local, remoteRaw) {}const sanitizedLocal = sanitizeCommission(local);const remoteWins = compareNewerWins(remote.briefUpdatedAt, sanitizedLocal.briefUpdatedAt);- const next = remoteWins ? preserveLocalCommissionFields(remote, sanitizedLocal) : local;+ const next = remoteWins+ ? preserveLocalCommissionFields(+ preserveLegacyCommissionFields(remote, sanitizedLocal, senderSchemaVersions?.creativeCommissions),+ sanitizedLocal,+ )+ : local;const changed = JSON.stringify(next) !== JSON.stringify(local);return { next, inserted: false, remoteWins, changed };}@@ -935,7 +974,7 @@ export async function listCommissionIdsForSync(options = {}) {* scheduler (a merged brief/tombstone can change what's armed). Mirrors* writersRoom's `mergeBodylessFromSync`, minus the PG row lock.*/-export async function mergeCommissionsFromSync(remoteRecords, { source = { via: 'sync', peerId: null } } = {}) {+export async function mergeCommissionsFromSync(remoteRecords, { source = { via: 'sync', peerId: null }, senderSchemaVersions = null } = {}) {if (!Array.isArray(remoteRecords)) return { applied: false, count: 0 };const store = commissionStore();let changed = 0;@@ -951,7 +990,7 @@ export async function mergeCommissionsFromSync(remoteRecords, { source = { via:if (!isStr(id) || !COMMISSION_ID_RE.test(id)) continue;const applied = await store.queueRecordWrite(id, async () => {const local = await store.readRaw(id, { includeDeleted: true });- const { next, inserted, remoteWins, changed: didChange } = mergeCommissionRecord(local, remote);+ const { next, inserted, remoteWins, changed: didChange } = mergeCommissionRecord(local, remote, { senderSchemaVersions });if (!next) return false;if (!inserted && (!remoteWins || !didChange)) return false;if (!inserted) {diff --git a/server/services/creativeCommissions/store.test.js b/server/services/creativeCommissions/store.test.jsindex 226808c9a8..3eae399348 100644--- a/server/services/creativeCommissions/store.test.js+++ b/server/services/creativeCommissions/store.test.js@@ -696,6 +696,55 @@ describe('commission BRIEF federation (#2686)', () => {expect(next.assignment.providerId).toBe('claude');});+ // A behind sender's sanitizer strips the brief fields its version predates,+ // so its winning brief omits them for lack of a slot — not as a clear (#8414).+ describe('additive brief fields from a behind sender (#8414)', () => {+ const LOCAL_TS = '2026-01-01T00:00:00.000Z';+ const REMOTE_TS = '2026-06-06T00:00:00.000Z';+ const musicTaste = { source: 'digital-twin', anchorCount: 4, explorationPercent: 40 };+ const localRecord = (overrides) => sanitizeCommission({+ id: 'commission-x', name: 'Local', updatedAt: LOCAL_TS,+ schedule: { kind: 'DAILY', atLocalTime: '02:00' }, runs: [{ id: 'run-1', status: 'ok' }],+ assignment: { providerId: 'claude', model: 'opus' },+ ...overrides,+ });+ const merge = (local, remote, version) => mergeCommissionRecord(+ local, { ...remote, id: 'commission-x', name: 'Renamed on peer', updatedAt: REMOTE_TS },+ { senderSchemaVersions: { creativeCommissions: version } },+ );++ it('keeps brief.musicTaste from a v3 sender but applies a v4 clear', () => {+ const local = localRecord({ targetAbility: 'music', brief: { intent: 'ambient', musicTaste } });+ const remote = { targetAbility: 'music', brief: { intent: 'ambient drone' } };++ const behind = merge(local, remote, 3);+ expect(behind.remoteWins).toBe(true);+ expect(behind.next.brief.intent).toBe('ambient drone');+ expect(behind.next.brief.musicTaste).toEqual(local.brief.musicTaste);+ // Machine-local fields still carry forward exactly as before.+ expect(behind.next.schedule.atLocalTime).toBe('02:00');+ expect(behind.next.runs).toHaveLength(1);+ expect(behind.next.assignment.providerId).toBe('claude');++ expect(merge(local, remote, 4).next.brief.musicTaste).toBeUndefined();+ });++ it('keeps the generation backend pin from a v2 sender but applies a v3 reset', () => {+ const local = localRecord({+ targetAbility: 'image',+ generation: { imageCount: 2, imageMode: 'codex', imageModelId: 'img-model-a' },+ });+ const remote = { targetAbility: 'image', generation: { imageCount: 4 } };++ const behind = merge(local, remote, 2).next;+ expect(behind.generation).toMatchObject({ imageCount: 4, imageMode: 'codex', imageModelId: 'img-model-a' });+ expect(behind.assignment.providerId).toBe('claude');++ const current = merge(local, remote, 3).next;+ expect(current.generation).toMatchObject({ imageCount: 4, imageMode: 'auto', imageModelId: null });+ });+ });+it('a stale remote loses to a newer local (no clobber)', () => {const local = sanitizeCommission({ id: 'commission-x', name: 'Newer', updatedAt: '2026-09-09T00:00:00.000Z' });const remote = { id: 'commission-x', name: 'Older', updatedAt: '2020-01-01T00:00:00.000Z' };diff --git a/server/services/sharing/importer.js b/server/services/sharing/importer.jsindex e19099f763..edb5aec875 100644--- a/server/services/sharing/importer.js+++ b/server/services/sharing/importer.js@@ -37,13 +37,12 @@ import { insertSeriesWithId, updateSeries, getSeries } from '../pipeline/series.import { insertIssueWithId, updateIssue, getIssue } from '../pipeline/issues.js';import { mergeReviewFromSync } from '../pipeline/manuscriptReview.js';import { mergeOutlineFromSync } from '../pipeline/reverseOutline.js';-import { insertUniverseWithId, updateUniverse, getUniverse } from '../universeBuilder.js';+import { insertUniverseWithId, updateUniverse, getUniverse, preserveLegacyUniverseFields } from '../universeBuilder.js';import { applyLegacySeriesCanonToUniverse } from '../pipeline/migrateSeriesCanon.js';import { findOrCreateUniverseCollection, findOrCreateSeriesCollection, addItem as addCollectionItem, ERR_DUPLICATE as COLLECTION_ERR_DUPLICATE } from '../mediaCollections.js';import { adoptImportedSubscription, withReexportSuppressed } from './subscriptions.js';import { getInstanceId, UNKNOWN_INSTANCE_ID } from '../instanceIdentity.js';import { mergePeerAnnotations } from '../mediaAnnotations.js';-import { preserveLegacyCharacterFields } from '../../lib/storyBible.js';import { isPlainObject } from '../../lib/objects.js';import { maybeJournalBeforeOverwrite, flushBaseHashes, setSyncBaseHash, contentHashForRecord } from '../../lib/conflictJournal.js';import { isStr } from '../../lib/textUtils.js';@@ -578,14 +577,7 @@ async function applyAutoMerge(bucket, manifest, records, { availableAssetKeys =record = { ...record, arcRole: 'climax' };}if (kind === 'universe') {- record = {- ...record,- characters: preserveLegacyCharacterFields(- record.characters,- existing.characters,- senderUniversesVersion,- ),- };+ record = preserveLegacyUniverseFields(record, existing, senderUniversesVersion);}// Non-blocking conflict journal for every synced record kind — a// share-bucket import that LWW-overwrites a locally-diverged recorddiff --git a/server/services/sharing/peerSyncReceive.js b/server/services/sharing/peerSyncReceive.jsindex 2a1b001e3e..106047966d 100644--- a/server/services/sharing/peerSyncReceive.js+++ b/server/services/sharing/peerSyncReceive.js@@ -260,9 +260,9 @@ export async function applyIncomingPush(payload, authorization) {// every PEER_SUBSCRIBABLE_KINDS entry has a descriptor (the registry guard// in recordKinds.test.js enforces it), so `desc` is never null here.// `senderSchemaVersions` rides every merge call uniformly: only- // mergeUniversesFromSync (gates the moodBoardId omitted-vs-cleared- // disambiguation, #4188) and mergeLoomsFromSync read it — every other- // merger ignores the extra key. The 12 kinds with no extra per-kind+ // mergeUniversesFromSync, mergeCommissionsFromSync (both gate the+ // omitted-vs-cleared disambiguation of additive fields, #4188/#8414) and+ // mergeLoomsFromSync read it — every other merger ignores the extra key. The 12 kinds with no extra per-kind// behavior need nothing further; the three genuinely special kinds below// add their bundled-doc handling on top of this single call.const mergeResult = await desc.merge([record], { source, senderSchemaVersions });diff --git a/server/services/sharing/recordKinds.js b/server/services/sharing/recordKinds.jsindex ab67d350e2..2f398e9933 100644--- a/server/services/sharing/recordKinds.js+++ b/server/services/sharing/recordKinds.js@@ -34,7 +34,8 @@* `merge` is called uniformly as `desc.merge(records, { source,* senderSchemaVersions })` — every merger destructures at least `{ source }`;* the dozen that don't also use `senderSchemaVersions` simply ignore the- * extra key (only `mergeUniversesFromSync` and `mergeLoomsFromSync` read it).+ * extra key (only `mergeUniversesFromSync`, `mergeLoomsFromSync` and+ * `mergeCommissionsFromSync` read it).*/import { getUniverse, mergeUniversesFromSync } from '../universeBuilder.js';import { getSeries, mergeSeriesFromSync } from '../pipeline/series.js';diff --git a/server/services/universeBuilder.test.js b/server/services/universeBuilder.test.jsindex 729dc59c05..cd79e31e4a 100644--- a/server/services/universeBuilder.test.js+++ b/server/services/universeBuilder.test.js@@ -1376,6 +1376,72 @@ describe("universeBuilder service", () => {expect(after.characters[0].voiceCanon).toMatchObject({ description: 'warm low alto', approved: true });expect(after.characters[0].identityPack.assets).toEqual([{ role: 'neutral', imageRef: 'neutral.png', approved: true }]);});++ // Additive fields a behind sender's sanitizer strips (#8414). Each case+ // seeds the field locally, then merges a newer remote that lacks it —+ // from a sender one version behind the field (omission = "no slot",+ // must preserve) and from a sender AT the field's version (omission =+ // the author's clear, must apply).+ const styleReference = {+ id: 'style-ref-example', title: 'Dust-lit ink wash', prompt: 'Granular ink wash',+ imageRefs: ['reference.png'], createdAt: '2026-01-01T00:00:00.000Z',+ };+ const withoutField = (list, field) => list.map(({ [field]: _omit, ...rest }) => rest);+ const legacyFieldCases = [+ {+ field: 'factual', since: 12,+ patch: { factual: true },+ strip: ({ factual: _omit, ...rest }) => rest,+ read: (u) => u.factual,+ kept: true, cleared: undefined,+ },+ {+ field: 'styleReferences', since: 8,+ patch: { styleReferences: [styleReference] },+ strip: (u) => ({ ...u, styleReferences: [] }),+ read: (u) => u.styleReferences,+ kept: [styleReference], cleared: [],+ },+ {+ field: 'character relationshipLinks', since: 6,+ patch: {+ characters: [+ { id: 'chr-1', name: 'A', relationshipLinks: [{ id: 'rel-1', targetCharacterId: 'chr-2', type: 'custom', description: 'rivals' }] },+ { id: 'chr-2', name: 'B' },+ ],+ },+ strip: (u) => ({ ...u, characters: withoutField(u.characters, 'relationshipLinks') }),+ read: (u) => u.characters.find((c) => c.id === 'chr-1').relationshipLinks.map((l) => l.id),+ kept: ['rel-1'], cleared: [],+ },+ {+ field: 'object attachments', since: 7,+ patch: {+ characters: [{ id: 'chr-1', name: 'A' }],+ objects: [{ id: 'obj-1', name: 'Brass Lamp', attachments: [{ id: 'att-1', characterId: 'chr-1', role: 'custom', emotion: 'dread' }] }],+ },+ strip: (u) => ({ ...u, objects: withoutField(u.objects, 'attachments') }),+ read: (u) => u.objects.find((o) => o.id === 'obj-1').attachments.map((a) => a.id),+ kept: ['att-1'], cleared: [],+ },+ ];++ it.each(legacyFieldCases)('preserves $field from a behind sender but honors an at-version clear (#8414)', async ({ since, patch, strip, read, kept, cleared }) => {+ for (const [senderVersion, expected] of [[since - 1, kept], [since, cleared]]) {+ const w = await seedWorld();+ await svc.updateUniverse(w.id, patch);+ const local = await svc.getUniverse(w.id);+ expect(read(local)).toEqual(kept);+ const r = await svc.mergeUniversesFromSync(+ [{ ...strip(local), name: 'Peer rename', updatedAt: new Date(Date.now() + 60_000).toISOString() }],+ { senderSchemaVersions: { universes: senderVersion } },+ );+ expect(r.applied).toBe(true);+ const after = await svc.getUniverse(w.id);+ expect(after.name).toBe('Peer rename');+ expect(read(after)).toEqual(expected);+ }+ });});describe("pruneTombstonedUniverses", () => {diff --git a/server/services/universeBuilder/sync.js b/server/services/universeBuilder/sync.jsindex 37d22bb734..cd563e527e 100644--- a/server/services/universeBuilder/sync.js+++ b/server/services/universeBuilder/sync.js@@ -8,7 +8,9 @@* re-exports this module so existing import paths keep working.*/-import { preserveLegacyCharacterFields } from '../../lib/storyBible.js';+import {+ isLegacyAbsentValue, preserveLegacyCharacterFields, preserveLegacyObjectFields,+} from '../../lib/storyBible.js';import {maybeJournalBeforeOverwrite, setSyncBaseHash, contentHashForRecord, flushBaseHashes,deleteSyncBaseHash, withBaseHashFlushBatch,@@ -36,6 +38,45 @@ async function cascadeDeleteSideEffects(id) {emitRecordDeleted('universe', id);}+// Additive universe-level fields an older peer's sanitizer cannot represent,+// keyed by the `universes` wire version that introduced each one. The version+// gate only rejects AHEAD senders, so a behind (or no-meta) sender's record+// flows through the LWW merge with these fields already sanitized away — its+// omission means "my code has no slot for this", not "the author cleared it".+// A sender at or above the version omitting the field IS a clear. The next+// additive universe field is a one-line addition here.+const ADDITIVE_UNIVERSE_FIELD_VERSIONS = Object.freeze({+ // v8 — shared, user-selected visual references.+ styleReferences: 8,+ // v9 — linked mood board (#4188).+ moodBoardId: 9,+ // v12 — factual/fiction axis (#7616). Persisted only when true.+ factual: 12,+});++/**+ * Carry the local copy's additive fields onto a remote universe that won LWW+ * from a sender too old to represent them — universe-level fields plus the+ * per-entry character and object fields (#8414). A version-aware sender's+ * omission passes through as the intentional clear it is. Pure: returns a new+ * record (or `remote` itself when nothing needed restoring).+ */+export function preserveLegacyUniverseFields(remote, local, senderUniversesVersion) {+ if (!remote || !local) return remote;+ const sender = Number(senderUniversesVersion) || 0;+ const out = { ...remote };+ for (const [field, since] of Object.entries(ADDITIVE_UNIVERSE_FIELD_VERSIONS)) {+ if (sender < since && isLegacyAbsentValue(out[field]) && !isLegacyAbsentValue(local[field])) {+ out[field] = local[field];+ }+ }+ // Only touch the lists the remote carries — a raw share-bucket record may+ // omit one, and an `undefined`-valued key would clobber it in a patch merge.+ if ('characters' in out) out.characters = preserveLegacyCharacterFields(out.characters, local.characters, sender);+ if ('objects' in out) out.objects = preserveLegacyObjectFields(out.objects, local.objects, sender);+ return out;+}+/*** Sync-orchestrator entry point. Merges a remote peer's universe array into* local state INSIDE the store's per-id write queue, so each remote record's@@ -54,10 +95,6 @@ async function cascadeDeleteSideEffects(id) {* post-merge count — so callers summing across categories don't over-report.*/export async function mergeUniversesFromSync(remoteUniverses, { source = { via: 'sync', peerId: null }, senderSchemaVersions = null } = {}) {- // Whether the sender's sanitizer knows `moodBoardId` (universes v9, #4188).- // The version gate only rejects AHEAD senders — a behind/no-meta sender's- // record flows through this merge, and its sanitized form omits the field.- const senderKnowsMoodBoardId = (Number(senderSchemaVersions?.universes) || 0) >= 9;const senderUniversesVersion = Number(senderSchemaVersions?.universes) || 0;if (!Array.isArray(remoteUniverses)) return { applied: false, count: 0 };// Records that transitioned to deleted via this merge get their orphan@@ -142,20 +179,13 @@ export async function mergeUniversesFromSync(remoteUniverses, { source = { via:// set, so absent-locally stays absent).if (local.imageMode) sanitized.imageMode = local.imageMode;if (local.imageModelId) sanitized.imageModelId = local.imageModelId;- // `moodBoardId` (#4188) rides the wire, but absent-on-wire is- // ambiguous: a v9-aware sender omits it to mean "cleared", while a- // pre-v9 (or no-meta) sender omits it because its sanitizer strips- // the field. Only honor the omission as a clear from a v9-aware- // sender; otherwise preserve the local link so a behind peer's- // unrelated edit can't LWW-strip it.- if (!sanitized.moodBoardId && local.moodBoardId && !senderKnowsMoodBoardId) {- sanitized.moodBoardId = local.moodBoardId;- }- sanitized.characters = preserveLegacyCharacterFields(- sanitized.characters,- local.characters,- senderUniversesVersion,- );+ // Additive fields (moodBoardId, factual, styleReferences, character+ // and object links, …) ride the wire, but absent-on-wire is+ // ambiguous: a version-aware sender omits one to mean "cleared",+ // while a behind (or no-meta) sender omits it because its sanitizer+ // strips the field. Restore only the latter so a behind peer's+ // unrelated edit can't LWW-strip them.+ Object.assign(sanitized, preserveLegacyUniverseFields(sanitized, local, senderUniversesVersion));// Non-blocking conflict journal: archive the about-to-be-lost local// version when BOTH sides diverged from the last synced base. Always// advances the base hash (clean or conflict) so the next snapshot