Skip to main content

Module watchdog

Module watchdog 

Source
Expand description

Movable-deadline watchdog for the per-execute timeout.

execute_with_options used to spawn a timer that slept the whole script budget and fired the cancel token — nothing could suspend or extend it mid-script. That can’t serve model-backed builtins (provider calls that legitimately run minutes): stretching the script budget to minutes hands a while true loop the same minutes. The two jobs need separate knobs.

Watchdog keeps the deadline in a tokio::sync::watch channel the timer task re-arms against. Builtins suspend the script clock through ToolCtx::patient, which acquires a WatchdogHold: while held, the hold’s own budget governs the deadline; on drop the script clock resumes with the remaining time it had at acquire (the same RAII discipline as the kernel’s VarsFrameGuard/CwdGuard).

Only the timer is suspendable. The cancel token the watchdog fires is the same one Kernel::cancel() and the embedder token cascade into — those stay live during a hold.

Structs§

Watchdog
The per-execute timeout timer with a movable deadline.
WatchdogHold
RAII hold on a Watchdog: releases (and restores the frozen remaining time) on drop. Handed to tools boxed inside a PatientGuard.