Skip to content

Add missing flag 4 tests - #2195

Closed
VegetarianOrc wants to merge 19 commits into
mainfrom
alexmazzeo/sdk-607-flag-4-add-missing-tests
Closed

VegetarianOrc wants to merge 19 commits into
mainfrom
alexmazzeo/sdk-607-flag-4-add-missing-tests

Conversation

@VegetarianOrc

@VegetarianOrc VegetarianOrc commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

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_replay now 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

  1. Refs SDK-607. Stacked on Keep flag 2 out of runs that use flag 4 #2194.

  2. How was this tested:

    • The changed tests pass on the local dev server and on time-skipping V2.
    • A change that ignores flags on replay makes the flag 2 and flag 4 cases fail where the outcomes differ.
    • test_workflow.py, test_replayer.py, test_workflow_flags.py and the Nexus file: 322 passed, 2 skipped.
    • poe lint passed.
  3. Any docs updates needed? No.

🤖 Generated with Claude Code

@VegetarianOrc
VegetarianOrc added this pull request to stack #2196 December 2, 2026 23:39
@VegetarianOrc VegetarianOrc changed the title alexmazzeo/sdk 607 flag 4 add missing tests Add missing flag 4 tests Dec 2, 2026
@VegetarianOrc
VegetarianOrc force-pushed the alexmazzeo/sdk-607-flag-4-add-missing-tests branch 2 times, most recently from 0ef06e5 to 54b7ac4 Compare December 3, 2026 00:13
@VegetarianOrc
VegetarianOrc removed this pull request from stack #2196 December 3, 2026 00:18
@VegetarianOrc
VegetarianOrc added this pull request to stack #2197 December 3, 2026 00:18
VegetarianOrc and others added 19 commits December 2, 2026 16:19
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
VegetarianOrc force-pushed the alexmazzeo/sdk-607-flag-4-add-missing-tests branch from 54b7ac4 to dbfcd22 Compare December 3, 2026 00:22
@VegetarianOrc
VegetarianOrc removed this pull request from stack #2197 December 3, 2026 00:37
@VegetarianOrc
VegetarianOrc added this pull request to stack #2199 December 3, 2026 00:37
Base automatically changed from alexmazzeo/sdk-606-flag-4-keep-flag-2-out-of-runs-whose to main December 3, 2026 00:47
@VegetarianOrc
VegetarianOrc removed this pull request from stack #2199 December 3, 2026 00:47
@VegetarianOrc

Copy link
Copy Markdown
Contributor Author

Merged into #2149 by fast-forward: commits 7f1e9df and dbfcd22 are on amazzeo/workflow-wait-condition-cancellation. GitHub retargeted this PR to main when #2194 merged, so it could not record the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant