Repository navigation
Add missing flag 4 tests - #2195
Closed
VegetarianOrc wants to merge 19 commits into
Closed
VegetarianOrc wants to merge 19 commits into
VegetarianOrc wants to merge 19 commits into
Conversation
VegetarianOrc
force-pushed
the
alexmazzeo/sdk-607-flag-4-add-missing-tests
branch
2 times, most recently
from
December 3, 2026 00:13
0ef06e5 to
54b7ac4
Compare
Flag 4 now applies all activation jobs before it runs workflow tasks, and sends cancellation only to the task that receives it. Remove flag 5. Batching alone changes which result wins when a cancellation arrives in the same workflow task, so one flag controls both behaviors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With flag 4, a start that resolves in the same activation as a cancellation raises CancelledError. The caller gets no handle, so the SDK now sends the cancel request to the child or operation before it raises. Flag 2 behavior does not change. Refs SDK-604. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With flag 4, the start cancel path can run after the child result resolved in the same activation. Core fails the task on a cancel for a terminated child, so skip the cancel when the result is known. Also address review findings in the start cancellation tests: - Use one worker for the child test, with a short task timeout. - Add a case where the child terminates in the same activation. - Skip the child test on the Java test server. - Run the Nexus test on time-skipping V2, and reuse WaitForCancelWorkflow. Refs SDK-604. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Name the flag 2 and flag 4 attributes after their flags, and name the start parameter after what the caller awaits. Move the decision that a cancellation wins over a resolved operation into its own helper, so _await_temporal_operation has one branch for resolved operations. Refs SDK-604. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs SDK-604. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
List the flag 4 effects that users can see but the fragment left out: external and child signals, handle cancel after a result, all_handlers_finished(), job failures during apply, Python 3.11 timeout rounding, and handler waits after cancellation. Also add a reminder to name the minimum replay version when flag 4 becomes a default. Refs SDK-605. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address review findings on the flag 4 fragment: - Split the first entry into three entries. - Name the exact call or handler that each entry affects. - Add update handlers to the job failure entry. - Name asyncio.CancelledError. - Follow the existing flag reminder form in the TODO. Refs SDK-605. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker checked flag 2 before flag 4. A worker with flag 2 as a default then recorded flag 2 on a run whose history holds flag 4, and the run changed to flag 2 behavior. Check flag 4 first when history does not hold flag 2, and check flag 2 last. A new run on a worker with both flags as defaults now records flag 4. Refs SDK-606. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address review findings on the flag precedence tests: - Start the handler wait on the second worker, so the result shows which flag the run uses. - Compare the full set of recorded flags. - Set both flags explicitly on each worker. - Remove cases that run the same code path. Refs SDK-606. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add tests that run with no flag, flag 2 and flag 4: - A Nexus operation result and a workflow cancellation in one activation. - An external signal and a workflow cancellation in one activation. - A signal handler wait after workflow cancellation on one worker. Also run the test for a flag first enabled on a later task with flag 4. The child start test now ends its hold when the cancellation arrives, so a regression fails instead of hanging. Refs SDK-607. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address review findings on the new flag 4 tests: - Give each outcome different commands, so replay detects a wrong flag decision. - Use a condition and timeout race in the later task test, so the result shows that the flag takes effect there. - Compare only the two batching flags in recorded flag sets. - Name the Nexus helpers and handler workflow for their role. Refs SDK-607. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VegetarianOrc
force-pushed
the
alexmazzeo/sdk-607-flag-4-add-missing-tests
branch
from
December 3, 2026 00:22
54b7ac4 to
dbfcd22
Compare
Base automatically changed from
alexmazzeo/sdk-606-flag-4-keep-flag-2-out-of-runs-whose
to
main
December 3, 2026 00:47
Contributor
Author
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.
What was changed
Add flag 4 tests. Each test runs with no flag, with flag 2 and with flag 4, and replays the recorded history:
test_workflow_cancel_and_operation_completion_in_same_activation: a Nexus operation completion and a workflow cancellation in one activation.test_workflow_cancel_and_external_signal_in_same_activation: an external signal result and a workflow cancellation in one activation.test_workflow_logic_flag_enabled_after_replaynow runs for flag 2 and flag 4. It uses a condition-or-timeout race, so the result shows that the flag takes effect on the later task.test_workflow_handler_wait_condition_after_cancel: a signal handler wait after workflow cancellation.Each outcome sends different commands, so a replay that makes the wrong flag decision fails. The child start test from #2192 now fails fast on a regression instead of hanging.
Why?
#2149 had no tests for these flag 4 behaviors.
Checklist
Refs SDK-607. Stacked on Keep flag 2 out of runs that use flag 4 #2194.
How was this tested:
test_workflow.py,test_replayer.py,test_workflow_flags.pyand the Nexus file: 322 passed, 2 skipped.poe lintpassed.Any docs updates needed? No.
🤖 Generated with Claude Code