Spaces:
Running
Running
| """Read-only check: project every prebaked case to its public view and report which | |
| rich payload each clue gets. Fails (exit 1) if any case ends up all-paper.""" | |
| from __future__ import annotations | |
| import sys | |
| from collections import Counter | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src")) | |
| from case_zero.api.case_adapter import casefile_to_public # noqa: E402 | |
| from case_zero.persistence.case_store import load_case # noqa: E402 | |
| from case_zero.persistence.paths import prebaked_cases_dir # noqa: E402 | |
| def payload_kind(ev) -> str: | |
| if ev.thread: | |
| return "thread" | |
| if ev.transcript: | |
| return "voicemail" | |
| if ev.rows: | |
| return "keycard" | |
| if ev.type == "IMAGE": | |
| return "cctv" if ev.icon == "cctv" else "photo" | |
| return "paper" | |
| def main() -> int: | |
| hist: Counter[str] = Counter() | |
| all_paper: list[str] = [] | |
| for path in sorted(prebaked_cases_dir().glob("*.json")): | |
| case = load_case(path) | |
| public = casefile_to_public(case) | |
| kinds = [] | |
| for ev in public.evidence: | |
| kind = payload_kind(ev) | |
| kinds.append(kind) | |
| hist[kind] += 1 | |
| print(f"{case.case_id} | {ev.id:10s} | {ev.icon:12s} | {kind:9s} | {ev.name[:52]}") | |
| if all(k == "paper" for k in kinds): | |
| all_paper.append(case.case_id) | |
| print("\n--- payload histogram:") | |
| for kind, n in hist.most_common(): | |
| print(f"{kind:9s} {n}") | |
| if all_paper: | |
| print(f"\nFAIL: all-paper cases: {all_paper}") | |
| return 1 | |
| print("\nOK: every case has at least one rich exhibit") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |