ids = set(output.get('source_ids', []))
known = {row['id'] for row in data['sources']}
check('引用均能映射回真实输入文件', bool(ids) and ids <= known)
check('不引用没有支持该结论的广告', 'ad-1' not in ids)
source_dir = folder / 'sources'
source_dir.mkdir(exist_ok=True)
for row in data['sources']:
    (source_dir / (row['id'] + '.txt')).write_text(row['text'])
(folder / 'answer.md').write_text(output['answer'] + '\n\n' + '\n'.join(f'- [{key}](sources/{key}.txt)' for key in sorted(ids)))
