Skip to main content

Module cron

Module cron 

Source
Expand description

Persistent cron scheduler for AgentMux.

Backs each enabled CronJob with a tokio task that sleeps until the next scheduled fire time (computed from the 5-field UTC cron expression), delivers the prompt as /agentmux/reactive/inject would — in process since identity M4c-3 (see FireDelivery) — and records the fire in the DB.

On startup, runs one catch-up fire for any job whose next scheduled time after last_fired is already in the past (FIRE_ONCE_NOW misfire policy — never replay all missed fires, never cause a cron storm).

See docs/specs/SPEC_CRON_LOOP_ROBUSTNESS_2026_06_25.md §3.2.

Structs§

CronScheduler

Functions§

fire_target 🔒
What a cron fire addresses: the UID when one was captured at creation, else the name (counted, spec §9.2 — cron.fire_by_name reaching zero is part of M5’s exit criterion).
is_expired_by_age 🔒
True when a job’s hard age-expiry bound (max_age_secs, seconds since created_at) has been reached. None = no bound, never expires by age (the default for every job created before this field existed, and for any job that explicitly opts out). See docs/specs/SPEC_AGENT_POLLING_AND_WAKEUP_HARDENING_2026_08_04.md Phase 0.
should_catchup 🔒
Determine if a job needs a catch-up fire on startup.

Type Aliases§

FireDelivery
In-process delivery of a fire: the server’s shared inject path (server::reactive::deliver, on the instance-key tier), given the job’s request and its creator’s UID. Identity M4c-3 (SPEC_AGENT_IDENTITY_CARRIED_NOT_DERIVED_2026_09_23.md §6.5.9): the scheduler is built before AppState, so the server installs this once AppState exists (CronScheduler::install_delivery), as it installs agent-turn delivery. Until then a fire POSTs to the route, as before.
HandleMap 🔒
Abort handles for every currently scheduled cron task.