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: keep a task with an unparseable cooldownUntil blocked instead of reviving it

[._.]/ Adam Eivy736ab275eda4
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index bc3b6b0b93..0f2af45c11 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -653,7 +653,12 @@ export function isWithinProjectLimit(task, agentsByProject, perProjectLimit) {
async function unblockExpiredCooldownsInQueue(blocked, defaultTaskType) {
for (const task of blocked || []) {
if (task.metadata?.blockedCategory !== 'orphan-cooldown' || !task.metadata?.cooldownUntil) continue;
- if (new Date(task.metadata.cooldownUntil).getTime() > Date.now()) continue;
+ // An unparseable `cooldownUntil` yields NaN, and NaN loses BOTH comparisons —
+ // so the expiry test has to be written as "is expired", not as the negation of
+ // "is still cooling". Guard it explicitly: a garbage timestamp leaves the task
+ // blocked (the pre-#3500 behavior) rather than reviving it on the next tick.
+ const cooldownUntil = new Date(task.metadata.cooldownUntil).getTime();
+ if (!(cooldownUntil <= Date.now())) continue;
emitLog('info', `⏰ Orphan cooldown expired for task ${task.id}, unblocking`, { taskId: task.id });
await updateTask(task.id, {
status: 'pending',
diff --git a/server/services/cosTaskGenerator.orphanCooldown.test.js b/server/services/cosTaskGenerator.orphanCooldown.test.js
index 121fdc9331..06eac7c7a2 100644
--- a/server/services/cosTaskGenerator.orphanCooldown.test.js
+++ b/server/services/cosTaskGenerator.orphanCooldown.test.js
@@ -118,4 +118,13 @@ describe('unblockExpiredOrphanCooldowns', () => {
expect(updateTaskMock).not.toHaveBeenCalled();
});
+
+ it('leaves a task with an unparseable cooldownUntil blocked rather than reviving it', async () => {
+ // NaN loses both `<=` and `>`, so writing the expiry test as the negation of
+ // "still cooling" would silently unblock every malformed timestamp on the
+ // next tick instead of leaving it parked for a human to look at.
+ await unblockExpiredOrphanCooldowns(store([cooldownTask('u1', 'not-a-date')]), store([]));
+
+ expect(updateTaskMock).not.toHaveBeenCalled();
+ });
});