from pathlib import Path
import json
import hashlib
import sys

try:
    ref_text = Path('/opt/ai-avatar-demo/data/voice_refs/approved/mandy0526_ref_text.txt').read_text(encoding='utf-8').strip()
    consent = json.loads(Path('/opt/ai-avatar-demo/data/voice_refs/consent_records/mandy0526_consent_gate7m_a.json').read_text(encoding='utf-8'))
    print('ref_text_len=', len(ref_text))
    print('ref_text_sha256=', hashlib.sha256(ref_text.encode('utf-8')).hexdigest())
    print('consent_allowed_use=', consent.get('allowed_use'))
    print('consent_target_text=', consent.get('target_text'))
    if consent.get('target_text') != '我是Yuka，很高興認識大家':
        print("ERROR: BLOCKED_CONSENT_TARGET_TEXT_MISMATCH!")
        sys.exit(1)
except Exception as e:
    print("ERROR:", repr(e))
    sys.exit(1)
