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

address review: setup.sh --input-type=module + tombstoneGc filters disabled peers

Adam Eivy1e0a9ef2de55
diff --git a/server/services/sharing/tombstoneGc.js b/server/services/sharing/tombstoneGc.js
index 660930d0a8..1d7124194e 100644
--- a/server/services/sharing/tombstoneGc.js
+++ b/server/services/sharing/tombstoneGc.js
@@ -47,17 +47,25 @@ const GRACE_MS = 24 * 60 * 60 * 1000; // 24h grace
*/
async function peerIdsSubscribedToKind(recordKind) {
const subs = await listPeerSubscriptions({ recordKind });
- // Filter against the live peer registry — peer_subscriptions.json rows
- // outlive peer removal (no cleanup hook on instance delete), so a
- // long-gone peer would otherwise be treated as an active subscriber.
- // getMinAckAcrossPeers would then include it with its frozen-at-removal
- // ack (often 0) and refuse to prune any tombstone for this kind. Bound
- // to the peers we can actually reach so a removed peer doesn't
- // permanently stall GC.
- const livePeerIds = new Set(
- (await getPeers().catch(() => [])).map((p) => p?.instanceId).filter(Boolean),
+ // Filter against the live peer registry — but only against peers
+ // ELIGIBLE TO SYNC. Three filters in lockstep with snapshotPeerIdsForKind:
+ // (1) Live in the registry — peer_subscriptions.json rows outlive peer
+ // removal (no cleanup hook on instance delete), so an unfiltered
+ // removed peer would freeze the cursor at its last ack (often 0)
+ // and refuse to prune.
+ // (2) p.enabled — disabled peers receive no pushes; their cursor
+ // never advances and would otherwise stall GC.
+ // (3) p.syncEnabled !== false — globally-silenced peers same as (2).
+ // Without (2) and (3), a per-record subscription belonging to a
+ // disabled/silenced peer would treat it as an active blocker even
+ // though it can't move.
+ const eligiblePeerIds = new Set(
+ (await getPeers().catch(() => []))
+ .filter((p) => p?.enabled && p.syncEnabled !== false)
+ .map((p) => p.instanceId)
+ .filter(Boolean),
);
- return [...new Set(subs.map((s) => s.peerId).filter((id) => id && livePeerIds.has(id)))];
+ return [...new Set(subs.map((s) => s.peerId).filter((id) => id && eligiblePeerIds.has(id)))];
}
/**
diff --git a/server/services/sharing/tombstoneGc.test.js b/server/services/sharing/tombstoneGc.test.js
index daf2284c2b..e2b6efdf64 100644
--- a/server/services/sharing/tombstoneGc.test.js
+++ b/server/services/sharing/tombstoneGc.test.js
@@ -173,6 +173,33 @@ describe('sweepTombstones — peers behind', () => {
expect(firstCallArgs).toEqual(['peer-live']);
expect(firstCallArgs).not.toContain('peer-ghost');
});
+
+ it('ignores subscriptions for disabled or globally-silenced peers (cursor stall)', async () => {
+ // Regression: peerIdsSubscribedToKind must mirror snapshotPeerIdsForKind
+ // — disabled peers (enabled:false) and globally-silenced peers
+ // (syncEnabled:false) receive no pushes, so their ack cursor never
+ // advances. Including them in getMinAckAcrossPeers would freeze the
+ // cutoff at their last ack (often 0) and stall GC indefinitely.
+ listPeerSubscriptions.mockImplementation(async ({ recordKind }) => {
+ if (recordKind === 'universe') return [
+ { peerId: 'peer-disabled' },
+ { peerId: 'peer-silenced' },
+ { peerId: 'peer-active' },
+ ];
+ return [];
+ });
+ getPeers.mockResolvedValue([
+ { instanceId: 'peer-disabled', enabled: false },
+ { instanceId: 'peer-silenced', enabled: true, syncEnabled: false },
+ { instanceId: 'peer-active', enabled: true },
+ ]);
+ getMinAckAcrossPeers.mockResolvedValue(NOW - 1000);
+ await sweepTombstones({ now: NOW });
+ const firstCallArgs = getMinAckAcrossPeers.mock.calls[0][0];
+ expect(firstCallArgs).toEqual(['peer-active']);
+ expect(firstCallArgs).not.toContain('peer-disabled');
+ expect(firstCallArgs).not.toContain('peer-silenced');
+ });
});
describe('sweepTombstones — return shape', () => {
diff --git a/setup.sh b/setup.sh
index 31e51c4de4..ebc36164c3 100755
--- a/setup.sh
+++ b/setup.sh
@@ -39,7 +39,12 @@ echo ""
# macOS Tailscale.app CLI is sandboxed (`tailscale cert` can't write outside its
# container → EPERM). Detection delegates to server/lib/tailscale.js so the
# candidate path list stays a single source of truth.
-if node -e "import('./server/lib/tailscale.js').then(m => process.exit(m.hasOnlySandboxedTailscale() ? 0 : 1)).catch(() => process.exit(1))" 2>/dev/null; then
+# --input-type=module is required: `node -e` defaults to CommonJS even when
+# the package.json declares "type":"module", so a top-level import() in the
+# command would be a syntax error and the detection would silently always
+# fail (suppressed by `2>/dev/null`). Without this flag the whole
+# auto-install branch never runs on macOS.
+if node --input-type=module -e "import('./server/lib/tailscale.js').then(m => process.exit(m.hasOnlySandboxedTailscale() ? 0 : 1)).catch(() => process.exit(1))" 2>/dev/null; then
echo "Detected Tailscale.app without the unsandboxed CLI."
echo "Installing tailscale via Homebrew so 'tailscale cert' can write to data/certs/..."
brewInstalled=0