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

fix: add 30-minute cooldown to brain scheduler after task failures to prevent retry spam

Adam Eivy889adbf5b535
diff --git a/.changelog/v0.13.x.md b/.changelog/v0.13.x.md
index c2005bf340..7faf69a2de 100644
--- a/.changelog/v0.13.x.md
+++ b/.changelog/v0.13.x.md
@@ -135,6 +135,11 @@ This release expands the genome dashboard with comprehensive cancer predispositi
## Improvements
+### Brain Scheduler — Failure Cooldown
+- **30-minute retry cooldown** after failed daily digest or weekly review tasks — prevents retry spam by tracking last failure time and skipping missed-task checks during the cooldown period
+- Failed catch-up attempts now log "(retry in 30min)" for visibility
+- Eliminates excessive retry attempts that would otherwise occur every minute after a failure
+
### CoS — Consolidated Duplicate Repo Maintenance Jobs
- **Merged `job-git-maintenance` into `job-github-repo-maintenance`** — the two jobs had overlapping scope (local git repo checks vs GitHub API audits) and are now a single unified job covering both local and remote repository maintenance
- Removed `git-maintenance` skill template; consolidated local repo checks (uncommitted changes, stale branches) into the `github-repo-maintenance` skill template
diff --git a/server/services/brainScheduler.js b/server/services/brainScheduler.js
index 92e7a66d57..ce37a3bb09 100644
--- a/server/services/brainScheduler.js
+++ b/server/services/brainScheduler.js
@@ -14,6 +14,11 @@ import { runDailyDigest, runWeeklyReview } from './brain.js';
let schedulerInterval = null;
let lastCheckTime = null;
const CHECK_INTERVAL_MS = 60000; // Check every minute
+const FAILURE_COOLDOWN_MS = 30 * 60 * 1000; // 30 minutes cooldown after failure
+
+// Track failures to prevent retry spam
+let lastDailyFailure = null;
+let lastWeeklyFailure = null;
// Day name to number mapping
const DAY_MAP = {
@@ -53,10 +58,21 @@ function isWeeklyReviewTime(settings, now) {
now.getMinutes() === minutes;
}
+/**
+ * Check if we're in cooldown after a failure
+ */
+function isInCooldown(lastFailure, now) {
+ if (!lastFailure) return false;
+ return (now.getTime() - lastFailure.getTime()) < FAILURE_COOLDOWN_MS;
+}
+
/**
* Check if daily digest was missed (should have run today but didn't)
*/
function isDailyDigestMissed(settings, now) {
+ // Respect cooldown after failure
+ if (isInCooldown(lastDailyFailure, now)) return false;
+
const { hours, minutes } = parseTime(settings.dailyDigestTime);
// Create target time for today
@@ -78,6 +94,9 @@ function isDailyDigestMissed(settings, now) {
* Check if weekly review was missed
*/
function isWeeklyReviewMissed(settings, now) {
+ // Respect cooldown after failure
+ if (isInCooldown(lastWeeklyFailure, now)) return false;
+
// Never run before — catch up now
if (!settings.lastWeeklyReview) return true;
@@ -104,12 +123,14 @@ async function checkSchedule() {
if (isDailyDigestTime(settings, now)) {
console.log('🧠 Scheduler: Running daily digest...');
runDailyDigest().catch(err => {
+ lastDailyFailure = new Date();
console.error(`🧠 Scheduler: Daily digest failed: ${err.message}`);
});
} else if (isDailyDigestMissed(settings, now)) {
console.log('🧠 Scheduler: Running missed daily digest (catch-up)...');
runDailyDigest().catch(err => {
- console.error(`🧠 Scheduler: Catch-up daily digest failed: ${err.message}`);
+ lastDailyFailure = new Date();
+ console.error(`🧠 Scheduler: Catch-up daily digest failed: ${err.message} (retry in 30min)`);
});
}
@@ -117,12 +138,14 @@ async function checkSchedule() {
if (isWeeklyReviewTime(settings, now)) {
console.log('🧠 Scheduler: Running weekly review...');
runWeeklyReview().catch(err => {
+ lastWeeklyFailure = new Date();
console.error(`🧠 Scheduler: Weekly review failed: ${err.message}`);
});
} else if (isWeeklyReviewMissed(settings, now)) {
console.log('🧠 Scheduler: Running missed weekly review (catch-up)...');
runWeeklyReview().catch(err => {
- console.error(`🧠 Scheduler: Catch-up weekly review failed: ${err.message}`);
+ lastWeeklyFailure = new Date();
+ console.error(`🧠 Scheduler: Catch-up weekly review failed: ${err.message} (retry in 30min)`);
});
}
}