            byid={r['id']:r for r in data['feeds']};root=ET.Element('opml',version='2.0');head=ET.SubElement(root,'head');ET.SubElement(head,'title').text='原创合成订阅清单';body=ET.SubElement(root,'body');seen=[]
            for group in output['groups']:
                node=ET.SubElement(body,'outline',text=group['title'],title=group['title'])
                for feedid in group['feed_ids']:
                    r=byid[feedid];seen.append(feedid);ET.SubElement(node,'outline',type='rss',text=r['title'],title=r['title'],xmlUrl=r['xmlUrl'],htmlUrl=r['htmlUrl'])
            ET.ElementTree(root).write(folder/'subscriptions.opml',encoding='utf-8',xml_declaration=True);artifacts.append('subscriptions.opml');r=ET.parse(folder/'subscriptions.opml').getroot();rows=[{'group':group.attrib['text'],'title':node.attrib['text'],'xmlUrl':node.attrib['xmlUrl'],'htmlUrl':node.attrib['htmlUrl']} for group in r.findall('./body/outline') for node in group.findall('outline')]
            check('OPML原生层级2.0可回读',r.tag=='opml' and r.attrib['version']=='2.0');check('所有feed恰好一次',sorted(seen)==sorted(byid) and len(seen)==len(set(seen)));check('xmlUrl与htmlUrl都保留',{x['xmlUrl'] for x in rows}=={x['xmlUrl'] for x in data['feeds']} and {x['htmlUrl'] for x in rows}=={x['htmlUrl'] for x in data['feeds']});result={'groups':output['groups'],'roundtrip':rows,'network_fetches':0}
