Skip to main content

spawn_evolution_cadence

Function spawn_evolution_cadence 

Source
pub fn spawn_evolution_cadence(
    state: Arc<ServerState>,
    interval_secs: u64,
) -> Option<JoinHandle<()>>
Expand description

Spawn the autonomous cadence timer (opt-in via .car/config.toml evolution_interval_secs): ONE background task over the daemon’s shared engine that every interval_secs runs run_evolution_cadence_cycle and appends the outcome as an EvolutionTriggered event (data.source = "cadence") to <journal_dir>/evolution.jsonl — capped at [EVOLUTION_LOG_MAX_EVENTS] in memory, and no-op cycles (nothing planned, nothing run) are not appended (kernel review S4), so an idle daemon doesn’t mint an audit line per tick. A tick that lands while the previous cycle is still running is skipped (CycleGuard); each cycle runs in its own task so a panic is isolated to that tick. The task ends with the daemon’s tokio runtime. Returns None (and warns) when the daemon has no shared engine to evolve.