"""W-E: S14 실 staging → build_pose_brief 방향 복원 오프라인 검증 (OLD vs NEW 대조)."""
import json
from pathlib import Path
from app.modules.pipeline.indoor_shared_pose_plan import build_pose_brief

CP = Path("/Users/manta/Documents/Projects/TheRoad-I1/projects/b0ad5c18-5140-4022-a2b0-805de0e5a385/checkpoints/episodes/0d30302a-51c8-4ac9-98e2-6cd9180512bf")
shots = json.loads((CP / "shot_staging" / "manifest.json").read_text())["data"]["shots"]

for sh in shots:
    if sh.get("scene_index") != 14:
        continue
    si, shi = sh["scene_index"], sh.get("shot_index")
    fsc = sh.get("frame_spatial_contract") or {}
    cons = fsc.get("constraints") or []
    has_gesture = any(str(c.get("gesture_action") or "none") != "none" for c in cons if isinstance(c, dict))
    angles = sh.get("character_angles") or []
    gdks = [a.get("gaze_direction_kind") for a in angles if isinstance(a, dict)]
    b = build_pose_brief(sh)
    print(f"S{si}sh{shi} framing={b['framing']} gdk={gdks}")
    for f in b["figures"]:
        print(f"   slot={f['slot']!r} pose={f['pose']!r}")
        print(f"   facing={f['facing']!r}")
        print(f"   gesture={f['gesture']!r}")
    if has_gesture:
        for c in cons:
            if isinstance(c, dict) and str(c.get("gesture_action") or "none") != "none":
                print(f"   [raw] ga={c.get('gesture_action')} gtl={c.get('gesture_target_label')!r} (target zone/depth 는 매칭 constraint 에서)")
