fix(auto): heartbeat before unit execution to prevent false-positive watchdog stalls

The HaltWatchdog fires when the loop goes >10s without a heartbeat. Each
iteration ends with a heartbeat, but unit execution itself can take 3+ minutes.
Without a heartbeat at the start of the unit phase, the watchdog detects idle
and emits a false-positive 'possible stuck iteration' error.

Add watchdog.heartbeat() immediately before both runUnitPhaseViaContract calls
(one in the custom-engine path, one in the dev path) so the watchdog timer is
reset before the long-running work begins.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot 2026-05-15 06:30:40 +02:00
parent e7cf168824
commit 1e99bd669e

View file

@ -891,6 +891,7 @@ export async function autoLoop(ctx, pi, s, deps) {
} }
// ── Unit execution (shared with dev path) ── // ── Unit execution (shared with dev path) ──
await enforceMinRequestInterval(s, ic.prefs); await enforceMinRequestInterval(s, ic.prefs);
watchdog.heartbeat(); // reset before long-running unit execution
const unitPhaseResult = await runUnitPhaseViaContract( const unitPhaseResult = await runUnitPhaseViaContract(
ic, ic,
iterData, iterData,
@ -1214,6 +1215,7 @@ export async function autoLoop(ctx, pi, s, deps) {
}); });
} }
await enforceMinRequestInterval(s, ic.prefs); await enforceMinRequestInterval(s, ic.prefs);
watchdog.heartbeat(); // reset before long-running unit execution
const unitPhaseResult = await runUnitPhaseViaContract( const unitPhaseResult = await runUnitPhaseViaContract(
ic, ic,
iterData, iterData,