From e43410f5e3df1669ba2c75f98e781321d97b872d Mon Sep 17 00:00:00 2001 From: Hare Date: Thu, 1 Oct 2026 17:12:02 +0900 Subject: [PATCH] Fence lifecycle capture on cancelled runs --- crates/worker/src/worker.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/worker/src/worker.rs b/crates/worker/src/worker.rs index 376a82bec..4313a184f 100644 --- a/crates/worker/src/worker.rs +++ b/crates/worker/src/worker.rs @@ -3474,7 +3474,9 @@ impl Worker { LogEntry::RunCompleted { .. } | LogEntry::RunYielded { .. } | LogEntry::RunResumed { .. } => Some(CommittedRunExit::NonFinal), - LogEntry::RunErrored { .. } => Some(CommittedRunExit::Interrupted), + LogEntry::RunCancelled { .. } | LogEntry::RunErrored { .. } => { + Some(CommittedRunExit::Interrupted) + } _ => None, }) .unwrap_or(CommittedRunExit::NonFinal); @@ -11252,7 +11254,7 @@ mod build_summary_prompt_tests { .commit_entry(LogEntry::RunErrored { ts: segment_log::now_millis(), interrupted: true, - message: "cancelled".to_string(), + message: "provider failed".to_string(), failure: Some(RunFailureKind::Engine), }) .unwrap(); @@ -11272,6 +11274,22 @@ mod build_summary_prompt_tests { capture_handle.capture().unwrap().run_exit, CommittedRunExit::Finished ); + worker + .commit_entry(LogEntry::Invoke { + ts: segment_log::now_millis(), + trigger: protocol::InvokeKind::UserSend, + }) + .unwrap(); + worker + .commit_entry(LogEntry::RunCancelled { + ts: segment_log::now_millis(), + }) + .unwrap(); + assert_eq!( + capture_handle.capture().unwrap().run_exit, + CommittedRunExit::Interrupted, + "a current cancellation must not inherit an earlier finished run" + ); worker .commit_entry(LogEntry::RunResumed { ts: segment_log::now_millis(),