Skip to main content

Module idle_sweep

Module idle_sweep 

Source
Expand description

The idle lead sweep: forge injects the board sweep when a project’s lead has nothing in flight.

The trigger is this module’s whole subject, not the procedure: the lead charter already carries how a sweep is walked, so the injected prompt only names the moment and the ending it owes. The pass never wakes a sleeping session - a lead with no session is skipped, and its next session start sweeps, as the charter says.

Re-exports§

use std::sync::Arc; 🔒
use std::time::SystemTime; 🔒
use forge_primitives::tasks::TaskStatus; 🔒
use tracing::Instrument; 🔒
use crate::SessionSlot; 🔒
use crate::chase::Deliver; 🔒
use crate::chase::Delivery; 🔒
use crate::chase::PromptDeliver; 🔒
use crate::mcp::workers::types::WorkerEntry; 🔒
use crate::workspace::Workspace; 🔒

Structs§

SweepClock 🔒
One lead’s injected-sweep clock, held in memory so a restart re-arms every lead.

Constants§

IDLE_SWEEP_FALLBACK_PROMPT
The fallback’s own lead-in. The fallback fires precisely when the lead is NOT idle, so it must not claim the board is quiet.
IDLE_SWEEP_FALLBACK_SECS
A lead that has stayed busy this long is swept anyway: the prompt queues behind the running turn, so it is a nudge and not an interruption.
IDLE_SWEEP_INTERVAL_SECS
How often the loop looks. A lead that goes idle is swept within this.
IDLE_SWEEP_MIN_GAP_SECS
At most one idle-triggered sweep per lead inside this window.
IDLE_SWEEP_PROMPT
The idle path’s prompt.

Functions§

age_secs 🔒
How long now is after since, and zero when the clock went backwards. An age that cannot be measured is unknown, never infinitely old: one NTP step must not sweep every lead.
lead_is_idle 🔒
Whether lead is idle: it is the project’s own agent, its session is live, no turn is running, it owns no row in progress, and the project has no live worker.