Repository navigation
Prove embedded timeout cleanup at signal/selection waits, under worker loss, and on the deadline turn - #1312
Merged
Conversation
…orker loss, and on the deadline turn Adds the missing embedded-execution proofs for deadline-triggered timeout cleanup (#863): - expiry while blocked on a signal wait: cleanup entered once, the typed WorkflowTimeoutCleanupRequested (cause: timeout) reaches the wait with the original request, instance and run identities, and a signal sent during cleanup is never applied and is rejected when the run closes; - expiry while blocked on a select() of a signal wait and a running activity: the interruption is delivered at the selection, the running branch is cancelled under the timeout request and its late heartbeat and result are refused, the signal branch never resolves the selection; - a worker process holding the cleanup turn dies by SIGKILL before the turn commits, and a fresh process repairs the lease and finishes from history: one WorkflowTimeoutCleanupStarted, the original cleanup deadline, the compensation replayed rather than repeated, outcome completed inside the window or expired after the hard deadline; - a timer or activity result recorded at or after the work deadline, before detection, lets the workflow return in the task that notices the deadline: cleanup is entered once, the run ends timed out with outcome completed and the business result discarded; a result recorded after cleanup started is discarded for the interruption instead. Tests only; no guarded source changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Member
Author
|
Independent review: PASS at
🤖 Generated with Claude Code |
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds the missing embedded-execution proofs for deadline-triggered timeout cleanup, for #863. The change is tests only and touches no guarded source, so the regression-corpus validator passes without a new fixture. All new tests are in
tests/Feature/V2/V2TimeoutCleanupTest.php.1. Expiry while waiting on a signal (
testExpiryWhileWaitingOnASignalInterruptsTheWaitAndALateSignalNeverApplies)await('approve')at its work deadline. The test asserts exactly oneWorkflowTimeoutCleanupStartedand oneCooperativeCancellationRequested, and exactly oneCooperativeCancellationDeliveredat the signal wait's sequence (call_kind: signal).WorkflowTimeoutCleanupRequestedwithcause: timeout, a request id equal to the cleanup event's command id, the same root instance and run (still one run), no parent request, and the original cleanup deadline.SignalRejectedwithrun_closed_before_signal_applied.WorkflowTimedOutwith cleanup outcomecompleted. There is noWorkflowCompletedand the output is null. A signal sent after close is rejected.2. Expiry while waiting on a selection (
testExpiryWhileWaitingOnASelectionCancelsEveryBranchAndNoBranchCommits)select()over a signal wait and an activity that a worker is already running. It gets the same once-only and identity assertions, with delivery at the selection (call_kind: parallel).ActivityCancelledunder the timeout request. Its worker's late heartbeat returnscan_continue: falseandcancel_requested: true, and its late completion is not recorded.SelectionResolvedand noSignalApplied, and the work activity has noActivityCompleted. The run ends timed out with cleanup outcomecompleted.3. Kill-and-replay during cleanup (
testAWorkerKilledMidCleanupIsReplacedFromHistoryWithoutRestartingCleanup, two cases)WorkerLossControl, with the new workertests/Support/TimeoutCleanupProcessLossProcessTest.php). A separate PHP worker process runs the cleanup turn and dies bySIGKILLwhile its workflow task is writing the compensation memo, before that write commits. The parent checks the turn is still leased by the dead worker, the run is open, and nothing from that turn committed.WorkflowTimeoutCleanupStarted, an unchanged cleanup deadline equal to the original hard deadline, and one delivery. The compensation activity is scheduled and completed once, so it is replayed rather than repeated.completedand the memo is written. If it first runs after the hard deadline, the outcome isexpiredand there is no memo.4. Completion in the task that notices the work deadline (
testCompletingInTheTaskThatNoticesTheWorkDeadlineEndsTimedOut, timer and activity cases, plustestAnActivityResultRecordedAfterCleanupStartsIsDiscardedForTheInterruption)WorkflowTimedOutwith outcomecompletedand the original deadline. The business result is discarded: noWorkflowCompletedand a null output.WorkflowTimeoutCleanupStartedis discarded, and the interruption is delivered at that activity call instead.I checked locally that the new tests fail when the behavior regresses. Skipping signal or selection delivery fails proofs 1 and 2. Letting a run with a pending timeout request complete normally fails proofs 1, 2 and 4. Delivering over an earlier-recorded result fails proof 4. Allowing cleanup re-entry fails proof 3.
🤖 Generated with Claude Code