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: exclude musicVideoProject rows from track GC floor for peers with a direct track subscription
[._.]/ Adam Eivy2a8ac128294a
diff --git a/server/services/sharing/tombstoneGc.js b/server/services/sharing/tombstoneGc.jsindex 03b34abbd4..1989339ec0 100644--- a/server/services/sharing/tombstoneGc.js+++ b/server/services/sharing/tombstoneGc.js@@ -217,13 +217,26 @@ function confirmedFloorForSub(sub, targetKind) {// Returns Infinity when there are no eligible rows for the kind (no per-record// constraint → the snapshot-coverage + per-peer-ack checks alone govern).+//+// #1922: a peer that has a DIRECT `track` subscription is already fully+// governed by that row's own `lastConfirmedPushedAt` floor — its bundled+// musicVideoProject rows must be excluded from the `track` floor for that+// peer, otherwise an unrelated/stale project subscription (one whose linked+// track this peer never even needed protecting) would needlessly hold back+// pruning for EVERY track tombstone, including ones the peer's direct track+// subscription already confirmed. Only a peer with NO direct `track`+// subscription relies on its musicVideoProject rows as the stand-in vehicle.function minConfirmedPushedAtForKind(subs, peers, recordKind) {const cohortKinds = cohortKindsFor(recordKind);const eligible = eligiblePeerIdSet(peers);+ const peersWithDirectKind = recordKind === 'track'+ ? new Set(subs.filter((s) => s.recordKind === 'track' && s.peerId && eligible.has(s.peerId)).map((s) => s.peerId))+ : null;let min = Infinity;for (const s of subs) {if (!cohortKinds.includes(s.recordKind)) continue;if (!s.peerId || !eligible.has(s.peerId)) continue;+ if (peersWithDirectKind && s.recordKind === 'musicVideoProject' && peersWithDirectKind.has(s.peerId)) continue;const confirmed = confirmedFloorForSub(s, recordKind);if (confirmed < min) min = confirmed;}diff --git a/server/services/sharing/tombstoneGc.test.js b/server/services/sharing/tombstoneGc.test.jsindex 2becbd1a2b..3cfebf7142 100644--- a/server/services/sharing/tombstoneGc.test.js+++ b/server/services/sharing/tombstoneGc.test.js@@ -896,4 +896,35 @@ describe('sweepTombstones — track GC cohort widened by musicVideoProject bundlawait sweepTombstones({ now: NOW, graceMs: 0 });expect(pruneTombstonedTracks).toHaveBeenCalledWith(minAck + 1);});++ it('does NOT hold the track cutoff hostage to a stale musicVideoProject row when the peer already has a confirmed direct track subscription', async () => {+ // Regression (codex review on #1922): a peer syncing BOTH Music and Music+ // Videos has its own direct `track` subscription, already fully governed+ // by that row's `lastConfirmedPushedAt` floor. Without excluding the+ // peer's musicVideoProject rows here, an unrelated/long-stale project+ // subscription (never confirmed a bundled track delivery — e.g. it has no+ // linked track at all) would needlessly hold back GC for EVERY track+ // tombstone, even ones the peer's direct track subscription already+ // confirmed.+ getMinAckAcrossPeers.mockResolvedValue(NOW);+ getPeers.mockResolvedValue([{ instanceId: 'peer-a', enabled: true }]);+ mockSubs({+ track: [+ { peerId: 'peer-a', createdAt: new Date(NOW - 60 * 60 * 1000).toISOString(), lastConfirmedPushedAt: NOW },+ ],+ musicVideoProject: [+ // Stale/unrelated project sub for the SAME peer: never confirmed a+ // bundled track delivery, floors to its old createdAt — must NOT gate+ // the track cutoff because peer-a already has a direct track sub.+ {+ peerId: 'peer-a',+ createdAt: new Date(NOW - 30 * 24 * 60 * 60 * 1000).toISOString(),+ lastConfirmedTrackBundleAtMs: null,+ },+ ],+ });+ await sweepTombstones({ now: NOW, graceMs: 0 });+ const cutoff = pruneTombstonedTracks.mock.calls[0][0];+ expect(cutoff).toBe(NOW + 1); // governed by the direct track row, not the stale MV row+ });});