@@ -894,3 +894,58 @@ def test_step_executes_function_when_second_check_returns_started():
894894 mock_state .get_checkpoint_result .call_count == 1
895895 ) # Only one check for AT_LEAST_ONCE
896896 assert mock_state .create_checkpoint .call_count == 2 # START + SUCCEED checkpoints
897+
898+
899+ def test_step_creates_start_checkpoint_when_status_is_ready ():
900+ """Test that create_checkpoint is called with START action when the step is in READY status."""
901+ mock_state = Mock (spec = ExecutionState )
902+ mock_state .durable_execution_arn = "test_arn"
903+
904+ # Simulate a step that is in READY status (e.g., returned from a previous checkpoint)
905+ ready_op = Operation (
906+ operation_id = "step_ready_1" ,
907+ operation_type = OperationType .STEP ,
908+ status = OperationStatus .READY ,
909+ step_details = StepDetails (attempt = 0 ),
910+ )
911+ ready_result = CheckpointedResult .create_from_operation (ready_op )
912+
913+ # After creating the sync START checkpoint, the refreshed result returns STARTED
914+ started_op = Operation (
915+ operation_id = "step_ready_1" ,
916+ operation_type = OperationType .STEP ,
917+ status = OperationStatus .STARTED ,
918+ step_details = StepDetails (attempt = 0 ),
919+ )
920+ started_result = CheckpointedResult .create_from_operation (started_op )
921+ mock_state .get_checkpoint_result .side_effect = [ready_result , started_result ]
922+
923+ config = StepConfig (step_semantics = StepSemantics .AT_MOST_ONCE_PER_RETRY )
924+ mock_callable = Mock (return_value = "ready_step_result" )
925+ mock_logger = Mock (spec = Logger )
926+ mock_logger .with_log_info .return_value = mock_logger
927+
928+ result = step_handler (
929+ mock_callable ,
930+ mock_state ,
931+ OperationIdentifier ("step_ready_1" , None , "test_step" ),
932+ config ,
933+ mock_logger ,
934+ )
935+
936+ assert result == "ready_step_result"
937+ mock_callable .assert_called_once ()
938+
939+ # Verify START checkpoint was created
940+ start_call = mock_state .create_checkpoint .call_args_list [0 ]
941+ start_operation = start_call [1 ]["operation_update" ]
942+ assert start_operation .operation_id == "step_ready_1"
943+ assert start_operation .operation_type is OperationType .STEP
944+ assert start_operation .sub_type is OperationSubType .STEP
945+ assert start_operation .action is OperationAction .START
946+
947+ # Verify SUCCEED checkpoint was also created after execution
948+ assert mock_state .create_checkpoint .call_count == 2
949+ success_call = mock_state .create_checkpoint .call_args_list [1 ]
950+ success_operation = success_call [1 ]["operation_update" ]
951+ assert success_operation .action is OperationAction .SUCCEED
0 commit comments