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
refactor([issue-1562]): honor fullSync in every category-gating reader (simplify pass)
[._.]/ Adam Eivy84d5aa558153
diff --git a/client/src/components/sharing/SyncToPeerButton.jsx b/client/src/components/sharing/SyncToPeerButton.jsxindex 7d44488e81..85a542c2b4 100644--- a/client/src/components/sharing/SyncToPeerButton.jsx+++ b/client/src/components/sharing/SyncToPeerButton.jsx@@ -94,6 +94,8 @@ export default function SyncToPeerButton({// Inbound-only direction → outbound pushes silently dropped.if (Array.isArray(peer.directions) && peer.directions.length > 0&& !peer.directions.includes('outbound')) return false;+ // A full-sync peer mirrors every category, so it can always receive.+ if (peer.fullSync === true) return true;const cats = peer.syncCategories;return !!cats && typeof cats === 'object' && cats[requiredCategory] === true;};diff --git a/client/src/components/sharing/SyncToPeerButton.test.jsx b/client/src/components/sharing/SyncToPeerButton.test.jsxindex 69ec4db4b7..437f1d746b 100644--- a/client/src/components/sharing/SyncToPeerButton.test.jsx+++ b/client/src/components/sharing/SyncToPeerButton.test.jsx@@ -53,6 +53,27 @@ describe('SyncToPeerButton', () => {expect(screen.queryByText(/No-id peer/i)).toBeNull();});+ it('a full-sync peer is subscribable even with no per-category map', async () => {+ // peerCanReceiveOutbound must honor fullSync — a mirror-everything peer can+ // always receive, regardless of its syncCategories.+ api.getInstances.mockResolvedValue({+ peers: [+ { instanceId: 'peer-full', name: 'Peer Full', enabled: true, status: 'online', host: 'host-f.tail.net', fullSync: true, syncCategories: {} },+ ],+ });+ api.subscribeToPeer.mockResolvedValue({ subscription: { id: 'peer-universe-u1-peer-full' } });+ const user = userEvent.setup();+ render(<SyncToPeerButton recordKind="universe" recordId="u1" />);+ await user.click(screen.getByRole('button', { name: /Sync/i }));+ const row = await screen.findByRole('button', { name: /Peer Full/i });+ expect(row).not.toBeDisabled();+ await user.click(row);+ await waitFor(() => expect(api.subscribeToPeer).toHaveBeenCalledWith(+ { peerId: 'peer-full', recordKind: 'universe', recordId: 'u1' },+ expect.anything(),+ ));+ });+it('shows a filled check when already subscribed to that peer', async () => {api.listPeerSubscriptions.mockResolvedValue({subscriptions: [{diff --git a/client/src/hooks/useSyncIntegrity.js b/client/src/hooks/useSyncIntegrity.jsindex ed93a6a2d4..2202b87db8 100644--- a/client/src/hooks/useSyncIntegrity.js+++ b/client/src/hooks/useSyncIntegrity.js@@ -137,7 +137,9 @@ export function useSyncIntegrity(kind, { peers: peersProp } = {}) {p.syncEnabled !== false &&p.instanceId &&category &&- p.syncCategories?.[category] === true,+ // A full-sync peer mirrors every category, so it's eligible regardless+ // of its per-category map.+ (p.fullSync === true || p.syncCategories?.[category] === true),);if (gen !== genRef.current) return; // stalediff --git a/server/services/sharing/peerSync.js b/server/services/sharing/peerSync.jsindex 2327a07bea..96ffc9fb2b 100644--- a/server/services/sharing/peerSync.js+++ b/server/services/sharing/peerSync.js@@ -552,20 +552,27 @@ export async function autoSubscribePeerToAllRecords(peerId, recordKind) {export async function getFullSyncCoverageForPeer(peerId) {const empty = { total: 0, confirmed: 0, pending: 0, fullyMirrored: true, byKind: {} };if (!isNonEmptyStr(peerId)) return empty;- const byKind = {};- let total = 0;- let confirmed = 0;- for (const kind of PEER_SUBSCRIBABLE_KINDS) {- const records = await listRecordsForKind(kind).catch(() => []);- const subs = await listPeerSubscriptions({ peerId, recordKind: kind }).catch(() => []);+ // Each kind's record list + subscription list are independent I/O — fetch all+ // kinds (and the two lists within a kind) concurrently.+ const perKind = await Promise.all(PEER_SUBSCRIBABLE_KINDS.map(async (kind) => {+ const [records, subs] = await Promise.all([+ listRecordsForKind(kind).catch(() => []),+ listPeerSubscriptions({ peerId, recordKind: kind }).catch(() => []),+ ]);// A record counts as confirmed only when its subscription carries a// confirmed-delivery water-mark — a created-but-never-pushed sub is pending.const confirmedIds = new Set(subs.filter(s => s.lastConfirmedPushedAt).map(s => s.recordId));const kindTotal = records.length;const kindConfirmed = records.filter(r => confirmedIds.has(r.id)).length;- byKind[kind] = { total: kindTotal, confirmed: kindConfirmed, pending: kindTotal - kindConfirmed };- total += kindTotal;- confirmed += kindConfirmed;+ return { kind, total: kindTotal, confirmed: kindConfirmed, pending: kindTotal - kindConfirmed };+ }));+ const byKind = {};+ let total = 0;+ let confirmed = 0;+ for (const k of perKind) {+ byKind[k.kind] = { total: k.total, confirmed: k.confirmed, pending: k.pending };+ total += k.total;+ confirmed += k.confirmed;}const pending = total - confirmed;return { total, confirmed, pending, fullyMirrored: pending === 0, byKind };@@ -2683,13 +2690,14 @@ export function installPeerSyncListener() {onPeerOnline = (peer) => {if (!peer?.instanceId) return;(async () => {- const cats = peer.syncCategories || {};- // KIND_TO_CATEGORY['universe']='universe', ['series']='pipeline'.- // Iterate the kind keys so the (kind, category) mapping stays single-- // sourced from KIND_TO_CATEGORY.+ // peerHasCategory owns the (kind → category) mapping and the fullSync+ // short-circuit, so iterate the kinds and let it decide.for (const kind of PEER_SUBSCRIBABLE_KINDS) {- const cat = KIND_TO_CATEGORY[kind];- if (cats[cat] === true) {+ // peerHasCategory short-circuits true for a full-sync peer, so a peer+ // that came online with its category bits off (or a freshly-added+ // full-sync peer whose instanceId we only just learned) still back-+ // subscribes every kind here.+ if (peerHasCategory(peer, kind)) {await autoSubscribePeerToAllRecords(peer.instanceId, kind).catch(() => {});}}