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: distinguish peers with anonymous sync ordinals
[._.]/ Adam Eivy7606e8986997
diff --git a/server/services/instances.js b/server/services/instances.jsindex 09a24696fe..ef42bbab58 100644--- a/server/services/instances.js+++ b/server/services/instances.js@@ -216,8 +216,8 @@ function validName(name, fallback) {* Peer display names, hosts, addresses and instance IDs can identify a machine.* Keep server logs generic so runtime sync events do not persist that data.*/-export function peerLogLabel() {- return 'peer';+export function peerLogLabel(ordinal = null) {+ return Number.isInteger(ordinal) && ordinal >= 0 ? `peer ${ordinal + 1}` : 'peer';}function isIPAddress(str) {diff --git a/server/services/instances.test.js b/server/services/instances.test.jsindex 09de9be886..12ae2b30ed 100644--- a/server/services/instances.test.js+++ b/server/services/instances.test.js@@ -175,10 +175,11 @@ describe('instances.js', () => {});describe('peerLogLabel', () => {- it('never includes peer names or network identity in server logs', () => {+ it('uses anonymous cycle ordinals without exposing peer identity', () => {+ expect(peerLogLabel()).toBe('peer');+ expect(peerLogLabel(0)).toBe('peer 1');+ expect(peerLogLabel(1)).toBe('peer 2');expect(peerLogLabel({ name: 'Example Machine', host: 'peer.example', address: '192.0.2.20', instanceId: 'abc123def456' })).toBe('peer');- expect(peerLogLabel({ name: 'NaN', host: 'peer.example' })).toBe('peer');- expect(peerLogLabel({})).toBe('peer');});});diff --git a/server/services/syncOrchestrator.js b/server/services/syncOrchestrator.jsindex 960a4d62ab..e6bb79c236 100644--- a/server/services/syncOrchestrator.js+++ b/server/services/syncOrchestrator.js@@ -726,10 +726,11 @@ const emptyCoverage = () => ({ universe: new Set(), pipeline: new Set(), mediaCo/*** Sync all data from a single peer*/-export async function syncWithPeer(peer, { logStart = true, onCategoryFailure } = {}) {+export async function syncWithPeer(peer, { logStart = true, onCategoryFailure, peerOrdinal = null } = {}) {if (!peer.instanceId) return { brain: { totalApplied: 0 }, memory: { totalApplied: 0 } };const peerId = peer.instanceId;+ const logLabel = peerLogLabel(peerOrdinal);// Prevent concurrent syncs for the same peerif (syncingPeers.has(peerId)) return { brain: { totalApplied: 0 }, memory: { totalApplied: 0 } };@@ -787,7 +788,7 @@ export async function syncWithPeer(peer, { logStart = true, onCategoryFailure }const categories = getEffectiveCategories(peer);const enabledNames = Object.entries(categories).filter(([, on]) => on).map(([k]) => k);if (logStart) {- console.log(`🔄 Sync starting with ${peerLogLabel(peer)}: categories=${enabledNames.join(',') || 'none'}`);+ console.log(`🔄 Sync starting with ${logLabel}: categories=${enabledNames.join(',') || 'none'}`);}emitSyncProgress({ phase: 'start', peerId });@@ -855,7 +856,7 @@ export async function syncWithPeer(peer, { logStart = true, onCategoryFailure }enabledDataCats.map(cat =>syncDataCategoryFromPeer(peer, peerId, cat, cachedChecksums, scopedInstanceId).catch(err => {- logFailureWithStack(`⚠️ ${cat} sync with ${peerLogLabel(peer)} failed`, err);+ logFailureWithStack(`⚠️ ${cat} sync with ${logLabel} failed`, err);recordCategoryFailure(cat, err);return { totalApplied: 0, checksum: null };})@@ -909,7 +910,7 @@ export async function syncWithPeer(peer, { logStart = true, onCategoryFailure }if (result.totalApplied > 0) parts.push(`${result.totalApplied} ${cat}`);}if (parts.length > 0) {- console.log(`🔄 Synced with ${peerLogLabel(peer)}: ${parts.join(', ')} changes`);+ console.log(`🔄 Synced with ${logLabel}: ${parts.join(', ')} changes`);}const totalApplied = brainResult.totalApplied + memoryResult.totalApplied@@ -1007,7 +1008,7 @@ export async function syncAllPeers() {if (membershipChanged) {if (online.length > 0) {- const names = online.map(p => peerLogLabel(p)).join(', ');+ const names = online.map((_, index) => peerLogLabel(index)).join(', ');console.log(`🔄 Sync cycle: ${online.length} peer${online.length === 1 ? '' : 's'} online (${names})`);} else {console.log('🔄 Sync cycle: peer membership changed (0 online)');@@ -1015,17 +1016,18 @@ export async function syncAllPeers() {}let cycleFailed = false;- const settled = await Promise.allSettled(online.map(p => syncWithPeer(p, {+ const settled = await Promise.allSettled(online.map((p, index) => syncWithPeer(p, {// The periodic path cannot know whether a sync will change data until it// finishes. Keep the start line only for an observable membership change.logStart: membershipChanged,+ peerOrdinal: index,onCategoryFailure: () => { cycleFailed = true; },})));for (let i = 0; i < settled.length; i++) {const result = settled[i];if (result.status === 'rejected') {cycleFailed = true;- logFailureWithStack(`❌ Sync with ${peerLogLabel(online[i])} failed`, result.reason);+ logFailureWithStack(`❌ Sync with ${peerLogLabel(i)} failed`, result.reason);}}diff --git a/server/services/syncOrchestrator.test.js b/server/services/syncOrchestrator.test.jsindex eeda4e43c5..012247ad23 100644--- a/server/services/syncOrchestrator.test.js+++ b/server/services/syncOrchestrator.test.js@@ -1261,7 +1261,7 @@ describe('syncOrchestrator', () => {await syncAllPeers();expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Sync cycle: 1 peer online'));- expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Sync starting with peer'));+ expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Sync starting with peer 1'));expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Sync cycle complete: 0 changes applied across 1 peer'));} finally {logSpy.mockRestore();@@ -1286,7 +1286,7 @@ describe('syncOrchestrator', () => {try {await syncAllPeers();- expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Synced with peer: 1 brain changes'));+ expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Synced with peer 1: 1 brain changes'));expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Sync cycle complete: 1 change applied across 1 peer'));} finally {logSpy.mockRestore();@@ -1310,7 +1310,7 @@ describe('syncOrchestrator', () => {try {await syncAllPeers();- expect(errorSpy.mock.calls.some(([message]) => String(message).includes('usage sync with peer failed'))).toBe(true);+ expect(errorSpy.mock.calls.some(([message]) => String(message).includes('usage sync with peer 1 failed'))).toBe(true);expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Sync cycle complete: 0 changes applied across 1 peer'));} finally {logSpy.mockRestore();