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 <kent.overstreet@linux.dev>
This commit is contained in:
parent
46b4f6f434
commit
7b1d6b8ad0
1 changed files with 8 additions and 4 deletions
|
|
@ -957,8 +957,11 @@ pub fn run_daemon() -> Result<(), String> {
|
||||||
let llm_sched = Arc::clone(&llm);
|
let llm_sched = Arc::clone(&llm);
|
||||||
let last_daily_sched = Arc::clone(&last_daily);
|
let last_daily_sched = Arc::clone(&last_daily);
|
||||||
let graph_health_sched = Arc::clone(&graph_health);
|
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| {
|
choir.spawn("scheduler").init(move |ctx| {
|
||||||
let mut last_health = std::time::Instant::now() - HEALTH_INTERVAL;
|
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");
|
ctx.set_progress("idle");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -977,11 +980,11 @@ pub fn run_daemon() -> Result<(), String> {
|
||||||
last_health = std::time::Instant::now();
|
last_health = std::time::Instant::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Daily jobs: once per day (wait for health check to cache metrics first)
|
// Consolidation cycle: every 6 hours (wait for health check to cache metrics first)
|
||||||
let last = *last_daily_sched.lock().unwrap();
|
|
||||||
let gh = graph_health_sched.lock().unwrap().clone();
|
let gh = graph_health_sched.lock().unwrap().clone();
|
||||||
if last.is_none_or(|d| d < today) && gh.is_some() {
|
if last_consolidation.elapsed() >= CONSOLIDATION_INTERVAL && gh.is_some() {
|
||||||
log_event("scheduler", "daily-trigger", &today.to_string());
|
log_event("scheduler", "consolidation-trigger",
|
||||||
|
&format!("{} (every 6h)", today));
|
||||||
|
|
||||||
// Use cached graph health plan (from consolidation_plan_quick).
|
// Use cached graph health plan (from consolidation_plan_quick).
|
||||||
let h = gh.as_ref().unwrap(); // guarded by gh.is_some() above
|
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);
|
knowledge.depend_on(&digest_links);
|
||||||
|
|
||||||
*last_daily_sched.lock().unwrap() = Some(today);
|
*last_daily_sched.lock().unwrap() = Some(today);
|
||||||
|
last_consolidation = std::time::Instant::now();
|
||||||
ctx.set_progress(format!("daily pipeline triggered ({today})"));
|
ctx.set_progress(format!("daily pipeline triggered ({today})"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue