durable-workflow 2.23.1__tar.gz → 2.24.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. {durable_workflow-2.23.1/src/durable_workflow.egg-info → durable_workflow-2.24.0}/PKG-INFO +1 -1
  2. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/pyproject.toml +3 -3
  3. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/__init__.py +2 -0
  4. durable_workflow-2.24.0/src/durable_workflow/_timeout_cleanup.py +63 -0
  5. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/activity.py +25 -7
  6. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/client.py +16 -9
  7. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/errors.py +46 -0
  8. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/replay_clock.py +81 -4
  9. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/retry_policy.py +42 -1
  10. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/testing.py +8 -0
  11. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/worker.py +142 -37
  12. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/workflow.py +80 -7
  13. {durable_workflow-2.23.1 → durable_workflow-2.24.0/src/durable_workflow.egg-info}/PKG-INFO +1 -1
  14. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow.egg-info/SOURCES.txt +7 -0
  15. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_checkpoint.py +3 -1
  16. durable_workflow-2.24.0/tests/test_activity_heartbeat_unavailable.py +297 -0
  17. durable_workflow-2.24.0/tests/test_business_replay_clock_entry.py +296 -0
  18. durable_workflow-2.24.0/tests/test_business_replay_clock_query_attestation.py +153 -0
  19. durable_workflow-2.24.0/tests/test_coalescing_signal_timer_replay.py +193 -0
  20. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_replay_regression_corpus.py +71 -0
  21. durable_workflow-2.24.0/tests/test_timeout_cleanup.py +430 -0
  22. durable_workflow-2.24.0/tests/test_worker_transient_5xx_retry.py +370 -0
  23. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_transient_runtime.py +10 -1
  24. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/LICENSE +0 -0
  25. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/README.md +0 -0
  26. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/setup.cfg +0 -0
  27. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_activity_checkpoint.py +0 -0
  28. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_activity_lease.py +0 -0
  29. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_activity_process.py +0 -0
  30. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_avro.py +0 -0
  31. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_cancellation_scope.py +0 -0
  32. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_cancellation_scope_history.py +0 -0
  33. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_capabilities_digest.py +0 -0
  34. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_condition_fingerprint.py +0 -0
  35. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_condition_input_order.py +0 -0
  36. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_continue_as_new.py +0 -0
  37. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_cooperative_cancellation.py +0 -0
  38. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_failure_reporting.py +0 -0
  39. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_metric_routes.py +0 -0
  40. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_poll_transport.py +0 -0
  41. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_prepared_local_activity.py +0 -0
  42. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_query_task_authority.py +0 -0
  43. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_response_limit.py +0 -0
  44. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_sticky_workflow_cache.py +0 -0
  45. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/_typed_values.py +0 -0
  46. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/auth_composition.py +0 -0
  47. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/cancellation.py +0 -0
  48. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/external_storage.py +0 -0
  49. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/external_task_input.py +0 -0
  50. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/external_task_result.py +0 -0
  51. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/history_bundle_verify.py +0 -0
  52. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/interceptors.py +0 -0
  53. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/invocable.py +0 -0
  54. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/metrics.py +0 -0
  55. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/nexus.py +0 -0
  56. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/py.typed +0 -0
  57. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/python_conformance.py +0 -0
  58. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/replay_clock_math.py +0 -0
  59. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/replay_conformance.py +0 -0
  60. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/replay_verify.py +0 -0
  61. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/serializer.py +0 -0
  62. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/server_compatibility.json +0 -0
  63. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/sync.py +0 -0
  64. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/telemetry.py +0 -0
  65. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/telemetry_carrier.py +0 -0
  66. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/worker_session.py +0 -0
  67. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/worker_status.py +0 -0
  68. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow/workflow_updates_conformance.py +0 -0
  69. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow.egg-info/dependency_links.txt +0 -0
  70. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow.egg-info/entry_points.txt +0 -0
  71. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow.egg-info/requires.txt +0 -0
  72. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/src/durable_workflow.egg-info/top_level.txt +0 -0
  73. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_acceptance_authority.py +0 -0
  74. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_acceptance_consumer.py +0 -0
  75. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_acceptance_entry.py +0 -0
  76. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_cancellation_policies.py +0 -0
  77. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_context.py +0 -0
  78. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_exponential_retry.py +0 -0
  79. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_heartbeat_authority.py +0 -0
  80. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_identity.py +0 -0
  81. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_install_inventory.py +0 -0
  82. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_lease_authority.py +0 -0
  83. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_lease_renewal.py +0 -0
  84. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_lease_worker.py +0 -0
  85. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_process.py +0 -0
  86. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_retry_cap_cell.py +0 -0
  87. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_retry_info.py +0 -0
  88. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_run_closed_refusal.py +0 -0
  89. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_activity_worker_lost.py +0 -0
  90. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_auth_composition.py +0 -0
  91. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_avro_value_benchmark.py +0 -0
  92. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_avro_value_protocol.py +0 -0
  93. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_business_replay_clock.py +0 -0
  94. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_business_replay_clock_child.py +0 -0
  95. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_business_replay_clock_parallel.py +0 -0
  96. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_business_replay_clock_redrive.py +0 -0
  97. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_business_replay_clock_sequence_claims.py +0 -0
  98. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cancellation_cause.py +0 -0
  99. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cancellation_context.py +0 -0
  100. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cancellation_remaining_time.py +0 -0
  101. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cancellation_scope_admission.py +0 -0
  102. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cancellation_scope_authoring.py +0 -0
  103. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cancellation_scope_boundary.py +0 -0
  104. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cancellation_scope_opening.py +0 -0
  105. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_capabilities_digest.py +0 -0
  106. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_capabilities_digest_unknown.py +0 -0
  107. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_checkpointed_batch_example.py +0 -0
  108. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_child_workflow_policies.py +0 -0
  109. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_ci_checkout.py +0 -0
  110. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_ci_integration_endpoint.py +0 -0
  111. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_client.py +0 -0
  112. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_client_iterators.py +0 -0
  113. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_client_telemetry.py +0 -0
  114. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_client_timeouts.py +0 -0
  115. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_codec_regression_corpus.py +0 -0
  116. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_command_keys_acceptance.py +0 -0
  117. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_command_keys_captured_inputs.py +0 -0
  118. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_command_keys_container_ownership.py +0 -0
  119. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_command_keys_workspace.py +0 -0
  120. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_committed_cancellation_scope_descendants.py +0 -0
  121. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_committed_cancellation_scope_groups.py +0 -0
  122. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_committed_cancellation_scope_history.py +0 -0
  123. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_committed_cancellation_scope_replay.py +0 -0
  124. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_completion_size_limit.py +0 -0
  125. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_condition_fingerprint.py +0 -0
  126. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_condition_occurrence_id.py +0 -0
  127. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_condition_replay_drift.py +0 -0
  128. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_continue_as_new_target.py +0 -0
  129. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_control_plane_parity_fixtures.py +0 -0
  130. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cooperative_cancellation.py +0 -0
  131. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cooperative_cancellation_client.py +0 -0
  132. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cooperative_cancellation_worker.py +0 -0
  133. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_cooperative_remote_worker.py +0 -0
  134. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_docs_release_channel.py +0 -0
  135. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_docstring_cross_references.py +0 -0
  136. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_durable_selection.py +0 -0
  137. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_empty_callback_failure.py +0 -0
  138. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_errors.py +0 -0
  139. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_external_storage.py +0 -0
  140. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_external_task_input.py +0 -0
  141. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_external_task_result.py +0 -0
  142. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_failure_reporting.py +0 -0
  143. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_generator_lifecycle.py +0 -0
  144. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_golden_history_replay.py +0 -0
  145. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_history_bundle_pruned.py +0 -0
  146. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_history_bundle_schema2.py +0 -0
  147. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_history_bundle_verify.py +0 -0
  148. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_history_event_contract.py +0 -0
  149. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_invocable.py +0 -0
  150. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_local_activity_backoff.py +0 -0
  151. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_local_failure_reporting.py +0 -0
  152. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_message_streams.py +0 -0
  153. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_metric_routes.py +0 -0
  154. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_metrics.py +0 -0
  155. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_native_timer_redrive_cell.py +0 -0
  156. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_native_timer_redrive_clock.py +0 -0
  157. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_nexus_durable_wait.py +0 -0
  158. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_nexus_namespace.py +0 -0
  159. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_nexus_wire.py +0 -0
  160. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_order_processing_example.py +0 -0
  161. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_ordered_condition_input.py +0 -0
  162. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_parallel_completion_order_replay.py +0 -0
  163. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_parallel_failure_order.py +0 -0
  164. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_parallel_group_boundaries.py +0 -0
  165. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_parallel_group_policy.py +0 -0
  166. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_parallel_member_failure_open_siblings.py +0 -0
  167. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_parallel_saga_authoring.py +0 -0
  168. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_patch_history.py +0 -0
  169. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_payload_policy_refresh.py +0 -0
  170. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_pending_operation_replay.py +0 -0
  171. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_physical_command_key_readback.py +0 -0
  172. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_poll_failure_backoff.py +0 -0
  173. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_poll_transport.py +0 -0
  174. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_portal_source_split.py +0 -0
  175. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_prepared_local_activity_client.py +0 -0
  176. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_prepared_local_activity_groups.py +0 -0
  177. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_prepared_local_activity_policies.py +0 -0
  178. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_prepared_local_activity_worker.py +0 -0
  179. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_public_boundary_scanner.py +0 -0
  180. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_publish_workflow_isolation.py +0 -0
  181. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_published_activity_acceptance.py +0 -0
  182. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_published_pagination_evidence.py +0 -0
  183. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_pypi_project_surface.py +0 -0
  184. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_python_conformance.py +0 -0
  185. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_queries.py +0 -0
  186. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_query_task_authority.py +0 -0
  187. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_query_timeout_retry.py +0 -0
  188. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_quiesced_snapshot.py +0 -0
  189. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_readme_quickstart.py +0 -0
  190. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_redrive_call_ledger.py +0 -0
  191. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_redrive_replay.py +0 -0
  192. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_redrive_successor_evidence.py +0 -0
  193. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_registration_ambiguity.py +0 -0
  194. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_release_metadata.py +0 -0
  195. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_release_promotion.py +0 -0
  196. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_replay.py +0 -0
  197. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_replay_clock.py +0 -0
  198. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_replay_conformance.py +0 -0
  199. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_replay_verify.py +0 -0
  200. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_response_body_limit.py +0 -0
  201. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_result_continue_as_new.py +0 -0
  202. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_retry_cap_download.py +0 -0
  203. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_retry_cap_workflow.py +0 -0
  204. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_retry_policy.py +0 -0
  205. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_run_activities.py +0 -0
  206. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_run_cancellation_scope_replay.py +0 -0
  207. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_run_closed_settlement_replay.py +0 -0
  208. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_runtime_external_payload_transport.py +0 -0
  209. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_schedule_origin.py +0 -0
  210. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_schedules.py +0 -0
  211. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_scoped_run_cancellation_context.py +0 -0
  212. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_sdk_metrics_contract.py +0 -0
  213. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_search_attribute_replay_identity.py +0 -0
  214. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_serializer.py +0 -0
  215. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_signal_external_workflow.py +0 -0
  216. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_signal_with_start.py +0 -0
  217. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_signals.py +0 -0
  218. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_sleep.py +0 -0
  219. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_standalone_activity_client.py +0 -0
  220. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_static_credential_validation.py +0 -0
  221. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_sticky_execution.py +0 -0
  222. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_sticky_history_suffix.py +0 -0
  223. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_storage_admission.py +0 -0
  224. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_sync.py +0 -0
  225. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_sync_activities.py +0 -0
  226. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_synthetic_command_key_readback.py +0 -0
  227. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_telemetry.py +0 -0
  228. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_telemetry_carrier.py +0 -0
  229. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_testing_failures.py +0 -0
  230. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_testing_harness.py +0 -0
  231. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_testing_nexus.py +0 -0
  232. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_threaded_heartbeat_example.py +0 -0
  233. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_tls_trust.py +0 -0
  234. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_transport_diagnostics.py +0 -0
  235. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_typed_values.py +0 -0
  236. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_typed_workflow_values.py +0 -0
  237. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_update_outcome.py +0 -0
  238. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_update_signal_condition_replay.py +0 -0
  239. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_updates.py +0 -0
  240. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_wait_condition.py +0 -0
  241. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker.py +0 -0
  242. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_deregistration.py +0 -0
  243. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_observation.py +0 -0
  244. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_session.py +0 -0
  245. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_startup_buffered.py +0 -0
  246. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_startup_raw.py +0 -0
  247. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_startup_read_budget.py +0 -0
  248. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_startup_snapshot.py +0 -0
  249. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_status.py +0 -0
  250. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_worker_telemetry_wire.py +0 -0
  251. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_workflow_entry_arguments.py +0 -0
  252. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_workflow_entrypoint_validation.py +0 -0
  253. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_workflow_handler_validation.py +0 -0
  254. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_workflow_identity.py +0 -0
  255. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_workflow_result_timeout.py +0 -0
  256. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_workflow_streams.py +0 -0
  257. {durable_workflow-2.23.1 → durable_workflow-2.24.0}/tests/test_workflow_updates_conformance.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: durable-workflow
3
- Version: 2.23.1
3
+ Version: 2.24.0
4
4
  Summary: Python client and worker SDK for Durable Workflow Cloud and self-hosted Server
5
5
  Author: Durable Workflow Contributors
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "durable-workflow"
7
- version = "2.23.1"
7
+ version = "2.24.0"
8
8
  description = "Python client and worker SDK for Durable Workflow Cloud and self-hosted Server"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -79,8 +79,8 @@ durable-workflow-replay-conformance = "durable_workflow.replay_conformance:main"
79
79
  durable-workflow-workflow-updates-conformance = "durable_workflow.workflow_updates_conformance:main"
80
80
 
81
81
  [tool.durable-workflow]
82
- product-train = "2.23.1"
83
- registry-version = "2.23.1"
82
+ product-train = "2.24.0"
83
+ registry-version = "2.24.0"
84
84
  supported-server-versions = "2.8.0"
85
85
  supported-server-release-baselines = { "2" = "2.8.0", "3" = "3.0.0" }
86
86
  worker-protocol-version = "1.20"
@@ -74,6 +74,7 @@ from .errors import (
74
74
  ActivityCancelled,
75
75
  ActivityFailed,
76
76
  ActivityHeartbeatResumeUnavailable,
77
+ ActivityHeartbeatUnavailable,
77
78
  ChildWorkflowCancelled,
78
79
  ChildWorkflowFailed,
79
80
  ChildWorkflowTerminated,
@@ -274,6 +275,7 @@ __all__ = [
274
275
  "ActivityRetryInfo",
275
276
  "ActivityHeartbeatCheckpoint",
276
277
  "ActivityHeartbeatResumeUnavailable",
278
+ "ActivityHeartbeatUnavailable",
277
279
  "ActivityInterceptorContext",
278
280
  "ActivityRetryPolicy",
279
281
  "BridgeAdapterOutcome",
@@ -0,0 +1,63 @@
1
+ """Worker side of deadline-triggered timeout cleanup (server#1201, workflow#863).
2
+
3
+ A worker that delivers cooperative cancellation advertises ``timeout_cleanup``
4
+ version 1, so the Server admits starts that reserve cleanup time on its queue.
5
+ When the engine's timeout request reaches workflow code as
6
+ :class:`~durable_workflow.errors.WorkflowTimeoutCleanupRequested` and the
7
+ workflow lets that exception escape, uncaught or re-raised, the
8
+ ``fail_workflow`` command carries ``failure.interruption: "timeout_cleanup"``.
9
+ The Server then records the cleanup as completed, and the run still closes as
10
+ timed out. Any other failure, including one that wraps the interruption, is an
11
+ ordinary failure, which the Server records as failed cleanup. The marker never
12
+ starts cleanup; the Server accepts it only while the run's own engine timeout
13
+ request is active.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from collections.abc import Sequence
19
+ from typing import Any
20
+
21
+ from .cancellation import CancellationContext
22
+ from .errors import WorkflowTimeoutCleanupRequested
23
+
24
+ CAPABILITY = "timeout_cleanup"
25
+ INTERRUPTION = "timeout_cleanup"
26
+ MINIMUM_PROTOCOL_VERSION = "1.20"
27
+ VERSION = 1
28
+
29
+
30
+ def manifest_entry() -> dict[str, Any]:
31
+ """The registration ``capability_manifest`` entry native Server admits."""
32
+ return {"supported": True, "minimum_protocol_version": MINIMUM_PROTOCOL_VERSION, "version": VERSION}
33
+
34
+
35
+ def failure_interruption(
36
+ failure: BaseException, *, delivered: Sequence[BaseException], run_id: str,
37
+ ) -> str | None:
38
+ """The portable marker for an escaped timeout interruption, else ``None``.
39
+
40
+ Only the exception object the runtime raised for this run's root request
41
+ with ``cause: "timeout"`` qualifies. An exception the application
42
+ constructs, a different exception raised from or wrapping the delivered
43
+ one, an ordinary or explicit ``cause: "cancellation"`` request and a
44
+ descendant or scoped request are not marked. The type alone never decides.
45
+ """
46
+ if not isinstance(failure, WorkflowTimeoutCleanupRequested):
47
+ return None
48
+ if not any(failure is candidate for candidate in delivered):
49
+ return None
50
+ context = failure.context
51
+ if (
52
+ not isinstance(context, CancellationContext)
53
+ or not context.is_timeout
54
+ or context.scope_origin is not None
55
+ or failure.request_id is None
56
+ or failure.request_id != context.request_id
57
+ or context.request_id != context.root_request_id
58
+ or context.parent_request_id is not None
59
+ or not run_id
60
+ or context.root_workflow_run_id != run_id
61
+ ):
62
+ return None
63
+ return INTERRUPTION
@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, Any
10
10
 
11
11
  from ._activity_checkpoint import ActivityHeartbeatCheckpoint, _HeartbeatResume, claim_resume
12
12
  from ._activity_lease import current_activity_authority
13
- from .errors import ActivityCancelled, ActivityWorkerLost
13
+ from .errors import ActivityCancelled, ActivityHeartbeatUnavailable, ActivityWorkerLost
14
14
 
15
15
  if TYPE_CHECKING:
16
16
  from .client import Client
@@ -160,6 +160,8 @@ class ActivityContext:
160
160
 
161
161
  The request runs on the worker's event loop using the original attempt
162
162
  and client. Async handlers must use ``await heartbeat()`` instead.
163
+ It raises the same errors as :meth:`heartbeat`, including
164
+ :class:`~durable_workflow.errors.ActivityHeartbeatUnavailable`.
163
165
  """
164
166
  loop = self._event_loop
165
167
  if loop is None or not loop.is_running():
@@ -193,6 +195,12 @@ class ActivityContext:
193
195
  Raises :class:`~durable_workflow.errors.ActivityWorkerLost`
194
196
  with the original Server reason when the attempt cannot continue,
195
197
  including an elapsed deadline, closed attempt or closed run.
198
+
199
+ Raises :class:`~durable_workflow.errors.ActivityHeartbeatUnavailable`
200
+ when a transient outage, such as a Server failover, outlasts the
201
+ client's transport retries. The heartbeat is not retried further, so
202
+ the activity can choose to keep working and heartbeat again later,
203
+ waiting at least its ``retry_after`` when set.
196
204
  """
197
205
  self._raise_if_cannot_continue()
198
206
  if self._heartbeat_callback is not None:
@@ -202,12 +210,22 @@ class ActivityContext:
202
210
  self._cancel_requested = True
203
211
  raise
204
212
  return
205
- resp = await self._client.heartbeat_activity_task(
206
- task_id=self._info.task_id,
207
- activity_attempt_id=self._info.activity_attempt_id,
208
- lease_owner=self._info.worker_id,
209
- details=details,
210
- )
213
+ try:
214
+ resp = await self._client.heartbeat_activity_task(
215
+ task_id=self._info.task_id,
216
+ activity_attempt_id=self._info.activity_attempt_id,
217
+ lease_owner=self._info.worker_id,
218
+ details=details,
219
+ )
220
+ except Exception as error:
221
+ # The worker's classification; imported here because worker imports this module.
222
+ from .worker import _transient_runtime_error
223
+
224
+ # Not retried here: the activity decides whether to keep working
225
+ # through an outage. Definitive refusals keep their own errors.
226
+ if _transient_runtime_error(error):
227
+ raise ActivityHeartbeatUnavailable(self._info.task_id, error) from error
228
+ raise
211
229
  if isinstance(resp, dict) and resp.get("cancel_requested"):
212
230
  self._cancel_requested = True
213
231
  raise ActivityCancelled()
@@ -74,6 +74,7 @@ from .errors import (
74
74
  REQUEST_ID_AMBIGUOUS,
75
75
  REQUEST_ID_CONFLICT,
76
76
  ContinueAsNewTargetUnsupported,
77
+ DurableWorkflowError,
77
78
  ExternalPayloadIntegrityMismatch,
78
79
  ExternalPayloadOversized,
79
80
  ExternalPayloadUnavailable,
@@ -104,7 +105,7 @@ from .external_storage import (
104
105
  )
105
106
  from .metrics import CLIENT_REQUEST_DURATION_SECONDS, CLIENT_REQUESTS, NOOP_METRICS, MetricsRecorder
106
107
  from .nexus import NexusOperationResult, nexus_request_payload
107
- from .retry_policy import TransportRetryPolicy
108
+ from .retry_policy import TransportRetryPolicy, response_retry_after
108
109
  from .telemetry import ExecutionTelemetry, current_execution_telemetry
109
110
  from .telemetry_carrier import supported as observability_supported
110
111
  from .worker_session import WorkerSessionOptions
@@ -2324,14 +2325,20 @@ class Client:
2324
2325
  # The HTTP error is the answer; an unusable digest in it
2325
2326
  # never replaces it. Ask for full capabilities next time.
2326
2327
  self._capabilities_digest.forget()
2327
- # The typed completion-size refusal carries the limit; the
2328
- # size is the encoded request body this client sent.
2329
- if raise_for_status is _raise_for_status:
2330
- raise_for_status(
2331
- exc.response.status_code, body, context=context,
2332
- request_bytes=_request_body_bytes(exc.request),
2333
- )
2334
- raise_for_status(exc.response.status_code, body, context=context)
2328
+ retry_after = response_retry_after(exc)
2329
+ try:
2330
+ # The typed completion-size refusal carries the limit; the
2331
+ # size is the encoded request body this client sent.
2332
+ if raise_for_status is _raise_for_status:
2333
+ raise_for_status(
2334
+ exc.response.status_code, body, context=context,
2335
+ request_bytes=_request_body_bytes(exc.request),
2336
+ )
2337
+ raise_for_status(exc.response.status_code, body, context=context)
2338
+ except DurableWorkflowError as typed:
2339
+ if retry_after is not None:
2340
+ typed.retry_after = retry_after
2341
+ raise
2335
2342
  raise # unreachable, but keeps type checker happy
2336
2343
 
2337
2344
  try:
@@ -26,6 +26,11 @@ from .cancellation import CancellationContext, ScopedCancellationContext
26
26
  class DurableWorkflowError(Exception):
27
27
  """Base class for every exception raised by the SDK."""
28
28
 
29
+ #: Seconds the Server asked the client to wait before retrying, parsed
30
+ #: from the ``Retry-After`` header of the HTTP response this error was
31
+ #: raised for (delta-seconds or HTTP-date). ``None`` when there was none.
32
+ retry_after: float | None = None
33
+
29
34
 
30
35
  class ContinueAsNewTargetUnsupported(DurableWorkflowError):
31
36
  """The current worker registration cannot send a continue-as-new target."""
@@ -359,6 +364,47 @@ class ServerError(DurableWorkflowError):
359
364
  )
360
365
 
361
366
 
367
+ class ActivityHeartbeatUnavailable(ServerError):
368
+ """An activity heartbeat could not reach the Server because of a transient outage.
369
+
370
+ :meth:`~durable_workflow.ActivityContext.heartbeat` and
371
+ :meth:`~durable_workflow.ActivityContext.heartbeat_sync` raise this after
372
+ the client's own transport retries are used up, for example during a
373
+ Server or database failover. It is raised only for failures that may
374
+ succeed unchanged once the Server recovers: a refused, reset or timed-out
375
+ connection; a 500, 502, 503 or 504 without a protocol ``reason`` or with
376
+ the generic ``server_error`` reason; a 503 ``storage_unavailable`` or
377
+ ``backend_unavailable``; and a 5xx or 429 that says ``retryable: true``.
378
+
379
+ The heartbeat was not confirmed, but the attempt has not lost its
380
+ authority. Activity code may keep working and heartbeat again later,
381
+ waiting at least ``retry_after`` when it is set. A cancellation or lost
382
+ attempt still raises :class:`~durable_workflow.errors.ActivityCancelled`
383
+ or :class:`~durable_workflow.errors.ActivityWorkerLost`, and other
384
+ refusals keep their own errors.
385
+
386
+ It subclasses :class:`~durable_workflow.errors.ServerError`, so existing
387
+ ``except ServerError`` handlers still catch it. ``status`` and ``body``
388
+ are those of the HTTP response, or ``0`` and ``None`` when no response
389
+ arrived. ``cause`` (also ``__cause__``) is the underlying error, and
390
+ ``retry_after`` is the Server's ``Retry-After`` in seconds, or ``None``
391
+ when it sent none.
392
+ """
393
+
394
+ def __init__(self, task_id: str, cause: BaseException) -> None:
395
+ if isinstance(cause, ServerError):
396
+ status, body = cause.status, cause.body
397
+ else:
398
+ status, body = 0, None
399
+ super().__init__(status, body)
400
+ detail = f"server returned {status}: {body!r}" if status else f"{type(cause).__name__}: {cause}"
401
+ self.args = (f"activity task {task_id!r} heartbeat not delivered; the Server is unavailable ({detail})",)
402
+ self.task_id = task_id
403
+ self.cause = cause
404
+ retry_after = getattr(cause, "retry_after", None)
405
+ self.retry_after = float(retry_after) if isinstance(retry_after, (int, float)) else None
406
+
407
+
362
408
  WORKFLOW_TASK_COMPLETION_BYTES = "workflow_task_completion_bytes"
363
409
 
364
410
 
@@ -34,6 +34,42 @@ _GROUP_FIELDS = ("parallel_group_id", "parallel_group_kind", "parallel_group_bas
34
34
  _SELECTION_FIELDS = ("selection_member_key", "selection_member_index", "selection_member_base_sequence",
35
35
  "selection_member_size", "selection_member_kind")
36
36
  _GroupMember = tuple[int | None, int, str, Sequence[Mapping[str, Any]] | None]
37
+ ENTRY_SCHEMA = "durable-workflow.worker-replay-clock/v1"
38
+ _ENTRY_SOURCES = frozenset({"run_started_at", "redrive_replayed_started_at"})
39
+ _ENTRY_INSTANT = re.compile(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z", re.ASCII)
40
+
41
+
42
+ @dataclass(frozen=True)
43
+ class EntryInstant:
44
+ """A validated ``WorkerReplayClock`` v1 carrier from a workflow task (server#1156)."""
45
+
46
+ started_at: datetime
47
+ source: str
48
+
49
+
50
+ def entry_instant(carrier: Any, run_id: str) -> EntryInstant | None:
51
+ """Validate a task's ``replay_clock`` object; anything unproved is absent.
52
+
53
+ The object is the Server's only availability signal. Its run must be the
54
+ task's run and its instant is strict UTC with six fractional digits. No
55
+ other time (lease, dispatch, history insertion or wall time) substitutes.
56
+ """
57
+ # The v1 schema forbids additional properties, so the key set is exact.
58
+ if not isinstance(carrier, Mapping) or set(carrier) != {"schema", "workflow_run_id", "started_at", "source"}:
59
+ return None
60
+ source = carrier["source"]
61
+ if carrier["schema"] != ENTRY_SCHEMA or not isinstance(source, str) or source not in _ENTRY_SOURCES:
62
+ return None
63
+ if not _identity(run_id) or carrier["workflow_run_id"] != run_id:
64
+ return None
65
+ value = carrier["started_at"]
66
+ if not isinstance(value, str) or _ENTRY_INSTANT.fullmatch(value) is None:
67
+ return None
68
+ try:
69
+ started_at = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
70
+ except ValueError:
71
+ return None
72
+ return EntryInstant(started_at, source)
37
73
 
38
74
 
39
75
  def _task() -> object | None:
@@ -49,6 +85,7 @@ class _Frame:
49
85
  time: datetime | None
50
86
  thread: int
51
87
  task: object | None
88
+ entry: bool = False
52
89
 
53
90
 
54
91
  _ACTIVE: ContextVar[_Frame | None] = ContextVar("business_replay_clock", default=None)
@@ -56,8 +93,8 @@ _DISCARD = threading.local()
56
93
 
57
94
 
58
95
  @contextlib.contextmanager
59
- def execution_scope(owner: object | None, time: datetime | None) -> Iterator[None]:
60
- token = _ACTIVE.set(_Frame(owner, time, threading.get_ident(), _task()))
96
+ def execution_scope(owner: object | None, time: datetime | None, *, entry: bool = False) -> Iterator[None]:
97
+ token = _ACTIVE.set(_Frame(owner, time, threading.get_ident(), _task(), entry))
61
98
  try:
62
99
  yield
63
100
  finally:
@@ -103,9 +140,14 @@ gc.callbacks.append(_collection)
103
140
  def read(owner: object) -> datetime:
104
141
  frame = _ACTIVE.get()
105
142
  if (getattr(_DISCARD, "active", False) or getattr(_DISCARD, "collecting", False)
106
- or frame is None or frame.owner is not owner or frame.time is None
143
+ or frame is None or frame.owner is not owner
107
144
  or frame.thread != threading.get_ident() or frame.task is not _task()):
108
145
  raise ReplayClockUnavailable()
146
+ if frame.time is None:
147
+ clock = getattr(owner, "_business_clock", None)
148
+ if frame.entry and isinstance(clock, BusinessReplayClock):
149
+ clock.entry_read_unavailable()
150
+ raise ReplayClockUnavailable()
109
151
  return frame.time
110
152
 
111
153
 
@@ -232,6 +274,7 @@ class BusinessReplayClock:
232
274
  def __init__(
233
275
  self, events: Sequence[Mapping[str, Any]], workflow_id: str, run_id: str,
234
276
  *, sequence_claim: Callable[[Mapping[str, Any]], int | None],
277
+ entry: EntryInstant | None = None,
235
278
  ) -> None:
236
279
  self.events = events
237
280
  self._by_sequence: dict[int, list[int]] = {}
@@ -249,11 +292,37 @@ class BusinessReplayClock:
249
292
  if (isinstance(payload, Mapping) and self._start_prefix(index, payload)
250
293
  and self._redrive_start(index, payload, workflow_id, run_id)):
251
294
  self.initial = (index, _time(payload.get("replayed_started_at")))
295
+ if entry is not None and self.initial[1] is None:
296
+ # The Server's carrier gives ordinary entry its canonical start. Its
297
+ # source must agree with the history's own start kind, and a
298
+ # redrive anchor this history already proves is never replaced.
299
+ expected = "redrive_replayed_started_at" if self._redrive_declared else "run_started_at"
300
+ if entry.source == expected and self._entry_agrees(starts, entry.started_at):
301
+ self.initial = (None, entry.started_at)
252
302
  self._pending: tuple[int | None, datetime | None] = self.initial
253
303
  self._current: tuple[int | None, datetime | None] = self.initial
304
+ # Whether the pending/current time is still the entry value. An empty
305
+ # group carries it into the next resume without consuming history.
306
+ self._pending_entry = True
307
+ self._current_entry = False
308
+ # A query or validation rebuild whose task does not attest the entry
309
+ # carrier cannot know what the workflow task's entry read returned.
310
+ self.entry_unattested = False
311
+ self.unattested_entry_read = False
254
312
  for index, event in enumerate(events):
255
313
  self._index_event(index, event, sequence_claim)
256
314
 
315
+ def _entry_agrees(self, starts: Sequence[int], started_at: datetime) -> bool:
316
+ """An anchor the start event records itself must equal the carrier's."""
317
+ for index in starts:
318
+ payload = self.events[index].get("payload")
319
+ if not isinstance(payload, Mapping) or "replayed_started_at" not in payload:
320
+ continue
321
+ # A present but unreadable anchor is a conflict, not an absence.
322
+ if _time(payload["replayed_started_at"]) != started_at:
323
+ return False
324
+ return True
325
+
257
326
  def _index_event(
258
327
  self, index: int, event: Mapping[str, Any], sequence_claim: Callable[[Mapping[str, Any]], int | None],
259
328
  ) -> None:
@@ -312,9 +381,16 @@ class BusinessReplayClock:
312
381
 
313
382
  def resume(self, owner: object, function: Callable[..., _T], *args: Any) -> _T:
314
383
  self._current, self._pending = self._pending, (None, None)
315
- with execution_scope(owner, self._current[1]):
384
+ entry, self._pending_entry = self._pending_entry, False
385
+ self._current_entry = entry
386
+ with execution_scope(owner, self._current[1], entry=entry):
316
387
  return function(*args)
317
388
 
389
+ def entry_read_unavailable(self) -> None:
390
+ """Record an entry read that only an unattested rebuild found unavailable."""
391
+ if self.entry_unattested:
392
+ self.unattested_entry_read = True
393
+
318
394
  def snapshot(self) -> datetime | None:
319
395
  # Only this final inspected prefix is proved for a query callback.
320
396
  index, time = self._current
@@ -326,6 +402,7 @@ class BusinessReplayClock:
326
402
  def preserve_boundary(self) -> None:
327
403
  """An empty group consumes no new event and retains the proved prefix."""
328
404
  self._pending = self._current
405
+ self._pending_entry = self._current_entry
329
406
 
330
407
  def observe_activity_group(
331
408
  self, members: Sequence[_GroupMember], failed_member: int | None, *, reconstruction: bool,
@@ -17,10 +17,13 @@ import asyncio
17
17
  import contextvars
18
18
  import json
19
19
  import logging
20
+ import math
20
21
  import random
21
22
  import re
22
23
  from collections.abc import Awaitable, Callable
23
24
  from dataclasses import dataclass
25
+ from datetime import datetime, timezone
26
+ from email.utils import parsedate_to_datetime
24
27
  from typing import TypeVar
25
28
 
26
29
  import httpx
@@ -36,6 +39,38 @@ _worker_storage_admission_stop: contextvars.ContextVar[Callable[[], bool] | None
36
39
  )
37
40
 
38
41
 
42
+ def parse_retry_after(value: str | None, *, now: datetime | None = None) -> float | None:
43
+ """Seconds to wait from an HTTP ``Retry-After`` value, or ``None``.
44
+
45
+ Both forms of RFC 9110 are accepted: delta-seconds (``"5"``) and an
46
+ HTTP-date (``"Wed, 25 Nov 2026 22:40:41 GMT"``). A date in the past waits
47
+ zero seconds. Anything else is ignored. Callers apply their own cap.
48
+ """
49
+ if value is None:
50
+ return None
51
+ value = value.strip()
52
+ if value.isascii() and value.isdigit():
53
+ # Callers cap the wait; an absurdly long value must not raise.
54
+ if len(value) > 10:
55
+ return float(10**10)
56
+ return float(int(value))
57
+ try:
58
+ when = parsedate_to_datetime(value)
59
+ except (TypeError, ValueError, IndexError, OverflowError):
60
+ return None
61
+ if when.tzinfo is None:
62
+ when = when.replace(tzinfo=timezone.utc)
63
+ seconds = (when - (now or datetime.now(timezone.utc))).total_seconds()
64
+ return max(0.0, seconds) if math.isfinite(seconds) else None
65
+
66
+
67
+ def response_retry_after(exc: BaseException) -> float | None:
68
+ """The ``Retry-After`` delay of a failed HTTP response, or ``None``."""
69
+ if not isinstance(exc, httpx.HTTPStatusError):
70
+ return None
71
+ return parse_retry_after(exc.response.headers.get("retry-after"))
72
+
73
+
39
74
  def _query_timeout_refusal(exc: httpx.HTTPStatusError) -> bool:
40
75
  request = exc.request
41
76
  if (exc.response.status_code != 504 or request.method != "POST"
@@ -220,7 +255,9 @@ class TransportRetryPolicy:
220
255
  child workflow retries with
221
256
  :class:`durable_workflow.workflow.ChildWorkflowRetryPolicy`.
222
257
 
223
- Uses exponential backoff with jitter to avoid thundering herd.
258
+ Uses exponential backoff with jitter to avoid thundering herd. A
259
+ ``Retry-After`` header on a retried response (delta-seconds or HTTP-date)
260
+ lengthens that wait, capped at ``max_backoff_seconds``.
224
261
  Canonical query timeouts end the original query and are surfaced without
225
262
  another query admission; unrelated transient HTTP failures still retry.
226
263
  """
@@ -320,6 +357,10 @@ class TransportRetryPolicy:
320
357
 
321
358
  if attempt + 1 < self.max_attempts:
322
359
  backoff = self.backoff_seconds(attempt)
360
+ retry_after = response_retry_after(exc)
361
+ if retry_after is not None:
362
+ # Honour the Server's Retry-After, capped by this policy's ceiling.
363
+ backoff = max(backoff, min(retry_after, self.max_backoff_seconds))
323
364
  await asyncio.sleep(backoff)
324
365
 
325
366
  attempt += 1
@@ -670,6 +670,7 @@ def replay_history(
670
670
  *,
671
671
  run_id: str = "",
672
672
  payload_codec: str | None = None,
673
+ replay_clock_entry: Mapping[str, Any] | None = None,
673
674
  ) -> ReplayOutcome:
674
675
  """Replay a production history against current workflow code.
675
676
 
@@ -681,6 +682,10 @@ def replay_history(
681
682
  This is the supported way to regression-test a workflow change against
682
683
  real production traffic: dump the history from ``Client.get_history``,
683
684
  save the JSON, and replay it on every PR.
685
+
686
+ A workflow that reads ``ctx.replay_now()`` at entry needs the workflow
687
+ task's ``replay_clock`` object as ``replay_clock_entry``; history alone
688
+ does not carry that instant.
684
689
  """
685
690
  return replay(
686
691
  workflow_cls,
@@ -688,6 +693,7 @@ def replay_history(
688
693
  list(start_input or []),
689
694
  run_id=run_id,
690
695
  payload_codec=payload_codec,
696
+ replay_clock_entry=replay_clock_entry,
691
697
  )
692
698
 
693
699
 
@@ -698,6 +704,7 @@ def replay_history_file(
698
704
  *,
699
705
  run_id: str = "",
700
706
  payload_codec: str | None = None,
707
+ replay_clock_entry: Mapping[str, Any] | None = None,
701
708
  ) -> ReplayOutcome:
702
709
  """Convenience wrapper: load a JSON history file and replay it.
703
710
 
@@ -712,6 +719,7 @@ def replay_history_file(
712
719
  start_input,
713
720
  run_id=run_id,
714
721
  payload_codec=payload_codec,
722
+ replay_clock_entry=replay_clock_entry,
715
723
  )
716
724
 
717
725