"""Record final source hashes and reported test evidence without business data.""" import hashlib import json from pathlib import Path base=Path(__file__).parent roots=[Path('C:/kefu/wechat_rpa'),Path('C:/wechat_rpa')] names=['ai_chat.py','model_protocol.py','model_gateway.py','backend_client.py','session_name.py','wechat_bot.py','wxwork_db.py','protocol_engine.py'] manifest=[] for root in roots: for name in names: path=root/name if not path.exists():continue content=path.read_bytes() compile(content,str(path),'exec') manifest.append({'path':str(path),'sha256':hashlib.sha256(content).hexdigest()}) for path in sorted(root.glob('test_*audit*.py')): compile(path.read_bytes(),str(path),'exec') manifest.append({'path':str(path),'sha256':hashlib.sha256(path.read_bytes()).hexdigest()}) evidence={} for name in ( 'visual-source-final','visual-target-final','visual-real-ocr-source','visual-real-ocr-target', 'ai-context-source','ai-context-target','protocol-source-final','protocol-target-final', 'knowledge-source-final','knowledge-target-final','gateway-guard-source','gateway-guard-target', 'knowledge-cache-source-after','knowledge-cache-target-after', 'visual-trace-source','visual-trace-target'): path=base/(name+'.json') if not path.exists():continue data=json.loads(path.read_text(encoding='utf-8-sig')) # OCR full cases retained in original artifact, aggregate in summary. if 'cases' in data: data={'cases':len(data['cases']),'exact':sum(bool(item.get('exact')) for item in data['cases'])} evidence[name]=data result={'date':'2026-09-16','source_files':manifest,'test_evidence':evidence, 'production_deployed':False,'real_wechat_messages_sent':False, 'real_model_requests':'synthetic data only; see live-*.json', 'backups':[str(root/'backups/recognition-audit-20260916') for root in roots]} (base/'final-verification.json').write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf-8') report=base/'TEST_REPORT.md' text=report.read_text(encoding='utf-8').replace('| 105/105 | 105/105 | 临时数据库与模拟上游;最终追加回归见结果 JSON |','| 126/126 | 126/126 | 含最终视觉角色路由、上传异常和知识检索组合回归 |') report.write_text(text,encoding='utf-8') print(json.dumps({'compiled_files':len(manifest),'evidence_groups':list(evidence),'report':str(report)},ensure_ascii=False))