From fcb5d0c16a093818dc73888d1337a92eeb61a15b Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 8 Apr 2026 01:03:00 +0900 Subject: [PATCH] fix(worker_boot): add seconds_since_update to state snapshot Clawhip needs to distinguish a stalled trust_required worker from one that just transitioned. Without a pre-computed staleness field it has to compute epoch delta itself from updated_at. seconds_since_update = now - updated_at at snapshot write time. Clawhip threshold: > 60s in trust_required = stalled; act. --- rust/crates/runtime/src/worker_boot.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/crates/runtime/src/worker_boot.rs b/rust/crates/runtime/src/worker_boot.rs index 15cb72c..93e4464 100644 --- a/rust/crates/runtime/src/worker_boot.rs +++ b/rust/crates/runtime/src/worker_boot.rs @@ -592,8 +592,12 @@ fn emit_state_file(worker: &Worker) { prompt_in_flight: bool, last_event: Option<&'a WorkerEvent>, updated_at: u64, + /// Seconds since last state transition. Clawhip uses this to detect + /// stalled workers without computing epoch deltas. + seconds_since_update: u64, } + let now = now_secs(); let snapshot = StateSnapshot { worker_id: &worker.worker_id, status: worker.status, @@ -602,6 +606,7 @@ fn emit_state_file(worker: &Worker) { prompt_in_flight: worker.prompt_in_flight, last_event: worker.events.last(), updated_at: worker.updated_at, + seconds_since_update: now.saturating_sub(worker.updated_at), }; if let Ok(json) = serde_json::to_string_pretty(&snapshot) {