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
retry the tombstone sweep next tick on failure instead of a full hour
[._.]/ Adam Eivye0e101bfd3ad
diff --git a/server/services/syncOrchestrator.js b/server/services/syncOrchestrator.jsindex 013f47c70e..76464dfe67 100644--- a/server/services/syncOrchestrator.js+++ b/server/services/syncOrchestrator.js@@ -1005,6 +1005,13 @@ export function initSyncOrchestrator() {* module-load path (same reason as `categoriesCoveredByPeerSync` above). Logs* a single-line summary only when something was actually pruned — quiet on* no-op cycles.+ *+ * Stamps `lastTombstoneSweepAt` BEFORE awaiting the sweep (not after) so a+ * slow sweep still under way can't have its claimed slot re-entered by a+ * later tick once the hour rolls over — the same reasoning as the module-+ * level doc comment. A sweep that FAILS resets the stamp back to 0, though,+ * so a transient error (e.g. the DB blips) retries on the very next tick+ * instead of going quiet for a full hour.*/async function runTombstoneSweep() {const now = Date.now();@@ -1013,6 +1020,7 @@ async function runTombstoneSweep() {const { sweepTombstones } = await import('./sharing/tombstoneGc.js');const result = await sweepTombstones().catch((err) => {console.error(`❌ Tombstone sweep failed: ${err.message}`);+ lastTombstoneSweepAt = 0;return null;});if (result && (result.universes > 0 || result.series > 0 || result.issues > 0 || result.collections > 0)) {diff --git a/server/services/syncOrchestrator.test.js b/server/services/syncOrchestrator.test.jsindex 297e1efa96..98190ac2b5 100644--- a/server/services/syncOrchestrator.test.js+++ b/server/services/syncOrchestrator.test.js@@ -1153,6 +1153,15 @@ describe('syncOrchestrator', () => {expect(sweepTombstones).toHaveBeenCalledTimes(2);});+ it('resets the tombstone-sweep gate on failure so the very next tick retries', async () => {+ initSyncOrchestrator();+ getPeers.mockResolvedValue([]);+ sweepTombstones.mockRejectedValueOnce(new Error('db blip'));+ await vi.advanceTimersByTimeAsync(60000); // first tick — sweeps, rejects+ await vi.advanceTimersByTimeAsync(60000); // second tick, only 60s later — retries because the failure cleared the gate+ expect(sweepTombstones).toHaveBeenCalledTimes(2);+ });+it('runs syncAllPeers and the brain tombstone sweep on every tick regardless of the tombstone-sweep gate', async () => {initSyncOrchestrator();getPeers.mockResolvedValue([]);