@temporalio/core-bridge 1.13.1 → 1.14.0

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 (422) hide show
  1. package/Cargo.lock +350 -436
  2. package/Cargo.toml +14 -13
  3. package/{sdk-core/fsm/rustfsm_procmacro/LICENSE.txt → LICENSE} +5 -5
  4. package/README.md +0 -1
  5. package/bridge-macros/Cargo.toml +16 -0
  6. package/bridge-macros/src/derive_js_function.rs +126 -0
  7. package/bridge-macros/src/derive_tryfromjs.rs +138 -0
  8. package/bridge-macros/src/derive_tryintojs.rs +151 -0
  9. package/bridge-macros/src/lib.rs +42 -0
  10. package/lib/native.d.ts +23 -9
  11. package/package.json +6 -5
  12. package/releases/aarch64-apple-darwin/index.node +0 -0
  13. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  14. package/releases/x86_64-apple-darwin/index.node +0 -0
  15. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  16. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  17. package/sdk-core/.cargo/config.toml +78 -12
  18. package/sdk-core/.clippy.toml +1 -0
  19. package/sdk-core/.github/workflows/heavy.yml +2 -0
  20. package/sdk-core/.github/workflows/per-pr.yml +90 -21
  21. package/sdk-core/AGENTS.md +17 -19
  22. package/sdk-core/ARCHITECTURE.md +44 -48
  23. package/sdk-core/Cargo.toml +25 -7
  24. package/sdk-core/README.md +16 -15
  25. package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
  26. package/sdk-core/arch_docs/diagrams/deps.svg +102 -0
  27. package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
  28. package/sdk-core/arch_docs/sdks_intro.md +299 -0
  29. package/sdk-core/{client → crates/client}/Cargo.toml +15 -16
  30. package/sdk-core/{client → crates/client}/src/callback_based.rs +1 -2
  31. package/sdk-core/{client → crates/client}/src/lib.rs +594 -457
  32. package/sdk-core/{client → crates/client}/src/metrics.rs +32 -8
  33. package/sdk-core/crates/client/src/proxy.rs +209 -0
  34. package/sdk-core/{client → crates/client}/src/raw.rs +648 -328
  35. package/sdk-core/crates/client/src/replaceable.rs +253 -0
  36. package/sdk-core/crates/client/src/request_extensions.rs +40 -0
  37. package/sdk-core/{client → crates/client}/src/retry.rs +32 -22
  38. package/sdk-core/crates/client/src/worker/mod.rs +1468 -0
  39. package/sdk-core/{client → crates/client}/src/workflow_handle/mod.rs +24 -21
  40. package/sdk-core/{core-api → crates/common}/Cargo.toml +21 -12
  41. package/sdk-core/{sdk-core-protos → crates/common}/build.rs +10 -23
  42. package/sdk-core/crates/common/protos/api_cloud_upstream/VERSION +1 -0
  43. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +18 -0
  44. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +38 -11
  45. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +21 -4
  46. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +6 -6
  47. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +22 -0
  48. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/create-release.yml +13 -0
  49. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv2.json +254 -5
  50. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv3.yaml +234 -5
  51. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
  52. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
  53. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
  54. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
  55. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
  56. package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
  57. package/sdk-core/{core-api → crates/common}/src/envconfig.rs +155 -56
  58. package/sdk-core/{core-api → crates/common}/src/errors.rs +8 -1
  59. package/sdk-core/{fsm/rustfsm_trait/src/lib.rs → crates/common/src/fsm_trait.rs} +1 -27
  60. package/sdk-core/{core-api → crates/common}/src/lib.rs +92 -9
  61. package/sdk-core/{test-utils/src → crates/common/src/protos}/canned_histories.rs +5 -5
  62. package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_builder.rs +3 -3
  63. package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_info.rs +2 -2
  64. package/sdk-core/{sdk-core-protos/src/lib.rs → crates/common/src/protos/mod.rs} +43 -26
  65. package/sdk-core/crates/common/src/protos/test_utils.rs +89 -0
  66. package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/utilities.rs +14 -5
  67. package/sdk-core/{core-api → crates/common}/src/telemetry/metrics.rs +449 -51
  68. package/sdk-core/{core-api → crates/common}/src/telemetry.rs +16 -1
  69. package/sdk-core/{core-api → crates/common}/src/worker.rs +112 -18
  70. package/sdk-core/crates/common/tests/worker_task_types_test.rs +129 -0
  71. package/sdk-core/crates/macros/Cargo.toml +23 -0
  72. package/sdk-core/{fsm/rustfsm_procmacro → crates/macros}/src/lib.rs +12 -12
  73. package/sdk-core/{sdk → crates/sdk}/Cargo.toml +18 -12
  74. package/sdk-core/{sdk → crates/sdk}/src/activity_context.rs +9 -7
  75. package/sdk-core/{sdk → crates/sdk}/src/app_data.rs +1 -1
  76. package/sdk-core/{sdk → crates/sdk}/src/interceptors.rs +2 -5
  77. package/sdk-core/{sdk → crates/sdk}/src/lib.rs +43 -42
  78. package/sdk-core/{sdk → crates/sdk}/src/workflow_context/options.rs +12 -3
  79. package/sdk-core/{sdk → crates/sdk}/src/workflow_context.rs +21 -19
  80. package/sdk-core/{sdk → crates/sdk}/src/workflow_future.rs +2 -2
  81. package/sdk-core/crates/sdk-core/Cargo.toml +222 -0
  82. package/sdk-core/{core/benches/workflow_replay.rs → crates/sdk-core/benches/workflow_replay_bench.rs} +15 -10
  83. package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +32 -0
  84. package/sdk-core/crates/sdk-core/machine_coverage/CancelExternalMachine_Coverage.puml +9 -0
  85. package/sdk-core/crates/sdk-core/machine_coverage/CancelWorkflowMachine_Coverage.puml +6 -0
  86. package/sdk-core/crates/sdk-core/machine_coverage/ChildWorkflowMachine_Coverage.puml +27 -0
  87. package/sdk-core/crates/sdk-core/machine_coverage/CompleteWorkflowMachine_Coverage.puml +6 -0
  88. package/sdk-core/crates/sdk-core/machine_coverage/ContinueAsNewWorkflowMachine_Coverage.puml +6 -0
  89. package/sdk-core/crates/sdk-core/machine_coverage/FailWorkflowMachine_Coverage.puml +6 -0
  90. package/sdk-core/crates/sdk-core/machine_coverage/LocalActivityMachine_Coverage.puml +23 -0
  91. package/sdk-core/crates/sdk-core/machine_coverage/ModifyWorkflowPropertiesMachine_Coverage.puml +5 -0
  92. package/sdk-core/crates/sdk-core/machine_coverage/PatchMachine_Coverage.puml +8 -0
  93. package/sdk-core/crates/sdk-core/machine_coverage/SignalExternalMachine_Coverage.puml +12 -0
  94. package/sdk-core/crates/sdk-core/machine_coverage/TimerMachine_Coverage.puml +13 -0
  95. package/sdk-core/crates/sdk-core/machine_coverage/UpdateMachine_Coverage.puml +19 -0
  96. package/sdk-core/crates/sdk-core/machine_coverage/UpsertSearchAttributesMachine_Coverage.puml +5 -0
  97. package/sdk-core/crates/sdk-core/machine_coverage/WorkflowTaskMachine_Coverage.puml +11 -0
  98. package/sdk-core/{core → crates/sdk-core}/src/abstractions.rs +62 -6
  99. package/sdk-core/crates/sdk-core/src/antithesis.rs +60 -0
  100. package/sdk-core/{core → crates/sdk-core}/src/core_tests/activity_tasks.rs +85 -250
  101. package/sdk-core/{core → crates/sdk-core}/src/core_tests/mod.rs +13 -16
  102. package/sdk-core/{core → crates/sdk-core}/src/core_tests/queries.rs +25 -24
  103. package/sdk-core/{core → crates/sdk-core}/src/core_tests/replay_flag.rs +11 -68
  104. package/sdk-core/{core → crates/sdk-core}/src/core_tests/updates.rs +21 -20
  105. package/sdk-core/{core → crates/sdk-core}/src/core_tests/workers.rs +242 -16
  106. package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_cancels.rs +10 -7
  107. package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_tasks.rs +150 -326
  108. package/sdk-core/{core → crates/sdk-core}/src/debug_client.rs +1 -1
  109. package/sdk-core/{core → crates/sdk-core}/src/ephemeral_server/mod.rs +18 -6
  110. package/sdk-core/{test-utils → crates/sdk-core}/src/histfetch.rs +9 -4
  111. package/sdk-core/{core → crates/sdk-core}/src/internal_flags.rs +15 -4
  112. package/sdk-core/{core → crates/sdk-core}/src/lib.rs +128 -72
  113. package/sdk-core/{core → crates/sdk-core}/src/pollers/mod.rs +13 -11
  114. package/sdk-core/{core → crates/sdk-core}/src/pollers/poll_buffer.rs +53 -18
  115. package/sdk-core/{core → crates/sdk-core}/src/protosext/mod.rs +14 -6
  116. package/sdk-core/{core → crates/sdk-core}/src/protosext/protocol_messages.rs +5 -12
  117. package/sdk-core/{core → crates/sdk-core}/src/replay/mod.rs +14 -11
  118. package/sdk-core/crates/sdk-core/src/retry_logic.rs +390 -0
  119. package/sdk-core/{core → crates/sdk-core}/src/telemetry/log_export.rs +2 -2
  120. package/sdk-core/{core → crates/sdk-core}/src/telemetry/metrics.rs +80 -33
  121. package/sdk-core/{core → crates/sdk-core}/src/telemetry/mod.rs +12 -6
  122. package/sdk-core/{core → crates/sdk-core}/src/telemetry/otel.rs +1 -1
  123. package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_meter.rs +14 -14
  124. package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_server.rs +2 -2
  125. package/sdk-core/{core/src/test_help/mod.rs → crates/sdk-core/src/test_help/integ_helpers.rs} +284 -329
  126. package/sdk-core/crates/sdk-core/src/test_help/mod.rs +13 -0
  127. package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +220 -0
  128. package/sdk-core/{core → crates/sdk-core}/src/worker/activities/activity_heartbeat_manager.rs +44 -8
  129. package/sdk-core/{core → crates/sdk-core}/src/worker/activities/local_activities.rs +33 -31
  130. package/sdk-core/{core → crates/sdk-core}/src/worker/activities.rs +31 -15
  131. package/sdk-core/{core → crates/sdk-core}/src/worker/client/mocks.rs +28 -15
  132. package/sdk-core/{core → crates/sdk-core}/src/worker/client.rs +275 -145
  133. package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +246 -0
  134. package/sdk-core/crates/sdk-core/src/worker/mod.rs +1462 -0
  135. package/sdk-core/{core → crates/sdk-core}/src/worker/nexus.rs +24 -12
  136. package/sdk-core/{core → crates/sdk-core}/src/worker/slot_provider.rs +18 -10
  137. package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/fixed_size.rs +5 -1
  138. package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/resource_based.rs +453 -57
  139. package/sdk-core/{core → crates/sdk-core}/src/worker/tuner.rs +179 -3
  140. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/driven_workflow.rs +1 -1
  141. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/history_update.rs +5 -267
  142. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/activity_state_machine.rs +147 -90
  143. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -91
  144. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +14 -12
  145. package/sdk-core/crates/sdk-core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +97 -0
  146. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/child_workflow_state_machine.rs +32 -229
  147. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -8
  148. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -50
  149. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -7
  150. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/local_activity_state_machine.rs +39 -584
  151. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/mod.rs +22 -17
  152. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +4 -74
  153. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/nexus_operation_state_machine.rs +118 -21
  154. package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +273 -0
  155. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/signal_external_state_machine.rs +9 -151
  156. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/timer_state_machine.rs +27 -132
  157. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/transition_coverage.rs +1 -2
  158. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/update_state_machine.rs +19 -13
  159. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +25 -80
  160. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
  161. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines.rs +68 -72
  162. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -15
  163. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/managed_run.rs +55 -37
  164. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/mod.rs +171 -61
  165. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/run_cache.rs +10 -7
  166. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_extraction.rs +4 -2
  167. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_poller.rs +15 -4
  168. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/workflow_stream.rs +38 -19
  169. package/sdk-core/crates/sdk-core/tests/c_bridge_smoke_test.c +10 -0
  170. package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +25 -0
  171. package/sdk-core/crates/sdk-core/tests/common/fake_grpc_server.rs +106 -0
  172. package/sdk-core/crates/sdk-core/tests/common/http_proxy.rs +134 -0
  173. package/sdk-core/{test-utils/src/lib.rs → crates/sdk-core/tests/common/mod.rs} +286 -334
  174. package/sdk-core/{test-utils/src → crates/sdk-core/tests/common}/workflows.rs +6 -4
  175. package/sdk-core/crates/sdk-core/tests/fsm_procmacro.rs +6 -0
  176. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dupe_transitions_fail.rs +1 -3
  177. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/dupe_transitions_fail.stderr +12 -0
  178. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dynamic_dest_pass.rs +2 -4
  179. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.rs +1 -3
  180. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.stderr +4 -4
  181. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_arg_pass.rs +2 -4
  182. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_pass.rs +2 -4
  183. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/medium_complex_pass.rs +2 -4
  184. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/no_handle_conversions_require_into_fail.rs +2 -4
  185. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/no_handle_conversions_require_into_fail.stderr +15 -0
  186. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/simple_pass.rs +2 -4
  187. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/struct_event_variant_fail.rs +1 -3
  188. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/struct_event_variant_fail.stderr +5 -0
  189. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_more_item_event_variant_fail.rs +1 -3
  190. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
  191. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_zero_item_event_variant_fail.rs +1 -3
  192. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
  193. package/sdk-core/{tests → crates/sdk-core/tests}/global_metric_tests.rs +22 -22
  194. package/sdk-core/{tests → crates/sdk-core/tests/heavy_tests}/fuzzy_workflow.rs +4 -4
  195. package/sdk-core/{tests → crates/sdk-core/tests}/heavy_tests.rs +25 -14
  196. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/activity_functions.rs +1 -1
  197. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/client_tests.rs +115 -123
  198. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/ephemeral_server_tests.rs +19 -15
  199. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/heartbeat_tests.rs +24 -20
  200. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/metrics_tests.rs +241 -67
  201. package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
  202. package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +513 -0
  203. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/queries_tests.rs +13 -11
  204. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/update_tests.rs +47 -29
  205. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/visibility_tests.rs +49 -27
  206. package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +1061 -0
  207. package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +920 -0
  208. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_versioning_tests.rs +58 -40
  209. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/activities.rs +268 -30
  210. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/appdata_propagation.rs +4 -4
  211. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +155 -0
  212. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +121 -0
  213. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +717 -0
  214. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +109 -0
  215. package/sdk-core/{core/src/core_tests → crates/sdk-core/tests/integ_tests/workflow_tests}/determinism.rs +108 -20
  216. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/eager.rs +10 -5
  217. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +2884 -0
  218. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +119 -0
  219. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/nexus.rs +174 -46
  220. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +740 -0
  221. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/replay.rs +78 -27
  222. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/resets.rs +46 -28
  223. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +294 -0
  224. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/stickyness.rs +9 -8
  225. package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +249 -0
  226. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/upsert_search_attrs.rs +72 -7
  227. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests.rs +97 -33
  228. package/sdk-core/{tests → crates/sdk-core/tests}/main.rs +40 -25
  229. package/sdk-core/{tests → crates/sdk-core/tests}/manual_tests.rs +25 -15
  230. package/sdk-core/{tests → crates/sdk-core/tests}/runner.rs +23 -41
  231. package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/mod.rs +11 -6
  232. package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/priority.rs +6 -6
  233. package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +59 -0
  234. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/include/temporal-sdk-core-c-bridge.h +215 -44
  235. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/client.rs +515 -214
  236. package/sdk-core/crates/sdk-core-c-bridge/src/envconfig.rs +314 -0
  237. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/lib.rs +2 -1
  238. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/metric.rs +1 -1
  239. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/random.rs +4 -4
  240. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/runtime.rs +42 -28
  241. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/testing.rs +2 -5
  242. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/context.rs +42 -41
  243. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/mod.rs +38 -34
  244. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/utils.rs +10 -11
  245. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/worker.rs +427 -121
  246. package/sdk-core/docker-cgroup-tests.sh +24 -0
  247. package/sdk-core/{docker → etc/docker}/docker-compose-ci.yaml +9 -9
  248. package/sdk-core/{docker → etc/docker}/docker-compose-telem.yaml +11 -11
  249. package/sdk-core/{docker → etc/docker}/docker-compose.yaml +8 -8
  250. package/sdk-core/{integ-with-otel.sh → etc/integ-with-otel.sh} +1 -1
  251. package/sdk-core/etc/regen-depgraph.sh +2 -2
  252. package/src/client.rs +117 -49
  253. package/src/helpers/callbacks.rs +4 -4
  254. package/src/helpers/errors.rs +7 -1
  255. package/src/helpers/handles.rs +1 -0
  256. package/src/helpers/try_from_js.rs +5 -4
  257. package/src/lib.rs +3 -2
  258. package/src/logs.rs +1 -1
  259. package/src/metrics.rs +6 -3
  260. package/src/runtime.rs +41 -24
  261. package/src/testing.rs +3 -3
  262. package/src/worker.rs +77 -44
  263. package/ts/native.ts +26 -9
  264. package/LICENSE.md +0 -23
  265. package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
  266. package/sdk-core/client/src/proxy.rs +0 -90
  267. package/sdk-core/client/src/worker_registry/mod.rs +0 -266
  268. package/sdk-core/core/Cargo.toml +0 -146
  269. package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
  270. package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
  271. package/sdk-core/core/src/retry_logic.rs +0 -224
  272. package/sdk-core/core/src/worker/heartbeat.rs +0 -231
  273. package/sdk-core/core/src/worker/mod.rs +0 -980
  274. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -165
  275. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -801
  276. package/sdk-core/core-c-bridge/Cargo.toml +0 -51
  277. package/sdk-core/etc/deps.svg +0 -162
  278. package/sdk-core/fsm/Cargo.toml +0 -21
  279. package/sdk-core/fsm/README.md +0 -3
  280. package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
  281. package/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
  282. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
  283. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -15
  284. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
  285. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
  286. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
  287. package/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
  288. package/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -21
  289. package/sdk-core/fsm/src/lib.rs +0 -2
  290. package/sdk-core/sdk-core-protos/Cargo.toml +0 -37
  291. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +0 -1
  292. package/sdk-core/test-utils/Cargo.toml +0 -38
  293. package/sdk-core/test-utils/src/interceptors.rs +0 -46
  294. package/sdk-core/tests/cloud_tests.rs +0 -23
  295. package/sdk-core/tests/integ_tests/polling_tests.rs +0 -294
  296. package/sdk-core/tests/integ_tests/worker_tests.rs +0 -203
  297. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -74
  298. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -57
  299. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -246
  300. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -65
  301. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -85
  302. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -908
  303. package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -51
  304. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -206
  305. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -164
  306. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -123
  307. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/build.yaml +0 -0
  308. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/push-to-buf.yml +0 -0
  309. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/CODEOWNERS +0 -0
  310. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/LICENSE +0 -0
  311. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/Makefile +0 -0
  312. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/README.md +0 -0
  313. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.gen.yaml +0 -0
  314. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.lock +0 -0
  315. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.yaml +0 -0
  316. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/connectivityrule/v1/message.proto +0 -0
  317. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +0 -0
  318. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +0 -0
  319. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +0 -0
  320. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +0 -0
  321. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +0 -0
  322. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +0 -0
  323. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/CODEOWNERS +0 -0
  324. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  325. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/ci.yml +0 -0
  326. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/publish-docs.yml +0 -0
  327. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/push-to-buf.yml +0 -0
  328. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +0 -0
  329. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +0 -0
  330. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +0 -0
  331. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/LICENSE +0 -0
  332. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/Makefile +0 -0
  333. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/README.md +0 -0
  334. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/api-linter.yaml +0 -0
  335. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.gen.yaml +0 -0
  336. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.lock +0 -0
  337. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.yaml +0 -0
  338. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/annotations.proto +0 -0
  339. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/http.proto +0 -0
  340. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/any.proto +0 -0
  341. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/descriptor.proto +0 -0
  342. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/duration.proto +0 -0
  343. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/empty.proto +0 -0
  344. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/struct.proto +0 -0
  345. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/timestamp.proto +0 -0
  346. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/wrappers.proto +0 -0
  347. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/payload_description.txt +0 -0
  348. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/activity/v1/message.proto +0 -0
  349. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -0
  350. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/command/v1/message.proto +0 -0
  351. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -0
  352. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -0
  353. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -0
  354. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/deployment.proto +0 -0
  355. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -0
  356. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -0
  357. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -0
  358. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/nexus.proto +0 -0
  359. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -0
  360. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -0
  361. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -0
  362. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -0
  363. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -0
  364. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -0
  365. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -0
  366. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/export/v1/message.proto +0 -0
  367. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -0
  368. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -0
  369. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/history/v1/message.proto +0 -0
  370. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/nexus/v1/message.proto +0 -0
  371. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -0
  372. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -0
  373. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -0
  374. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/query/v1/message.proto +0 -0
  375. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -0
  376. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/rules/v1/message.proto +0 -0
  377. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -0
  378. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +0 -0
  379. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -0
  380. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +0 -0
  381. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/worker_config.proto +0 -0
  382. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +0 -0
  383. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -0
  384. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/update/v1/message.proto +0 -0
  385. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/version/v1/message.proto +0 -0
  386. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/worker/v1/message.proto +0 -0
  387. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -0
  388. /package/sdk-core/{sdk-core-protos → crates/common}/protos/google/rpc/status.proto +0 -0
  389. /package/sdk-core/{sdk-core-protos → crates/common}/protos/grpc/health/v1/health.proto +0 -0
  390. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -0
  391. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -0
  392. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -0
  393. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/common/common.proto +0 -0
  394. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/core_interface.proto +0 -0
  395. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -0
  396. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/nexus/nexus.proto +0 -0
  397. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -0
  398. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -0
  399. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/Makefile +0 -0
  400. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/api-linter.yaml +0 -0
  401. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/buf.yaml +0 -0
  402. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -0
  403. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -0
  404. /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/constants.rs +0 -0
  405. /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/task_token.rs +0 -0
  406. /package/sdk-core/{fsm → crates/macros}/LICENSE.txt +0 -0
  407. /package/sdk-core/{core → crates/sdk-core}/src/abstractions/take_cell.rs +0 -0
  408. /package/sdk-core/{core → crates/sdk-core}/src/worker/slot_supplier.rs +0 -0
  409. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/ends_empty_wft_complete.bin +0 -0
  410. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-16_history.bin +0 -0
  411. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-23_history.bin +0 -0
  412. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-85_history.bin +0 -0
  413. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/fail_wf_task.bin +0 -0
  414. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-0_history.bin +0 -0
  415. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-1_history.bin +0 -0
  416. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-2_history.bin +0 -0
  417. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-3_history.bin +0 -0
  418. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/old_change_marker_format.bin +0 -0
  419. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/timer_workflow_history.bin +0 -0
  420. /package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/priority.rs +0 -0
  421. /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/build.rs +0 -0
  422. /package/sdk-core/{cargo-tokio-console.sh → etc/cargo-tokio-console.sh} +0 -0
@@ -1,13 +1,19 @@
1
- use super::{EventInfo, WFMachinesAdapter, WFMachinesError, workflow_machines::MachineResponse};
1
+ use super::{
2
+ EventInfo, MachineError, StateMachine, TransitionResult, WFMachinesAdapter, WFMachinesError,
3
+ fsm, workflow_machines::MachineResponse,
4
+ };
2
5
  use crate::{
3
6
  protosext::protocol_messages::UpdateRequest,
4
- worker::workflow::machines::{HistEventData, NewMachineWithResponse},
7
+ worker::workflow::{
8
+ fatal,
9
+ machines::{HistEventData, NewMachineWithResponse},
10
+ nondeterminism,
11
+ },
5
12
  };
6
13
  use itertools::Itertools;
7
14
  use prost::EncodeError;
8
- use rustfsm::{MachineError, StateMachine, TransitionResult, fsm};
9
15
  use std::convert::TryFrom;
10
- use temporal_sdk_core_protos::{
16
+ use temporalio_common::protos::{
11
17
  coresdk::{
12
18
  workflow_activation::DoUpdate,
13
19
  workflow_commands::{UpdateResponse, update_response},
@@ -119,10 +125,10 @@ impl UpdateMachine {
119
125
  ) -> Result<Vec<MachineResponse>, WFMachinesError> {
120
126
  let cmds = match resp.response {
121
127
  None => {
122
- return Err(WFMachinesError::Fatal(format!(
128
+ return Err(fatal!(
123
129
  "Update response for update {} had an empty result, this is a lang layer bug.",
124
130
  &self.shared_state.meta.update_id
125
- )));
131
+ ));
126
132
  }
127
133
  Some(update_response::Response::Accepted(_)) => {
128
134
  self.on_event(UpdateMachineEvents::Accept)
@@ -135,11 +141,11 @@ impl UpdateMachine {
135
141
  }
136
142
  }
137
143
  .map_err(|e| match e {
138
- MachineError::InvalidTransition => WFMachinesError::Nondeterminism(format!(
144
+ MachineError::InvalidTransition => nondeterminism!(
139
145
  "Invalid transition while handling update response (id {}) in state {}",
140
146
  &self.shared_state.meta.update_id,
141
147
  self.state(),
142
- )),
148
+ ),
143
149
  MachineError::Underlying(e) => e,
144
150
  })?;
145
151
  cmds.into_iter()
@@ -172,9 +178,9 @@ impl UpdateMachine {
172
178
  outgoing_id: String,
173
179
  msg: UpdateMsg,
174
180
  ) -> Result<MachineResponse, WFMachinesError> {
175
- let accept_body = msg.pack().map_err(|e| {
176
- WFMachinesError::Fatal(format!("Failed to serialize update response: {e:?}"))
177
- })?;
181
+ let accept_body = msg
182
+ .pack()
183
+ .map_err(|e| fatal!("Failed to serialize update response: {e:?}"))?;
178
184
  Ok(MachineResponse::IssueNewMessage(ProtocolMessage {
179
185
  id: outgoing_id.clone(),
180
186
  protocol_instance_id: self.shared_state.instance_id.clone(),
@@ -221,9 +227,9 @@ impl TryFrom<HistEventData> for UpdateMachineEvents {
221
227
  UpdateMachineEvents::WorkflowExecutionUpdateCompleted
222
228
  }
223
229
  _ => {
224
- return Err(WFMachinesError::Nondeterminism(format!(
230
+ return Err(nondeterminism!(
225
231
  "Update machine does not handle this event: {e}"
226
- )));
232
+ ));
227
233
  }
228
234
  })
229
235
  }
@@ -1,16 +1,15 @@
1
- use super::{NewMachineWithCommand, workflow_machines::MachineResponse};
1
+ use super::{
2
+ NewMachineWithCommand, StateMachine, TransitionResult, fsm, workflow_machines::MachineResponse,
3
+ };
2
4
  use crate::{
3
5
  internal_flags::CoreInternalFlags,
4
6
  worker::workflow::{
5
7
  InternalFlagsRef, WFMachinesError,
6
- machines::{
7
- EventInfo, HistEventData, WFMachinesAdapter,
8
- patch_state_machine::VERSION_SEARCH_ATTR_KEY,
9
- },
8
+ machines::{EventInfo, HistEventData, WFMachinesAdapter},
10
9
  },
11
10
  };
12
- use rustfsm::{StateMachine, TransitionResult, fsm};
13
- use temporal_sdk_core_protos::{
11
+ use temporalio_common::protos::{
12
+ VERSION_SEARCH_ATTR_KEY,
14
13
  coresdk::workflow_commands::UpsertWorkflowSearchAttributes,
15
14
  temporal::api::{
16
15
  command::v1::{UpsertWorkflowSearchAttributesCommandAttributes, command},
@@ -178,86 +177,32 @@ impl From<Created> for CommandIssued {
178
177
 
179
178
  #[cfg(test)]
180
179
  mod tests {
181
- use super::{super::OnEventWrapper, *};
180
+ use super::{super::OnEventWrapper, StateMachine, *};
182
181
  use crate::{
183
182
  replay::TestHistoryBuilder,
184
- test_help::{MockPollCfg, ResponseType, build_fake_sdk, build_mock_pollers, mock_worker},
185
- worker::{
186
- client::mocks::mock_worker_client,
187
- workflow::machines::patch_state_machine::VERSION_SEARCH_ATTR_KEY,
183
+ test_help::{
184
+ MockPollCfg, ResponseType, WorkerTestHelpers, build_mock_pollers, mock_worker,
188
185
  },
186
+ worker::client::mocks::mock_worker_client,
189
187
  };
190
- use rustfsm::StateMachine;
191
188
  use std::collections::HashMap;
192
- use temporal_sdk::WfContext;
193
- use temporal_sdk_core_api::Worker;
194
- use temporal_sdk_core_protos::{
195
- DEFAULT_WORKFLOW_TYPE,
196
- coresdk::{
197
- AsJsonPayloadExt,
198
- workflow_activation::{WorkflowActivationJob, workflow_activation_job},
199
- workflow_commands::SetPatchMarker,
200
- workflow_completion::WorkflowActivationCompletion,
201
- },
202
- temporal::api::{
203
- command::v1::{Command, command::Attributes},
204
- common::v1::Payload,
205
- enums::v1::EventType,
206
- history::v1::{HistoryEvent, UpsertWorkflowSearchAttributesEventAttributes},
189
+ use temporalio_common::{
190
+ Worker,
191
+ protos::{
192
+ coresdk::{
193
+ AsJsonPayloadExt,
194
+ workflow_activation::{WorkflowActivationJob, workflow_activation_job},
195
+ workflow_commands::SetPatchMarker,
196
+ workflow_completion::WorkflowActivationCompletion,
197
+ },
198
+ temporal::api::{
199
+ command::v1::command::Attributes,
200
+ common::v1::Payload,
201
+ enums::v1::EventType,
202
+ history::v1::{HistoryEvent, UpsertWorkflowSearchAttributesEventAttributes},
203
+ },
207
204
  },
208
205
  };
209
- use temporal_sdk_core_test_utils::WorkerTestHelpers;
210
-
211
- #[tokio::test]
212
- async fn upsert_search_attrs_from_workflow() {
213
- let mut t = TestHistoryBuilder::default();
214
- t.add_by_type(EventType::WorkflowExecutionStarted);
215
- t.add_full_wf_task();
216
- t.add_workflow_execution_completed();
217
-
218
- let (k1, k2) = ("foo", "bar");
219
-
220
- let mut mock_cfg = MockPollCfg::from_hist_builder(t);
221
- mock_cfg.completion_asserts_from_expectations(|mut asserts| {
222
- asserts.then(|wft| {
223
- assert_matches!(
224
- wft.commands.as_slice(),
225
- [Command { attributes: Some(
226
- command::Attributes::UpsertWorkflowSearchAttributesCommandAttributes(msg)
227
- ), .. }, ..] => {
228
- let fields = &msg.search_attributes.as_ref().unwrap().indexed_fields;
229
- let payload1 = fields.get(k1).unwrap();
230
- let payload2 = fields.get(k2).unwrap();
231
- assert_eq!(payload1.data[0], 0x01);
232
- assert_eq!(payload2.data[0], 0x02);
233
- assert_eq!(fields.len(), 2);
234
- }
235
- );
236
- });
237
- });
238
-
239
- let mut worker = build_fake_sdk(mock_cfg);
240
- worker.register_wf(DEFAULT_WORKFLOW_TYPE, move |ctx: WfContext| async move {
241
- ctx.upsert_search_attributes([
242
- (
243
- String::from(k1),
244
- Payload {
245
- data: vec![0x01],
246
- ..Default::default()
247
- },
248
- ),
249
- (
250
- String::from(k2),
251
- Payload {
252
- data: vec![0x02],
253
- ..Default::default()
254
- },
255
- ),
256
- ]);
257
- Ok(().into())
258
- });
259
- worker.run().await.unwrap();
260
- }
261
206
 
262
207
  #[rstest::rstest]
263
208
  fn upsert_search_attrs_sm() {
@@ -7,7 +7,7 @@ use std::{
7
7
  collections::{HashMap, HashSet},
8
8
  time::SystemTime,
9
9
  };
10
- use temporal_sdk_core_protos::temporal::api::common::v1::WorkflowExecution;
10
+ use temporalio_common::protos::temporal::api::common::v1::WorkflowExecution;
11
11
 
12
12
  #[derive(Default)]
13
13
  pub(super) struct LocalActivityData {
@@ -25,16 +25,17 @@ use crate::{
25
25
  workflow::{
26
26
  CommandID, DrivenWorkflow, HistoryUpdate, InternalFlagsRef, LocalResolution,
27
27
  OutgoingJob, RunBasics, WFCommand, WFCommandVariant, WFMachinesError,
28
- WorkflowStartedInfo,
28
+ WorkflowStartedInfo, fatal,
29
29
  history_update::NextWFT,
30
30
  machines::{
31
31
  HistEventData, activity_state_machine::ActivityMachine,
32
32
  child_workflow_state_machine::ChildWorkflowMachine,
33
33
  modify_workflow_properties_state_machine::modify_workflow_properties,
34
34
  nexus_operation_state_machine::NexusOperationMachine,
35
- patch_state_machine::VERSION_SEARCH_ATTR_KEY, update_state_machine::UpdateMachine,
35
+ update_state_machine::UpdateMachine,
36
36
  upsert_search_attributes_state_machine::upsert_search_attrs_internal,
37
37
  },
38
+ nondeterminism,
38
39
  },
39
40
  },
40
41
  };
@@ -51,25 +52,27 @@ use std::{
51
52
  sync::Arc,
52
53
  time::{Duration, Instant, SystemTime},
53
54
  };
54
- use temporal_sdk_core_api::worker::{WorkerConfig, WorkerDeploymentVersion};
55
- use temporal_sdk_core_protos::{
56
- coresdk::{
57
- common::{NamespacedWorkflowExecution, VersioningIntent},
58
- workflow_activation,
59
- workflow_activation::{
60
- NotifyHasPatch, UpdateRandomSeed, WorkflowActivation, workflow_activation_job,
55
+ use temporalio_common::{
56
+ protos::{
57
+ VERSION_SEARCH_ATTR_KEY,
58
+ coresdk::{
59
+ common::{NamespacedWorkflowExecution, VersioningIntent},
60
+ workflow_activation::{
61
+ self, NotifyHasPatch, UpdateRandomSeed, WorkflowActivation, workflow_activation_job,
62
+ },
63
+ workflow_commands::ContinueAsNewWorkflowExecution,
61
64
  },
62
- workflow_commands::ContinueAsNewWorkflowExecution,
63
- },
64
- temporal::api::{
65
- command::v1::{
66
- Command as ProtoCommand, CommandAttributesExt, command::Attributes as ProtoCmdAttrs,
65
+ temporal::api::{
66
+ command::v1::{
67
+ Command as ProtoCommand, CommandAttributesExt, command::Attributes as ProtoCmdAttrs,
68
+ },
69
+ enums::v1::EventType,
70
+ history::v1::{HistoryEvent, history_event},
71
+ protocol::v1::{Message as ProtocolMessage, message::SequencingId},
72
+ sdk::v1::{UserMetadata, WorkflowTaskCompletedMetadata},
67
73
  },
68
- enums::v1::EventType,
69
- history::v1::{HistoryEvent, history_event},
70
- protocol::v1::{Message as ProtocolMessage, message::SequencingId},
71
- sdk::v1::{UserMetadata, WorkflowTaskCompletedMetadata},
72
74
  },
75
+ worker::{WorkerConfig, WorkerDeploymentVersion},
73
76
  };
74
77
 
75
78
  type Result<T, E = WFMachinesError> = std::result::Result<T, E>;
@@ -244,11 +247,11 @@ macro_rules! cancel_machine {
244
247
  let machine = if let Machines::$machine_variant(m) = $self.machine_mut(m_key) {
245
248
  m
246
249
  } else {
247
- return Err(WFMachinesError::Nondeterminism(format!(
250
+ return Err(nondeterminism!(
248
251
  "Machine was not a {} when it should have been during cancellation: {:?}",
249
252
  stringify!($machine_variant),
250
253
  $cmd_id
251
- )));
254
+ ));
252
255
  };
253
256
  let machine_resps = machine.$cancel_method($($args),*)?;
254
257
  $self.process_machine_responses(m_key, machine_resps)?
@@ -364,10 +367,10 @@ impl WorkflowMachines {
364
367
  }
365
368
  self.process_machine_responses(mk, resps)?;
366
369
  } else {
367
- return Err(WFMachinesError::Nondeterminism(format!(
370
+ return Err(nondeterminism!(
368
371
  "Command matching activity with seq num {seq} existed but was not a \
369
372
  local activity!"
370
- )));
373
+ ));
371
374
  }
372
375
  self.local_activity_data.done_executing(seq);
373
376
  }
@@ -463,6 +466,11 @@ impl WorkflowMachines {
463
466
  continue_as_new_suggested: self.continue_as_new_suggested,
464
467
  deployment_version_for_current_task: deployment_version_for_current_task
465
468
  .map(Into::into),
469
+ last_sdk_version: (*self.observed_internal_flags)
470
+ .borrow()
471
+ .last_sdk_version()
472
+ .unwrap_or_default()
473
+ .to_owned(),
466
474
  }
467
475
  }
468
476
 
@@ -566,10 +574,9 @@ impl WorkflowMachines {
566
574
  (evts, has_final_event)
567
575
  }
568
576
  NextWFT::NeedFetch => {
569
- return Err(WFMachinesError::Fatal(
577
+ return Err(fatal!(
570
578
  "Need to fetch history events to continue applying workflow task, but this \
571
579
  should be prevented ahead of time! This is a Core SDK bug."
572
- .to_string(),
573
580
  ));
574
581
  }
575
582
  };
@@ -642,10 +649,11 @@ impl WorkflowMachines {
642
649
  while let Some(event) = history.next() {
643
650
  let eid = event.event_id;
644
651
  if eid != self.last_processed_event + 1 {
645
- return Err(WFMachinesError::Fatal(format!(
652
+ return Err(fatal!(
646
653
  "History is out of order. Last processed event: {}, event id: {}",
647
- self.last_processed_event, eid
648
- )));
654
+ self.last_processed_event,
655
+ eid
656
+ ));
649
657
  }
650
658
  let next_event = history.peek();
651
659
 
@@ -775,9 +783,7 @@ impl WorkflowMachines {
775
783
  self.local_activity_data.insert_peeked_marker(la_dat);
776
784
  }
777
785
  } else {
778
- return Err(WFMachinesError::Fatal(format!(
779
- "Local activity marker was unparsable: {e:?}"
780
- )));
786
+ return Err(fatal!("Local activity marker was unparsable: {e:?}"));
781
787
  }
782
788
  } else if let Some(
783
789
  history_event::Attributes::WorkflowExecutionUpdateAcceptedEventAttributes(ref atts),
@@ -849,10 +855,9 @@ impl WorkflowMachines {
849
855
  let are_more_events =
850
856
  next_event.is_some() || !event_dat.current_task_is_last_in_history;
851
857
  return if are_more_events {
852
- Err(WFMachinesError::Fatal(
858
+ Err(fatal!(
853
859
  "Machines were fed a history which has an event after workflow execution was \
854
860
  terminated!"
855
- .to_string(),
856
861
  ))
857
862
  } else {
858
863
  Ok(EventHandlingOutcome::Normal)
@@ -860,9 +865,9 @@ impl WorkflowMachines {
860
865
  }
861
866
  if event.event_type() == EventType::Unspecified || event.attributes.is_none() {
862
867
  return if !event.worker_may_ignore {
863
- Err(WFMachinesError::Fatal(format!(
868
+ Err(fatal!(
864
869
  "Event type is unspecified! This history is invalid. Event detail: {event:?}"
865
- )))
870
+ ))
866
871
  } else {
867
872
  debug!("Event is ignorable");
868
873
  Ok(EventHandlingOutcome::SkipEvent {
@@ -887,10 +892,10 @@ impl WorkflowMachines {
887
892
  .machines_by_event_id
888
893
  .get(&initial_cmd_id)
889
894
  .ok_or_else(|| {
890
- WFMachinesError::Nondeterminism(format!(
895
+ nondeterminism!(
891
896
  "During event handling, this event had an initial command ID but we \
892
897
  could not find a matching command for it: {event:?}"
893
- ))
898
+ )
894
899
  })?;
895
900
  self.submachine_handle_event(*mkey, event_dat)?;
896
901
  } else {
@@ -917,9 +922,9 @@ impl WorkflowMachines {
917
922
  let event = &event_dat.event;
918
923
 
919
924
  if event.is_local_activity_marker() {
920
- let deets = event.extract_local_activity_marker_data().ok_or_else(|| {
921
- WFMachinesError::Fatal(format!("Local activity marker was unparsable: {event:?}"))
922
- })?;
925
+ let deets = event
926
+ .extract_local_activity_marker_data()
927
+ .ok_or_else(|| fatal!("Local activity marker was unparsable: {event:?}"))?;
923
928
  let cmdid = CommandID::LocalActivity(deets.seq);
924
929
  let mkey = self.get_machine_key(cmdid)?;
925
930
  if let Machines::LocalActivityMachine(lam) = self.machine(mkey) {
@@ -928,10 +933,10 @@ impl WorkflowMachines {
928
933
  return Ok(EventHandlingOutcome::Normal);
929
934
  }
930
935
  } else {
931
- return Err(WFMachinesError::Fatal(format!(
936
+ return Err(fatal!(
932
937
  "Encountered local activity marker but the associated machine was of the \
933
938
  wrong type! {event:?}"
934
- )));
939
+ ));
935
940
  }
936
941
  }
937
942
 
@@ -952,9 +957,7 @@ impl WorkflowMachines {
952
957
  let command = if let Some(c) = maybe_command {
953
958
  c
954
959
  } else {
955
- return Err(WFMachinesError::Nondeterminism(format!(
956
- "No command scheduled for event {event}"
957
- )));
960
+ return Err(nondeterminism!("No command scheduled for event {event}"));
958
961
  };
959
962
 
960
963
  let canceled_before_sent = self
@@ -1001,9 +1004,9 @@ impl WorkflowMachines {
1001
1004
  attrs,
1002
1005
  );
1003
1006
  } else {
1004
- return Err(WFMachinesError::Fatal(format!(
1007
+ return Err(fatal!(
1005
1008
  "WorkflowExecutionStarted event did not have appropriate attributes: {event_dat}"
1006
- )));
1009
+ ));
1007
1010
  }
1008
1011
  }
1009
1012
  Ok(EventType::WorkflowTaskScheduled) => {
@@ -1037,9 +1040,9 @@ impl WorkflowMachines {
1037
1040
  }
1038
1041
  }
1039
1042
  _ => {
1040
- return Err(WFMachinesError::Fatal(format!(
1043
+ return Err(fatal!(
1041
1044
  "The event is not a non-stateful event, but we tried to handle it as one: {event_dat}"
1042
- )));
1045
+ ));
1043
1046
  }
1044
1047
  }
1045
1048
  Ok(())
@@ -1075,13 +1078,12 @@ impl WorkflowMachines {
1075
1078
 
1076
1079
  match message.body {
1077
1080
  IncomingProtocolMessageBody::UpdateRequest(ur) => {
1078
- let seq_id = if let SequencingId::EventId(eid) = message
1079
- .sequencing_id
1080
- .ok_or_else(|| WFMachinesError::Fatal(SEQIDERR.to_string()))?
1081
+ let seq_id = if let SequencingId::EventId(eid) =
1082
+ message.sequencing_id.ok_or_else(|| fatal!("{SEQIDERR}"))?
1081
1083
  {
1082
1084
  eid
1083
1085
  } else {
1084
- return Err(WFMachinesError::Fatal(SEQIDERR.to_string()));
1086
+ return Err(fatal!("{SEQIDERR}"));
1085
1087
  };
1086
1088
  let um = UpdateMachine::init(
1087
1089
  message.id,
@@ -1206,9 +1208,9 @@ impl WorkflowMachines {
1206
1208
  );
1207
1209
  }
1208
1210
  c => {
1209
- return Err(WFMachinesError::Fatal(format!(
1211
+ return Err(fatal!(
1210
1212
  "A machine requested to create a new command of an unsupported type: {c:?}"
1211
- )));
1213
+ ));
1212
1214
  }
1213
1215
  },
1214
1216
  MachineResponse::IssueFakeLocalActivityMarker(seq) => {
@@ -1352,10 +1354,8 @@ impl WorkflowMachines {
1352
1354
  WFCommandVariant::AddLocalActivity(attrs) => {
1353
1355
  let seq = attrs.seq;
1354
1356
  let attrs: ValidScheduleLA =
1355
- ValidScheduleLA::from_schedule_la(attrs).map_err(|e| {
1356
- WFMachinesError::Fatal(format!(
1357
- "Invalid schedule local activity request (seq {seq}): {e}"
1358
- ))
1357
+ ValidScheduleLA::from_schedule_la(attrs, cmd.metadata).map_err(|e| {
1358
+ fatal!("Invalid schedule local activity request (seq {seq}): {e}")
1359
1359
  })?;
1360
1360
  let (la, mach_resp) = new_local_activity(
1361
1361
  attrs,
@@ -1463,10 +1463,7 @@ impl WorkflowMachines {
1463
1463
  }
1464
1464
  WFCommandVariant::RequestCancelExternalWorkflow(attrs) => {
1465
1465
  let we = attrs.workflow_execution.ok_or_else(|| {
1466
- WFMachinesError::Fatal(
1467
- "Cancel external workflow command had no workflow_execution field"
1468
- .to_string(),
1469
- )
1466
+ fatal!("Cancel external workflow command had no workflow_execution field")
1470
1467
  })?;
1471
1468
  self.add_cmd_to_wf_task(
1472
1469
  new_external_cancel(
@@ -1514,11 +1511,11 @@ impl WorkflowMachines {
1514
1511
  let m = if let Machines::UpdateMachine(m) = self.machine_mut(m_key) {
1515
1512
  m
1516
1513
  } else {
1517
- return Err(WFMachinesError::Nondeterminism(format!(
1514
+ return Err(nondeterminism!(
1518
1515
  "Tried to handle an update response for \
1519
1516
  update with instance id {} but it was not found!",
1520
1517
  &ur.protocol_instance_id
1521
- )));
1518
+ ));
1522
1519
  };
1523
1520
  let resps = m.handle_response(ur)?;
1524
1521
  self.process_machine_responses(m_key, resps)?;
@@ -1546,9 +1543,10 @@ impl WorkflowMachines {
1546
1543
  }
1547
1544
 
1548
1545
  fn get_machine_key(&self, id: CommandID) -> Result<MachineKey> {
1549
- Ok(*self.id_to_machine.get(&id).ok_or_else(|| {
1550
- WFMachinesError::Nondeterminism(format!("Missing associated machine for {id:?}"))
1551
- })?)
1546
+ Ok(*self
1547
+ .id_to_machine
1548
+ .get(&id)
1549
+ .ok_or_else(|| nondeterminism!("Missing associated machine for {id:?}"))?)
1552
1550
  }
1553
1551
 
1554
1552
  fn get_machine_by_msg(&self, protocol_instance_id: &str) -> Result<MachineKey> {
@@ -1556,9 +1554,7 @@ impl WorkflowMachines {
1556
1554
  .machines_by_protocol_instance_id
1557
1555
  .get(protocol_instance_id)
1558
1556
  .ok_or_else(|| {
1559
- WFMachinesError::Fatal(format!(
1560
- "Missing associated machine for protocol message {protocol_instance_id}"
1561
- ))
1557
+ fatal!("Missing associated machine for protocol message {protocol_instance_id}")
1562
1558
  })?)
1563
1559
  }
1564
1560
 
@@ -1751,10 +1747,10 @@ fn patch_marker_handling(
1751
1747
  debug!("Deprecated patch marker tried against non-patch machine, skipping.");
1752
1748
  skip_one_or_two_events(next_event)
1753
1749
  } else {
1754
- Err(WFMachinesError::Nondeterminism(format!(
1750
+ Err(nondeterminism!(
1755
1751
  "Non-deprecated patch marker encountered for change {patch_name}, but there is \
1756
1752
  no corresponding change command!"
1757
- )))
1753
+ ))
1758
1754
  }
1759
1755
  }
1760
1756
  } else if patch_machine.is_some() {
@@ -1,13 +1,15 @@
1
1
  #![allow(clippy::enum_variant_names)]
2
2
 
3
- use super::{EventInfo, WFMachinesAdapter, WFMachinesError, workflow_machines::MachineResponse};
4
- use crate::worker::workflow::machines::HistEventData;
5
- use rustfsm::{StateMachine, TransitionResult, fsm};
3
+ use super::{
4
+ EventInfo, StateMachine, TransitionResult, WFMachinesAdapter, WFMachinesError, fsm,
5
+ workflow_machines::MachineResponse,
6
+ };
7
+ use crate::worker::workflow::{fatal, machines::HistEventData, nondeterminism};
6
8
  use std::{
7
9
  convert::{TryFrom, TryInto},
8
10
  time::SystemTime,
9
11
  };
10
- use temporal_sdk_core_protos::temporal::api::{
12
+ use temporalio_common::protos::temporal::api::{
11
13
  enums::v1::{CommandType, EventType, WorkflowTaskFailedCause},
12
14
  history::v1::history_event::Attributes::WorkflowTaskFailedEventAttributes,
13
15
  };
@@ -65,10 +67,9 @@ impl WFMachinesAdapter for WorkflowTaskMachine {
65
67
  let (event_id, event_type) = if let Some(ei) = event_info {
66
68
  (ei.event_id, ei.event_type)
67
69
  } else {
68
- return Err(WFMachinesError::Fatal(
70
+ return Err(fatal!(
69
71
  "WF Task machine should never issue a task started trigger \
70
72
  command in response to non-history events"
71
- .to_string(),
72
73
  ));
73
74
  };
74
75
 
@@ -100,16 +101,15 @@ impl TryFrom<HistEventData> for WorkflowTaskMachineEvents {
100
101
  match time.try_into() {
101
102
  Ok(t) => t,
102
103
  Err(_) => {
103
- return Err(WFMachinesError::Fatal(
104
+ return Err(fatal!(
104
105
  "Workflow task started event timestamp was inconvertible"
105
- .to_string(),
106
106
  ));
107
107
  }
108
108
  }
109
109
  } else {
110
- return Err(WFMachinesError::Fatal(format!(
110
+ return Err(fatal!(
111
111
  "Workflow task started event must contain timestamp: {e}"
112
- )));
112
+ ));
113
113
  };
114
114
  WFTStartedDat {
115
115
  started_event_id: e.event_id,
@@ -135,15 +135,13 @@ impl TryFrom<HistEventData> for WorkflowTaskMachineEvents {
135
135
  },
136
136
  })
137
137
  } else {
138
- return Err(WFMachinesError::Fatal(format!(
139
- "Workflow task failed is missing attributes: {e}"
140
- )));
138
+ return Err(fatal!("Workflow task failed is missing attributes: {e}"));
141
139
  }
142
140
  }
143
141
  _ => {
144
- return Err(WFMachinesError::Nondeterminism(format!(
142
+ return Err(nondeterminism!(
145
143
  "Event does not apply to a wf task machine: {e}"
146
- )));
144
+ ));
147
145
  }
148
146
  })
149
147
  }