from __future__ import annotations
from pathlib import Path

root=Path(__file__).resolve().parent
win=(root/'static/app.js').read_text(encoding='utf-8')
android_candidates=sorted(root.parent.glob('Android_v*_PATCH/assets/index.html'))
android_path=android_candidates[-1] if android_candidates else None
android=android_path.read_text(encoding='utf-8') if android_path else ''

# Character web-autofill -> editor -> saved dossier aliasing.
for src in ([win,android] if android else [win]):
    assert "'appearance.hair_color':'charHairColor'" in src
    assert "'appearance.eye_color':'charEyeColor'" in src
    assert 'appearance_profile={' in src
    assert 'personality_profile={' in src
    assert 'life_history.background' in src
    assert 'continuity.immutable_facts' in src

# Scenario secret knowledge scopes survive UI/save/World Bible instead of flattening.
for src in ([win,android] if android else [win]):
    assert 'hidden_from' in src
    assert 'known by:' in src.lower()
    assert 'hidden from:' in src.lower()
    assert 'secrets_knowledge' in src
    assert 'creatorPhysicalContinuity' in src
    assert 'physical_continuity' in src

# Both platforms route researched Scenarios and Characters to dedicated live endpoints.
assert '/api/creator/character-autofill' in win and '/api/creator/scenario-autofill' in win
if android:
    for endpoint in ['melumiyachat-character-autofill','melumiyachat-scenario-autofill','melumiyachat-start-rp','melumiyachat-continuity']:
        assert endpoint in android, endpoint

print('PASS — creator research/schema round-trip wiring')
