from afk_developer.event_store import DurableEventStore from afk_developer.friction_report import build_friction_report def test_friction_report_separates_recovery_and_human_attention(tmp_path) -> None: store = DurableEventStore(tmp_path / "governance-events.jsonl") store.append( "run_event_recorded", { "run_kind": "attempt_summary", "text": "Attempt", "task_id": "task-a", "data": {"role": "coder", "reasoning_effort": "high"}, }, ) store.append( "run_event_recorded", { "run_kind": "review", "text": "Quarantined scratch", "task_id": "task-a", "data": {"mechanical_repair": True}, }, ) store.append( "run_event_recorded", { "run_kind": "task_blocked", "text": "Awaiting human", "task_id": "task-a", "data": {"human_validation": True}, }, ) store.append("effect_intended", {"effect_id": "q1", "operation": "quarantine"}) report = build_friction_report(store) assert report.counters["worker_attempts"] == 1 assert report.counters["mechanical_repairs"] == 1 assert report.counters["strong_model_calls"] == 1 assert report.awaiting_product_validation == ["task-a"] assert report.pending_effects == {"q1": "quarantine"}