import json
d = json.load(open(r"scripts/tier2/artifacts/result_migration_small_files_20260617/full_audit.json"))
from collections import defaultdict
by_file = defaultdict(lambda: {"silent": 0, "broad": 0, "unclear": 0, "sites": []})
for f_info in d["files"]:
    fname = f_info["filename"]
    for finding in f_info["findings"]:
        if finding["category"] == "INTERNAL_SILENT_SWALLOW":
            by_file[fname]["silent"] += 1
            by_file[fname]["sites"].append((finding["line"], "SILENT", finding.get("context", "")))
        elif finding["category"] == "INTERNAL_BROAD_CATCH":
            by_file[fname]["broad"] += 1
            by_file[fname]["sites"].append((finding["line"], "BROAD", finding.get("context", "")))
        elif finding["category"] == "UNCLEAR":
            by_file[fname]["unclear"] += 1
            by_file[fname]["sites"].append((finding["line"], "UNCLEAR", finding.get("context", "")))
priority = [
    "src/warmup.py",
    "src/startup_profiler.py",
    "src/file_cache.py",
    "src/orchestrator_pm.py",
    "src/project_manager.py",
    "src/log_registry.py",
    "src/models.py",
    "src/multi_agent_conductor.py",
    "src/theme_2.py",
    "src/shell_runner.py",
    "src/session_logger.py",
]
for fname in priority:
    info = by_file.get(fname, {"silent": 0, "broad": 0, "unclear": 0, "sites": []})
    total = info["silent"] + info["broad"] + info["unclear"]
    if total > 0:
        print(f"{fname}: {info['silent']} silent + {info['broad']} broad + {info['unclear']} unclear = {total}")
        for line, kind, ctx in info["sites"][:10]:
            print(f"  L{line:4d} {kind} ctx={ctx}")