from app.agents.schemas.task import AgentTask
from app.agents.verifier import verify_task_result


def test_verifier_verdict_is_separate_from_task_lifecycle_status():
    task = AgentTask(task_id="task-1", title="Verify", status="blocked", result_summary="waiting")

    verdict = verify_task_result(task=task)

    assert verdict.status == "skipped"
    assert verdict.summary == "waiting"


def test_verifier_prefers_explicit_result_success_signal():
    verdict = verify_task_result(result={"success": True, "summary": "all checks passed"})

    assert verdict.status == "passed"
    assert verdict.summary == "all checks passed"


def test_verifier_treats_completed_task_result_as_passed():
    verdict = verify_task_result(result={"status": "completed", "summary": "done", "evidence": [{"type": "log"}]})

    assert verdict.status == "passed"
    assert verdict.summary == "done"


def test_verifier_treats_blocked_task_result_as_skipped():
    verdict = verify_task_result(result={"status": "blocked", "summary": "waiting on user"})

    assert verdict.status == "skipped"
    assert verdict.summary == "waiting on user"


def test_verifier_fails_when_no_verification_input_exists():
    verdict = verify_task_result()

    assert verdict.status == "failed"
    assert verdict.summary == "No verification input available."
