From 7b1d6b8ad0408800a32f2bb395bb1de19ac199b0 Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Sat, 14 Mar 2026 20:08:47 -0400 Subject: [PATCH] daemon: consolidation cycle every 6 hours instead of daily The graph changes fast with 1000+ agents per cycle. Daily was too slow for the feedback loop. 6-hour cycle means Elo evaluation and agent reallocation happen 4x per day. Runs on first tick after daemon start (initialized to past). Co-Authored-By: Kent Overstreet --- poc-memory/src/agents/daemon.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/poc-memory/src/agents/daemon.rs b/poc-memory/src/agents/daemon.rs index 7616871..9bcdaf6 100644 --- a/poc-memory/src/agents/daemon.rs +++ b/poc-memory/src/agents/daemon.rs @@ -957,8 +957,11 @@ pub fn run_daemon() -> Result<(), String> { let llm_sched = Arc::clone(&llm); let last_daily_sched = Arc::clone(&last_daily); let graph_health_sched = Arc::clone(&graph_health); + const CONSOLIDATION_INTERVAL: Duration = Duration::from_secs(6 * 3600); // 6 hours + choir.spawn("scheduler").init(move |ctx| { let mut last_health = std::time::Instant::now() - HEALTH_INTERVAL; + let mut last_consolidation = std::time::Instant::now() - CONSOLIDATION_INTERVAL; // run on first tick ctx.set_progress("idle"); loop { @@ -977,11 +980,11 @@ pub fn run_daemon() -> Result<(), String> { last_health = std::time::Instant::now(); } - // Daily jobs: once per day (wait for health check to cache metrics first) - let last = *last_daily_sched.lock().unwrap(); + // Consolidation cycle: every 6 hours (wait for health check to cache metrics first) let gh = graph_health_sched.lock().unwrap().clone(); - if last.is_none_or(|d| d < today) && gh.is_some() { - log_event("scheduler", "daily-trigger", &today.to_string()); + if last_consolidation.elapsed() >= CONSOLIDATION_INTERVAL && gh.is_some() { + log_event("scheduler", "consolidation-trigger", + &format!("{} (every 6h)", today)); // Use cached graph health plan (from consolidation_plan_quick). let h = gh.as_ref().unwrap(); // guarded by gh.is_some() above @@ -1059,6 +1062,7 @@ pub fn run_daemon() -> Result<(), String> { knowledge.depend_on(&digest_links); *last_daily_sched.lock().unwrap() = Some(today); + last_consolidation = std::time::Instant::now(); ctx.set_progress(format!("daily pipeline triggered ({today})")); }