def attach(fei_or_fe, definition, opts={})

      fe = Ruote.extract_fexp(@context, fei_or_fe).to_h
      fei = fe['fei']

      cfei = fei.merge(
        'expid' => "#{fei['expid']}_0",
        'subid' => Ruote.generate_subid(fei.inspect))

      tree = @context.reader.read(definition)
      tree[0] = 'sequence'

      fields = fe['applied_workitem']['fields']
      if fs = opts[:fields] || opts[:workitem]
        fields = fs
      elsif fs = opts[:merge_fields]
        fields.merge!(fs)
      end

      @context.storage.put_msg(
        'launch', # "apply" is OK, but "launch" stands out better
        'parent_id' => fei,
        'fei' => cfei,
        'tree' => tree,
        'workitem' => { 'fields' => fields },
        'attached' => true)

      Ruote::FlowExpressionId.new(cfei)
    end
def attach(fei_or_fe, definition, opts={})

      fe = Ruote.extract_fexp(@context, fei_or_fe).to_h
      fei = fe['fei']

      cfei = fei.merge(
        'expid' => "#{fei['expid']}_0",
        'subid' => Ruote.generate_subid(fei.inspect))

      tree = @context.reader.read(definition)
      tree[0] = 'sequence'

      fields = fe['applied_workitem']['fields']
      if fs = opts[:fields] || opts[:workitem]
        fields = fs
      elsif fs = opts[:merge_fields]
        fields.merge!(fs)
      end

      @context.storage.put_msg(
        'launch', # "apply" is OK, but "launch" stands out better
        'parent_id' => fei,
        'fei' => cfei,
        'tree' => tree,
        'workitem' => { 'fields' => fields },
        'attached' => true)

      Ruote::FlowExpressionId.new(cfei)
    end
Given a flow expression id, locates the corresponding ruote
 expression and attaches a subprocess to it.

 Accepts the fei as a Hash or as a FlowExpressionId instance.

 By default, the workitem of the expression you attach to provides
 the initial workitem for the attached branch. By using the
 :fields/:workitem or :merge_fields options, one can change that.

 Returns the fei of the attached [root] expression
 (as a FlowExpressionId instance).