nodes: 0, module; 1, function_definition; 2, function_name:find_sorted_task_dependencies; 3, parameters; 4, block; 5, identifier:task; 6, identifier:task_name; 7, identifier:task_id; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, comment:# make sure we deal with the decision task first, or we may populate; 17, comment:# signing:build0:decision before signing:decision; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, return_statement; 22, comment:"""Find the taskIds of the chain of trust dependencies of a given task.
  
      Args:
          task (dict): the task definition to inspect.
          task_name (str): the name of the task, for logging and naming children.
          task_id (str): the taskId of the task.
  
      Returns:
          list: tuples associating dependent task ``name`` to dependent task ``taskId``.
  
      """; 23, call; 24, assignment; 25, assignment; 26, assignment; 27, assignment; 28, assignment; 29, assignment; 30, assignment; 31, call; 32, call; 33, identifier:dependencies; 34, attribute; 35, argument_list; 36, identifier:cot_input_dependencies; 37, list_comprehension; 38, identifier:upstream_artifacts_dependencies; 39, list_comprehension; 40, identifier:dependencies; 41, list; 42, identifier:dependencies; 43, call; 44, identifier:parent_task_id; 45, boolean_operator; 46, identifier:parent_task_type; 47, string; 48, identifier:parent_tuple; 49, call; 50, attribute; 51, argument_list; 52, attribute; 53, argument_list; 54, identifier:log; 55, identifier:info; 56, call; 57, call; 58, for_in_clause; 59, call; 60, for_in_clause; 61, list_splat; 62, list_splat; 63, identifier:_sort_dependencies_by_name_then_task_id; 64, argument_list; 65, call; 66, call; 67, string_content:parent; 68, identifier:_craft_dependency_tuple; 69, argument_list; 70, identifier:dependencies; 71, identifier:insert; 72, integer:0; 73, identifier:parent_tuple; 74, identifier:log; 75, identifier:info; 76, call; 77, attribute; 78, argument_list; 79, identifier:_craft_dependency_tuple; 80, argument_list; 81, pattern_list; 82, call; 83, identifier:_craft_dependency_tuple; 84, argument_list; 85, identifier:artifact_dict; 86, call; 87, identifier:cot_input_dependencies; 88, identifier:upstream_artifacts_dependencies; 89, identifier:dependencies; 90, identifier:get_parent_task_id; 91, argument_list; 92, identifier:get_decision_task_id; 93, argument_list; 94, identifier:task_name; 95, identifier:parent_task_type; 96, identifier:parent_task_id; 97, attribute; 98, argument_list; 99, string:"find_sorted_task_dependencies {} {}"; 100, identifier:format; 101, identifier:task_name; 102, identifier:task_id; 103, identifier:task_name; 104, identifier:task_type; 105, identifier:task_id; 106, identifier:task_type; 107, identifier:task_id; 108, attribute; 109, argument_list; 110, identifier:task_name; 111, subscript; 112, subscript; 113, attribute; 114, argument_list; 115, identifier:task; 116, identifier:task; 117, string; 118, identifier:format; 119, identifier:dependencies; 120, call; 121, identifier:items; 122, identifier:artifact_dict; 123, string; 124, identifier:artifact_dict; 125, string; 126, call; 127, identifier:get; 128, string; 129, list; 130, string_content:found dependencies: {}; 131, attribute; 132, argument_list; 133, string_content:taskType; 134, string_content:taskId; 135, attribute; 136, argument_list; 137, string_content:upstreamArtifacts; 138, call; 139, identifier:get; 140, string; 141, dictionary; 142, identifier:task; 143, identifier:get; 144, string; 145, dictionary; 146, attribute; 147, argument_list; 148, string_content:inputs; 149, string_content:payload; 150, subscript; 151, identifier:get; 152, string; 153, dictionary; 154, identifier:task; 155, string; 156, string_content:chainOfTrust; 157, string_content:extra
code: def find_sorted_task_dependencies(task, task_name, task_id):
      """Find the taskIds of the chain of trust dependencies of a given task.
  
      Args:
          task (dict): the task definition to inspect.
          task_name (str): the name of the task, for logging and naming children.
          task_id (str): the taskId of the task.
  
      Returns:
          list: tuples associating dependent task ``name`` to dependent task ``taskId``.
  
      """
      log.info("find_sorted_task_dependencies {} {}".format(task_name, task_id))
  
      cot_input_dependencies = [
          _craft_dependency_tuple(task_name, task_type, task_id)
          for task_type, task_id in task['extra'].get('chainOfTrust', {}).get('inputs', {}).items()
      ]
  
      upstream_artifacts_dependencies = [
          _craft_dependency_tuple(task_name, artifact_dict['taskType'], artifact_dict['taskId'])
          for artifact_dict in task.get('payload', {}).get('upstreamArtifacts', [])
      ]
  
      dependencies = [*cot_input_dependencies, *upstream_artifacts_dependencies]
      dependencies = _sort_dependencies_by_name_then_task_id(dependencies)
  
      parent_task_id = get_parent_task_id(task) or get_decision_task_id(task)
      parent_task_type = 'parent'
      # make sure we deal with the decision task first, or we may populate
      # signing:build0:decision before signing:decision
      parent_tuple = _craft_dependency_tuple(task_name, parent_task_type, parent_task_id)
      dependencies.insert(0, parent_tuple)
  
      log.info('found dependencies: {}'.format(dependencies))
      return dependencies