"""Area #2 W6 — prompt injection raw gaze_target → enum-based prose + active prompt cleanup."""


def test_scene_consistency_step_no_raw_gaze_injection():
    """scene_consistency_step.py:741-742 — raw `eyes→{_gaze}` injection 폐기 verify."""
    import app.core.steps.scene_consistency_step as scs
    source = open(scs.__file__).read()
    # raw f", eyes→{_gaze}" 패턴 폐기
    assert "eyes→{_gaze}" not in source, (
        "scene_consistency_step.py 안 `eyes→{_gaze}` raw injection 잔존 — W6 미완료"
    )
    assert "eyes→{" not in source, (
        "scene_consistency_step.py 안 `eyes→{...}` raw f-string 변종 잔존 — broader catch"
    )
    # 신 prose: enum-based (v13 3 field 중 하나 이상 read 의무)
    assert "gaze_direction_kind" in source or "subject_state" in source, (
        "scene_consistency_step.py 가 v13 3-field structured read 안 함 — W6 미완료"
    )
    # Gate 4: silent default 금지 (gaze_direction_kind / subject_state 는 v13 schema required)
    assert "a.get('gaze_direction_kind'" not in source, (
        "Gate 4 fail-fast — gaze_direction_kind 는 v13 schema required field, silent default 금지"
    )
    assert 'a.get("gaze_direction_kind"' not in source, (
        "Gate 4 fail-fast — gaze_direction_kind 는 v13 schema required field, silent default 금지"
    )
    assert "a.get('subject_state'" not in source, (
        "Gate 4 fail-fast — subject_state 는 v13 schema required field, silent default 금지"
    )
    assert 'a.get("subject_state"' not in source, (
        "Gate 4 fail-fast — subject_state 는 v13 schema required field, silent default 금지"
    )


def test_scene_consistency_step_no_legacy_gaze_target_read():
    """scene_consistency_step.py — legacy `a.get("gaze_target", ...)` read 폐기 verify."""
    import app.core.steps.scene_consistency_step as scs
    source = open(scs.__file__).read()
    # legacy gaze_target field read (gaze_target_id 와 다름, word boundary)
    assert 'a.get("gaze_target",' not in source, (
        "scene_consistency_step.py 안 legacy `a.get(\"gaze_target\", ...)` 잔존 — W6 미완료"
    )
    assert "a.get('gaze_target'," not in source, (
        "scene_consistency_step.py 안 legacy `a.get('gaze_target', ...)` 잔존 — W6 미완료"
    )
    assert 'a.get("gaze_target")' not in source, (
        "scene_consistency_step.py 안 legacy `a.get(\"gaze_target\")` 잔존 — W6 미완료"
    )
    assert "a.get('gaze_target')" not in source, (
        "scene_consistency_step.py 안 legacy `a.get('gaze_target')` 잔존 — W6 미완료"
    )


def test_detail_steps_camera_focusing_prompt_neutralized():
    """detail_steps.py:2298 카메라 포커싱 active prompt — 시나리오 특정 예시 중립화 verify (사용자 추가 scope)."""
    import app.core.steps.detail_steps as ds
    source = open(ds.__file__).read()
    # gender-specific pronoun (her/his) + emotional/state label (trembling, wide eyes)
    assert "trembling hands" not in source, (
        "detail_steps.py 안 'trembling hands' emotional state label 잔존 — Gate 2 정합 의무"
    )
    assert "wide eyes" not in source, (
        "detail_steps.py 안 'wide eyes' emotional state label 잔존 — Gate 2 정합 의무"
    )
    # 작품 특정 prop (blade piercing, letter)
    assert "blade piercing" not in source, (
        "detail_steps.py 안 'blade piercing' 작품 특정 prop 잔존 — Gate 2 정합 의무"
    )
    assert "focus on the letter" not in source, (
        "detail_steps.py 안 'focus on the letter' 작품 특정 prop 잔존 — Gate 2 정합 의무"
    )
