refactor(scheduler): split 15s tick into 4 independent intervals

Split the single 15s setInterval in scheduler.ts (6 serial jobs) into 4
independent schedulers so a slow job no longer stalls the others:

- scheduler-heartbeat.ts (15s): wake eligible agents, CEO bootstrap,
  schedule automation trigger
- scheduler-lock-recovery.ts (60s): stale task-lock recovery and stale
  workspace-lock release
- scheduler-idle-automation.ts (60s): idle-agent automation dispatch
- scheduler-housekeeping.ts (300s): monthly budget reset, expired budget
  incident auto-close, stale review sweep, expired wakeup purge

scheduler.ts is now a thin composer exposing startAllSchedulers /
stopAllSchedulers. Bootstrap and service-graph updated accordingly.
Business logic, error isolation, and atomic actions preserved.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 21:47:09 -04:00
1 parent 2676400e0c
commit f8052c3741
8 files changed
+307 -173

No files matched your search

+1 -1
View File
@@ -321,7 +321,7 @@ export function createServiceGraph({
shouldQuit: () => isQuittingRef.current,
onBeforeQuit: () => {
isQuittingRef.current = true;
orchestrationService?.stopHeartbeatScheduler();
orchestrationService?.stopAllSchedulers();
automationService?.destroy();
apiServerRef.current?.stop();
apiServerRef.current = null;