Skip to content

Commit fcb5d0c

Browse files
committed
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.
1 parent 314f0c9 commit fcb5d0c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

rust/crates/runtime/src/worker_boot.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,12 @@ fn emit_state_file(worker: &Worker) {
592592
prompt_in_flight: bool,
593593
last_event: Option<&'a WorkerEvent>,
594594
updated_at: u64,
595+
/// Seconds since last state transition. Clawhip uses this to detect
596+
/// stalled workers without computing epoch deltas.
597+
seconds_since_update: u64,
595598
}
596599

600+
let now = now_secs();
597601
let snapshot = StateSnapshot {
598602
worker_id: &worker.worker_id,
599603
status: worker.status,
@@ -602,6 +606,7 @@ fn emit_state_file(worker: &Worker) {
602606
prompt_in_flight: worker.prompt_in_flight,
603607
last_event: worker.events.last(),
604608
updated_at: worker.updated_at,
609+
seconds_since_update: now.saturating_sub(worker.updated_at),
605610
};
606611

607612
if let Ok(json) = serde_json::to_string_pretty(&snapshot) {

0 commit comments

Comments
 (0)