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
test([mediacollections-deterministic-loadone-fastpath]): lock canonical-wins on a live random-id duplicate
[._.]/ Adam Eivy292dc99698e8
diff --git a/server/services/mediaCollections.test.js b/server/services/mediaCollections.test.jsindex 64da819fe3..fda9386df6 100644--- a/server/services/mediaCollections.test.js+++ b/server/services/mediaCollections.test.js@@ -431,6 +431,23 @@ describe('mediaCollections service', () => {expect(found?.id).toBe('uuid-live');});+ it('findCollectionByUniverseId prefers the canonical deterministic id when a live random-id duplicate also carries the stamp', async () => {+ // A transient duplicate — e.g. an unconverged peer pushed a random-id+ // copy while a converged canonical copy already exists. The fast path+ // deterministically returns the canonical uc-<id> record (the converged+ // cross-machine identity) rather than whichever the directory scan+ // happened to list first (the old loadAll order was filesystem-dependent,+ // so this also removes a source of non-determinism). Items union-merge on+ // sync, so the random-id duplicate is reconciled without loss.+ const now = new Date().toISOString();+ await seedState({ collections: [+ { id: 'uc-u-1', name: 'Universe: Foo', description: '', coverKey: null, universeId: 'u-1', items: [], createdAt: now, updatedAt: now },+ { id: 'uuid-dupe', name: 'Universe: Foo', description: '', coverKey: null, universeId: 'u-1', items: [], createdAt: now, updatedAt: now },+ ] });+ const found = await svc.findCollectionByUniverseId('u-1');+ expect(found?.id).toBe('uc-u-1');+ });+it('renameCollectionForUniverse cascades a new name onto the linked collection', async () => {const linked = await svc.findOrCreateCollectionByName({name: 'Universe: Foo', universeId: 'u-1',