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

fix([issue-729]): keep universe styleImageRefs off the sync wire and conflict hash

[._.]/ Adam Eivy4a655f8da065
diff --git a/server/lib/conflictJournal.test.js b/server/lib/conflictJournal.test.js
index 6cea74eecb..5b279333d0 100644
--- a/server/lib/conflictJournal.test.js
+++ b/server/lib/conflictJournal.test.js
@@ -56,6 +56,17 @@ describe('conflictJournal', () => {
expect(cj.contentHashForRecord('universe', uni({ ephemeral: true }))).toBeNull();
});
+ it('contentHashForRecord ignores styleImageRefs (probe renders never feed conflict detection)', () => {
+ // styleImageRefs is stripped from the wire projection contentHashForRecord
+ // reuses, so a base style-probe render that only adds/changes those refs
+ // must NOT shift the content hash — otherwise a render alone could register
+ // a phantom 3-way divergence whose conflict diff can't even mention the
+ // field (RESTORABLE_FIELDS.universe omits it).
+ const base = cj.contentHashForRecord('universe', uni());
+ expect(cj.contentHashForRecord('universe', uni({ styleImageRefs: ['probe-1.png'] }))).toBe(base);
+ expect(cj.contentHashForRecord('universe', uni({ styleImageRefs: ['probe-1.png', 'probe-2.png'] }))).toBe(base);
+ });
+
it('no base → treated as clean (no journal), base seeded for next time', async () => {
const local = uni({ starterPrompt: 'local', updatedAt: '2026-05-01T00:00:00Z' });
const remote = uni({ starterPrompt: 'remote', updatedAt: '2026-05-02T00:00:00Z' });
diff --git a/server/lib/syncWire.js b/server/lib/syncWire.js
index 474e3fbe04..e999048dbe 100644
--- a/server/lib/syncWire.js
+++ b/server/lib/syncWire.js
@@ -123,6 +123,23 @@ export function sanitizeRecordForWire(kind, record) {
}
return { ...minimized, ...sanitizeSoftDeleteFields(record) };
}
+ // `styleImageRefs` (universe base "style probe" renders) is WIRE-LOCAL:
+ // per-peer, regenerable, and NOT a restorable conflict field
+ // (RESTORABLE_FIELDS.universe omits it). Strip it from every universe
+ // payload so (1) an older peer that lacks the field in its sanitizer
+ // can't drop-then-LWW-strip it back off a newer peer on round-trip, and
+ // (2) it never feeds the conflict-journal content hash (contentHashForRecord
+ // reuses this projection) — a probe render alone would otherwise register a
+ // phantom 3-way divergence whose diff can't mention the field. Stripping
+ // here (rather than bumping the `universes` schema version) keeps universe
+ // sync flowing to not-yet-upgraded peers: a whole-category gate would
+ // 412-reject ALL universe transfers over a low-stakes, one-click-regenerable
+ // field. The strip is byte-stable against pre-field peers — they never sent
+ // it, so the wire/hash form is unchanged for them.
+ if (kind === 'universe') {
+ const { styleImageRefs: _styleImageRefs, ...universeRest } = rest;
+ return { ...universeRest, ...sanitizeSoftDeleteFields(record) };
+ }
return { ...rest, ...sanitizeSoftDeleteFields(record) };
}
case 'mediaCollection': {
diff --git a/server/lib/syncWire.test.js b/server/lib/syncWire.test.js
index 2724498b86..1682f6b910 100644
--- a/server/lib/syncWire.test.js
+++ b/server/lib/syncWire.test.js
@@ -164,6 +164,29 @@ describe('syncWire', () => {
expect(sanitizeRecordForWire('universe', { id: 'u1', ephemeral: 'yes' })).not.toBeNull();
expect(sanitizeRecordForWire('universe', { id: 'u1', ephemeral: false })).not.toBeNull();
});
+
+ it('strips styleImageRefs from universe wire form (wire-local probe renders)', () => {
+ // styleImageRefs are per-peer, regenerable base style-probe renders. They
+ // must never cross the wire: an older peer that lacks the field in its
+ // sanitizer would drop it on receive, then LWW-strip it back off a newer
+ // peer after its own edit. The wire form is byte-stable against a record
+ // that never carried the field at all.
+ const withRefs = sanitizeRecordForWire('universe', {
+ id: 'u1', name: 'U', styleImageRefs: ['a.png', 'b.png'],
+ });
+ expect(withRefs.styleImageRefs).toBeUndefined();
+ const without = sanitizeRecordForWire('universe', { id: 'u1', name: 'U' });
+ expect(JSON.stringify(withRefs)).toBe(JSON.stringify(without));
+ });
+
+ it('does NOT strip styleImageRefs from series/issue wire form (universe-only field)', () => {
+ // The strip is scoped to `kind === 'universe'` — series/issue records
+ // never carry styleImageRefs, but a stray value (hand-edit, corrupted
+ // payload) on those kinds must pass through unchanged so the strip can't
+ // silently alter unrelated record shapes.
+ const series = sanitizeRecordForWire('series', { id: 's1', name: 'S', styleImageRefs: ['x.png'] });
+ expect(series.styleImageRefs).toEqual(['x.png']);
+ });
});
describe('sanitizeStateForWire', () => {
diff --git a/server/services/universeBuilder.js b/server/services/universeBuilder.js
index 1455eaaa2d..2ece683dc8 100644
--- a/server/services/universeBuilder.js
+++ b/server/services/universeBuilder.js
@@ -778,8 +778,11 @@ const sanitizeTemplate = (raw) => {
// Base "style probe" renders — images generated from the raw style preset
// (influences embrace/avoid + styleNotes) with NO subject, so the user can
// see the world's base visual emphasis. Additive + regenerable; sanitized
- // like canon imageRefs (dedupe + cap). Not wire-version-gated (low-stakes,
- // one-click to regenerate if an older peer round-trips and strips it).
+ // like canon imageRefs (dedupe + cap). WIRE-LOCAL: stripped from every
+ // universe payload by sanitizeRecordForWire (so an older peer can't
+ // drop-then-LWW-strip it off a newer one) and excluded from the
+ // conflict-journal content hash (which reuses that projection). Per-peer +
+ // one-click to regenerate, so no schema-version gate is needed.
styleImageRefs: sanitizeEntryImageRefs(raw.styleImageRefs),
locked,
characters,